From b6bc83ba71476e7a0232152b8bc6b09cebe74c9b Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Wed, 22 Feb 2017 11:53:36 +0000 Subject: [PATCH] Moves the bulky JSON objects for shortcuts to show in the shortcut overviews into helper service so can be reused a bit easier --- .../common/services/templatehelper.service.js | 95 ++++++++++++++++++- .../src/views/scripts/edit.controller.js | 54 +---------- .../src/views/templates/edit.controller.js | 86 +---------------- 3 files changed, 102 insertions(+), 133 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js index 01e544c78d..63eed66917 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/templatehelper.service.js @@ -1,7 +1,7 @@ (function() { 'use strict'; - function templateHelperService() { + function templateHelperService(localizationService) { //crappy hack due to dictionary items not in umbracoNode table function getInsertDictionarySnippet(nodeName) { @@ -36,6 +36,94 @@ return "@section " + sectionName + "\r\n{\r\n\r\n\t{0}\r\n\r\n}\r\n"; } + function getGeneralShortcuts(){ + return { + "name": localizationService.localize("shortcuts_generalHeader"), + "shortcuts": [ + { + "description": localizationService.localize("buttons_undo"), + "keys": [{ "key": "ctrl" }, { "key": "z" }] + }, + { + "description": localizationService.localize("buttons_redo"), + "keys": [{ "key": "ctrl" }, { "key": "y" }] + }, + { + "description": localizationService.localize("buttons_save"), + "keys": [{ "key": "ctrl" }, { "key": "s" }] + } + ] + }; + } + + function getEditorShortcuts(){ + return { + "name": localizationService.localize("shortcuts_editorHeader"), + "shortcuts": [ + { + "description": localizationService.localize("shortcuts_commentLine"), + "keys": [{ "key": "ctrl" }, { "key": "/" }] + }, + { + "description": localizationService.localize("shortcuts_removeLine"), + "keys": [{ "key": "ctrl" }, { "key": "d" }] + }, + { + "description": localizationService.localize("shortcuts_copyLineUp"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] + }, + { + "description": localizationService.localize("shortcuts_copyLineDown"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] + }, + { + "description": localizationService.localize("shortcuts_moveLineUp"), + "keys": [{ "key": "alt" }, { "key": "up" }] + }, + { + "description": localizationService.localize("shortcuts_moveLineDown"), + "keys": [{ "key": "alt" }, { "key": "down" }] + } + ] + }; + } + + function getTemplateEditorShortcuts(){ + return { + "name": "Umbraco", //No need to localise Umbraco is the same in all languages :) + "shortcuts": [ + { + "description": localizationService.format(["template_insert", "template_insertPageField"], "%0% %1%"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "v" }] + }, + { + "description": localizationService.format(["template_insert", "template_insertPartialView"], "%0% %1%"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "p" }] + }, + { + "description": localizationService.format(["template_insert", "template_insertDictionaryItem"], "%0% %1%"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "d" }] + }, + { + "description": localizationService.format(["template_insert", "template_insertMacro"], "%0% %1%"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "m" }] + }, + { + "description": localizationService.localize("template_queryBuilder"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "q" }] + }, + { + "description": localizationService.format(["template_insert", "template_insertSections"], "%0% %1%"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "s" }] + }, + { + "description": localizationService.localize("template_mastertemplate"), + "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "t" }] + } + ] + }; + } + //////////// var service = { @@ -44,7 +132,10 @@ getQuerySnippet: getQuerySnippet, getRenderBodySnippet: getRenderBodySnippet, getRenderSectionSnippet: getRenderSectionSnippet, - getAddSectionSnippet: getAddSectionSnippet + getAddSectionSnippet: getAddSectionSnippet, + getGeneralShortcuts: getGeneralShortcuts, + getEditorShortcuts: getEditorShortcuts, + getTemplateEditorShortcuts: getTemplateEditorShortcuts }; return service; diff --git a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js index cc16105983..9121b6db88 100644 --- a/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/scripts/edit.controller.js @@ -1,7 +1,7 @@ (function () { "use strict"; - function ScriptsEditController($scope, $routeParams, $timeout, appState, editorState, navigationService, assetsService, codefileResource, contentEditingHelper, notificationsService, localizationService) { + function ScriptsEditController($scope, $routeParams, $timeout, appState, editorState, navigationService, assetsService, codefileResource, contentEditingHelper, notificationsService, localizationService, templateHelper) { var vm = this; var currentPosition = null; @@ -19,54 +19,10 @@ vm.showKeyboardShortcut = false; //Keyboard shortcuts for help dialog - vm.page.keyboardShortcutsOverview = [ - { - "name": localizationService.localize("shortcuts_generalHeader"), - "shortcuts": [ - { - "description": localizationService.localize("buttons_undo"), - "keys": [{ "key": "ctrl" }, { "key": "z" }] - }, - { - "description": localizationService.localize("buttons_redo"), - "keys": [{ "key": "ctrl" }, { "key": "y" }] - }, - { - "description": localizationService.localize("buttons_save"), - "keys": [{ "key": "ctrl" }, { "key": "s" }] - } - ] - }, - { - "name": localizationService.localize("shortcuts_editorHeader"), - "shortcuts": [ - { - "description": localizationService.localize("shortcuts_commentLine"), - "keys": [{ "key": "ctrl" }, { "key": "/" }] - }, - { - "description": localizationService.localize("shortcuts_removeLine"), - "keys": [{ "key": "ctrl" }, { "key": "d" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineUp"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineDown"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineUp"), - "keys": [{ "key": "alt" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineDown"), - "keys": [{ "key": "alt" }, { "key": "down" }] - } - ] - } - ]; + vm.page.keyboardShortcutsOverview = []; + vm.page.keyboardShortcutsOverview.push(templateHelper.getGeneralShortcuts()); + vm.page.keyboardShortcutsOverview.push(templateHelper.getEditorShortcuts()); + vm.script = {}; diff --git a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js index 0b36a86672..b7d19dd2ec 100644 --- a/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/templates/edit.controller.js @@ -21,88 +21,10 @@ vm.showKeyboardShortcut = false; //Keyboard shortcuts for help dialog - vm.page.keyboardShortcutsOverview = [ - { - "name": localizationService.localize("shortcuts_generalHeader"), - "shortcuts": [ - { - "description": localizationService.localize("buttons_undo"), - "keys": [{ "key": "ctrl" }, { "key": "z" }] - }, - { - "description": localizationService.localize("buttons_redo"), - "keys": [{ "key": "ctrl" }, { "key": "y" }] - }, - { - "description": localizationService.localize("buttons_save"), - "keys": [{ "key": "ctrl" }, { "key": "s" }] - } - ] - }, - { - "name": localizationService.localize("shortcuts_editorHeader"), - "shortcuts": [ - { - "description": localizationService.localize("shortcuts_commentLine"), - "keys": [{ "key": "ctrl" }, { "key": "/" }] - }, - { - "description": localizationService.localize("shortcuts_removeLine"), - "keys": [{ "key": "ctrl" }, { "key": "d" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineUp"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_copyLineDown"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "down" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineUp"), - "keys": [{ "key": "alt" }, { "key": "up" }] - }, - { - "description": localizationService.localize("shortcuts_moveLineDown"), - "keys": [{ "key": "alt" }, { "key": "down" }] - } - ] - }, - { - "name": "Umbraco", //No need to localise Umbraco is the same in all languages :) - "shortcuts": [ - { - "description": localizationService.format(["template_insert", "template_insertPageField"], "%0% %1%"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "v" }] - }, - { - "description": localizationService.format(["template_insert", "template_insertPartialView"], "%0% %1%"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "p" }] - }, - { - "description": localizationService.format(["template_insert", "template_insertDictionaryItem"], "%0% %1%"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "d" }] - }, - { - "description": localizationService.format(["template_insert", "template_insertMacro"], "%0% %1%"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "m" }] - }, - { - "description": localizationService.localize("template_queryBuilder"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "q" }] - }, - { - "description": localizationService.format(["template_insert", "template_insertSections"], "%0% %1%"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "s" }] - }, - { - "description": localizationService.localize("template_mastertemplate"), - "keys": [{ "key": "alt" }, { "key": "shift" }, { "key": "t" }] - }, - ] - } - ]; - + vm.page.keyboardShortcutsOverview = []; + vm.page.keyboardShortcutsOverview.push(templateHelper.getGeneralShortcuts()); + vm.page.keyboardShortcutsOverview.push(templateHelper.getEditorShortcuts()); + vm.page.keyboardShortcutsOverview.push(templateHelper.getTemplateEditorShortcuts()); vm.save = function () {