diff --git a/.wvr/build-config.js b/.wvr/build-config.js index b8825952..e76e65d8 100644 --- a/.wvr/build-config.js +++ b/.wvr/build-config.js @@ -70,24 +70,6 @@ const config = { from: './node_modules/bootstrap/dist/css/bootstrap.min.css.map', to: './resources/styles/bootstrap/dist/css/bootstrap.min.css.map', }, - { - from: './node_modules/tinymce/plugins/**/plugin.js', - to({ context, absoluteFilename }) { - return `${absoluteFilename.replace(/^.*\/node_modules\/tinymce\/plugins\//, "plugins/")}`; - }, - }, - { - from: './node_modules/tinymce/themes/**/theme.js', - to({ context, absoluteFilename }) { - return `${absoluteFilename.replace(/^.*\/node_modules\/tinymce\/themes\//, "themes/")}`; - }, - }, - { - from: './node_modules/tinymce/skins/**/*.css', - to({ context, absoluteFilename }) { - return `${absoluteFilename.replace(/^.*\/node_modules\/tinymce\/skins\//, "skins/")}`; - }, - }, ], entry: { app: [ diff --git a/app/controllers/notificationController.js b/app/controllers/notificationController.js index a1a82202..9e4346db 100644 --- a/app/controllers/notificationController.js +++ b/app/controllers/notificationController.js @@ -1,4 +1,4 @@ -app.controller('NotificationController', function ($controller, $scope, Notification, NotificationRepo, NgTableParams) { +app.controller('NotificationController', function ($controller, $scope, $timeout, Notification, NotificationRepo, NgTableParams) { angular.extend(this, $controller('AbstractScheduleController', { $scope: $scope @@ -27,24 +27,27 @@ app.controller('NotificationController', function ($controller, $scope, Notifica $scope.forms = {}; - $scope.notificationToDelete = {}; + var emptyNotification = { + name: '', + body: '', + active: false, + locations: [] + }; + + $scope.notificationToDelete = new Notification(emptyNotification); + + $scope.notificationData = new Notification(emptyNotification); $scope.resetNotifications = function () { - if ($scope.notificationData) { - $scope.notificationData.refresh(); - $scope.notificationData.clearValidationResults(); - } + $scope.notificationData.refresh(); + $scope.notificationData.clearValidationResults(); + for (var key in $scope.forms) { if (!$scope.forms[key].$pristine) { $scope.forms[key].$setPristine(); } } - $scope.notificationData = new Notification({ - name: '', - body: '', - active: false, - locations: [] - }); + Object.assign($scope.notificationData, emptyNotification); $scope.closeModal(); }; @@ -59,8 +62,17 @@ app.controller('NotificationController', function ($controller, $scope, Notifica }; $scope.editNotification = function (notification) { - $scope.notificationData = notification; - $scope.openModal('#editNotificationModal'); + Object.assign($scope.notificationData, notification); + $timeout(function () { + $scope.openModal('#editNotificationModal'); + var modal = angular.element('#editNotificationModal'); + if (modal) { + var iframe = modal.find("iframe"); + if (iframe && iframe.length >= 1) { + iframe[0].contentDocument.body.innerHTML = notification.body; + } + } + }); }; $scope.updateNotification = function () { @@ -73,8 +85,10 @@ app.controller('NotificationController', function ($controller, $scope, Notifica }; $scope.confirmDelete = function (notification) { - $scope.openModal('#deleteNotificationModal'); - $scope.notificationToDelete = notification; + Object.assign($scope.notificationToDelete, notification); + $timeout(function() { + $scope.openModal('#deleteNotificationModal'); + }); }; $scope.deleteNotification = function () { @@ -83,7 +97,7 @@ app.controller('NotificationController', function ($controller, $scope, Notifica if (angular.fromJson(res.body).meta.status === 'SUCCESS') { $scope.closeModal(); $scope.deleting = false; - $scope.notificationToDelete = {}; + Object.assign($scope.notificationToDelete, emptyNotification); $scope.tableParams.reload(); } }); @@ -111,17 +125,19 @@ app.controller('NotificationController', function ($controller, $scope, Notifica NotificationRepo.ready().then(function () { buildTable(); + + document.addEventListener("contentSave", function (e) { + $scope.notificationData.body = e.detail.data; + $scope.save(); + }); + + $scope.save = function () { + $scope.notificationData.body = encodeURIComponent($scope.notificationData.body); + $scope.notificationData.update($scope.notificationData); + $scope.notificationData.body = decodeURIComponent($scope.notificationData.body); + }; + $scope.tableParams.reload(); }); - $scope.tinymceOptions = { - selector: 'textarea', - theme: "modern", - plugins: "link lists", - toolbar: "undo redo | formatselect bold italic separator | alignleft aligncenter alignright | numlist bullist | forecolor backcolor", - relative_urls: false, - remove_script_host : false, - convert_urls : true - }; - }); diff --git a/app/views/modals/addNotificationModal.html b/app/views/modals/addNotificationModal.html index 512b14e4..312feedf 100644 --- a/app/views/modals/addNotificationModal.html +++ b/app/views/modals/addNotificationModal.html @@ -14,7 +14,7 @@