Merge pull request #3330 from FinnStutzenstein/PluginDev

Improvements for plugin integration
This commit is contained in:
Emanuel Schütze 2017-08-14 15:06:14 +02:00 committed by GitHub
commit f0d840148e
5 changed files with 43 additions and 9 deletions

View File

@ -76,6 +76,7 @@ General:
- Improved performance for PDF generation significantly (by upgrading - Improved performance for PDF generation significantly (by upgrading
to pdfmake 0.1.30) [#3278, #3285]. to pdfmake 0.1.30) [#3278, #3285].
- Bugfixes for PDF creation [#3227, #3251, #3279, #3286, #3346]. - Bugfixes for PDF creation [#3227, #3251, #3279, #3286, #3346].
- Improvements for plugin integration [#3330].
Version 2.1.1 (2017-04-05) Version 2.1.1 (2017-04-05)

View File

@ -335,6 +335,7 @@
</span> </span>
</div> </div>
</div> </div>
<template-hook hook-name="agendaListAdditionalContentColumn"></template-hook>
</small> </small>
</div> </div>
<div style="width: 40%;" class="pull-right"> <div style="width: 40%;" class="pull-right">

View File

@ -1512,6 +1512,11 @@ img {
margin-left: 2px; margin-left: 2px;
} }
/* Bootbox: override z-index, that bootboxes are higher than ngDialogs */
.bootbox {
z-index: 100000;
}
/* angular-chosen: override default width of select fields in quickmode */ /* angular-chosen: override default width of select fields in quickmode */
.chosen-container { .chosen-container {
width: 100% !important; width: 100% !important;

View File

@ -476,6 +476,17 @@ angular.module('OpenSlidesApp.core', [
]) ])
// Template hooks // Template hooks
// 2 possible uses:
// - { Id: 'myHookId', template: '<button>click me</button>' }
// - { 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.:
// { Id: 'hookId', template: '<button ng-click="customFn()">click me</button>',
// scope: {
// customFn: function () { /*Do something */ },
// },
// }
.factory('templateHooks', [ .factory('templateHooks', [
function () { function () {
var hooks = {}; var hooks = {};
@ -493,23 +504,37 @@ angular.module('OpenSlidesApp.core', [
.directive('templateHook', [ .directive('templateHook', [
'$compile', '$compile',
'$http',
'$q',
'$templateCache',
'templateHooks', 'templateHooks',
function ($compile, templateHooks) { function ($compile, $http, $q, $templateCache, templateHooks) {
return { return {
restrict: 'E', restrict: 'E',
template: '', template: '',
link: function (scope, iElement, iAttr) { link: function (scope, iElement, iAttr) {
var hooks = templateHooks.hooks[iAttr.hookName]; var hooks = templateHooks.hooks[iAttr.hookName];
var html;
if (hooks) { if (hooks) {
html = hooks.map(function (hook) { var templates = _.map(hooks, function (hook) {
return '<div>' + hook.template + '</div>'; // Populate scope
}).join(''); _.forEach(hook.scope, function (value, key) {
} else { if (!scope.hasOwnProperty(key)) {
html = ''; scope[key] = value;
} }
});
// 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.
if (hook.template) {
return '<div>' + hook.template + '</div>';
} else {
return $templateCache.get(hook.templateUrl);
}
});
var html = templates.join('');
iElement.append($compile(html)(scope)); iElement.append($compile(html)(scope));
} }
}
}; };
} }
]) ])

View File

@ -80,7 +80,9 @@ angular.module('OpenSlidesApp.core.site', [
this.scope = scope; this.scope = scope;
}, },
updateMainMenu: function () { updateMainMenu: function () {
if (this.scope) {
this.scope.elements = this.getElements(); this.scope.elements = this.getElements();
}
}, },
getElements: function() { getElements: function() {
var elements = mainMenuList.filter(function (element) { var elements = mainMenuList.filter(function (element) {