From afd8e7d404f7801882b675592ff86629b69f3625 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 3 Jul 2018 16:06:37 +0200 Subject: [PATCH] remove code for content mini editor --- .../umblaunchminieditor.directive.js | 25 ----- .../services/minieditorhelper.service.js | 89 --------------- .../common/dialogs/content/edit.controller.js | 103 ------------------ .../views/common/dialogs/content/edit.html | 80 -------------- .../contentpicker/contentpicker.controller.js | 3 +- 5 files changed, 1 insertion(+), 299 deletions(-) delete mode 100644 src/Umbraco.Web.UI.Client/src/common/directives/components/umblaunchminieditor.directive.js delete mode 100644 src/Umbraco.Web.UI.Client/src/common/services/minieditorhelper.service.js delete mode 100644 src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.controller.js delete mode 100644 src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.html diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umblaunchminieditor.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umblaunchminieditor.directive.js deleted file mode 100644 index 11b934ce96..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umblaunchminieditor.directive.js +++ /dev/null @@ -1,25 +0,0 @@ -/** -* @ngdoc directive -* @name umbraco.directives.directive:umbLaunchMiniEditor -* @restrict E -* @function -* @description -* Used on a button to launch a mini content editor editor dialog -**/ -angular.module("umbraco.directives") - .directive('umbLaunchMiniEditor', function (miniEditorHelper) { - return { - restrict: 'A', - replace: false, - scope: { - node: '=umbLaunchMiniEditor', - }, - link: function(scope, element, attrs) { - - element.click(function() { - miniEditorHelper.launchMiniEditor(scope.node); - }); - - } - }; - }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/minieditorhelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/minieditorhelper.service.js deleted file mode 100644 index 693457c7e8..0000000000 --- a/src/Umbraco.Web.UI.Client/src/common/services/minieditorhelper.service.js +++ /dev/null @@ -1,89 +0,0 @@ -(function () { - 'use strict'; - - function miniEditorHelper(dialogService, editorState, fileManager, contentEditingHelper, $q) { - - var launched = false; - - function launchMiniEditor(node) { - - var deferred = $q.defer(); - - launched = true; - - //We need to store the current files selected in the file manager locally because the fileManager - // is a singleton and is shared globally. The mini dialog will also be referencing the fileManager - // and we don't want it to be sharing the same files as the main editor. So we'll store the current files locally here, - // clear them out and then launch the dialog. When the dialog closes, we'll reset the fileManager to it's previous state. - var currFiles = _.groupBy(fileManager.getFiles(), "alias"); - fileManager.clearFiles(); - - //We need to store the original editorState entity because it will need to change when the mini editor is loaded so that - // any property editors that are working with editorState get given the correct entity, otherwise strange things will - // start happening. - var currEditorState = editorState.getCurrent(); - - dialogService.open({ - template: "views/common/dialogs/content/edit.html", - id: node.id, - closeOnSave: true, - tabFilter: ["Generic properties"], - callback: function (data) { - - //set the node name back - node.name = data.name; - - //reset the fileManager to what it was - fileManager.clearFiles(); - _.each(currFiles, function (val, key) { - fileManager.setFiles(key, _.map(currFiles['upload'], function (i) { return i.file; })); - }); - - //reset the editor state - editorState.set(currEditorState); - - //Now we need to check if the content item that was edited was actually the same content item - // as the main content editor and if so, update all property data - if (data.id === currEditorState.id) { - var changed = contentEditingHelper.reBindChangedProperties(currEditorState, data); - } - - launched = false; - - deferred.resolve(data); - - }, - closeCallback: function () { - //reset the fileManager to what it was - fileManager.clearFiles(); - _.each(currFiles, function (val, key) { - fileManager.setFiles(key, _.map(currFiles['upload'], function (i) { return i.file; })); - }); - - //reset the editor state - editorState.set(currEditorState); - - launched = false; - - deferred.reject(); - - } - }); - - return deferred.promise; - - } - - var service = { - launchMiniEditor: launchMiniEditor - }; - - return service; - - } - - - angular.module('umbraco.services').factory('miniEditorHelper', miniEditorHelper); - - -})(); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.controller.js deleted file mode 100644 index c4aa39930d..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.controller.js +++ /dev/null @@ -1,103 +0,0 @@ -function ContentEditDialogController($scope, editorState, $routeParams, $q, $timeout, $window, appState, contentResource, entityResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, treeService, fileManager, formHelper, umbRequestHelper, umbModelMapper, $http) { - - $scope.defaultButton = null; - $scope.subButtons = []; - var dialogOptions = $scope.$parent.dialogOptions; - - // This is a helper method to reduce the amount of code repitition for actions: Save, Publish, SendToPublish - function performSave(args) { - contentEditingHelper.contentEditorPerformSave({ - saveMethod: args.saveMethod, - scope: $scope, - content: $scope.content - }).then(function (content) { - //success - if (dialogOptions.closeOnSave) { - $scope.submit(content); - } - - }, function(err) { - //error - }); - } - - function filterTabs(entity, blackList) { - if (blackList) { - _.each(entity.tabs, function (tab) { - tab.hide = _.contains(blackList, tab.alias); - }); - } - - return entity; - }; - - function init(content) { - var buttons = contentEditingHelper.configureContentEditorButtons({ - create: $routeParams.create, - content: content, - methods: { - saveAndPublish: $scope.saveAndPublish, - sendToPublish: $scope.sendToPublish, - save: $scope.save, - unPublish: angular.noop - } - }); - $scope.defaultButton = buttons.defaultButton; - $scope.subButtons = buttons.subButtons; - - //This is a total hack but we have really no other way of sharing data to the property editors of this - // content item, so we'll just set the property on the content item directly - $scope.content.isDialogEditor = true; - - editorState.set($scope.content); - } - - //check if the entity is being passed in, otherwise load it from the server - if (angular.isObject(dialogOptions.entity)) { - $scope.loaded = true; - $scope.content = filterTabs(dialogOptions.entity, dialogOptions.tabFilter); - init($scope.content); - } - else { - contentResource.getById(dialogOptions.id) - .then(function(data) { - $scope.loaded = true; - $scope.content = filterTabs(data, dialogOptions.tabFilter); - init($scope.content); - //in one particular special case, after we've created a new item we redirect back to the edit - // route but there might be server validation errors in the collection which we need to display - // after the redirect, so we will bind all subscriptions which will show the server validation errors - // if there are any and then clear them so the collection no longer persists them. - serverValidationManager.executeAndClearAllSubscriptions(); - }); - } - - $scope.sendToPublish = function () { - performSave({ saveMethod: contentResource.sendToPublish }); - }; - - $scope.saveAndPublish = function () { - performSave({ saveMethod: contentResource.publish }); - }; - - $scope.save = function () { - performSave({ saveMethod: contentResource.save }); - }; - - // this method is called for all action buttons and then we proxy based on the btn definition - $scope.performAction = function (btn) { - - if (!btn || !angular.isFunction(btn.handler)) { - throw "btn.handler must be a function reference"; - } - - if (!$scope.busy) { - btn.handler.apply(this); - } - }; - -} - - -angular.module("umbraco") - .controller("Umbraco.Dialogs.Content.EditController", ContentEditDialogController); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.html deleted file mode 100644 index a5b73d1c98..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/content/edit.html +++ /dev/null @@ -1,80 +0,0 @@ -
- -
-
- -
- - - - - -
- -
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js index 1e3fc8f567..02a2fa748c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js @@ -10,10 +10,9 @@ * @param {any} angularHelper * @param {any} navigationService * @param {any} $location - * @param {any} miniEditorHelper * @param {any} localizationService */ -function contentPickerController($scope, entityResource, editorState, iconHelper, $routeParams, angularHelper, navigationService, $location, miniEditorHelper, localizationService, editorService) { +function contentPickerController($scope, entityResource, editorState, iconHelper, $routeParams, angularHelper, navigationService, $location, localizationService, editorService) { var unsubscribe;