admin: display publication confirmation; show an alert when empty scene
This commit is contained in:
parent
2c1506853b
commit
f5bdc60573
2 changed files with 19 additions and 6 deletions
|
@ -75,7 +75,7 @@ angular.module("FICApp")
|
|||
})
|
||||
.factory("Scene", function($resource) {
|
||||
return $resource("/api/public.json", null, {
|
||||
'update': {method: 'PUT'},
|
||||
'update': {method: 'PUT', isArray: true},
|
||||
})
|
||||
})
|
||||
.factory("Team", function($resource) {
|
||||
|
@ -368,7 +368,7 @@ angular.module("FICApp")
|
|||
};
|
||||
})
|
||||
|
||||
.controller("PublicController", function($scope, Scene, Theme, Teams, Exercice) {
|
||||
.controller("PublicController", function($scope, $rootScope, Scene, Theme, Teams, Exercice) {
|
||||
$scope.scenes = Scene.query();
|
||||
$scope.themes = Theme.query();
|
||||
$scope.teams = Teams.get();
|
||||
|
@ -403,23 +403,31 @@ angular.module("FICApp")
|
|||
$scope.exercices = Exercice.query();
|
||||
|
||||
$scope.clearScene = function() {
|
||||
Scene.delete(function() {
|
||||
$scope.scenes = [];
|
||||
});
|
||||
$scope.someUpdt = true;
|
||||
$scope.scenes = [];
|
||||
};
|
||||
$scope.saveScenes = function() {
|
||||
Scene.update($scope.scenes);
|
||||
$scope.someUpdt = false;
|
||||
var prms = Scene.update($scope.scenes);
|
||||
prms.$promise.then(function() {
|
||||
$rootScope.newBox('success', 'Scene successfully published!');
|
||||
}, function(response) {
|
||||
$rootScope.newBox('danger', 'An error occurs when saving scene:', response.data);
|
||||
});
|
||||
};
|
||||
$scope.addScene = function() {
|
||||
$scope.someUpdt = true;
|
||||
$scope.scenes.push({params: {}});
|
||||
};
|
||||
$scope.delScene = function(s) {
|
||||
$scope.someUpdt = true;
|
||||
angular.forEach($scope.scenes, function(scene, k) {
|
||||
if (scene == s)
|
||||
$scope.scenes.splice(k, 1);
|
||||
});
|
||||
};
|
||||
$scope.upScene = function(s) {
|
||||
$scope.someUpdt = true;
|
||||
angular.forEach($scope.scenes, function(scene, k) {
|
||||
if (scene == s && k > 0) {
|
||||
$scope.scenes.splice(k, 1);
|
||||
|
@ -428,6 +436,7 @@ angular.module("FICApp")
|
|||
});
|
||||
};
|
||||
$scope.downScene = function(s) {
|
||||
$scope.someUpdt = true;
|
||||
var move = true;
|
||||
angular.forEach($scope.scenes, function(scene, k) {
|
||||
if (move && scene == s) {
|
||||
|
|
Reference in a new issue