implement choices_cost
This commit is contained in:
parent
f9abdd23c6
commit
476f0f553c
18 changed files with 180 additions and 24 deletions
|
|
@ -426,6 +426,30 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = true;
|
||||
};
|
||||
|
||||
$scope.wantchoices = function(kid) {
|
||||
$scope.my.exercices[$rootScope.current_exercice].flags[kid].wcsubmitted = true;
|
||||
$http({ url: "/wantchoices/" + $rootScope.current_exercice, method: "POST", data: { id: Math.floor(kid) } }).then(function(response) {
|
||||
var checkDiffWC = function() {
|
||||
$http.get("/my.json").then(function(response) {
|
||||
var my = response.data;
|
||||
if (my.exercices[$rootScope.current_exercice].flags[kid].choices)
|
||||
$rootScope.recvMy(my);
|
||||
else {
|
||||
if (cbd)
|
||||
$timeout.cancel(cbd);
|
||||
cbd = $timeout(checkDiffWC, 750);
|
||||
}
|
||||
});
|
||||
};
|
||||
checkDiffWC();
|
||||
}, function(response) {
|
||||
$scope.messageClass = {"text-danger": true};
|
||||
$scope.sberr = "Oups !";
|
||||
$scope.message = response.data.errmsg;
|
||||
$scope.my.exercices[$rootScope.current_exercice].flags[kid].wcsubmitted = false;
|
||||
});
|
||||
}
|
||||
})
|
||||
.controller("MyTeamController", function($scope, $http, $rootScope, $timeout) {
|
||||
$rootScope.current_theme = 0;
|
||||
|
|
|
|||
|
|
@ -88,8 +88,16 @@
|
|||
<div class="form-group" ng-repeat="(kid,key) in my.exercices[current_exercice].flags">
|
||||
<label for="sol_{{ kid }}">{{ key.label }} :</label>
|
||||
<span ng-if="key.found && key.value" ng-bind="key.value"></span>
|
||||
<input type="text" class="form-control" id="sol_{{ kid }}" autocomplete="off" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found && !key.choices">
|
||||
<select class="custom-select" id="sol_{{ kid }}" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found && key.choices" ng-options="l as v for (l, v) in key.choices"></select>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="sol_{{ kid }}" autocomplete="off" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found && !key.choices">
|
||||
<select class="custom-select" id="sol_{{ kid }}" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found && key.choices" ng-options="l as v for (l, v) in key.choices"></select>
|
||||
<div class="input-group-append" ng-if="key.choices_cost">
|
||||
<button class="btn btn-success" type="button" ng-click="wantchoices(kid)" ng-class="{disabled: key.wcsubmitted}" title="Cliquez pour échanger ce champ de texte par une liste de choix. L'opération vous coûtera {{ key.choices_cost }} points.">
|
||||
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span>
|
||||
Liste de propositions ({{ key.choices_cost }} points)
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<small class="form-text text-muted" ng-if="!key.found && key.help.length > 0" ng-bind="key.help"></small>
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback text-success" aria-hidden="true" ng-if="key.found" title="Flag trouvé à {{ key.found | date:'mediumTime'}}"></span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
<div class="col-sm-10">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="newName" ng-model="newName" placeholder="{{ my.name }}">
|
||||
<span class="input-group-btn">
|
||||
<div class="input-group-append">
|
||||
<button type="submit" class="btn btn-info">Valider</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Reference in a new issue