From f37ad0f6c343e62d281d260407f656e03cf376bc Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Fri, 6 Jan 2017 11:18:15 +0100 Subject: [PATCH] Use ckeditor to edit projector messages --- CHANGELOG | 1 + openslides/core/static/js/core/site.js | 62 ++++++++++++++++++- .../templates/core/projector-controls.html | 15 +---- .../core/projector-message-form.html | 12 ++++ .../static/templates/core/slide_message.html | 2 +- 5 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 openslides/core/static/templates/core/projector-message-form.html diff --git a/CHANGELOG b/CHANGELOG index 915486123..125909cd7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ Core: - Added template hook system for plugins. - Made a lot of code clean up, improvements and bug fixes in client and backend. +- Use CKEditor for editin projector messages. Motions: - Added adjustable line numbering mode (outside, inside, none) for each diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index 645b289c7..29530ff25 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -381,6 +381,43 @@ angular.module('OpenSlidesApp.core.site', [ } ]) +.factory('ProjectorMessageForm', [ + 'Editor', + 'gettextCatalog', + function (Editor, gettextCatalog) { + return { + getDialog: function (message) { + return { + template: 'static/templates/core/projector-message-form.html', + controller: 'ProjectorMessageEditCtrl', + className: 'ngdialog-theme-default wide-form', + closeByEscape: false, + closeByDocument: false, + resolve: { + projectorMessage: function () { + return message; + } + }, + }; + }, + getFormFields: function () { + return [ + { + key: 'message', + type: 'editor', + templateOptions: { + label: gettextCatalog.getString('Message'), + }, + data: { + ckeditorOptions: Editor.getOptions() + } + }, + ]; + }, + }; + } +]) + /* This factory handles the filtering of the OS-data-tables. It contains * all logic needed for the table header filtering. Things to configure: * - multiselectFilters: A dict associating the filter name to a list (empty per default). E.g. @@ -992,8 +1029,11 @@ angular.module('OpenSlidesApp.core.site', [ 'ProjectorMessage', 'Countdown', 'gettextCatalog', + 'ngDialog', + 'ProjectorMessageForm', function($scope, $http, $interval, $state, $q, Config, Projector, CurrentListOfSpeakersItem, - ListOfSpeakersOverlay, ProjectionDefault, ProjectorMessage, Countdown, gettextCatalog) { + ListOfSpeakersOverlay, ProjectionDefault, ProjectorMessage, Countdown, gettextCatalog, + ngDialog, ProjectorMessageForm) { ProjectorMessage.bindAll({}, $scope, 'messages'); var intervals = []; @@ -1106,8 +1146,7 @@ angular.module('OpenSlidesApp.core.site', [ // *** message functions *** $scope.editMessage = function (message) { - message.editFlag = false; - ProjectorMessage.save(message); + ngDialog.open(ProjectorMessageForm.getDialog(message)); }; $scope.addMessage = function () { var message = {message: ''}; @@ -1130,6 +1169,23 @@ angular.module('OpenSlidesApp.core.site', [ } ]) +.controller('ProjectorMessageEditCtrl', [ + '$scope', + 'projectorMessage', + 'ProjectorMessage', + 'ProjectorMessageForm', + function ($scope, projectorMessage, ProjectorMessage, ProjectorMessageForm) { + $scope.formFields = ProjectorMessageForm.getFormFields(); + $scope.model = angular.copy(projectorMessage); + + $scope.save = function (message) { + ProjectorMessage.inject(message); + ProjectorMessage.save(message); + $scope.closeThisDialog(); + }; + } +]) + .controller('ManageProjectorsCtrl', [ '$scope', '$http', diff --git a/openslides/core/static/templates/core/projector-controls.html b/openslides/core/static/templates/core/projector-controls.html index c1fa61031..2ca50baaa 100644 --- a/openslides/core/static/templates/core/projector-controls.html +++ b/openslides/core/static/templates/core/projector-controls.html @@ -239,7 +239,7 @@ @@ -249,18 +249,7 @@ ng-class="{ 'projected': isProjected(message).length }">    -
- -
-
- - - - -
-
+
diff --git a/openslides/core/static/templates/core/projector-message-form.html b/openslides/core/static/templates/core/projector-message-form.html new file mode 100644 index 000000000..39acae226 --- /dev/null +++ b/openslides/core/static/templates/core/projector-message-form.html @@ -0,0 +1,12 @@ +

Edit message

+ +
+ + + + +
diff --git a/openslides/core/static/templates/core/slide_message.html b/openslides/core/static/templates/core/slide_message.html index 80f757212..0ea8c2a0f 100644 --- a/openslides/core/static/templates/core/slide_message.html +++ b/openslides/core/static/templates/core/slide_message.html @@ -1,4 +1,4 @@
-
+