From aeba68782c5f93e2d1bd2836798a51e9e85a28bc Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Mon, 8 Feb 2016 10:54:58 +0100 Subject: [PATCH] fixes: U4-7903 Using shortcut for "add property" removes "add property"-field for other tabs in document type editor && U4-7904 Add property using shortcut - submit button text is missing --- .../components/forms/hotkey.directive.js | 74 +++++++++++-------- .../components/umbgroupsbuilder.directive.js | 19 ++++- .../notifications/confirmroutechange.html | 4 +- .../views/components/umb-groups-builder.html | 11 ++- 4 files changed, 69 insertions(+), 39 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js index 310d69a8a2..882e273002 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/forms/hotkey.directive.js @@ -15,45 +15,55 @@ angular.module("umbraco.directives") keyCombo = scope.$eval(attrs["hotkey"]); } - // disable shortcuts in input fields if keycombo is 1 character - if (keyCombo) { + function activate() { - if (keyCombo.length === 1) { - options = { - inputDisabled: true - }; - } + if (keyCombo) { - keyboardService.bind(keyCombo, function() { - - var element = $(el); - var activeElementType = document.activeElement.tagName; - var clickableElements = ["A", "BUTTON"]; - - if (element.is("a,div,button,input[type='button'],input[type='submit'],input[type='checkbox']") && !element.is(':disabled')) { - - if (element.is(':visible') || attrs.hotkeyWhenHidden) { - - // when keycombo is enter and a link or button has focus - click the link or button instead of using the hotkey - if (keyCombo === "enter" && clickableElements.indexOf(activeElementType) === 0) { - document.activeElement.click(); - } else { - element.click(); - } - - } - - } else { - element.focus(); + // disable shortcuts in input fields if keycombo is 1 character + if (keyCombo.length === 1) { + options = { + inputDisabled: true + }; } - }, options); + keyboardService.bind(keyCombo, function() { - el.on('$destroy', function() { - keyboardService.unbind(keyCombo); - }); + var element = $(el); + var activeElementType = document.activeElement.tagName; + var clickableElements = ["A", "BUTTON"]; + + if (element.is("a,div,button,input[type='button'],input[type='submit'],input[type='checkbox']") && !element.is(':disabled')) { + + if (element.is(':visible') || attrs.hotkeyWhenHidden) { + + if (attrs.hotkeyWhen && attrs.hotkeyWhen === "false") { + return; + } + + // when keycombo is enter and a link or button has focus - click the link or button instead of using the hotkey + if (keyCombo === "enter" && clickableElements.indexOf(activeElementType) === 0) { + document.activeElement.click(); + } else { + element.click(); + } + + } + + } else { + element.focus(); + } + + }, options); + + el.on('$destroy', function() { + keyboardService.unbind(keyCombo); + }); + + } } + activate(); + }; }); diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js index 328884cfa1..caa79439be 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbgroupsbuilder.directive.js @@ -28,6 +28,8 @@ // add init tab addInitGroup(scope.model.groups); + activateFirstGroup(scope.model.groups); + // localize texts localizationService.localize("validation_validation").then(function(value) { validationTranslated = value; @@ -153,14 +155,14 @@ return resourceLookup(scope.model.id, selectedContentTypeAliases, propAliasesExisting).then(function (filteredAvailableCompositeTypes) { _.each(scope.compositionsDialogModel.availableCompositeContentTypes, function (current) { - //reset first + //reset first current.allowed = true; //see if this list item is found in the response (allowed) list var found = _.find(filteredAvailableCompositeTypes, function (f) { return current.contentType.alias === f.contentType.alias; }); - //allow if the item was found in the response (allowed) list - + //allow if the item was found in the response (allowed) list - // and ensure its set to allowed if it is currently checked, // DO not allow if it's a locked content type. current.allowed = scope.model.lockedCompositeContentTypes.indexOf(current.contentType.alias) === -1 && @@ -181,7 +183,7 @@ } function setupAvailableContentTypesModel(result) { - scope.compositionsDialogModel.availableCompositeContentTypes = result; + scope.compositionsDialogModel.availableCompositeContentTypes = result; //iterate each one and set it up _.each(scope.compositionsDialogModel.availableCompositeContentTypes, function (c) { //enable it if it's part of the selected model @@ -276,7 +278,7 @@ // submit overlay if no compositions has been removed // or the action has been confirmed } else { - + // make sure that all tabs has an init property if (scope.model.groups.length !== 0) { angular.forEach(scope.model.groups, function(group) { @@ -454,6 +456,15 @@ return groups; } + function activateFirstGroup(groups) { + if (groups && groups.length > 0) { + var firstGroup = groups[0]; + if(!firstGroup.tabState || firstGroup.tabState === "inActive") { + firstGroup.tabState = "active"; + } + } + } + /* ---------- PROPERTIES ---------- */ scope.addProperty = function(property, group) { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/notifications/confirmroutechange.html b/src/Umbraco.Web.UI.Client/src/views/common/notifications/confirmroutechange.html index 97be02baea..80942baaeb 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/notifications/confirmroutechange.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/notifications/confirmroutechange.html @@ -3,5 +3,5 @@

Are you sure you want to navigate away from this page? - you have unsaved changes

- - \ No newline at end of file + + diff --git a/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html b/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html index d6fb05c57e..dd4ed268d4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/umb-groups-builder.html @@ -75,6 +75,7 @@ ng-disabled="tab.inherited" umb-auto-focus umb-auto-resize + on-focus="activateGroup(tab)" required val-server-field="{{'Groups[' + $index + '].Name'}}" /> @@ -109,7 +110,15 @@
  • - +