added logic for media and member type angular callbacks that existed for content types - assuming this is important and should be there for all content types. Added alias information to validation message returned from server.

This commit is contained in:
Shannon
2016-02-04 19:40:29 +01:00
parent 2cd4e9aa99
commit 0ea68f4f42
3 changed files with 67 additions and 5 deletions

View File

@@ -180,8 +180,39 @@
// type when server side validation fails - as opposed to content where we are capable of saving the content
// item if server side validation fails
redirectOnFailure: false,
//no-op for rebind callback... we don't really need to rebind for content types
rebindCallback: angular.noop
// we need to rebind... the IDs that have been created!
rebindCallback: function (origContentType, savedContentType) {
vm.contentType.id = savedContentType.id;
vm.contentType.groups.forEach(function (group) {
if (!group.name) return;
var k = 0;
while (k < savedContentType.groups.length && savedContentType.groups[k].name != group.name)
k++;
if (k == savedContentType.groups.length) {
group.id = 0;
return;
}
var savedGroup = savedContentType.groups[k];
if (!group.id) group.id = savedGroup.id;
group.properties.forEach(function (property) {
if (property.id || !property.alias) return;
k = 0;
while (k < savedGroup.properties.length && savedGroup.properties[k].alias != property.alias)
k++;
if (k == savedGroup.properties.length) {
property.id = 0;
return;
}
var savedProperty = savedGroup.properties[k];
property.id = savedProperty.id;
});
});
}
}).then(function (data) {
//success
syncTreeNode(vm.contentType, data.path);

View File

@@ -129,8 +129,39 @@
// type when server side validation fails - as opposed to content where we are capable of saving the content
// item if server side validation fails
redirectOnFailure: false,
//no-op for rebind callback... we don't really need to rebind for content types
rebindCallback: angular.noop
// we need to rebind... the IDs that have been created!
rebindCallback: function (origContentType, savedContentType) {
vm.contentType.id = savedContentType.id;
vm.contentType.groups.forEach(function (group) {
if (!group.name) return;
var k = 0;
while (k < savedContentType.groups.length && savedContentType.groups[k].name != group.name)
k++;
if (k == savedContentType.groups.length) {
group.id = 0;
return;
}
var savedGroup = savedContentType.groups[k];
if (!group.id) group.id = savedGroup.id;
group.properties.forEach(function (property) {
if (property.id || !property.alias) return;
k = 0;
while (k < savedGroup.properties.length && savedGroup.properties[k].alias != property.alias)
k++;
if (k == savedGroup.properties.length) {
property.id = 0;
return;
}
var savedProperty = savedGroup.properties[k];
property.id = savedProperty.id;
});
});
}
}).then(function (data) {
//success
syncTreeNode(vm.contentType, data.path);

View File

@@ -91,7 +91,7 @@ namespace Umbraco.Web.Models.ContentEditing
var lastProperty = duplicateProperties.Last().Last();
var propertyGroup = Groups.Single(x => x.Properties.Contains(lastProperty));
yield return new ValidationResult("Duplicate property aliases not allowed", new[]
yield return new ValidationResult("Duplicate property aliases not allowed: " + lastProperty.Alias, new[]
{
string.Format("Groups[{0}].Properties[{1}].Alias", propertyGroup.SortOrder, lastProperty.SortOrder)
});