Got Data Type Creation working. Need to look at fixing up the issues with creating content/media tomorrow.

This commit is contained in:
Shannon
2013-08-20 18:10:19 +10:00
parent b901ae3269
commit 7df641cf2b
11 changed files with 57 additions and 29 deletions

View File

@@ -147,7 +147,7 @@ function contentEditingHelper($location, $routeParams, notificationsService, ser
this.handleValidationErrors(args.allNewProps, args.err.data.ModelState);
if (!this.redirectToCreatedContent(args.err.data.id, args.err.data.ModelState)) {
if (!args.redirectOnFailure || !this.redirectToCreatedContent(args.err.data.id, args.err.data.ModelState)) {
//we are not redirecting because this is not new content, it is existing content. In this case
// we need to detect what properties have changed and re-bind them with the server data. Then we need
// to re-bind any server validation errors after the digest takes place.
@@ -204,7 +204,7 @@ function contentEditingHelper($location, $routeParams, notificationsService, ser
}
args.scope.$broadcast("saved", { scope: args.scope });
if (!this.redirectToCreatedContent(args.scope.content.id)) {
if (!this.redirectToCreatedContent(args.newContent.id)) {
//we are not redirecting because this is not new content, it is existing content. In this case
// we need to detect what properties have changed and re-bind them with the server data.

View File

@@ -8,7 +8,7 @@
* @description
* Defines the methods that are called when menu items declare only an action to execute
*/
function umbracoMenuActions($q, treeService, $location) {
function umbracoMenuActions($q, treeService, $location, navigationService) {
return {
@@ -41,9 +41,13 @@ function umbracoMenuActions($q, treeService, $location) {
* @param {object} args.section The current section
*/
"CreateChildEntity": function (args) {
navigationService.hideNavigation();
var route = "/" + args.section + "/" + treeService.getTreeAlias(args.treeNode) + "/edit/" + args.treeNode.id;
//change to new path
$location.path(route).search({ create: true });
}
};
}

View File

@@ -73,6 +73,7 @@ function ContentEditController($scope, $routeParams, $location, contentResource,
contentEditingHelper.handleSaveError({
err: err,
redirectOnFailure: true,
allNewProps: allNewProps,
allOrigProps: contentEditingHelper.getAllProps($scope.content),
rebindCallback: contentEditingHelper.reBindChangedProperties(allOrigProps, allNewProps)

View File

@@ -8,22 +8,7 @@
*/
function DataTypeEditController($scope, $routeParams, $location, dataTypeResource, notificationsService, angularHelper, serverValidationManager, contentEditingHelper) {
//set up the standard data type props
function createDisplayProps() {
$scope.properties = {
selectedEditor: {
alias: "selectedEditor",
description: "Select a property editor",
label: "Property editor"
},
selectedEditorId: {
alias: "selectedEditorId",
label: "Property editor GUID"
}
};
}
//setup the pre-values as props
//method used to configure the pre-values when we retreive them from the server
function createPreValueProps(preVals) {
$scope.preValues = [];
for (var i = 0; i < preVals.length; i++) {
@@ -38,6 +23,22 @@ function DataTypeEditController($scope, $routeParams, $location, dataTypeResourc
}
}
//set up the standard data type props
$scope.properties = {
selectedEditor: {
alias: "selectedEditor",
description: "Select a property editor",
label: "Property editor"
},
selectedEditorId: {
alias: "selectedEditorId",
label: "Property editor GUID"
}
};
//setup the pre-values as props
$scope.preValues = [];
if ($routeParams.create) {
//we are creating so get an empty content item
dataTypeResource.getScaffold($routeParams.id, $routeParams.doctype)
@@ -45,7 +46,6 @@ function DataTypeEditController($scope, $routeParams, $location, dataTypeResourc
$scope.loaded = true;
$scope.preValuesLoaded = true;
$scope.content = data;
createDisplayProps();
});
}
else {
@@ -55,7 +55,6 @@ function DataTypeEditController($scope, $routeParams, $location, dataTypeResourc
$scope.loaded = true;
$scope.preValuesLoaded = true;
$scope.content = data;
createDisplayProps();
createPreValueProps($scope.content.preValues);
//in one particular special case, after we've created a new item we redirect back to the edit

View File

@@ -71,6 +71,7 @@ function mediaEditController($scope, $routeParams, mediaResource, notificationsS
contentEditingHelper.handleSaveError({
err: err,
redirectOnFailure: true,
allNewProps: allNewProps,
allOrigProps: contentEditingHelper.getAllProps($scope.content),
rebindCallback: contentEditingHelper.reBindChangedProperties(allOrigProps, allNewProps)

View File

@@ -1,7 +1,8 @@
<div>
<input name="requiredField" type="text" id="{{model.alias}}" class="umb-textstring span7 textstring"
ng-model="model.value"
val-server="value"/>
required
val-server="value" />
<span class="help-inline" val-msg-for="requiredField" val-toggle-msg="required">Required</span>
<span class="help-inline" val-msg-for="requiredField" val-toggle-msg="valServer">{{propertyForm.requiredField.errorMsg}}</span>