Fixes: Stay on the same content app when changing language
This commit is contained in:
@@ -46,10 +46,6 @@
|
||||
}
|
||||
|
||||
bindEvents();
|
||||
|
||||
// set first app to active
|
||||
// We need to track active
|
||||
$scope.content.apps[0].active = true;
|
||||
|
||||
resetVariantFlags();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
openVariants: "<",
|
||||
onCloseSplitView: "&",
|
||||
onSelectVariant: "&",
|
||||
onOpenSplitView: "&"
|
||||
onOpenSplitView: "&",
|
||||
onSelectApp: "&"
|
||||
},
|
||||
controllerAs: 'vm',
|
||||
controller: umbVariantContentController
|
||||
@@ -33,6 +34,7 @@
|
||||
vm.selectVariant = selectVariant;
|
||||
vm.openSplitView = openSplitView;
|
||||
vm.backToListView = backToListView;
|
||||
vm.selectApp = selectApp;
|
||||
|
||||
/** Called when the component has linked all elements, this is when the form controller is available */
|
||||
function postLink() {
|
||||
@@ -65,6 +67,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to proxy a callback
|
||||
* @param {any} item
|
||||
*/
|
||||
function selectApp(item) {
|
||||
if(vm.onSelectApp) {
|
||||
vm.onSelectApp({"app": item});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to proxy a callback
|
||||
* @param {any} variant
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
controller: umbVariantContentEditorsController
|
||||
};
|
||||
|
||||
function umbVariantContentEditorsController($scope, $element, $location, $timeout) {
|
||||
function umbVariantContentEditorsController($scope, $location, $timeout) {
|
||||
|
||||
var prevContentDateUpdated = null;
|
||||
|
||||
var vm = this;
|
||||
var activeAppAlias = null;
|
||||
|
||||
vm.$onInit = onInit;
|
||||
vm.$onChanges = onChanges;
|
||||
@@ -29,6 +30,7 @@
|
||||
vm.openSplitView = openSplitView;
|
||||
vm.closeSplitView = closeSplitView;
|
||||
vm.selectVariant = selectVariant;
|
||||
vm.selectApp = selectApp;
|
||||
|
||||
//Used to track how many content views there are (for split view there will be 2, it could support more in theory)
|
||||
vm.editors = [];
|
||||
@@ -37,6 +39,8 @@
|
||||
|
||||
/** Called when the component initializes */
|
||||
function onInit() {
|
||||
// set first app to active
|
||||
vm.content.apps[0].active = true;
|
||||
prevContentDateUpdated = angular.copy(vm.content.updateDate);
|
||||
setActiveCulture();
|
||||
}
|
||||
@@ -141,7 +145,7 @@
|
||||
//with a copy of the contentApps. This is required because each editor renders it's own
|
||||
//header and content apps section and the content apps contains the view for editing content itself
|
||||
//and we need to assign a view model to the subView so that it is scoped to the current
|
||||
//editor so that split views work.
|
||||
//editor so that split views work.
|
||||
|
||||
//copy the apps from the main model if not assigned yet to the variant
|
||||
if (!variant.apps) {
|
||||
@@ -191,6 +195,16 @@
|
||||
vm.openVariants[editorIndex] = variant.language.culture;
|
||||
}
|
||||
|
||||
// make sure the same app it set to active in the new variant
|
||||
if(activeAppAlias) {
|
||||
angular.forEach(variant.apps, function(app) {
|
||||
app.active = false;
|
||||
if(app.alias === activeAppAlias) {
|
||||
app.active = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return variant;
|
||||
}
|
||||
/**
|
||||
@@ -288,6 +302,17 @@
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the active app in a variable so we can remember it when changing language
|
||||
* @param {any} app This is the model of the selected app
|
||||
*/
|
||||
function selectApp(app) {
|
||||
if(app && app.alias) {
|
||||
activeAppAlias = app.alias;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module('umbraco.directives').component('umbVariantContentEditors', umbVariantContentEditors);
|
||||
|
||||
@@ -246,6 +246,12 @@ Use this directive to construct a header inside the main editor window.
|
||||
}
|
||||
};
|
||||
|
||||
scope.selectNavigationItem = function(item) {
|
||||
if(scope.onSelectNavigationItem) {
|
||||
scope.onSelectNavigationItem({"item": item});
|
||||
}
|
||||
}
|
||||
|
||||
scope.openIconPicker = function () {
|
||||
var iconPicker = {
|
||||
icon: scope.icon.split(' ')[0],
|
||||
@@ -336,6 +342,7 @@ Use this directive to construct a header inside the main editor window.
|
||||
openVariants: "<",
|
||||
hideChangeVariant: "<?",
|
||||
navigation: "=",
|
||||
onSelectNavigationItem: "&?",
|
||||
key: "=",
|
||||
onBack: "&?",
|
||||
showBackButton: "<?",
|
||||
|
||||
@@ -20,8 +20,11 @@
|
||||
scope.clickNavigationItem = function (selectedItem) {
|
||||
scope.showDropdown = false;
|
||||
runItemAction(selectedItem);
|
||||
eventsService.emit("app.tabChange", selectedItem);
|
||||
setItemToActive(selectedItem);
|
||||
if(scope.onSelect) {
|
||||
scope.onSelect({"item": selectedItem});
|
||||
}
|
||||
eventsService.emit("app.tabChange", selectedItem);
|
||||
};
|
||||
|
||||
scope.toggleDropdown = function () {
|
||||
@@ -124,7 +127,8 @@
|
||||
replace: true,
|
||||
templateUrl: 'views/components/editor/umb-editor-navigation.html',
|
||||
scope: {
|
||||
navigation: "="
|
||||
navigation: "=",
|
||||
onSelect: "&"
|
||||
},
|
||||
link: link
|
||||
};
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
|
||||
<umb-editor-view ng-if="!page.loading">
|
||||
|
||||
<umb-variant-content-editors page="page"
|
||||
content="content"
|
||||
culture="culture">
|
||||
<umb-variant-content-editors
|
||||
page="page"
|
||||
content="content"
|
||||
culture="culture">
|
||||
</umb-variant-content-editors>
|
||||
|
||||
<umb-editor-footer>
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
open-variants="vm.openVariants"
|
||||
on-open-split-view="vm.openSplitView(variant)"
|
||||
on-close-split-view="vm.closeSplitView($index)"
|
||||
on-select-variant="vm.selectVariant(variant, $index)">
|
||||
on-select-variant="vm.selectVariant(variant, $index)"
|
||||
on-select-app="vm.selectApp(app)">
|
||||
</umb-variant-content>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
<div>
|
||||
<umb-load-indicator ng-if="vm.editor.loading">
|
||||
<umb-load-indicator
|
||||
ng-if="vm.editor.loading">
|
||||
</umb-load-indicator>
|
||||
|
||||
<div class="umb-split-view__content" ng-show="!vm.editor.loading">
|
||||
|
||||
<ng-form name="contentHeaderForm">
|
||||
<umb-editor-header menu="vm.page.menu"
|
||||
hide-menu="vm.page.hideActionsMenu"
|
||||
name="vm.editor.content.name"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true"
|
||||
navigation="vm.editor.content.apps"
|
||||
variants="vm.editor.content.variants"
|
||||
open-variants="vm.openVariants"
|
||||
hide-change-variant="vm.page.hideChangeVariant"
|
||||
on-back="vm.backToListView()"
|
||||
show-back-button="vm.page.listViewPath !== null"
|
||||
split-view-open="vm.editorCount > 1"
|
||||
on-open-in-split-view="vm.openSplitView(variant)"
|
||||
on-close-split-view="vm.onCloseSplitView()"
|
||||
on-select-variant="vm.selectVariant(variant)"
|
||||
server-validation-name-field="{{'Variants[' + vm.editorIndex + '].Name'}}">
|
||||
<umb-editor-header
|
||||
menu="vm.page.menu"
|
||||
hide-menu="vm.page.hideActionsMenu"
|
||||
name="vm.editor.content.name"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true"
|
||||
navigation="vm.editor.content.apps"
|
||||
on-select-navigation-item="vm.selectApp(item)"
|
||||
variants="vm.editor.content.variants"
|
||||
open-variants="vm.openVariants"
|
||||
hide-change-variant="vm.page.hideChangeVariant"
|
||||
on-back="vm.backToListView()"
|
||||
show-back-button="vm.page.listViewPath !== null"
|
||||
split-view-open="vm.editorCount > 1"
|
||||
on-open-in-split-view="vm.openSplitView(variant)"
|
||||
on-close-split-view="vm.onCloseSplitView()"
|
||||
on-select-variant="vm.selectVariant(variant)"
|
||||
server-validation-name-field="{{'Variants[' + vm.editorIndex + '].Name'}}">
|
||||
</umb-editor-header>
|
||||
</ng-form>
|
||||
|
||||
|
||||
@@ -92,15 +92,18 @@
|
||||
</div>
|
||||
|
||||
<div ng-if="navigation && splitViewOpen !== true" style="margin-left: 20px;">
|
||||
<umb-editor-navigation data-element="editor-sub-views"
|
||||
navigation="navigation">
|
||||
<umb-editor-navigation
|
||||
data-element="editor-sub-views"
|
||||
navigation="navigation"
|
||||
on-select="selectNavigationItem(item)">
|
||||
</umb-editor-navigation>
|
||||
</div>
|
||||
|
||||
<div ng-if="menu.currentNode && splitViewOpen !== true && hideMenu !== true" style="margin-left: 20px;">
|
||||
<umb-editor-menu data-element="editor-actions"
|
||||
current-node="menu.currentNode"
|
||||
current-section="{{menu.currentSection}}">
|
||||
<umb-editor-menu
|
||||
data-element="editor-actions"
|
||||
current-node="menu.currentNode"
|
||||
current-section="{{menu.currentSection}}">
|
||||
</umb-editor-menu>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user