U4-7371 New Content type editor - Better validation when trying to create a new document/media/member type with the same name as an existing one & U4-7696 New content type editor - server side validation fails when creating new document type
This commit is contained in:
@@ -7,7 +7,8 @@ angular.module("umbraco.directives")
|
||||
scope: {
|
||||
alias: '=',
|
||||
aliasFrom: '=',
|
||||
enableLock: '=?'
|
||||
enableLock: '=?',
|
||||
serverValidationField: '@'
|
||||
},
|
||||
link: function (scope, element, attrs, ctrl) {
|
||||
|
||||
@@ -32,7 +33,7 @@ angular.module("umbraco.directives")
|
||||
generateAliasTimeout = $timeout(function () {
|
||||
updateAlias = true;
|
||||
entityResource.getSafeAlias(value, true).then(function (safeAlias) {
|
||||
if(updateAlias) {
|
||||
if (updateAlias) {
|
||||
scope.alias = safeAlias.alias;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,7 +11,17 @@
|
||||
|
||||
function LockedFieldDirective($timeout, localizationService) {
|
||||
|
||||
function link(scope, el, attr, ngModel) {
|
||||
function link(scope, el, attr, ngModelCtrl) {
|
||||
|
||||
//watch the ngModel so we can manually update the textbox view value when it changes
|
||||
// this ensures that the normal flow (i.e. a user editing the text box) occurs so that
|
||||
// the parsers, validators and viewchangelisteners execute
|
||||
scope.$watch("ngModel", function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
scope.lockedFieldForm.lockedField.$setViewValue(newValue);
|
||||
scope.lockedFieldForm.lockedField.$render();
|
||||
}
|
||||
});
|
||||
|
||||
var input = el.find('.umb-locked-field__input');
|
||||
|
||||
@@ -79,7 +89,7 @@
|
||||
replace: true,
|
||||
templateUrl: 'views/components/umb-locked-field.html',
|
||||
scope: {
|
||||
model: '=ngModel',
|
||||
ngModel: "=",
|
||||
locked: "=?",
|
||||
placeholderText: "=?",
|
||||
regexValidation: "=?",
|
||||
|
||||
@@ -46,6 +46,8 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
|
||||
throw "args.saveMethod is not defined";
|
||||
}
|
||||
|
||||
var redirectOnFailure = args.redirectOnFailure !== undefined ? args.redirectOnFailure : true;
|
||||
|
||||
var self = this;
|
||||
|
||||
//we will use the default one for content if not specified
|
||||
@@ -75,7 +77,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
|
||||
|
||||
}, function (err) {
|
||||
self.handleSaveError({
|
||||
redirectOnFailure: true,
|
||||
redirectOnFailure: redirectOnFailure,
|
||||
err: err,
|
||||
rebindCallback: function() {
|
||||
rebindCallback.apply(self, [args.content, err.data]);
|
||||
|
||||
@@ -25,7 +25,12 @@
|
||||
|
||||
<div class="umb-panel-header-name" ng-if="nameLocked">{{ name }}</div>
|
||||
|
||||
<umb-generate-alias class="umb-panel-header-alias" ng-if="!hideAlias" alias="$parent.alias" alias-from="$parent.name" enable-lock="true"></umb-generate-alias>
|
||||
<umb-generate-alias class="umb-panel-header-alias"
|
||||
ng-if="!hideAlias"
|
||||
alias="$parent.alias"
|
||||
alias-from="$parent.name"
|
||||
enable-lock="true"
|
||||
server-validation-field="Alias"></umb-generate-alias>
|
||||
|
||||
<input type="text" class="umb-panel-header-description" placeholder="Enter description..." ng-if="!hideDescription" ng-model="$parent.description" />
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
<umb-locked-field
|
||||
locked="locked"
|
||||
ng-model="alias"
|
||||
placeholder-text="placeholderText">
|
||||
placeholder-text="placeholderText"
|
||||
server-validation-field="{{serverValidationField}}">
|
||||
</umb-locked-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ng-form class="umb-locked-field">
|
||||
<ng-form name="lockedFieldForm" class="umb-locked-field">
|
||||
|
||||
<div class="umb-locked-field__wrapper">
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<input type="text"
|
||||
class="umb-locked-field__input"
|
||||
name="lockedField"
|
||||
ng-model="model"
|
||||
ng-model="inputModel"
|
||||
ng-disabled="locked"
|
||||
ng-class="{'-unlocked': !locked}"
|
||||
placeholder="{{placeholderText}}"
|
||||
@@ -21,7 +21,7 @@
|
||||
umb-auto-resize
|
||||
required
|
||||
val-server-field="{{serverValidationField}}"
|
||||
title="{{model}}" />
|
||||
title="{{inputModel}}" />
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -155,6 +155,10 @@
|
||||
saveMethod: contentTypeResource.save,
|
||||
scope: $scope,
|
||||
content: vm.contentType,
|
||||
//We do not redirect on failure for doc types - this is because it is not possible to actually save the doc
|
||||
// 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,
|
||||
// we need to rebind... the IDs that have been created!
|
||||
rebindCallback: function (origContentType, savedContentType) {
|
||||
vm.contentType.id = savedContentType.id;
|
||||
|
||||
@@ -136,6 +136,10 @@
|
||||
saveMethod: mediaTypeResource.save,
|
||||
scope: $scope,
|
||||
content: vm.contentType,
|
||||
//We do not redirect on failure for doc types - this is because it is not possible to actually save the doc
|
||||
// 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
|
||||
}).then(function (data) {
|
||||
|
||||
@@ -90,6 +90,10 @@
|
||||
saveMethod: memberTypeResource.save,
|
||||
scope: $scope,
|
||||
content: vm.contentType,
|
||||
//We do not redirect on failure for doc types - this is because it is not possible to actually save the doc
|
||||
// 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
|
||||
}).then(function (data) {
|
||||
|
||||
Reference in New Issue
Block a user