Skip to content

Commit

Permalink
Changes all ObjectControllers to Controller
Browse files Browse the repository at this point in the history
* Except current user, which is a particularly tricky transition
  • Loading branch information
gschorkopf committed Aug 17, 2016
1 parent 5fb8e81 commit 7c04cc9
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion app/controllers/courses/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';

var CoursesNewController = Ember.ObjectController.extend({
var CoursesNewController = Ember.Controller.extend({
stateAbbreviations: ["","AK","AL","AR","AZ","CA","CO",
"CT","DC","DE","FL","GA","GU","HI","IA","ID","IL",
"IN","KS","KY","LA","MA","MD","ME","MH","MI","MN",
Expand Down
1 change: 1 addition & 0 deletions app/controllers/current-user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Ember from 'ember';

// TODO: Update to simply 'Controller' after getting rid of janky auth
var CurrentUserController = Ember.ObjectController.extend({
isAuthenticated: function() {
return this.get('model.isLoaded');
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/password/edit.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import Ember from 'ember';

var PasswordEditController = Ember.ObjectController.extend({
var PasswordEditController = Ember.Controller.extend({
needs: "sessions",
showPasswordError: false,

actions: {
changePassword: function() {
var _this = this,
password = this.get('model'),
isValidPassword = this.get('password') === this.get('passwordConfirmation');
isValidPassword = password.get('password') === password.get('passwordConfirmation');

if (isValidPassword) {
password.save().then(function(user) {
var email = user.get('email'),
password = _this.get('password');
password = user.get('password');

_this.get('controllers.sessions').send('loginWithCredentials', email, password);
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/profile/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';

var ProfileSettingsController = Ember.ObjectController.extend({
var ProfileSettingsController = Ember.Controller.extend({
actions: {
saveChanges: function() {
this.get('model').save();
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/review/edit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';

var ReviewEditController = Ember.ObjectController.extend({
var ReviewEditController = Ember.Controller.extend({
ratingChoices: [1,2,3,4,5,6,7,8,9,10],

actions: {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reviews/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var ReviewsIndexController = Ember.ArrayController.extend({

isAlreadyReviewed: function () {
var currentUserId = this.get('currentUser.id'),
currentUserReview = this.get('content').findBy('user.id', currentUserId);
currentUserReview = this.get('content').findBy('model.user.id', currentUserId);

return !!currentUserReview;
}.property('content'),
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reviews/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';

var ReviewsNewController = Ember.ObjectController.extend({
var ReviewsNewController = Ember.Controller.extend({

ratingChoices: [1,2,3,4,5,6,7,8,9,10],

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/round/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Ember from 'ember';

var RoundIndexController = Ember.ObjectController.extend({
var RoundIndexController = Ember.Controller.extend({
columnWidth: function() {
var scorecardColumns = this.get('scorecards.length');
var scorecardColumns = this.get('model.scorecards.length');
var scorecardColumnPercentage = 100 / scorecardColumns;

return 'width: ' + scorecardColumnPercentage + '%;';
}.property('scorecards.length'),
}.property('model.scorecards.length'),

holeNumbers: function() {
var turnsCount = this.get('scorecards.firstObject.turns.length');
var turnsCount = this.get('model.scorecards.firstObject.turns.length');
var holeNumbers = new Array(turnsCount)
.join().split(',')
.map(function(item, index){ return ++index; });

return holeNumbers;
}.property('scorecards.firstObject.turns.length')
}.property('model.scorecards.firstObject.turns.length')

});

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/rounds/new.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Ember from 'ember';

var RoundsNewController = Ember.ObjectController.extend({
var RoundsNewController = Ember.Controller.extend({
selectedPlayer: null,
query: null,
nearestCourses: false,

potentialPlayers: function() {
var friends = this.get('friends');
var players = this.get('players');
var players = this.get('model.players');
players.forEach(function(p) { friends.removeObject(p); });

return friends;
}.property('friends.@each', 'players.@each'),
}.property('friends.@each', 'model.players.@each'),


noPlayerSelected: function() {
Expand All @@ -20,13 +20,13 @@ var RoundsNewController = Ember.ObjectController.extend({

actions: {
addPlayer: function() {
this.get('players').addObject(this.get('selectedPlayer'));
this.get('model.players').addObject(this.get('selectedPlayer'));
this.set('selectedPlayer', null);
this.set('query', null);
},

removePlayer: function(player) {
this.get('players').removeObject(player);
this.get('model.players').removeObject(player);
},

updateCourseInput: function(nearestCourse) {
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/users/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ember from 'ember';

var UsersNewController = Ember.ObjectController.extend({
var UsersNewController = Ember.Controller.extend({
needs: "sessions",

actions: {
Expand All @@ -9,9 +9,9 @@ var UsersNewController = Ember.ObjectController.extend({
user = this.get('model');

if (user.get('hasValidPassword')) {
user.save().then(function() {
var email = self.get('email'),
password = self.get('password');
user.save().then(function(user) {
var email = user.get('email'),
password = user.get('password');

self.get('controllers.sessions').send("loginWithCredentials", email, password);
});
Expand Down
8 changes: 4 additions & 4 deletions app/templates/courses/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
<label for="name">
* Name
</label>
{{input value=name type="text" id="name" required=true classNames="form-control"}}
{{input value=model.name type="text" id="name" required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="city">
* City
</label>
{{input value=city type="text" id="city" required=true classNames="form-control"}}
{{input value=model.city type="text" id="city" required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="state">
* State
</label>
{{view "select" content=stateAbbreviations value=state required=true classNames="form-control"}}
{{view "select" content=stateAbbreviations value=model.state required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="holeCount">
* Hole Count
</label>
{{input value=holeCount type="number" id="holeCount" required=true min=9 max=27 classNames="form-control"}}
{{input value=model.holeCount type="number" id="holeCount" required=true min=9 max=27 classNames="form-control"}}
</div>
<p>
For now, Frolfr only supports U.S. courses
Expand Down
6 changes: 3 additions & 3 deletions app/templates/password/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<label for="password">
* Password
</label>
{{input value=password type="password" id="password" required=true classNames="form-control"}}
{{input value=model.password type="password" id="password" required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="passwordConfirmation">
* Password Confirmation
</label>
{{input value=passwordConfirmation type="password" id="passwordConfirmation" required=true classNames="form-control"}}
{{input value=model.passwordConfirmation type="password" id="passwordConfirmation" required=true classNames="form-control"}}
</div>
{{#if showPasswordError}}
<p>
Expand All @@ -24,4 +24,4 @@
<button type="submit" class="btn btn-block btn-lg btn-primary">
Change Password
</button>
</form>
</form>
14 changes: 7 additions & 7 deletions app/templates/profile/settings.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
<label for="firstName">
* First Name
</label>
{{input value=firstName type="text" id="firstName" required=true classNames="form-control"}}
{{input value=model.firstName type="text" id="firstName" required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="middleName">
* Middle Name
</label>
{{input value=middleName type="text" id="middleName" classNames="form-control"}}
{{input value=model.middleName type="text" id="middleName" classNames="form-control"}}
</div>
<div class="form-group">
<label for="lastName">
* Last Name
</label>
{{input value=lastName type="text" id="lastName" required=true classNames="form-control"}}
{{input value=model.lastName type="text" id="lastName" required=true classNames="form-control"}}
</div>
<div class="form-group row">
<div class='col-xs-6'>
<button class="btn btn-block btn-success btn-lg {{if isDirty 'active' 'disabled'}}" type="submit" {{action "saveChanges" on="click"}}>
<button class="btn btn-block btn-success btn-lg {{if model.isDirty 'active' 'disabled'}}" type="submit" {{action "saveChanges" on="click"}}>
Save
</button>
</div>
<div class='col-xs-6'>
<button class="btn btn-block btn-danger btn-lg {{if isDirty 'active' 'disabled'}}" {{action "cancel" on="click"}}>
<button class="btn btn-block btn-danger btn-lg {{if model.isDirty 'active' 'disabled'}}" {{action "cancel" on="click"}}>
Cancel
</button>
</div>
Expand All @@ -42,9 +42,9 @@
<h2 class="text-center">
Avatar
</h2>
{{#if hasAvatar}}
{{#if model.hasAvatar}}
<div class="text-center">
<img src={{avatarUrl}} class="avatar u-circle" />
<img src={{model.avatarUrl}} class="avatar u-circle" />
</div>
{{else}}
<p>
Expand Down
8 changes: 4 additions & 4 deletions app/templates/review/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

<div class='form-group'>
<label>* Rating</label>
{{view Ember.Select content=ratingChoices value=rating required=true prompt="Select Rating" classNames='form-control'}}
{{view Ember.Select content=ratingChoices value=model.rating required=true prompt="Select Rating" classNames='form-control'}}
</div>

<div class='form-group'>
<label>* Comments</label>
{{textarea value=post required=true classNames='form-control' rows=10}}
{{textarea value=model.post required=true classNames='form-control' rows=10}}
</div>

<div class="form-group row">
<div class='col-xs-6'>
<button class="btn btn-block btn-success btn-lg {{if isDirty 'active' 'disabled'}}" type="submit" {{action "saveChanges" on="click"}}>
<button class="btn btn-block btn-success btn-lg {{if model.isDirty 'active' 'disabled'}}" type="submit" {{action "saveChanges" on="click"}}>
Save
</button>
</div>
<div class='col-xs-6'>
<button class="btn btn-block btn-danger btn-lg {{if isDirty 'active' 'disabled'}}" {{action "cancel" on="click"}}>
<button class="btn btn-block btn-danger btn-lg {{if model.isDirty 'active' 'disabled'}}" {{action "cancel" on="click"}}>
Cancel
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/reviews/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<form {{action "submitReview" content on="submit"}}>
<div class='form-group'>
<label>* Rating</label>
{{view Ember.Select content=ratingChoices value=rating required=true prompt="Select Rating" classNames='form-control'}}
{{view Ember.Select content=ratingChoices value=model.rating required=true prompt="Select Rating" classNames='form-control'}}
</div>
<div class='form-group'>
<label>* Comments</label>
{{textarea value=post required=true classNames='form-control' rows=10}}
{{textarea value=model.post required=true classNames='form-control' rows=10}}
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Save</button>
</form>
6 changes: 3 additions & 3 deletions app/templates/round/index.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class='well'>
<header class='text-center'>
<h3>{{courseName}}</h3>
<h5>{{display-date createdAt}}</h5>
<h3>{{model.courseName}}</h3>
<h5>{{display-date model.createdAt}}</h5>
</header>
</div>

{{scorecards-table scorecards=scorecards holeNumbers=holeNumbers hasHoleLinks=true}}
{{scorecards-table scorecards=model.scorecards holeNumbers=holeNumbers hasHoleLinks=true}}
4 changes: 2 additions & 2 deletions app/templates/rounds/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<label for="course">
* Course
</label>
{{view "select" content=courses selection=course.content optionValuePath="content.id" optionLabelPath="content.name" prompt="Select Course" id="course" required=true classNames="form-control"}}
{{view "select" content=courses selection=model.course.content optionValuePath="content.id" optionLabelPath="content.name" prompt="Select Course" id="course" required=true classNames="form-control"}}
</div>
<p>
Can't see the course you're looking for? Why not
Expand Down Expand Up @@ -50,7 +50,7 @@
{{currentUser.fullName}}
</div>
</div>
{{#each players as |player|}}
{{#each model.players as |player|}}
<div class="block-grid-item">
{{#if player.hasAvatar}}
<img src={{player.avatarUrl}} class="u-circle friend-avatar" />
Expand Down
12 changes: 6 additions & 6 deletions app/templates/users/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
<label for="firstName">
* First Name
</label>
{{input value=firstName type="text" id="firstName" required=true classNames="form-control"}}
{{input value=model.firstName type="text" id="firstName" required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="middleName">
Middle Name
</label>
{{input value=middleName type="text" id="middleName" classNames="form-control"}}
{{input value=model.middleName type="text" id="middleName" classNames="form-control"}}
</div>
<div class="form-group">
<label for="lastName">
* Last Name
</label>
{{input value=lastName type="text" id="lastName" required=true classNames="form-control"}}
{{input value=model.lastName type="text" id="lastName" required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="email">
* Email
</label>
{{input value=email type="text" id="email" required=true classNames="form-control"}}
{{input value=model.email type="text" id="email" required=true classNames="form-control"}}
{{#each model.errors.email as |error|}}
<div class="error">
{{error.message}}
Expand All @@ -36,13 +36,13 @@
<label for="password">
* Password
</label>
{{input value=password type="password" id="password" required=true classNames="form-control"}}
{{input value=model.password type="password" id="password" required=true classNames="form-control"}}
</div>
<div class="form-group">
<label for="passwordConfirmation">
* Password Confirmation
</label>
{{input value=passwordConfirmation type="password" id="passwordConfirmation" required=true classNames="form-control"}}
{{input value=model.passwordConfirmation type="password" id="passwordConfirmation" required=true classNames="form-control"}}
</div>
{{#if showPasswordError}}
<p>
Expand Down

0 comments on commit 7c04cc9

Please sign in to comment.