From aed18205c4fadadba69659f32ddaf9648f8f06d5 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Sat, 14 Jan 2017 17:58:54 +0100 Subject: [PATCH] showing config save status (closes #2842) --- CHANGELOG | 1 + openslides/core/static/css/app.css | 3 ++ openslides/core/static/js/core/site.js | 47 ++++++++++++++++--- .../static/templates/config-form-field.html | 45 ++++++++++++------ 4 files changed, 75 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5c1f0806a..f75403a58 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -43,6 +43,7 @@ Core: - Added smooth projector scroll. - Added watching permissions in client and change the view immediately on changes. - Validate HTML strings from CKEditor against XSS attacks. +- Added success/error symbol to config to show if saving was successful. Motions: - Added adjustable line numbering mode (outside, inside, none) for each diff --git a/openslides/core/static/css/app.css b/openslides/core/static/css/app.css index 1120fefe0..b6fd9b845 100644 --- a/openslides/core/static/css/app.css +++ b/openslides/core/static/css/app.css @@ -1052,6 +1052,9 @@ img { .input-comments > div { margin-bottom: 5px } +.config-checkbox { + padding: 6px 12px; +} /** Pojector sidebar **/ .col2 .projectorSelector { diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index b6bb74d3a..165470eb5 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -661,7 +661,7 @@ angular.module('OpenSlidesApp.core.site', [ } else { $scope.value = gettextCatalog.getString($scope.default_value); } - $scope.save(field.key, $scope.value); + $scope.save(field, $scope.value); }; } }; @@ -843,26 +843,61 @@ angular.module('OpenSlidesApp.core.site', [ // Config Controller .controller('ConfigCtrl', [ '$scope', + '$timeout', 'MajorityMethodChoices', 'Config', 'configOptions', 'gettextCatalog', 'DateTimePickerTranslation', 'Editor', - function($scope, MajorityMethodChoices, Config, configOptions, gettextCatalog, DateTimePickerTranslation, Editor) { + function($scope, $timeout, MajorityMethodChoices, Config, configOptions, + gettextCatalog, DateTimePickerTranslation, Editor) { Config.bindAll({}, $scope, 'configs'); $scope.configGroups = configOptions.data.config_groups; $scope.dateTimePickerTranslatedButtons = DateTimePickerTranslation.getButtons(); $scope.ckeditorOptions = Editor.getOptions(); $scope.ckeditorOptions.on.change = function (event) { - $scope.save(event.editor.element.$.id, this.getData()); + // we could just retrieve the key, but we need the configOption object. + var configOption_key = event.editor.element.$.id; + + // find configOption object + var subgroups = _.flatMap($scope.configGroups, function (group) { + return group.subgroups; + }); + var items = _.flatMap(subgroups, function (subgroup) { + return subgroup.items; + }); + var configOption = _.find(items, function (_item) { + return _item.key === configOption_key; + }); + + var editor = this; + // The $timeout executes the given function in an angular context. Because + // this is a standard JS event, all changes may not happen in the digist-cylce. + // By using $timeout angular calls $apply for us that we do not have to care + // about starting the digist-cycle. + $timeout(function () { + $scope.save(configOption, editor.getData()); + }, 1); }; // save changed config value - $scope.save = function(key, value) { - Config.get(key).value = value; - Config.save(key); + $scope.save = function(configOption, value) { + Config.get(configOption.key).value = value; + Config.save(configOption.key).then(function (success) { + configOption.success = true; + // fade out the success symbol after 2 seconds. + $timeout(function () { + var element = $('#success-field-' + configOption.key); + element.fadeOut(800, function () { + configOption.success = void 0; + }); + }, 2000); + }, function (error) { + configOption.success = false; + configOption.errorMessage = error.data.detail; + }); }; // For comments input diff --git a/openslides/core/static/templates/config-form-field.html b/openslides/core/static/templates/config-form-field.html index e9507da36..9333b70d8 100644 --- a/openslides/core/static/templates/config-form-field.html +++ b/openslides/core/static/templates/config-form-field.html @@ -2,27 +2,34 @@
- - + + +
+ +
+ -
+
@@ -43,20 +50,20 @@
- - - -