v8: Fix dictionary items overview (#4456)

This commit is contained in:
Bjarne Fyrstenborg
2019-02-14 17:04:11 +01:00
committed by Sebastiaan Janssen
parent 20e12644e5
commit d76d9b8bcf
7 changed files with 60 additions and 37 deletions

View File

@@ -1,19 +1,19 @@
<div ng-controller="Umbraco.Editors.Dictionary.CreateController as vm">
<div class="umbracoDialog umb-dialog-body with-footer" ng-controller="Umbraco.Editors.Dictionary.CreateController as vm">
<div class="umb-pane">
<h5><localize key="create_createUnder">Create an item under</localize> {{currentNode.name}}</h5>
</div>
<div class="umb-pane">
<form name="createDictionaryForm"
ng-submit="vm.createItem()"
val-form-manager>
<form novalidate name="createDictionaryForm"
ng-submit="vm.createItem()"
val-form-manager>
<umb-control-group label="Enter a item-name" hide-label="true">
<input type="text" name="itemKey" ng-model="vm.itemKey" class="umb-textstring textstring input-block-level" required />
</umb-control-group>
<umb-control-group label="@general_name" hide-label="false">
<input type="text" name="itemKey" ng-model="vm.itemKey" class="umb-textstring textstring input-block-level" umb-auto-focus required />
</umb-control-group>
<button type="submit" class="btn btn-primary"><localize key="general_create">Create</localize></button>
</form>
<button type="submit" class="btn btn-primary"><localize key="general_create">Create</localize></button>
</form>
</div>
</div>
</div>

View File

@@ -7,38 +7,41 @@
* The controller for creating dictionary items
*/
function DictionaryCreateController($scope, $location, dictionaryResource, navigationService, notificationsService, formHelper, appState) {
var vm = this;
vm.itemKey = "";
vm.createItem = createItem;
function createItem() {
var node = $scope.currentNode;
if (formHelper.submitForm({ scope: $scope, formCtrl: this.createDictionaryForm })) {
dictionaryResource.create(node.id, vm.itemKey).then(function (data) {
navigationService.hideMenu();
var node = $scope.currentNode;
// set new item as active in tree
var currPath = node.path ? node.path : "-1";
navigationService.syncTree({ tree: "dictionary", path: currPath + "," + data, forceReload: true, activate: true });
// reset form state
formHelper.resetForm({ scope: $scope });
// navigate to edit view
var currentSection = appState.getSectionState("currentSection");
$location.path("/" + currentSection + "/dictionary/edit/" + data);
}, function (err) {
if (err.data && err.data.message) {
notificationsService.error(err.data.message);
dictionaryResource.create(node.id, vm.itemKey).then(function (data) {
navigationService.hideMenu();
}
});
}
vm.createItem = createItem;
// set new item as active in tree
var currPath = node.path ? node.path : "-1";
navigationService.syncTree({ tree: "dictionary", path: currPath + "," + data, forceReload: true, activate: true });
// reset form state
formHelper.resetForm({ scope: $scope });
// navigate to edit view
var currentSection = appState.getSectionState("currentSection");
$location.path("/" + currentSection + "/dictionary/edit/" + data);
}, function (err) {
if (err.data && err.data.message) {
notificationsService.error(err.data.message);
navigationService.hideMenu();
}
});
}
}
}
angular.module("umbraco").controller("Umbraco.Editors.Dictionary.CreateController", DictionaryCreateController);

View File

@@ -1,4 +1,5 @@
<div ng-controller="Umbraco.Editors.Dictionary.ListController as vm">
<umb-load-indicator ng-if="vm.loading">
</umb-load-indicator>
@@ -12,12 +13,22 @@
</umb-editor-header>
<umb-editor-container>
<table class="table table-hover" ng-if="vm.items">
<umb-box ng-if="vm.items.length === 0">
<umb-box-content class="block-form">
<umb-empty-state size="small">
<localize key="dictionary_noItems">There are no dictionary items.</localize>
</umb-empty-state>
</umb-box-content>
</umb-box>
<table class="table table-hover" ng-if="vm.items.length > 0">
<thead>
<tr>
<th><localize key="general_name">Name</localize></th>
<th ng-repeat="column in vm.items[0].translations">{{column.displayName}}</th>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in vm.items track by item.id" ng-click="vm.clickItem(item.id)" style="cursor: pointer;">
@@ -31,7 +42,7 @@
</tr>
</tbody>
</table>
</umb-editor-container>
</umb-editor-view>
</div>