From 4d6aade16a1ec8459fc99e624c516a1f530d61bf Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Fri, 22 Jan 2016 20:45:04 +0100 Subject: [PATCH] Send option request for config page just once (Fixes #1813) Add permission check in config template. --- openslides/core/static/js/core/base.js | 11 ++++++++++- openslides/core/static/js/core/site.js | 10 +++++----- openslides/core/static/templates/config.html | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 59201377e..cfb47e8b5 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -281,11 +281,20 @@ angular.module('OpenSlidesApp.core', [ ]) .factory('Config', [ + '$http', 'DS', - function(DS) { + function($http, DS) { + var configOptions; return DS.defineResource({ name: 'core/config', idAttribute: 'key', + configOptions: configOptions, + getConfigOptions: function () { + if (!this.configOptions) { + this.configOptions = $http({ 'method': 'OPTIONS', 'url': '/rest/core/config/' }); + } + return this.configOptions; + }, }); } ]) diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index 452c62d8f..37d07bd0d 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -219,8 +219,8 @@ angular.module('OpenSlidesApp.core.site', [ url: '/config', controller: 'ConfigCtrl', resolve: { - configOption: function($http) { - return $http({ 'method': 'OPTIONS', 'url': '/rest/core/config/' }); + configOptions: function(Config) { + return Config.getConfigOptions(); } } }) @@ -436,10 +436,10 @@ angular.module('OpenSlidesApp.core.site', [ .controller('ConfigCtrl', [ '$scope', 'Config', - 'configOption', - function($scope, Config, configOption) { + 'configOptions', + function($scope, Config, configOptions) { Config.bindAll({}, $scope, 'configs'); - $scope.configGroups = configOption.data.config_groups; + $scope.configGroups = configOptions.data.config_groups; // save changed config value $scope.save = function(key, value) { diff --git a/openslides/core/static/templates/config.html b/openslides/core/static/templates/config.html index cc995add9..501adeca3 100644 --- a/openslides/core/static/templates/config.html +++ b/openslides/core/static/templates/config.html @@ -5,7 +5,8 @@
-
+