Merge and simplify the variants selector to use routing logic now that we have routing built in for languages, now the pending changes alert is just using the default route change
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function ContentEditController($rootScope, $scope, $routeParams, $q, $timeout, $window, $location, appState, contentResource, entityResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, treeService, fileManager, formHelper, umbRequestHelper, keyboardService, umbModelMapper, editorState, $http, eventsService, relationResource, overlayService) {
|
||||
function ContentEditController($rootScope, $scope, $routeParams, $q, $timeout, $window, $location,
|
||||
appState, contentResource, entityResource, navigationService, notificationsService, angularHelper,
|
||||
serverValidationManager, contentEditingHelper, treeService, fileManager, formHelper, umbRequestHelper,
|
||||
keyboardService, umbModelMapper, editorState, $http, eventsService, relationResource, overlayService) {
|
||||
|
||||
var evts = [];
|
||||
|
||||
@@ -17,6 +20,7 @@
|
||||
$scope.page.listViewPath = null;
|
||||
$scope.page.isNew = $scope.isNew ? true : false;
|
||||
$scope.page.buttonGroupState = "init";
|
||||
$scope.page.languageId = $scope.languageId;
|
||||
$scope.allowOpen = true;
|
||||
|
||||
// add all editors to an editors array to support split view
|
||||
@@ -82,13 +86,13 @@
|
||||
|
||||
$scope.content.apps = [];
|
||||
|
||||
if($scope.content.isContainer) {
|
||||
if ($scope.content.isContainer) {
|
||||
// add list view app
|
||||
$scope.content.apps.push(listview);
|
||||
|
||||
// remove the list view tab
|
||||
angular.forEach($scope.content.tabs, function(tab, index){
|
||||
if(tab.alias === "umbContainerView") {
|
||||
angular.forEach($scope.content.tabs, function (tab, index) {
|
||||
if (tab.alias === "umbContainerView") {
|
||||
tab.hide = true;
|
||||
}
|
||||
});
|
||||
@@ -109,7 +113,7 @@
|
||||
$scope.editors.push(editor);
|
||||
}
|
||||
else if ($scope.editors.length === 1) {
|
||||
$scope.editors[0].content = $scope.content
|
||||
$scope.editors[0].content = $scope.content;
|
||||
}
|
||||
else {
|
||||
//fixme - need to fix something here if we are re-loading a content item that is in a split view
|
||||
@@ -205,7 +209,7 @@
|
||||
scope: $scope,
|
||||
content: $scope.content,
|
||||
action: args.action
|
||||
}).then(function(data) {
|
||||
}).then(function (data) {
|
||||
//success
|
||||
init($scope.content);
|
||||
syncTreeNode($scope.content, data.path);
|
||||
@@ -213,7 +217,7 @@
|
||||
$scope.page.buttonGroupState = "success";
|
||||
return $q.when(data);
|
||||
},
|
||||
function(err) {
|
||||
function (err) {
|
||||
//error
|
||||
if (err) {
|
||||
editorState.set($scope.content);
|
||||
@@ -253,11 +257,11 @@
|
||||
}
|
||||
else {
|
||||
|
||||
getNode();
|
||||
//Browse content nodes based on the selected tree language variant
|
||||
$scope.page.languageId ? getNode($scope.page.languageId) : getNode();
|
||||
|
||||
}
|
||||
|
||||
|
||||
$scope.unPublish = function () {
|
||||
|
||||
if (formHelper.submitForm({ scope: $scope, skipValidation: true })) {
|
||||
@@ -281,7 +285,7 @@
|
||||
|
||||
$scope.page.buttonGroupState = "success";
|
||||
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
$scope.page.buttonGroupState = 'error';
|
||||
});
|
||||
}
|
||||
@@ -304,18 +308,18 @@
|
||||
variants: $scope.content.variants, //set a model property for the dialog
|
||||
skipFormValidation: true, //when submitting the overlay form, skip any client side validation
|
||||
submitButtonLabel: "Publish",
|
||||
submit: function(model) {
|
||||
submit: function (model) {
|
||||
model.submitButtonState = "busy";
|
||||
|
||||
//we need to return this promise so that the dialog can handle the result and wire up the validation response
|
||||
return performSave({
|
||||
saveMethod: contentResource.publish,
|
||||
action: "publish"
|
||||
}).then(function(data) {
|
||||
}).then(function (data) {
|
||||
overlayService.close();
|
||||
return $q.when(data);
|
||||
},
|
||||
function(err) {
|
||||
function (err) {
|
||||
model.submitButtonState = "error";
|
||||
//re-map the dialog model since we've re-bound the properties
|
||||
dialog.variants = $scope.content.variants;
|
||||
@@ -326,7 +330,7 @@
|
||||
if (err.data && err.data.ModelState) {
|
||||
var keys = _.keys(err.data.ModelState);
|
||||
var foundVariantError = _.find(keys,
|
||||
function(k) {
|
||||
function (k) {
|
||||
return k.startsWith("publish_variant_");
|
||||
});
|
||||
if (!foundVariantError) {
|
||||
@@ -338,7 +342,7 @@
|
||||
return $q.reject(err);
|
||||
});
|
||||
},
|
||||
close: function(oldModel) {
|
||||
close: function (oldModel) {
|
||||
overlayService.close();
|
||||
}
|
||||
};
|
||||
@@ -381,7 +385,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
$scope.backToListView = function() {
|
||||
$scope.backToListView = function () {
|
||||
$location.path($scope.page.listViewPath);
|
||||
};
|
||||
|
||||
@@ -393,7 +397,7 @@
|
||||
|
||||
var relation = null;
|
||||
var target = null;
|
||||
var error = { headline: "Cannot automatically restore this item", content: "Use the Move menu item to move it manually"};
|
||||
var error = { headline: "Cannot automatically restore this item", content: "Use the Move menu item to move it manually" };
|
||||
|
||||
if (data.length == 0) {
|
||||
notificationsService.error(error.headline, "There is no 'restore' relation found for this node. Use the Move menu item to move it manually.");
|
||||
@@ -411,7 +415,7 @@
|
||||
target = data;
|
||||
|
||||
// make sure the target item isn't in the recycle bin
|
||||
if(target.path.indexOf("-20") !== -1) {
|
||||
if (target.path.indexOf("-20") !== -1) {
|
||||
notificationsService.error(error.headline, "The item you want to restore it under (" + target.name + ") is in the recycle bin. Use the Move menu item to move the item manually.");
|
||||
$scope.page.buttonRestore = "error";
|
||||
return;
|
||||
@@ -429,51 +433,18 @@
|
||||
$scope.page.buttonRestore = "error";
|
||||
notificationsService.error(error.headline, error.content);
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.selectVariant = function(variant, variants, form) {
|
||||
// show the discard changes dialog it there are unsaved changes
|
||||
if(form.$dirty) {
|
||||
var notification = {
|
||||
view: "confirmroutechange",
|
||||
args: {
|
||||
onDiscard: function() {
|
||||
setSelectedVariant(variant, variants);
|
||||
notificationsService.remove(notification);
|
||||
form.$setPristine();
|
||||
}
|
||||
}
|
||||
};
|
||||
notificationsService.add(notification);
|
||||
return;
|
||||
}
|
||||
// switch variant if all changes are saved
|
||||
setSelectedVariant(variant, variants);
|
||||
};
|
||||
|
||||
function setSelectedVariant(selectedVariant, variants) {
|
||||
angular.forEach(variants, function(variant) {
|
||||
variant.current = false;
|
||||
});
|
||||
|
||||
selectedVariant.current = true;
|
||||
|
||||
//go get the variant
|
||||
getNode(selectedVariant.language.id);
|
||||
}
|
||||
|
||||
$scope.closeSplitView = function(index, editor) {
|
||||
$scope.closeSplitView = function (index, editor) {
|
||||
// hacky animation stuff - it will be much better when angular is upgraded
|
||||
editor.loading = true;
|
||||
editor.collapsed = true;
|
||||
$timeout(function(){
|
||||
$timeout(function () {
|
||||
$scope.editors.splice(index, 1);
|
||||
}, 400);
|
||||
};
|
||||
|
||||
$scope.openInSplitView = function(selectedVariant) {
|
||||
$scope.openInSplitView = function (selectedVariant) {
|
||||
|
||||
console.log(selectedVariant);
|
||||
|
||||
@@ -483,19 +454,19 @@
|
||||
editor.loading = true;
|
||||
$scope.editors.push(editor);
|
||||
var editorIndex = $scope.editors.length - 1;
|
||||
$timeout(function(){
|
||||
$timeout(function () {
|
||||
$scope.editors[editorIndex].collapsed = false;
|
||||
}, 100);
|
||||
|
||||
// fake loading of content
|
||||
// TODO: Make this real, but how do we deal with saving since currently we only save one variant at a time?!
|
||||
$timeout(function(){
|
||||
$timeout(function () {
|
||||
$scope.editors[editorIndex].content = angular.copy($scope.content);
|
||||
$scope.editors[editorIndex].content.name = "What a variant";
|
||||
// set selected variant on split view content
|
||||
console.log($scope.editors[editorIndex].content.variants);
|
||||
angular.forEach($scope.editors[editorIndex].content.variants, function(variant) {
|
||||
if(variant.culture === selectedVariant.culture) {
|
||||
angular.forEach($scope.editors[editorIndex].content.variants, function (variant) {
|
||||
if (variant.culture === selectedVariant.culture) {
|
||||
variant.current = true;
|
||||
} else {
|
||||
variant.current = false;
|
||||
@@ -511,7 +482,7 @@
|
||||
.then(function (path) {
|
||||
|
||||
// remove the node that we're working on
|
||||
if($scope.page.menu.currentNode) {
|
||||
if ($scope.page.menu.currentNode) {
|
||||
treeService.removeNode($scope.page.menu.currentNode);
|
||||
}
|
||||
|
||||
@@ -554,7 +525,8 @@
|
||||
page: "=?",
|
||||
saveMethod: "&",
|
||||
getMethod: "&",
|
||||
getScaffoldMethod: "&?"
|
||||
getScaffoldMethod: "&?",
|
||||
languageId: "=?"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ Use this directive to construct a header inside the main editor window.
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
function EditorHeaderDirective(iconHelper) {
|
||||
function EditorHeaderDirective(iconHelper, $location) {
|
||||
|
||||
function link(scope, el, attr, ctrl) {
|
||||
|
||||
@@ -246,11 +246,9 @@ Use this directive to construct a header inside the main editor window.
|
||||
}
|
||||
};
|
||||
|
||||
scope.selectVariant = function(event, variant) {
|
||||
if(scope.onSelectVariant) {
|
||||
scope.onSelectVariant({"variant": variant});
|
||||
scope.selectVariant = function (event, variant) {
|
||||
scope.vm.dropdownOpen = false;
|
||||
}
|
||||
$location.search({ languageId: variant.language.id });
|
||||
};
|
||||
|
||||
scope.openIconPicker = function() {
|
||||
@@ -323,7 +321,6 @@ Use this directive to construct a header inside the main editor window.
|
||||
hideDescription: "@",
|
||||
descriptionLocked: "@",
|
||||
variants: "=",
|
||||
onSelectVariant: "&",
|
||||
navigation: "=",
|
||||
key: "=",
|
||||
onBack: "&?",
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="umb-dashboard__content">
|
||||
|
||||
<umb-tabs-content view="true">
|
||||
<umb-tab id="tab{{tab.id}}" ng-repeat="tab in dashboard.tabs" rel="{{tab.id}}">
|
||||
<umb-tab id="tab{{tab.id}}" ng-repeat="tab in dashboard.tabs" rel="{{tab.id}}" class="row-fluid">
|
||||
|
||||
<div ng-repeat="property in tab.properties" ng-switch on="property.serverSide">
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
hide-alias="true"
|
||||
navigation="editor.content.apps"
|
||||
variants="editor.content.variants"
|
||||
on-select-variant="selectVariant(variant, editor.content.variants, contentForm)"
|
||||
on-back="backToListView()"
|
||||
show-back-button="{{page.listViewPath}}"
|
||||
split-view-open="editors.length > 1"
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*/
|
||||
function ContentEditController($scope, $routeParams, contentResource) {
|
||||
|
||||
|
||||
|
||||
function scaffoldEmpty() {
|
||||
return contentResource.getScaffold($routeParams.id, $routeParams.doctype);
|
||||
}
|
||||
@@ -23,6 +21,7 @@ function ContentEditController($scope, $routeParams, contentResource) {
|
||||
$scope.getScaffoldMethod = $routeParams.blueprintId ? scaffoldBlueprint : scaffoldEmpty;
|
||||
$scope.page = $routeParams.page;
|
||||
$scope.isNew = $routeParams.create;
|
||||
$scope.languageId = $routeParams.languageId;
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Content.EditController", ContentEditController);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
get-method="getMethod"
|
||||
get-scaffold-method="getScaffoldMethod"
|
||||
tree-alias="content"
|
||||
is-new="isNew">
|
||||
is-new="isNew"
|
||||
language-id="languageId">
|
||||
</content-editor>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user