More localization and validation of blueprints

This commit is contained in:
Lars-Erik Aabech
2017-06-05 00:20:02 +02:00
4 changed files with 64 additions and 35 deletions

View File

@@ -5,20 +5,18 @@
contentResource,
notificationsService,
navigationService,
localizationService
) {
localizationService,
formHelper) {
var successText = {}, errorText = {};
var successText = {};
localizationService.localizeMany([
"content_createBlueprintFrom",
"content_createdBlueprintHeading",
"content_createdBlueprintMessage",
"content_failedBlueprintMessage",
"content_failedBlueprintMessage"
"content_createdBlueprintMessage"
]).then(function(localizedValues) {
successText.heading = localizedValues[0];
successText.message = localizedValues[1].replace("%0%", $scope.name);
errorText.heading = localizedValues[2];
errorText.message = localizedValues[3];
$scope.label = localizedValues[0] + " " + $scope.name;
successText.heading = localizedValues[1];
successText.message = localizedValues[2].replace("%0%", $scope.name);
});
$scope.name = $scope.currentNode.name;
@@ -27,16 +25,35 @@
navigationService.hideMenu();
};
$scope.create = function () {
contentResource.createBlueprintFromContent($scope.currentNode.id, $scope.name)
.then(
function () { notificationsService.showNotification({ type: 3, header: successText.heading, message: successText.message }) },
function () { notificationsService.showNotification({ type: 2, header: errorText.heading, message: errorText.message }) }
);
navigationService.hideMenu();
}
}
$scope.create = function() {
if (formHelper.submitForm({
scope: $scope,
formCtrl: this.blueprintForm,
statusMessage: "Creating blueprint..."
})) {
contentResource.createBlueprintFromContent($scope.currentNode.id, $scope.name)
.then(function() {
notificationsService.showNotification({
type: 3,
header: successText.heading,
message: successText.message
});
navigationService.hideMenu();
},
function(response) {
for (var n = 0; n < response.data.notifications.length; n++) {
notificationsService.showNotification({
type: 2,
header: response.data.notifications[n].header,
message: response.data.notifications[n].message
});
}
}
);
}
};
}
angular.module("umbraco").controller("Umbraco.Editors.Content.CreateBlueprintController", CreateBlueprintController);

View File

@@ -1,20 +1,28 @@
<div ng-controller="Umbraco.Editors.Content.CreateBlueprintController">
<div class="umb-dialog-body with-footer" ng-cloak>
<div class="umb-pane">
<h5><localize key="content_createBlueprintFrom">Create a blueprint from</localize> {{currentNode.name}}</h5>
<form name="blueprintForm"
novalidate
ng-submit="create()"
val-form-manager>
<div class="umbracoDialog umb-dialog-body with-footer"
ng-cloak>
<div class="umb-pane">
<umb-control-group label="{{label}}" hide-label="false">
<input type="text" name="name" ng-model="name" class="umb-textstring textstring input-block-level" required />
</umb-control-group>
</div>
<label for="name"><localize key="content_blueprintName">Name</localize></label>
<input type="text" name="name" id="name" ng-model="name" />
</div>
</div>
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
<button class="btn umb-button btn-info" ng-click="cancel()">
<localize key="general_cancel">Cancel</localize>
</button>
<button class="btn umb-button btn-success" ng-click="create()">
<localize key="general_create">Create blueprint</localize>
</button>
</div>
<button class="btn umb-button btn-success">
<localize key="general_create">Create blueprint</localize>
</button>
</div>
</form>
</div>

View File

@@ -339,8 +339,8 @@ namespace Umbraco.Web.Editors
//not allowed
var notificationModel = new SimpleNotificationModel();
notificationModel.AddSuccessNotification(
Services.TextService.Localize("content_failedBlueprintHeading"),
Services.TextService.Localize("content_duplicateBlueprintMessage")
Services.TextService.Localize("content/failedBlueprintHeading"),
Services.TextService.Localize("content/duplicateBlueprintMessage")
);
return Request.CreateValidationErrorResponse(notificationModel);
}

View File

@@ -92,8 +92,12 @@ namespace Umbraco.Web.Trees
return menu;
}
var ct = Services.EntityService.Get(int.Parse(id), UmbracoObjectTypes.DocumentType);
//no menu if it's a content type
if (ct != null) return null;
//only refresh if it's a content type
if (ct != null)
{
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
return menu;
}
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)));