Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions client/app/admin/controllers/team-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ angular.module('freefootieApp')

var Team = $resource('/api/teams/:id');
var Division = $resource('/api/divisions/:id');
var Player = $resource('/api/players/:id');

$scope.edit = {editing: false};

var teamCheckpoint = $scope.currentTeam = Team.get({id: $routeParams.id}, function(team) {
teamCheckpoint = angular.copy(team);
$scope.division = Division.get({id: team.division});
$scope.players = (team.players || []).map(function(player){
return Player.get({id: player});
});
teamCheckpoint = angular.copy(team);
});

$scope.$watch('currentTeam', function(newVal) {
$scope.needsSave = !angular.equals(newVal, teamCheckpoint);
Expand All @@ -28,11 +22,13 @@ angular.module('freefootieApp')
teamCheckpoint = angular.copy(team);
$scope.needsSave = false;
});
}
};

$scope.cancel = function() {
angular.copy(teamCheckpoint, $scope.currentTeam);
}
};

});
$scope.addPlayer = function() {
$scope.currentTeam.players.push({number: "", name: "New Player"});
};
});
13 changes: 4 additions & 9 deletions client/app/admin/views/team-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,19 @@ <h1 class="topcoat-navigation-bar__title">{{currentTeam.name}}</h1>
</div>
<div class="topcoat-list">
<ul class="topcoat-list__container">
<li class="topcoat-list__item" ng-hide="edit.editing">
<li class="topcoat-list__item">
<property title="Team Name" model="currentTeam.name"></property>
<property title="Coach" model="currentTeam.coach"></property>
<property title="Coach Phone" model="currentTeam.phone"></property>
<property title="Division" model="currentTeam.division" options="division._id as division.name for division in divisions"><property>
</li>
<li class="topcoat-list__item" ng-show="edit.editing" style="line-height: 50px">
Coach:
<input type="text" class="topcoat-text-input" placeholder="Name" ng-model="currentTeam.coach" style="width: 100px"/>
<input type="text" class="topcoat-text-input" placeholder="Phone Number" ng-model="currentTeam.phone"/>
</li>
<li ng-repeat="player in players" class="topcoat-list__item">
{{player.number}}&nbsp - {{player.name}}
<li ng-repeat="player in currentTeam.players" class="topcoat-list__item">
{{player.number}}&nbsp - {{player.name}}
</li>
<li class="edit-row" ng-show="needsSave">
<button class="topcoat-button--cta" ng-click="update(currentTeam)" >Save</button>
<button class="topcoat-button" ng-click="cancel()">Cancel</button>
</li>
</ul>
</div>
<div class="vs" style="margin-top:10px; font-weight: bold" ng-click="edit.editing=true">+</div>
<div class="vs" style="margin-top:10px; font-weight: bold" ng-click="addPlayer()">+</div>