admin: add button to move to previous and next exercice
authorPierre-Olivier Mercier <nemunaire@nemunai.re>
Sun, 9 Dec 2018 18:06:29 +0000 (19:06 +0100)
committerPierre-Olivier Mercier <nemunaire@nemunai.re>
Sun, 9 Dec 2018 23:31:29 +0000 (00:31 +0100)
admin/static/js/app.js
admin/static/views/exercice.html

index 1ae9b7c..5cae4d4 100644 (file)
@@ -1055,6 +1055,21 @@ angular.module("FICApp")
        } else {
            $scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
        }
+       $http({
+           url: "/api/themes.json",
+           method: "GET"
+       }).then(function(response) {
+           $scope.themes = response.data
+           var last_exercice = null;
+           angular.forEach($scope.themes[$scope.exercice.id_theme].exercices, function(exercice, k) {
+               if (last_exercice != null) {
+                   $scope.themes[$scope.exercice.id_theme].exercices[last_exercice].next = k;
+                   exercice.previous = last_exercice;
+               }
+               last_exercice = k;
+               exercice.id = k;
+           });
+       });
        $scope.exercices = Exercice.query();
        $scope.fields = ["title", "urlid", "statement", "headline", "overview", "finished", "depend", "gain", "coefficient", "videoURI", "issue", "issuekind"];
 
index 53c132c..69b6841 100644 (file)
@@ -1,5 +1,10 @@
 <h2>
   {{exercice.title}}
+  <small ng-if="themes && themes[exercice.id_theme]"><a href="themes/{{ exercice.id_theme }}" title="{{themes[exercice.id_theme].authors | stripHTML}}">{{themes[exercice.id_theme].name}}</a></small>
+  <div class="btn-group" role="group" ng-if="themes[exercice.id_theme].exercices[exercice.id]">
+    <a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].previous }}" title="Exercice précédent" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].previous}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></a>
+    <a href="exercices/{{ themes[exercice.id_theme].exercices[exercice.id].next }}" title="Exercice suivant" ng-class="{'disabled': !themes[exercice.id_theme].exercices[exercice.id].next}" class="btn btn-sm btn-light"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></a>
+  </div>
   <button type="button" ng-click="syncExo()" ng-class="{'disabled': inSync}" class="float-right btn btn-sm btn-light"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Synchroniser</button>
 </h2>