Skip to content

Commit f39909d

Browse files
patrickdemooij9nul800sebastiaan
authored andcommitted
8258: Added create dictionary item button
(cherry picked from commit 49132e2) # Conflicts: # src/Umbraco.Web.UI/Umbraco/config/lang/en.xml # src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml
1 parent 64dc1d4 commit f39909d

File tree

4 files changed

+64
-40
lines changed

4 files changed

+64
-40
lines changed

src/Umbraco.Web.UI.Client/src/views/dictionary/dictionary.list.controller.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/**
1+
/**
22
* @ngdoc controller
33
* @name Umbraco.Editors.Dictionary.ListController
44
* @function
55
*
66
* @description
77
* The controller for listting dictionary items
88
*/
9-
function DictionaryListController($scope, $location, dictionaryResource, localizationService, appState) {
9+
function DictionaryListController($scope, $location, dictionaryResource, localizationService, appState, navigationService) {
1010
var vm = this;
1111
vm.title = "Dictionary overview";
1212
vm.loading = false;
@@ -31,7 +31,17 @@ function DictionaryListController($scope, $location, dictionaryResource, localiz
3131
$location.path("/" + currentSection + "/dictionary/edit/" + id);
3232
}
3333

34+
function createNewItem() {
35+
var rootNode = appState.getTreeState("currentRootNode").root;
36+
//We need to load the menu first before we can access the menu actions.
37+
navigationService.showMenu({ node: rootNode }).then(function () {
38+
const action = appState.getMenuState("menuActions").find(item => item.alias === "create");
39+
navigationService.executeMenuAction(action, rootNode, appState.getSectionState("currentSection"));
40+
});
41+
}
42+
3443
vm.clickItem = clickItem;
44+
vm.createNewItem = createNewItem;
3545

3646
function onInit() {
3747
localizationService.localize("dictionaryItem_overviewTitle").then(function (value) {

src/Umbraco.Web.UI.Client/src/views/dictionary/list.html

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div ng-controller="Umbraco.Editors.Dictionary.ListController as vm">
1+
<div ng-controller="Umbraco.Editors.Dictionary.ListController as vm">
22

33
<umb-load-indicator ng-if="vm.loading">
44
</umb-load-indicator>
@@ -13,43 +13,55 @@
1313
</umb-editor-header>
1414
<umb-editor-container>
1515

16-
<umb-box ng-if="vm.items.length === 0">
17-
<umb-box-content class="block-form">
18-
19-
<umb-empty-state size="small">
20-
<localize key="dictionary_noItems">There are no dictionary items.</localize>
21-
</umb-empty-state>
22-
23-
</umb-box-content>
24-
</umb-box>
25-
26-
<table class="table table-hover" ng-if="vm.items.length > 0">
27-
<caption class="sr-only"><localize key="visuallyHiddenTexts_dictionaryListCaption"></localize></caption>
28-
<thead>
29-
<tr>
30-
<th><localize key="general_name">Name</localize></th>
31-
<th ng-repeat="column in vm.items[0].translations | orderBy:'displayName'">{{column.displayName}}</th>
32-
</tr>
33-
</thead>
34-
<tbody>
35-
<tr ng-repeat="item in vm.items track by item.id" style="cursor: pointer;">
36-
<th>
37-
<button type="button" ng-style="item.style" class="btn-reset bold" ng-click="vm.clickItem(item.id)">{{item.name}}</button>
38-
</th>
39-
<td ng-repeat="column in item.translations | orderBy:'displayName'">
40-
<button type="button" class="btn-reset" ng-click="vm.clickItem(item.id)">
41-
<umb-icon icon="{{ column.hasTranslation ? 'icon-check' : 'icon-alert' }}"
42-
class="{{ column.hasTranslation ? 'color-green' : 'color-red' }}">
43-
</umb-icon>
44-
<span class="sr-only">
45-
<localize ng-if="column.hasTranslation" key="visuallyHiddenTexts_hasTranslation"></localize>
46-
<localize ng-if="!column.hasTranslation" key="visuallyHiddenTexts_noTranslation"></localize>
47-
</span>
48-
</button>
49-
</td>
50-
</tr>
51-
</tbody>
52-
</table>
16+
<umb-editor-sub-header>
17+
18+
<umb-editor-sub-header-content-left>
19+
<umb-button button-style="outline"
20+
type="button"
21+
action="vm.createNewItem()"
22+
label-key="dictionary_createNew">
23+
</umb-button>
24+
</umb-editor-sub-header-content-left>
25+
26+
</umb-editor-sub-header>
27+
28+
<umb-box ng-if="vm.items.length === 0">
29+
<umb-box-content class="block-form">
30+
31+
<umb-empty-state size="small">
32+
<localize key="dictionary_noItems">There are no dictionary items.</localize>
33+
</umb-empty-state>
34+
35+
</umb-box-content>
36+
</umb-box>
37+
38+
<table class="table table-hover" ng-if="vm.items.length > 0">
39+
<caption class="sr-only"><localize key="visuallyHiddenTexts_dictionaryListCaption"></localize></caption>
40+
<thead>
41+
<tr>
42+
<th><localize key="general_name">Name</localize></th>
43+
<th ng-repeat="column in vm.items[0].translations | orderBy:'displayName'">{{column.displayName}}</th>
44+
</tr>
45+
</thead>
46+
<tbody>
47+
<tr ng-repeat="item in vm.items track by item.id" style="cursor: pointer;">
48+
<th>
49+
<button type="button" ng-style="item.style" class="btn-reset bold" ng-click="vm.clickItem(item.id)">{{item.name}}</button>
50+
</th>
51+
<td ng-repeat="column in item.translations | orderBy:'displayName'">
52+
<button type="button" class="btn-reset" ng-click="vm.clickItem(item.id)">
53+
<umb-icon icon="{{ column.hasTranslation ? 'icon-check' : 'icon-alert' }}"
54+
class="{{ column.hasTranslation ? 'color-green' : 'color-red' }}">
55+
</umb-icon>
56+
<span class="sr-only">
57+
<localize ng-if="column.hasTranslation" key="visuallyHiddenTexts_hasTranslation"></localize>
58+
<localize ng-if="!column.hasTranslation" key="visuallyHiddenTexts_noTranslation"></localize>
59+
</span>
60+
</button>
61+
</td>
62+
</tr>
63+
</tbody>
64+
</table>
5365

5466
</umb-editor-container>
5567
</umb-editor-view>

src/Umbraco.Web.UI/Umbraco/config/lang/en.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@
526526
</area>
527527
<area alias="dictionary">
528528
<key alias="noItems">There are no dictionary items.</key>
529+
<key alias="createNew">Create dictionary item</key>
529530
</area>
530531
<area alias="dictionaryItem">
531532
<key alias="description"><![CDATA[

src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@
532532
</area>
533533
<area alias="dictionary">
534534
<key alias="noItems">There are no dictionary items.</key>
535+
<key alias="createNew">Create dictionary item</key>
535536
</area>
536537
<area alias="dictionaryItem">
537538
<key alias="description"><![CDATA[

0 commit comments

Comments
 (0)