From 4faf3dd2c0a21d88c84d5ca521b943d3850b0f78 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Sat, 9 Jan 2016 11:45:25 +0100 Subject: [PATCH] Send assignments OPTION request for phases once only. --- openslides/assignments/static/js/assignments/base.js | 11 ++++++++++- openslides/assignments/static/js/assignments/site.js | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openslides/assignments/static/js/assignments/base.js b/openslides/assignments/static/js/assignments/base.js index bfb11841f..a40613ba6 100644 --- a/openslides/assignments/static/js/assignments/base.js +++ b/openslides/assignments/static/js/assignments/base.js @@ -67,17 +67,26 @@ angular.module('OpenSlidesApp.assignments', []) ]) .factory('Assignment', [ + '$http', 'DS', 'AssignmentRelatedUser', 'AssignmentPoll', 'jsDataModel', 'gettext', - function (DS, AssignmentRelatedUser, AssignmentPoll, jsDataModel, gettext) { + function ($http, DS, AssignmentRelatedUser, AssignmentPoll, jsDataModel, gettext) { var name = 'assignments/assignment'; + var phases; return DS.defineResource({ name: name, useClass: jsDataModel, agendaSupplement: gettext('Election'), + phases: phases, + getPhases: function () { + if (!this.phases) { + this.phases = $http({ 'method': 'OPTIONS', 'url': '/rest/assignments/assignment/' }); + } + return phases; + }, methods: { getResourceName: function () { return name; diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index 7b14328df..bcfb23b63 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -34,8 +34,8 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) assignments: function(Assignment) { return Assignment.findAll(); }, - phases: function($http) { - return $http({ 'method': 'OPTIONS', 'url': '/rest/assignments/assignment/' }); + phases: function(Assignment) { + return Assignment.getPhases(); } } })