Got Data Type Creation working. Need to look at fixing up the issues with creating content/media tomorrow.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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 });
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -44,6 +44,12 @@ namespace Umbraco.Web.Editors
|
||||
return Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dataType);
|
||||
}
|
||||
|
||||
public DataTypeDisplay GetEmpty()
|
||||
{
|
||||
var dt = new DataTypeDefinition(-1, Guid.Empty);
|
||||
return Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the pre-values for the specified property editor
|
||||
/// </summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Web.Http.Filters;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -70,9 +71,11 @@ namespace Umbraco.Web.Editors
|
||||
case ContentSaveAction.SaveNew:
|
||||
//create the persisted model from mapping the saved model
|
||||
persisted = Mapper.Map<IDataTypeDefinition>(dataType);
|
||||
((DataTypeDefinition)persisted).ResetIdentity();
|
||||
break;
|
||||
default:
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.NotFound, new ArgumentOutOfRangeException());
|
||||
return;
|
||||
}
|
||||
|
||||
//now assign the persisted entity to the model so we can use it in the action
|
||||
|
||||
@@ -16,9 +16,12 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is nullable because when we are creating a new one, it is nothing
|
||||
/// </summary>
|
||||
[DataMember(Name = "selectedEditor", IsRequired = true)]
|
||||
[Required]
|
||||
public Guid SelectedEditor { get; set; }
|
||||
public Guid? SelectedEditor { get; set; }
|
||||
|
||||
[DataMember(Name = "availableEditors")]
|
||||
public IEnumerable<PropertyEditorBasic> AvailableEditors { get; set; }
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(display => display.AvailableEditors, expression => expression.ResolveUsing<AvailablePropertyEditorsResolver>())
|
||||
.ForMember(display => display.PreValues, expression => expression.ResolveUsing(
|
||||
new PreValueDisplayResolver(lazyDataTypeService)))
|
||||
.ForMember(display => display.SelectedEditor, expression => expression.MapFrom(definition => definition.ControlId));
|
||||
.ForMember(display => display.SelectedEditor, expression => expression.MapFrom(
|
||||
definition => definition.ControlId == Guid.Empty ? null : (Guid?) definition.ControlId));
|
||||
|
||||
config.CreateMap<DataTypeSave, IDataTypeDefinition>()
|
||||
.ConstructUsing(save => new DataTypeDefinition(-1, save.SelectedEditor) {CreateDate = DateTime.Now})
|
||||
|
||||
@@ -22,17 +22,26 @@ namespace Umbraco.Web.Models.Mapping
|
||||
|
||||
protected override IEnumerable<PreValueFieldDisplay> ResolveCore(IDataTypeDefinition source)
|
||||
{
|
||||
var propEd = PropertyEditorResolver.Current.GetById(source.ControlId);
|
||||
if (propEd == null)
|
||||
PropertyEditor propEd = null;
|
||||
if (source.ControlId != Guid.Empty)
|
||||
{
|
||||
throw new InvalidOperationException("Could not find property editor with id " + source.ControlId);
|
||||
propEd = PropertyEditorResolver.Current.GetById(source.ControlId);
|
||||
if (propEd == null)
|
||||
{
|
||||
throw new InvalidOperationException("Could not find property editor with id " + source.ControlId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var dataTypeService = (DataTypeService) _dataTypeService.Value;
|
||||
var preVals = dataTypeService.GetPreValuesCollectionByDataTypeId(source.Id);
|
||||
var dictionaryVals = PreValueCollection.AsDictionary(preVals);
|
||||
|
||||
var result = propEd.PreValueEditor.Fields.Select(Mapper.Map<PreValueFieldDisplay>).ToArray();
|
||||
var result = Enumerable.Empty<PreValueFieldDisplay>();
|
||||
if (propEd != null)
|
||||
{
|
||||
result = propEd.PreValueEditor.Fields.Select(Mapper.Map<PreValueFieldDisplay>).ToArray();
|
||||
}
|
||||
var currentIndex = 0; //used if the collection is non-dictionary based.
|
||||
foreach (var field in result)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user