From d0bca313a6dd9c0501938d2ed7329318d8c4d7b0 Mon Sep 17 00:00:00 2001 From: Jason Savell Date: Mon, 10 Jun 2024 10:38:15 -0500 Subject: [PATCH 01/10] downgrade tinymce to latest version compatible with angular-ui-tinymce --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc8b849..c58d71a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "angular-ui-tinymce": "0.0.19", "ng-csv": "0.3.6", "ng-table": "3.0.1", - "tinymce": "7.0.0" + "tinymce": "^4.9" }, "devDependencies": { }, From e401973ae1f1178287c7bf81fd3a66cc84bda7b7 Mon Sep 17 00:00:00 2001 From: Rincy Mathew Date: Wed, 3 Jul 2024 08:17:29 -0500 Subject: [PATCH 02/10] WIP - added tl-wysiwyg in the add notification modal --- app/controllers/notificationController.js | 22 ++++++++++++---------- app/views/modals/addNotificationModal.html | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/controllers/notificationController.js b/app/controllers/notificationController.js index a1a8220..e8dc950 100644 --- a/app/controllers/notificationController.js +++ b/app/controllers/notificationController.js @@ -111,17 +111,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 512b14e..312feed 100644 --- a/app/views/modals/addNotificationModal.html +++ b/app/views/modals/addNotificationModal.html @@ -14,7 +14,7 @@
{{ notificationRepo.getValidationResults().messages.body.minlength }}
- +
From cd63b1cdab71c83660c12e3fcf78c0911abb1ba4 Mon Sep 17 00:00:00 2001 From: William Welling Date: Wed, 3 Jul 2024 11:50:22 -0500 Subject: [PATCH 03/10] Use tl-wysiwyg for edit notification Required manually adding body to tinymce iframe document --- app/controllers/notificationController.js | 2 ++ app/views/modals/editNotificationModal.html | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/notificationController.js b/app/controllers/notificationController.js index e8dc950..8d50e87 100644 --- a/app/controllers/notificationController.js +++ b/app/controllers/notificationController.js @@ -61,6 +61,8 @@ app.controller('NotificationController', function ($controller, $scope, Notifica $scope.editNotification = function (notification) { $scope.notificationData = notification; $scope.openModal('#editNotificationModal'); + const iframe = angular.element('#editNotificationModal').find("iframe")[0]; + iframe.contentDocument.body.innerHTML = notification.body; }; $scope.updateNotification = function () { diff --git a/app/views/modals/editNotificationModal.html b/app/views/modals/editNotificationModal.html index d04018a..f85df02 100644 --- a/app/views/modals/editNotificationModal.html +++ b/app/views/modals/editNotificationModal.html @@ -13,7 +13,8 @@ - + +
From ae60e79c47f570b5f8607dbb80e7a842af5eb8da Mon Sep 17 00:00:00 2001 From: William Welling Date: Wed, 3 Jul 2024 11:58:02 -0500 Subject: [PATCH 04/10] Add checks for iframe --- app/controllers/notificationController.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/notificationController.js b/app/controllers/notificationController.js index 8d50e87..2e929da 100644 --- a/app/controllers/notificationController.js +++ b/app/controllers/notificationController.js @@ -61,8 +61,13 @@ app.controller('NotificationController', function ($controller, $scope, Notifica $scope.editNotification = function (notification) { $scope.notificationData = notification; $scope.openModal('#editNotificationModal'); - const iframe = angular.element('#editNotificationModal').find("iframe")[0]; - iframe.contentDocument.body.innerHTML = notification.body; + const modal = angular.element('#editNotificationModal'); + if (modal) { + const iframe = modal.find("iframe"); + if (iframe && iframe.length >= 1) { + iframe[0].contentDocument.body.innerHTML = notification.body; + } + } }; $scope.updateNotification = function () { From 0b2d36005043a9ebfb80d4e4c044f4d0e9d9bd84 Mon Sep 17 00:00:00 2001 From: William Welling Date: Wed, 3 Jul 2024 11:59:36 -0500 Subject: [PATCH 05/10] Remove unnecessary build config --- .wvr/build-config.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.wvr/build-config.js b/.wvr/build-config.js index b882595..e76e65d 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: [ From 132a7fe0a87b3d2bdf825ba123e008cbba08786e Mon Sep 17 00:00:00 2001 From: William Welling Date: Fri, 5 Jul 2024 09:09:53 -0500 Subject: [PATCH 06/10] Add some digest cycles and preserve notification data binding --- app/controllers/notificationController.js | 43 ++++++++++++++--------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/app/controllers/notificationController.js b/app/controllers/notificationController.js index 2e929da..b37948f 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 @@ -29,17 +29,24 @@ app.controller('NotificationController', function ($controller, $scope, Notifica $scope.notificationToDelete = {}; + $scope.notificationData = new Notification({ + name: '', + body: '', + active: false, + locations: [] + }); + $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({ + Object.assign($scope.notificationData, { + id: undefined, name: '', body: '', active: false, @@ -59,15 +66,17 @@ app.controller('NotificationController', function ($controller, $scope, Notifica }; $scope.editNotification = function (notification) { - $scope.notificationData = notification; - $scope.openModal('#editNotificationModal'); - const modal = angular.element('#editNotificationModal'); - if (modal) { - const iframe = modal.find("iframe"); - if (iframe && iframe.length >= 1) { - iframe[0].contentDocument.body.innerHTML = notification.body; + Object.assign($scope.notificationData, notification); + $timeout(function () { + $scope.openModal('#editNotificationModal'); + const modal = angular.element('#editNotificationModal'); + if (modal) { + const iframe = modal.find("iframe"); + if (iframe && iframe.length >= 1) { + iframe[0].contentDocument.body.innerHTML = notification.body; + } } - } + }); }; $scope.updateNotification = function () { @@ -80,8 +89,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 () { From e6ac5d12d4f486a7ca0b19b8e455ebecbf35c91e Mon Sep 17 00:00:00 2001 From: William Welling Date: Fri, 5 Jul 2024 09:25:17 -0500 Subject: [PATCH 07/10] Fix delete notification --- app/controllers/notificationController.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/app/controllers/notificationController.js b/app/controllers/notificationController.js index b37948f..cdc81f3 100644 --- a/app/controllers/notificationController.js +++ b/app/controllers/notificationController.js @@ -27,14 +27,16 @@ app.controller('NotificationController', function ($controller, $scope, $timeout $scope.forms = {}; - $scope.notificationToDelete = {}; - - $scope.notificationData = new Notification({ + var emptyNotification = { name: '', body: '', active: false, locations: [] - }); + }; + + $scope.notificationToDelete = new Notification(emptyNotification); + + $scope.notificationData = new Notification(emptyNotification); $scope.resetNotifications = function () { $scope.notificationData.refresh(); @@ -45,13 +47,7 @@ app.controller('NotificationController', function ($controller, $scope, $timeout $scope.forms[key].$setPristine(); } } - Object.assign($scope.notificationData, { - id: undefined, - name: '', - body: '', - active: false, - locations: [] - }); + Object.assign($scope.notificationData, emptyNotification); $scope.closeModal(); }; @@ -101,7 +97,7 @@ app.controller('NotificationController', function ($controller, $scope, $timeout if (angular.fromJson(res.body).meta.status === 'SUCCESS') { $scope.closeModal(); $scope.deleting = false; - $scope.notificationToDelete = {}; + Object.assign($scope.notificationToDelete, emptyNotification); $scope.tableParams.reload(); } }); From 364b613e8fcfca39bbc5ea2cbb3505a2b47cc56d Mon Sep 17 00:00:00 2001 From: William Welling Date: Fri, 5 Jul 2024 09:43:22 -0500 Subject: [PATCH 08/10] Fix notification controller tests --- .../controllers/notificationControllerTest.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/unit/controllers/notificationControllerTest.js b/tests/unit/controllers/notificationControllerTest.js index 697d754..6ba18da 100644 --- a/tests/unit/controllers/notificationControllerTest.js +++ b/tests/unit/controllers/notificationControllerTest.js @@ -9,10 +9,11 @@ describe('controller: NotificationController', function () { module('mock.notification'); module('mock.notificationRepo'); - inject(function ($controller, $q, $rootScope, _NgTableParams_, _Notification_, _NotificationRepo_) { + inject(function ($controller, $q, $rootScope, $timeout, _NgTableParams_, _Notification_, _NotificationRepo_) { installPromiseMatchers(); q = $q; scope = $rootScope.$new(); + timeout = $timeout; controller = $controller('NotificationController', { $scope: scope, @@ -72,13 +73,14 @@ describe('controller: NotificationController', function () { describe('Are the scope methods working as expected', function () { it('resetNotifications should reset notifications', function () { - var notification; - scope.notificationData = null; + var notification = new Notification(); + scope.notificationData = notification; scope.closeModal = function() {}; spyOn(scope, 'closeModal'); scope.resetNotifications(); + scope.$digest(); expect(scope.closeModal).toHaveBeenCalled(); expect(scope.ideaData).not.toEqual(null); @@ -109,14 +111,14 @@ describe('controller: NotificationController', function () { expect(notification.clearValidationResults).toHaveBeenCalled(); }); it('editNotification should open a modal', function () { - scope.notificationData = null; scope.openModal = function(name) { }; spyOn(scope, 'openModal'); scope.editNotification(mockNotification1); + timeout.flush(); + scope.$digest(); - expect(scope.notificationData).toEqual(mockNotification1); expect(scope.openModal).toHaveBeenCalled(); }); @@ -133,14 +135,14 @@ describe('controller: NotificationController', function () { expect(scope.notificationRepo.update).toHaveBeenCalled(); }); it('confirmDelete should should open a modal', function () { - scope.notificationToDelete = null; scope.openModal = function(name) { }; spyOn(scope, 'openModal'); scope.confirmDelete(mockNotification1); + timeout.flush(); + scope.$digest(); - expect(scope.notificationToDelete).toEqual(mockNotification1); expect(scope.openModal).toHaveBeenCalled(); }); it('deleteNotification should delete a notification', function () { From 2809f72219d3f014cd6b543b9cff4718d0563172 Mon Sep 17 00:00:00 2001 From: William Welling Date: Mon, 8 Jul 2024 09:43:43 -0500 Subject: [PATCH 09/10] Remove tinymce tamu-library-components brings in tinymce --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index c58d71a..f151898 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,7 @@ "@wvr/core": "2.2.6", "angular-ui-tinymce": "0.0.19", "ng-csv": "0.3.6", - "ng-table": "3.0.1", - "tinymce": "^4.9" + "ng-table": "3.0.1" }, "devDependencies": { }, From dcc2928d9f71f71e411e4727a2e640da4bedf295 Mon Sep 17 00:00:00 2001 From: William Welling Date: Mon, 8 Jul 2024 10:14:39 -0500 Subject: [PATCH 10/10] Use var to be consistent with AngularJS code --- app/controllers/notificationController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/notificationController.js b/app/controllers/notificationController.js index cdc81f3..9e4346d 100644 --- a/app/controllers/notificationController.js +++ b/app/controllers/notificationController.js @@ -65,9 +65,9 @@ app.controller('NotificationController', function ($controller, $scope, $timeout Object.assign($scope.notificationData, notification); $timeout(function () { $scope.openModal('#editNotificationModal'); - const modal = angular.element('#editNotificationModal'); + var modal = angular.element('#editNotificationModal'); if (modal) { - const iframe = modal.find("iframe"); + var iframe = modal.find("iframe"); if (iframe && iframe.length >= 1) { iframe[0].contentDocument.body.innerHTML = notification.body; }