Fixes media picker property editor attribute declaration, fixes promise chaining when saving content, fixes the boolean pre-value editor to accept a 'true' boolean value

This commit is contained in:
Shannon
2018-04-10 13:37:54 +10:00
parent 3d92ce96f3
commit 2ee955e664
4 changed files with 35 additions and 27 deletions

View File

@@ -200,27 +200,28 @@
$scope.page.buttonGroupState = "busy";
return contentEditingHelper.contentEditorPerformSave({
saveMethod: args.saveMethod,
scope: $scope,
content: $scope.content,
action: args.action
}).then(function (data) {
//success
init($scope.content);
syncTreeNode($scope.content, data.path);
return contentEditingHelper.contentEditorPerformSave({
saveMethod: args.saveMethod,
scope: $scope,
content: $scope.content,
action: args.action
}).then(function(data) {
//success
init($scope.content);
syncTreeNode($scope.content, data.path);
$scope.page.buttonGroupState = "success";
$scope.page.buttonGroupState = "success";
return $q.when(data);
},
function(err) {
//error
if (err) {
editorState.set($scope.content);
}
}, function (err) {
//error
if (err) {
editorState.set($scope.content);
}
$scope.page.buttonGroupState = "error";
return $q.reject(err);
});
$scope.page.buttonGroupState = "error";
return $q.reject(err);
});
}
function resetLastListPageNumber(content) {
@@ -303,17 +304,18 @@
variants: $scope.content.variants, //set a model property for the dialog
skipFormValidation: true, //when submitting the overlay form, skip any client side validation
submitButtonLabel: "Publish",
submit: function (model) {
submit: function(model) {
model.submitButtonState = "busy";
//we need to return this promise so that the dialog can handle the result and wire up the validation response
return performSave({
saveMethod: contentResource.publish,
action: "publish"
}).then(function () {
}).then(function(data) {
overlayService.close();
return $q.when(data);
},
function (err) {
function(err) {
model.submitButtonState = "error";
//re-map the dialog model since we've re-bound the properties
dialog.variants = $scope.content.variants;
@@ -323,9 +325,10 @@
//will need to fix validation errors on the properties
if (err.data && err.data.ModelState) {
var keys = _.keys(err.data.ModelState);
var foundVariantError = _.find(keys, function(k) {
return k.startsWith("publish_variant_");
});
var foundVariantError = _.find(keys,
function(k) {
return k.startsWith("publish_variant_");
});
if (!foundVariantError) {
//no variant errors, close the dialog
overlayService.close();
@@ -335,7 +338,7 @@
return $q.reject(err);
});
},
close: function (oldModel) {
close: function(oldModel) {
overlayService.close();
}
};

View File

@@ -69,6 +69,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, notifica
});
args.scope.busy = false;
return $q.when(data);
}, function (err) {
self.handleSaveError({

View File

@@ -1,4 +1,7 @@
angular.module("umbraco").controller("Umbraco.PrevalueEditors.BooleanController",
function ($scope) {
if ($scope.model.value === 1 || $scope.model.value === "1" || $scope.model.value === true) {
$scope.model.value = "1";
}
$scope.htmlId = "bool-" + String.CreateGuid();
});

View File

@@ -7,7 +7,8 @@ namespace Umbraco.Web.PropertyEditors
/// <summary>
/// Represents a media picker property editor.
/// </summary>
[DataEditor(Constants.PropertyEditors.Aliases.MediaPicker, EditorType.PropertyValue | EditorType.MacroParameter, "mediapicker", ValueTypes.Text, Group = "media", Icon = "icon-picture")]
[DataEditor(Constants.PropertyEditors.Aliases.MediaPicker, EditorType.PropertyValue | EditorType.MacroParameter,
"Media Picker", "mediapicker", ValueType = ValueTypes.Text, Group = "media", Icon = "icon-picture")]
public class MediaPickerPropertyEditor : DataEditor
{
/// <summary>