From c38cf562d59ccd8e6e5a6d808abd1a15c4b5ac9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Thu, 18 Aug 2016 16:49:50 +0200 Subject: [PATCH] Added template hooks for plugins. --- CHANGELOG | 1 + .../static/templates/agenda/item-detail.html | 2 + openslides/core/static/js/core/base.js | 37 +++++++++++++++++++ .../templates/motions/motionpoll-form.html | 1 + 4 files changed, 41 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 118e79ecf..4ea03c3dd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -30,6 +30,7 @@ Users: Other: - Removed config cache to support multiple threads or processes. - Fixed bug, that the last change of a config value was not send via autoupdate. +- Added template hooks for plugins (in item detail view and motion poll form). Version 2.0 (2016-04-18) diff --git a/openslides/agenda/static/templates/agenda/item-detail.html b/openslides/agenda/static/templates/agenda/item-detail.html index 8af8ce460..67169b2f8 100644 --- a/openslides/agenda/static/templates/agenda/item-detail.html +++ b/openslides/agenda/static/templates/agenda/item-detail.html @@ -70,6 +70,8 @@ + +

Last speakers

diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 2dbe81201..ab51690bc 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -250,6 +250,43 @@ angular.module('OpenSlidesApp.core', [ } ]) + +// Template hooks + +.factory('templateHooks', [ + function () { + var hooks = {}; + return { + hooks: hooks, + registerHook: function (hook) { + if (hooks[hook.Id] === undefined) { + hooks[hook.Id] = []; + } + hooks[hook.Id].push(hook); + } + }; + } +]) + +.directive('templateHook', [ + '$compile', + 'templateHooks', + function ($compile, templateHooks) { + return { + restrict: 'E', + template: '', + link: function (scope, iElement, iAttr) { + var hooks = templateHooks.hooks[iAttr.hookName]; + var html = hooks.map(function (hook) { + return '
' + hook.template + '
'; + }).join(''); + iElement.append($compile(html)(scope)); + } + }; + } +]) + + .factory('jsDataModel', [ '$http', 'Projector', diff --git a/openslides/motions/static/templates/motions/motionpoll-form.html b/openslides/motions/static/templates/motions/motionpoll-form.html index 203c51671..aedd2fbc3 100644 --- a/openslides/motions/static/templates/motions/motionpoll-form.html +++ b/openslides/motions/static/templates/motions/motionpoll-form.html @@ -11,6 +11,7 @@
+