admin: display publication confirmation; show an alert when empty scene
This commit is contained in:
parent
f2089c4d96
commit
eefac93091
|
@ -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) {
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
<h2>Interface publique<a ng-click="clearScene()" class="pull-right btn btn-danger"><span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span> Vider la scène</a><a ng-click="addScene()" class="pull-right btn btn-primary" style="margin-right: 10px"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Ajouter un élément</a><button type="submit" style="margin-right: 10px" class="pull-right btn btn-success"><span class="glyphicon glyphicon-save" aria-hidden="true"></span> Publier cette scène</button>
|
||||
</h2>
|
||||
|
||||
<div class="alert alert-info" ng-if="!scenes.length">
|
||||
<strong ng-if="!someUpdt">Aucun contenu n'est actuellement affiché.</strong>
|
||||
<strong ng-if="someUpdt">Aucun contenu à afficher.</strong>
|
||||
</div>
|
||||
<div class="well" ng-repeat="scene in scenes">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-6">
|
||||
|
|
Loading…
Reference in New Issue
Block a user