diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js
index feec6db24..5732f7a92 100644
--- a/openslides/core/static/js/core/base.js
+++ b/openslides/core/static/js/core/base.js
@@ -553,27 +553,57 @@ angular.module('OpenSlidesApp.core', [
])
// Template hooks
-// 2 possible uses:
-// - { Id: 'myHookId', template: '' }
-// - { Id: 'myHookId', templateUrl: '/static/templates/plugin_name/my-hook.html' }
-// It is possible to provide a scope, that is merged into the scope of the templateHook.
-// This overrides functions/values of the parent scope, but there may are conflicts
-// with other plugins defining the same function/value. E.g.:
+// Possible uses:
+// 1. { id: 'myHookId', template: '' }
+// 2. { id: 'myHookId', templateUrl: '/static/templates/plugin_name/my-hook.html' }
+// 3. { id: 'myHookId' }
+//
+// Deprecated: Give the id with 'Id'. Please use 'id'.
+//
+// Option 3 is for just changing the scope (see below), but not the original content. This
+// is usefull to alter a JS behavior, e.g. on a ng-click. In this case, override is false
+// for this template hook.
+//
+// It is possible to provide a scope, that is merged into the surrounding scope.
+// You can override functions or values of the surrounding scope by providing them:
// { Id: 'hookId', template: '',
// scope: {
-// customFn: function () { /*Do something */ },
+// customOrOverwritten: function () { /*Do something */ },
// },
// }
+// Or you provide a function that returns an object of functions/values to overwrite to
+// get access to the scope merged in:
+// { Id: 'hookId', template: '',
+// scope: function (scope) {
+// return {
+// customOrOverwritten: function () {
+// scope.value = /* change it */;
+// },
+// };
+// },
+// }
+//
+// As a default, template hooks in flavour of option 1 and 2 override the content that was
+// originally there. Provide 'override: false', to prevent overriding the original content.
.factory('templateHooks', [
function () {
var hooks = {};
return {
hooks: hooks,
registerHook: function (hook) {
- if (hooks[hook.Id] === undefined) {
- hooks[hook.Id] = [];
+ // Deprecated: Set the new style 'id', if 'Id' is given.
+ if (hook.id === undefined) {
+ hook.id = hook.Id;
}
- hooks[hook.Id].push(hook);
+
+ if (hooks[hook.id] === undefined) {
+ hooks[hook.id] = [];
+ }
+ // set override default
+ if (hook.override === undefined) {
+ hook.override = !!(hook.template || hook.templateUrl);
+ }
+ hooks[hook.id].push(hook);
}
};
}
@@ -584,21 +614,41 @@ angular.module('OpenSlidesApp.core', [
'$http',
'$q',
'$templateCache',
+ '$timeout',
'templateHooks',
- function ($compile, $http, $q, $templateCache, templateHooks) {
+ function ($compile, $http, $q, $templateCache, $timeout, templateHooks) {
return {
restrict: 'E',
template: '',
link: function (scope, iElement, iAttr) {
var hooks = templateHooks.hooks[iAttr.hookName];
if (hooks) {
- var templates = _.map(hooks, function (hook) {
- // Populate scope
- _.forEach(hook.scope, function (value, key) {
- if (!scope.hasOwnProperty(key)) {
- scope[key] = value;
- }
+ // Populate scopes
+ _.forEach(hooks, function (hook) {
+ var _scope = hook.scope;
+ // If it is a function, get the scope from the function and provide
+ // the original scope.
+ if (typeof hook.scope === 'function') {
+ _scope = hook.scope(scope);
+ }
+
+ _.forEach(_scope, function (value, key) {
+ scope[key] = value;
});
+ });
+
+ // Check, if at least one hook overrides the original content.
+ var override = _.some(hooks, function (hook) {
+ return hook.override;
+ });
+
+ // filter hooks, that does actually have a template
+ hooks = _.filter(hooks, function (hook) {
+ return hook.template || hook.templateUrl;
+ });
+
+ // Get all templates
+ var templates = _.map(hooks, function (hook) {
// Either a template (html given as string) or a templateUrl has
// to be given. If a scope is provided, the schope of this templateHook
// is populated with the given functions/values.
@@ -608,8 +658,17 @@ angular.module('OpenSlidesApp.core', [
return $templateCache.get(hook.templateUrl);
}
});
- var html = templates.join('');
- iElement.append($compile(html)(scope));
+
+ // Wait for the dom to build up, so we can retrieve the inner html of iElement.
+ $timeout(function () {
+ var html = override ? '' : iElement.html();
+ if (templates.length) {
+ html += templates.join('');
+ }
+
+ iElement.empty();
+ iElement.append($compile(html)(scope));
+ });
}
}
};
diff --git a/openslides/motions/static/templates/motions/motion-detail.html b/openslides/motions/static/templates/motions/motion-detail.html
index eaffec05a..2a601e6d3 100644
--- a/openslides/motions/static/templates/motions/motion-detail.html
+++ b/openslides/motions/static/templates/motions/motion-detail.html
@@ -468,10 +468,12 @@
-
+
+
+
Personal note
diff --git a/openslides/motions/static/templates/motions/motion-list.html b/openslides/motions/static/templates/motions/motion-list.html
index eaf157070..9e4421e74 100644
--- a/openslides/motions/static/templates/motions/motion-list.html
+++ b/openslides/motions/static/templates/motions/motion-list.html
@@ -21,6 +21,7 @@
Import
+
Motions
diff --git a/openslides/motions/views.py b/openslides/motions/views.py
index c9b1b130a..b7672d870 100644
--- a/openslides/motions/views.py
+++ b/openslides/motions/views.py
@@ -447,13 +447,15 @@ class MotionViewSet(ModelViewSet):
raise ValidationError({'detail': 'You can not create a poll in this motion state.'})
try:
with transaction.atomic():
- motion.create_poll(skip_autoupdate=True)
+ poll = motion.create_poll(skip_autoupdate=True)
except WorkflowError as e:
raise ValidationError({'detail': e})
motion.write_log([ugettext_noop('Vote created')], request.user, skip_autoupdate=True)
inform_changed_data(motion)
- return Response({'detail': _('Vote created successfully.')})
+ return Response({
+ 'detail': _('Vote created successfully.'),
+ 'createdPollId': poll.pk})
class MotionPollViewSet(UpdateModelMixin, DestroyModelMixin, GenericViewSet):
diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js
index c2ced0f02..8cfded5a9 100644
--- a/openslides/users/static/js/users/site.js
+++ b/openslides/users/static/js/users/site.js
@@ -565,6 +565,9 @@ angular.module('OpenSlidesApp.users.site', [
_.forEach($scope.users, function (user) {
user.has_last_email_send = !!user.last_email_send;
});
+ if ($scope.updateUsers) {
+ $scope.updateUsers();
+ }
});
Group.bindAll({where: {id: {'>': 1}}}, $scope, 'groups');
$scope.$watch(function () {
diff --git a/openslides/users/static/templates/users/user-list.html b/openslides/users/static/templates/users/user-list.html
index d31d81791..2ab33d4bf 100644
--- a/openslides/users/static/templates/users/user-list.html
+++ b/openslides/users/static/templates/users/user-list.html
@@ -19,6 +19,7 @@
Import
+