Fixes: U4-7251 When changing a data type name to be the same as another we suffix the duplication with a number - this needs to be reflected in the UI

This commit is contained in:
Shannon
2015-10-14 16:54:58 +02:00
parent c0bd5f4d14
commit 85e46cbbe5
3 changed files with 33 additions and 7 deletions
@@ -118,9 +118,9 @@ namespace Umbraco.Core.Persistence.Repositories
{
var sql = new Sql();
sql.Select(isCount ? "COUNT(*)" : "*")
.From<DataTypeDto>()
.InnerJoin<NodeDto>()
.On<DataTypeDto, NodeDto>(left => left.DataTypeId, right => right.NodeId)
.From<DataTypeDto>(SqlSyntax)
.InnerJoin<NodeDto>(SqlSyntax)
.On<DataTypeDto, NodeDto>(SqlSyntax, left => left.DataTypeId, right => right.NodeId)
.Where<NodeDto>(x => x.NodeObjectType == NodeObjectTypeId);
return sql;
}
@@ -338,9 +338,9 @@ AND umbracoNode.id <> @id",
{
//first just get all pre-values for this data type so we can compare them to see if we need to insert or update or replace
var sql = new Sql().Select("*")
.From<DataTypePreValueDto>()
.From<DataTypePreValueDto>(SqlSyntax)
.Where<DataTypePreValueDto>(dto => dto.DataTypeNodeId == dataType.Id)
.OrderBy<DataTypePreValueDto>(dto => dto.SortOrder);
.OrderBy<DataTypePreValueDto>(dto => dto.SortOrder, SqlSyntax);
currentVals = Database.Fetch<DataTypePreValueDto>(sql).ToArray();
}
@@ -431,7 +431,7 @@ AND umbracoNode.id <> @id",
var sql = new Sql();
sql.Select("*")
.From<NodeDto>()
.From<NodeDto>(SqlSyntax)
.Where<NodeDto>(x => x.NodeObjectType == NodeObjectTypeId && x.Text.StartsWith(nodeName));
int uniqueNumber = 1;
@@ -24,6 +24,28 @@ function dataTypeHelper() {
return preValues;
},
rebindChangedProperties: function (origContent, savedContent) {
//a method to ignore built-in prop changes
var shouldIgnore = function (propName) {
return _.some(["notifications", "ModelState"], function (i) {
return i === propName;
});
};
//check for changed built-in properties of the content
for (var o in origContent) {
//ignore the ones listed in the array
if (shouldIgnore(o)) {
continue;
}
if (!_.isEqual(origContent[o], savedContent[o])) {
origContent[o] = savedContent[o];
}
}
}
};
@@ -6,7 +6,7 @@
* @description
* The controller for the content editor
*/
function DataTypeEditController($scope, $routeParams, $location, appState, navigationService, treeService, dataTypeResource, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, formHelper, editorState) {
function DataTypeEditController($scope, $routeParams, $location, appState, navigationService, treeService, dataTypeResource, notificationsService, angularHelper, serverValidationManager, contentEditingHelper, formHelper, editorState, dataTypeHelper) {
//setup scope vars
$scope.page = {};
@@ -158,6 +158,8 @@ function DataTypeEditController($scope, $routeParams, $location, appState, navig
$scope.page.saveButtonState = "success";
dataTypeHelper.rebindChangedProperties($scope.content, data);
}, function(err) {
//NOTE: in the case of data type values we are setting the orig/new props
@@ -171,6 +173,8 @@ function DataTypeEditController($scope, $routeParams, $location, appState, navig
//share state
editorState.set($scope.content);
dataTypeHelper.rebindChangedProperties($scope.content, data);
});
}