Don't keep appending the content name on each change of the language dropdown
(cherry picked from 02c3a5a5b2797d59b229d1fbcc8ab6524f247e55 and 7de7e59f55)
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
|
||||
function EditorContentHeader(serverValidationManager, localizationService, editorState) {
|
||||
|
||||
|
||||
function link(scope, el, attr, ctrl) {
|
||||
|
||||
var unsubscribe = [];
|
||||
|
||||
|
||||
if (!scope.serverValidationNameField) {
|
||||
scope.serverValidationNameField = "Name";
|
||||
}
|
||||
@@ -15,15 +15,16 @@
|
||||
}
|
||||
|
||||
scope.isNew = scope.content.state == "NotCreated";
|
||||
|
||||
|
||||
localizationService.localizeMany([
|
||||
scope.isNew ? "placeholders_a11yCreateItem" : "placeholders_a11yEdit",
|
||||
scope.isNew ? "placeholders_a11yCreateItem" : "placeholders_a11yEdit",
|
||||
"placeholders_a11yName",
|
||||
scope.isNew?"general_new":"general_edit"]
|
||||
scope.isNew ? "general_new" : "general_edit"]
|
||||
).then(function (data) {
|
||||
|
||||
scope.a11yMessage = data[0];
|
||||
scope.a11yName = data[1];
|
||||
var title = data[2] +":";
|
||||
var title = data[2] + ": ";
|
||||
if (!scope.isNew) {
|
||||
scope.a11yMessage += " " + scope.content.name;
|
||||
title += scope.content.name;
|
||||
@@ -33,16 +34,17 @@
|
||||
scope.a11yName = name + " " + scope.a11yName;
|
||||
title += name;
|
||||
}
|
||||
scope.$root.locationTitle = title + " - " + scope.$root.locationTitle ;
|
||||
|
||||
scope.$emit("$changeTitle", title);
|
||||
});
|
||||
scope.vm = {};
|
||||
scope.vm.dropdownOpen = false;
|
||||
scope.vm.currentVariant = "";
|
||||
scope.vm.variantsWithError = [];
|
||||
scope.vm.defaultVariant = null;
|
||||
|
||||
|
||||
scope.vm.errorsOnOtherVariants = false;// indicating wether to show that other variants, than the current, have errors.
|
||||
|
||||
|
||||
function checkErrorsOnOtherVariants() {
|
||||
var check = false;
|
||||
angular.forEach(scope.content.variants, function (variant) {
|
||||
@@ -52,10 +54,10 @@
|
||||
});
|
||||
scope.vm.errorsOnOtherVariants = check;
|
||||
}
|
||||
|
||||
|
||||
function onCultureValidation(valid, errors, allErrors, culture) {
|
||||
var index = scope.vm.variantsWithError.indexOf(culture);
|
||||
if(valid === true) {
|
||||
if (valid === true) {
|
||||
if (index !== -1) {
|
||||
scope.vm.variantsWithError.splice(index, 1);
|
||||
}
|
||||
@@ -66,165 +68,165 @@
|
||||
}
|
||||
checkErrorsOnOtherVariants();
|
||||
}
|
||||
|
||||
|
||||
function onInit() {
|
||||
|
||||
|
||||
// find default.
|
||||
angular.forEach(scope.content.variants, function (variant) {
|
||||
if (variant.language.isDefault) {
|
||||
scope.vm.defaultVariant = variant;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setCurrentVariant();
|
||||
|
||||
|
||||
angular.forEach(scope.content.apps, (app) => {
|
||||
if (app.alias === "umbContent") {
|
||||
app.anchors = scope.content.tabs;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
angular.forEach(scope.content.variants, function (variant) {
|
||||
unsubscribe.push(serverValidationManager.subscribe(null, variant.language.culture, null, onCultureValidation));
|
||||
});
|
||||
|
||||
unsubscribe.push(serverValidationManager.subscribe(null, null, null, onCultureValidation));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function setCurrentVariant() {
|
||||
angular.forEach(scope.content.variants, function (variant) {
|
||||
if (variant.active) {
|
||||
scope.vm.currentVariant = variant;
|
||||
checkErrorsOnOtherVariants();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
scope.goBack = function () {
|
||||
if (scope.onBack) {
|
||||
scope.onBack();
|
||||
}
|
||||
};
|
||||
angular.forEach(scope.content.variants, function (variant) {
|
||||
unsubscribe.push(serverValidationManager.subscribe(null, variant.language.culture, null, onCultureValidation));
|
||||
});
|
||||
|
||||
scope.selectVariant = function (event, variant) {
|
||||
unsubscribe.push(serverValidationManager.subscribe(null, null, null, onCultureValidation));
|
||||
|
||||
if (scope.onSelectVariant) {
|
||||
scope.vm.dropdownOpen = false;
|
||||
scope.onSelectVariant({ "variant": variant });
|
||||
}
|
||||
};
|
||||
|
||||
scope.selectNavigationItem = function(item) {
|
||||
if(scope.onSelectNavigationItem) {
|
||||
scope.onSelectNavigationItem({"item": item});
|
||||
}
|
||||
}
|
||||
|
||||
scope.selectAnchorItem = function(item, anchor) {
|
||||
if(scope.onSelectAnchorItem) {
|
||||
scope.onSelectAnchorItem({"item": item, "anchor": anchor});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scope.closeSplitView = function () {
|
||||
if (scope.onCloseSplitView) {
|
||||
scope.onCloseSplitView();
|
||||
}
|
||||
};
|
||||
|
||||
scope.openInSplitView = function (event, variant) {
|
||||
if (scope.onOpenInSplitView) {
|
||||
scope.vm.dropdownOpen = false;
|
||||
scope.onOpenInSplitView({ "variant": variant });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* keep track of open variants - this is used to prevent the same variant to be open in more than one split view
|
||||
* @param {any} culture
|
||||
*/
|
||||
scope.variantIsOpen = function(culture) {
|
||||
return (scope.openVariants.indexOf(culture) !== -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a variant has a error, used to display errors in variant switcher.
|
||||
* @param {any} culture
|
||||
*/
|
||||
scope.variantHasError = function(culture) {
|
||||
// if we are looking for the default language we also want to check for invariant.
|
||||
if (culture === scope.vm.defaultVariant.language.culture) {
|
||||
if(scope.vm.variantsWithError.indexOf("invariant") !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(scope.vm.variantsWithError.indexOf(culture) !== -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
onInit();
|
||||
|
||||
//watch for the active culture changing, if it changes, update the current variant
|
||||
if (scope.content.variants) {
|
||||
scope.$watch(function () {
|
||||
for (var i = 0; i < scope.content.variants.length; i++) {
|
||||
var v = scope.content.variants[i];
|
||||
if (v.active) {
|
||||
return v.language.culture;
|
||||
}
|
||||
}
|
||||
return scope.vm.currentVariant.language.culture; //should never get here
|
||||
}, function (newValue, oldValue) {
|
||||
if (newValue !== scope.vm.currentVariant.language.culture) {
|
||||
setCurrentVariant();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
scope.$on('$destroy', function () {
|
||||
for (var u in unsubscribe) {
|
||||
unsubscribe[u]();
|
||||
function setCurrentVariant() {
|
||||
angular.forEach(scope.content.variants, function (variant) {
|
||||
if (variant.active) {
|
||||
scope.vm.currentVariant = variant;
|
||||
checkErrorsOnOtherVariants();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var directive = {
|
||||
transclude: true,
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
templateUrl: 'views/components/editor/umb-editor-content-header.html',
|
||||
scope: {
|
||||
name: "=",
|
||||
nameDisabled: "<?",
|
||||
menu: "=",
|
||||
hideActionsMenu: "<?",
|
||||
content: "=",
|
||||
openVariants: "<",
|
||||
hideChangeVariant: "<?",
|
||||
onSelectNavigationItem: "&?",
|
||||
onSelectAnchorItem: "&?",
|
||||
showBackButton: "<?",
|
||||
onBack: "&?",
|
||||
splitViewOpen: "=?",
|
||||
onOpenInSplitView: "&?",
|
||||
onCloseSplitView: "&?",
|
||||
onSelectVariant: "&?",
|
||||
serverValidationNameField: "@?",
|
||||
serverValidationAliasField: "@?"
|
||||
},
|
||||
link: link
|
||||
scope.goBack = function () {
|
||||
if (scope.onBack) {
|
||||
scope.onBack();
|
||||
}
|
||||
};
|
||||
|
||||
return directive;
|
||||
scope.selectVariant = function (event, variant) {
|
||||
|
||||
if (scope.onSelectVariant) {
|
||||
scope.vm.dropdownOpen = false;
|
||||
scope.onSelectVariant({ "variant": variant });
|
||||
}
|
||||
};
|
||||
|
||||
scope.selectNavigationItem = function (item) {
|
||||
if (scope.onSelectNavigationItem) {
|
||||
scope.onSelectNavigationItem({ "item": item });
|
||||
}
|
||||
}
|
||||
|
||||
scope.selectAnchorItem = function (item, anchor) {
|
||||
if (scope.onSelectAnchorItem) {
|
||||
scope.onSelectAnchorItem({ "item": item, "anchor": anchor });
|
||||
}
|
||||
}
|
||||
|
||||
scope.closeSplitView = function () {
|
||||
if (scope.onCloseSplitView) {
|
||||
scope.onCloseSplitView();
|
||||
}
|
||||
};
|
||||
|
||||
scope.openInSplitView = function (event, variant) {
|
||||
if (scope.onOpenInSplitView) {
|
||||
scope.vm.dropdownOpen = false;
|
||||
scope.onOpenInSplitView({ "variant": variant });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* keep track of open variants - this is used to prevent the same variant to be open in more than one split view
|
||||
* @param {any} culture
|
||||
*/
|
||||
scope.variantIsOpen = function (culture) {
|
||||
return (scope.openVariants.indexOf(culture) !== -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a variant has a error, used to display errors in variant switcher.
|
||||
* @param {any} culture
|
||||
*/
|
||||
scope.variantHasError = function (culture) {
|
||||
// if we are looking for the default language we also want to check for invariant.
|
||||
if (culture === scope.vm.defaultVariant.language.culture) {
|
||||
if (scope.vm.variantsWithError.indexOf("invariant") !== -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (scope.vm.variantsWithError.indexOf(culture) !== -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
onInit();
|
||||
|
||||
//watch for the active culture changing, if it changes, update the current variant
|
||||
if (scope.content.variants) {
|
||||
scope.$watch(function () {
|
||||
for (var i = 0; i < scope.content.variants.length; i++) {
|
||||
var v = scope.content.variants[i];
|
||||
if (v.active) {
|
||||
return v.language.culture;
|
||||
}
|
||||
}
|
||||
return scope.vm.currentVariant.language.culture; //should never get here
|
||||
}, function (newValue, oldValue) {
|
||||
if (newValue !== scope.vm.currentVariant.language.culture) {
|
||||
setCurrentVariant();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
scope.$on('$destroy', function () {
|
||||
for (var u in unsubscribe) {
|
||||
unsubscribe[u]();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var directive = {
|
||||
transclude: true,
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
templateUrl: 'views/components/editor/umb-editor-content-header.html',
|
||||
scope: {
|
||||
name: "=",
|
||||
nameDisabled: "<?",
|
||||
menu: "=",
|
||||
hideActionsMenu: "<?",
|
||||
content: "=",
|
||||
openVariants: "<",
|
||||
hideChangeVariant: "<?",
|
||||
onSelectNavigationItem: "&?",
|
||||
onSelectAnchorItem: "&?",
|
||||
showBackButton: "<?",
|
||||
onBack: "&?",
|
||||
splitViewOpen: "=?",
|
||||
onOpenInSplitView: "&?",
|
||||
onCloseSplitView: "&?",
|
||||
onSelectVariant: "&?",
|
||||
serverValidationNameField: "@?",
|
||||
serverValidationAliasField: "@?"
|
||||
},
|
||||
link: link
|
||||
};
|
||||
|
||||
return directive;
|
||||
}
|
||||
|
||||
angular.module('umbraco.directives').directive('umbEditorContentHeader', EditorContentHeader);
|
||||
|
||||
})();
|
||||
}) ();
|
||||
|
||||
@@ -43,7 +43,13 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
|
||||
}
|
||||
|
||||
var currentRouteParams = null;
|
||||
|
||||
|
||||
var originalTitle = "";
|
||||
|
||||
$rootScope.$on('$changeTitle', function (event, titlePrefix) {
|
||||
$rootScope.locationTitle = titlePrefix + " - " + originalTitle;
|
||||
});
|
||||
|
||||
/** execute code on each successful route */
|
||||
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
|
||||
|
||||
@@ -90,7 +96,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
|
||||
|
||||
$rootScope.locationTitle = "Umbraco - " + $location.$$host;
|
||||
}
|
||||
|
||||
originalTitle = $rootScope.locationTitle;
|
||||
});
|
||||
|
||||
/** When the route change is rejected - based on checkAuth - we'll prevent the rejected route from executing including
|
||||
|
||||
Reference in New Issue
Block a user