Merge branch 'temp8' of https://github.com/umbraco/Umbraco-CMS into temp8
This commit is contained in:
@@ -26,20 +26,43 @@
|
||||
$scope.allowOpen = true;
|
||||
$scope.app = null;
|
||||
|
||||
function init(content) {
|
||||
if (!$scope.app) {
|
||||
// set first app to active
|
||||
function init() {
|
||||
|
||||
var content = $scope.content;
|
||||
|
||||
// we need to check wether an app is present in the current data, if not we will present the default app.
|
||||
var isAppPresent = false;
|
||||
|
||||
// on first init, we dont have any apps. but if we are re-initializing, we do, but ...
|
||||
if ($scope.app) {
|
||||
|
||||
// lets check if it still exists as part of our apps array. (if not we have made a change to our docType, even just a re-save of the docType it will turn into new Apps.)
|
||||
_.forEach(content.apps, function(app) {
|
||||
if (app === $scope.app) {
|
||||
isAppPresent = true;
|
||||
}
|
||||
});
|
||||
|
||||
// if we did reload our DocType, but still have the same app we will try to find it by the alias.
|
||||
if (isAppPresent === false) {
|
||||
_.forEach(content.apps, function(app) {
|
||||
if (app.alias === $scope.app.alias) {
|
||||
isAppPresent = true;
|
||||
app.active = true;
|
||||
$scope.appChanged(app);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if we still dont have a app, lets show the first one:
|
||||
if (isAppPresent === false) {
|
||||
content.apps[0].active = true;
|
||||
$scope.app = content.apps[0];
|
||||
$scope.appChanged(content.apps[0]);
|
||||
}
|
||||
|
||||
if (infiniteMode) {
|
||||
createInfiniteModeButtons(content);
|
||||
} else {
|
||||
createButtons(content);
|
||||
}
|
||||
|
||||
editorState.set($scope.content);
|
||||
|
||||
editorState.set(content);
|
||||
|
||||
//We fetch all ancestors of the node to generate the footer breadcrumb navigation
|
||||
if (!$scope.page.isNew) {
|
||||
@@ -129,7 +152,7 @@
|
||||
"/content/content/edit/" + data.parentId;
|
||||
}
|
||||
|
||||
init($scope.content);
|
||||
init();
|
||||
|
||||
syncTreeNode($scope.content, $scope.content.path, true);
|
||||
|
||||
@@ -340,7 +363,7 @@
|
||||
showNotifications: args.showNotifications
|
||||
}).then(function (data) {
|
||||
//success
|
||||
init($scope.content);
|
||||
init();
|
||||
syncTreeNode($scope.content, data.path);
|
||||
|
||||
eventsService.emit("content.saved", { content: $scope.content, action: args.action });
|
||||
@@ -414,7 +437,7 @@
|
||||
|
||||
$scope.content = data;
|
||||
|
||||
init($scope.content);
|
||||
init();
|
||||
|
||||
resetLastListPageNumber($scope.content);
|
||||
|
||||
@@ -454,7 +477,7 @@
|
||||
.then(function (data) {
|
||||
formHelper.resetForm({ scope: $scope });
|
||||
contentEditingHelper.reBindChangedProperties($scope.content, data);
|
||||
init($scope.content);
|
||||
init();
|
||||
syncTreeNode($scope.content, data.path);
|
||||
$scope.page.buttonGroupState = "success";
|
||||
eventsService.emit("content.unpublished", { content: $scope.content });
|
||||
@@ -845,8 +868,14 @@
|
||||
* @param {any} app
|
||||
*/
|
||||
$scope.appChanged = function (app) {
|
||||
|
||||
$scope.app = app;
|
||||
createButtons($scope.content);
|
||||
|
||||
if (infiniteMode) {
|
||||
createInfiniteModeButtons($scope.content);
|
||||
} else {
|
||||
createButtons($scope.content);
|
||||
}
|
||||
};
|
||||
|
||||
// methods for infinite editing
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
hide-description="true"
|
||||
hide-alias="true"
|
||||
navigation="content.apps"
|
||||
on-select-navigation-item="appChanged(app)">
|
||||
on-select-navigation-item="appChanged(item)">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container>
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
* @description
|
||||
* The controller for the media editor
|
||||
*/
|
||||
function mediaEditController($scope, $routeParams, $q, appState, mediaResource, entityResource, navigationService, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, fileManager, formHelper, editorState, umbRequestHelper, $http, eventsService) {
|
||||
function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
entityResource, navigationService, notificationsService, angularHelper,
|
||||
serverValidationManager, contentEditingHelper, fileManager, formHelper,
|
||||
editorState, umbRequestHelper, $http, eventsService) {
|
||||
|
||||
var evts = [];
|
||||
var nodeId = null;
|
||||
@@ -41,7 +44,91 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
$scope.page.listViewPath = null;
|
||||
$scope.page.saveButtonState = "init";
|
||||
$scope.page.submitButtonLabelKey = "buttons_save";
|
||||
$scope.app = null;
|
||||
|
||||
if (create) {
|
||||
|
||||
$scope.page.loading = true;
|
||||
|
||||
mediaResource.getScaffold(nodeId, $routeParams.doctype)
|
||||
.then(function (data) {
|
||||
$scope.content = data;
|
||||
|
||||
init();
|
||||
|
||||
$scope.page.loading = false;
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
$scope.page.loading = true;
|
||||
loadMedia()
|
||||
.then(function(){
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
var content = $scope.content;
|
||||
|
||||
// we need to check wether an app is present in the current data, if not we will present the default app.
|
||||
var isAppPresent = false;
|
||||
|
||||
// on first init, we dont have any apps. but if we are re-initializing, we do, but ...
|
||||
if ($scope.app) {
|
||||
|
||||
// lets check if it still exists as part of our apps array. (if not we have made a change to our docType, even just a re-save of the docType it will turn into new Apps.)
|
||||
_.forEach(content.apps, function(app) {
|
||||
if (app === $scope.app) {
|
||||
isAppPresent = true;
|
||||
}
|
||||
});
|
||||
|
||||
// if we did reload our DocType, but still have the same app we will try to find it by the alias.
|
||||
if (isAppPresent === false) {
|
||||
_.forEach(content.apps, function(app) {
|
||||
if (app.alias === $scope.app.alias) {
|
||||
isAppPresent = true;
|
||||
app.active = true;
|
||||
$scope.appChanged(app);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// if we still dont have a app, lets show the first one:
|
||||
if (isAppPresent === false) {
|
||||
content.apps[0].active = true;
|
||||
$scope.appChanged(content.apps[0]);
|
||||
}
|
||||
|
||||
|
||||
editorState.set($scope.content);
|
||||
|
||||
bindEvents();
|
||||
|
||||
}
|
||||
|
||||
function bindEvents() {
|
||||
//bindEvents can be called more than once and we don't want to have multiple bound events
|
||||
for (var e in evts) {
|
||||
eventsService.unsubscribe(evts[e]);
|
||||
}
|
||||
|
||||
evts.push(eventsService.on("editors.mediaType.saved", function(name, args) {
|
||||
// if this media item uses the updated media type we need to reload the media item
|
||||
if(args && args.mediaType && args.mediaType.key === $scope.content.contentType.key) {
|
||||
$scope.page.loading = true;
|
||||
loadMedia().then(function() {
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
$scope.page.submitButtonLabelKey = "buttons_save";
|
||||
|
||||
/** Syncs the content item to it's tree node - this occurs on first load and after saving */
|
||||
function syncTreeNode(content, path, initialLoad) {
|
||||
|
||||
@@ -68,45 +155,6 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (create) {
|
||||
|
||||
$scope.page.loading = true;
|
||||
|
||||
mediaResource.getScaffold(nodeId, $routeParams.doctype)
|
||||
.then(function (data) {
|
||||
$scope.content = data;
|
||||
|
||||
editorState.set($scope.content);
|
||||
|
||||
init();
|
||||
|
||||
$scope.page.loading = false;
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
$scope.page.loading = true;
|
||||
loadMedia()
|
||||
.then(function(){
|
||||
$scope.page.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
if (!$scope.app) {
|
||||
// set first app to active
|
||||
$scope.content.apps[0].active = true;
|
||||
$scope.app = $scope.content.apps[0];
|
||||
}
|
||||
|
||||
// setup infinite mode
|
||||
if(infiniteMode) {
|
||||
$scope.page.submitButtonLabelKey = "buttons_saveAndClose";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$scope.save = function () {
|
||||
|
||||
@@ -212,14 +260,12 @@ function mediaEditController($scope, $routeParams, $q, appState, mediaResource,
|
||||
|
||||
$scope.appChanged = function (app) {
|
||||
$scope.app = app;
|
||||
}
|
||||
|
||||
evts.push(eventsService.on("editors.mediaType.saved", function(name, args) {
|
||||
// if this media item uses the updated media type we need to reload the media item
|
||||
if(args && args.mediaType && args.mediaType.key === $scope.content.contentType.key) {
|
||||
loadMedia();
|
||||
|
||||
// setup infinite mode
|
||||
if(infiniteMode) {
|
||||
$scope.page.submitButtonLabelKey = "buttons_saveAndClose";
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
//ensure to unregister from all events!
|
||||
$scope.$on('$destroy', function () {
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function MediaTypesEditController($scope, $routeParams, mediaTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $filter, $q, localizationService, overlayHelper, eventsService) {
|
||||
function MediaTypesEditController($scope, $routeParams, mediaTypeResource,
|
||||
dataTypeResource, editorState, contentEditingHelper, formHelper,
|
||||
navigationService, iconHelper, contentTypeHelper, notificationsService,
|
||||
$filter, $q, localizationService, overlayHelper, eventsService) {
|
||||
|
||||
var vm = this;
|
||||
var evts = [];
|
||||
|
||||
Reference in New Issue
Block a user