admin: Add exercice's tags: sync, api, interface done

This commit is contained in:
nemunaire 2018-11-18 22:44:23 +01:00 committed by Pierre-Olivier Mercier
commit f183985982
10 changed files with 166 additions and 20 deletions

View file

@ -208,6 +208,11 @@ angular.module("FICApp")
update: {method: 'PUT'}
})
})
.factory("ExerciceTags", function($resource) {
return $resource("/api/exercices/:exerciceId/tags", { exerciceId: '@idExercice'}, {
update: {method: 'PUT'}
})
})
.factory("ExerciceFile", function($resource) {
return $resource("/api/exercices/:exerciceId/files/:fileId", { exerciceId: '@idExercice', fileId: '@id' }, {
update: {method: 'PUT'}
@ -1023,6 +1028,11 @@ angular.module("FICApp")
$scope.exercices = Exercice.query();
$scope.fields = ["title", "urlid", "statement", "overview", "depend", "gain", "coefficient", "videoURI"];
$scope.showTags = false;
$scope.toggleTags = function(val) {
$scope.showTags = val ||!$scope.showTags;
}
$scope.showDownloads = false;
$scope.toggleDownloads = function(val) {
$scope.showDownloads = val ||!$scope.showDownloads;
@ -1054,6 +1064,22 @@ angular.module("FICApp")
}
})
.controller("ExerciceTagsController", function($scope, ExerciceTags, $routeParams, $rootScope, $http) {
$scope.tags = ExerciceTags.query({ exerciceId: $routeParams.exerciceId });
$scope.addTag = function() {
$scope.toggleTags(true);
$scope.tags.push("");
}
$scope.deleteTag = function() {
$scope.tags.splice($scope.tags.indexOf(this.tag), 1);
return $scope.saveTags();
}
$scope.saveTags = function() {
ExerciceTags.update({ exerciceId: $routeParams.exerciceId }, this.tags);
}
})
.controller("ExerciceFilesController", function($scope, ExerciceFile, $routeParams, $rootScope, $http) {
$scope.files = ExerciceFile.query({ exerciceId: $routeParams.exerciceId });

View file

@ -24,8 +24,8 @@
</div>
</form>
<div class="col-md-4" ng-controller="ExerciceFilesController" ng-show="exercice.id">
<div class="card border-secondary">
<div class="col-md-4" ng-show="exercice.id">
<div class="card border-secondary" ng-controller="ExerciceFilesController">
<div class="card-header bg-secondary text-light">
<h4 class="m-0" ng-click="toggleDownloads()"><small class="glyphicon" ng-class="{'glyphicon-chevron-right': !showDownloads, 'glyphicon-chevron-down': showDownloads}" aria-hidden="true"></small> Téléchargements</h4>
</div>
@ -49,7 +49,7 @@
</div>
</div>
<div class="mt-2 card border-info" ng-controller="ExerciceHintsController" ng-show="exercice.id">
<div class="mt-2 card border-info" ng-controller="ExerciceHintsController">
<div class="card-header bg-info text-light">
<button type="button" ng-click="addHint()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<button type="button" ng-click="syncHints()" class="float-right btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
@ -79,7 +79,7 @@
</div>
</div>
<div class="mt-2 card border-success" ng-controller="ExerciceFlagsController" ng-show="exercice.id">
<div class="mt-2 card border-success" ng-controller="ExerciceFlagsController">
<div class="card-header bg-success border-success text-light">
<button type="button" ng-click="addFlag()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<button type="button" ng-click="syncFlags()" class="float-right btn btn-sm btn-light ml-2"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button>
@ -114,7 +114,7 @@
</div>
</div>
<div class="mt-2 card border-success" ng-controller="ExerciceMCQFlagsController" ng-show="exercice.id">
<div class="mt-2 card border-success" ng-controller="ExerciceMCQFlagsController">
<div class="card-header bg-success text-light">
<button type="button" ng-click="addQuiz()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<h4 class="m-0" ng-click="toggleQuizz()"><small class="glyphicon" ng-class="{'glyphicon-chevron-right': !showQuizz, 'glyphicon-chevron-down': showQuizz}" aria-hidden="true"></small> Quizz</h4>
@ -152,6 +152,22 @@
</div>
</div>
<div class="mt-2 card border-warning" ng-controller="ExerciceTagsController">
<div class="card-header bg-warning text-light">
<button type="button" ng-click="addTag()" class="float-right btn btn-sm btn-primary ml-2"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
<button type="button" ng-click="saveTags()" class="float-right btn btn-sm btn-success ml-2" ng-show="showTags"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
<h4 class="m-0" ng-click="toggleTags()"><small class="glyphicon" ng-class="{'glyphicon-chevron-right': !showTags, 'glyphicon-chevron-down': showTags}" aria-hidden="true"></small> Tags</h4>
</div>
<div class="list-group" ng-show="showTags">
<form ng-submit="saveTags()" class="list-group-item bg-light text-dark">
<div class="row form-group" ng-repeat="(k, tag) in tags track by $index">
<input type="text" ng-model="tags[k]" class="col form-control form-control-sm" placeholder="#tag">
<button type="button" ng-click="deleteTag()" class="btn btn-sm btn-danger col-auto"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
</div>
</form>
</div>
</div>
</div>
</div>