Can lock theme
This commit is contained in:
parent
b8c5ec6725
commit
d4ce0dd474
9 changed files with 85 additions and 43 deletions
|
|
@ -210,6 +210,23 @@ func updateTheme(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if theme.Locked != ut.Locked {
|
||||
exercices, err := theme.GetExercices()
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
|
||||
return
|
||||
}
|
||||
for _, exercice := range exercices {
|
||||
if exercice.Disabled != ut.Locked {
|
||||
exercice.Disabled = ut.Locked
|
||||
_, err = exercice.Update()
|
||||
if err != nil {
|
||||
log.Println("Unable to enable/disable exercice: ", exercice.Id, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, ut)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1539,7 +1539,7 @@ angular.module("FICApp")
|
|||
})
|
||||
.controller("ThemeController", function($scope, Theme, $routeParams, $location, $rootScope, $http) {
|
||||
$scope.theme = Theme.get({ themeId: $routeParams.themeId });
|
||||
$scope.fields = ["name", "urlid", "authors", "headline", "intro", "image", "partner_txt", "partner_href", "partner_img"];
|
||||
$scope.fields = ["name", "urlid", "locked", "authors", "headline", "intro", "image", "partner_txt", "partner_href", "partner_img"];
|
||||
|
||||
$scope.saveTheme = function() {
|
||||
if (this.theme.id) {
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
<div class="row">
|
||||
<form ng-submit="saveTheme()" class="col-4">
|
||||
<div ng-class="{'form-group': field != 'disabled', 'form-check': field == 'disabled'}" ng-repeat="field in fields">
|
||||
<input type="checkbox" class="form-check-input" id="{{ field }}" ng-model="theme[field]" ng-if="field == 'disabled'">
|
||||
<div ng-class="{'form-group': field != 'locked', 'form-check': field == 'locked'}" ng-repeat="field in fields">
|
||||
<input type="checkbox" class="form-check-input" id="{{ field }}" ng-model="theme[field]" ng-if="field == 'locked'">
|
||||
<label for="{{ field }}">{{ field | capitalize }}</label>
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="theme[field]" ng-if="field != 'intro' && field != 'disabled'">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="theme[field]" ng-if="field != 'intro' && field != 'locked'">
|
||||
<textarea class="form-control form-control-sm" id="{{ field }}" ng-model="theme[field]" ng-if="field == 'intro'"></textarea>
|
||||
</div>
|
||||
<div class="text-right" ng-show="theme.id">
|
||||
|
|
|
|||
Reference in a new issue