Skip to content

Commit

Permalink
8258: Added create dictionary item button
Browse files Browse the repository at this point in the history
(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
  • Loading branch information
patrickdemooij9 authored and nul800sebastiaan committed Nov 3, 2021
1 parent 0e3fc7f commit 8acf04c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
/**
* @ngdoc controller
* @name Umbraco.Editors.Dictionary.ListController
* @function
*
* @description
* The controller for listting dictionary items
*/
function DictionaryListController($scope, $location, dictionaryResource, localizationService, appState) {
function DictionaryListController($scope, $location, dictionaryResource, localizationService, appState, navigationService) {
var vm = this;
vm.title = "Dictionary overview";
vm.loading = false;
Expand All @@ -31,7 +31,17 @@ function DictionaryListController($scope, $location, dictionaryResource, localiz
$location.path("/" + currentSection + "/dictionary/edit/" + id);
}

function createNewItem() {
var rootNode = appState.getTreeState("currentRootNode").root;
//We need to load the menu first before we can access the menu actions.
navigationService.showMenu({ node: rootNode }).then(function () {
const action = appState.getMenuState("menuActions").find(item => item.alias === "create");
navigationService.executeMenuAction(action, rootNode, appState.getSectionState("currentSection"));
});
}

vm.clickItem = clickItem;
vm.createNewItem = createNewItem;

function onInit() {
localizationService.localize("dictionaryItem_overviewTitle").then(function (value) {
Expand Down
88 changes: 50 additions & 38 deletions src/Umbraco.Web.UI.Client/src/views/dictionary/list.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div ng-controller="Umbraco.Editors.Dictionary.ListController as vm">
<div ng-controller="Umbraco.Editors.Dictionary.ListController as vm">

<umb-load-indicator ng-if="vm.loading">
</umb-load-indicator>
Expand All @@ -13,43 +13,55 @@
</umb-editor-header>
<umb-editor-container>

<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">
<caption class="sr-only"><localize key="visuallyHiddenTexts_dictionaryListCaption"></localize></caption>
<thead>
<tr>
<th><localize key="general_name">Name</localize></th>
<th ng-repeat="column in vm.items[0].translations | orderBy:'displayName'">{{column.displayName}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in vm.items track by item.id" style="cursor: pointer;">
<th>
<button type="button" ng-style="item.style" class="btn-reset bold" ng-click="vm.clickItem(item.id)">{{item.name}}</button>
</th>
<td ng-repeat="column in item.translations | orderBy:'displayName'">
<button type="button" class="btn-reset" ng-click="vm.clickItem(item.id)">
<umb-icon icon="{{ column.hasTranslation ? 'icon-check' : 'icon-alert' }}"
class="{{ column.hasTranslation ? 'color-green' : 'color-red' }}">
</umb-icon>
<span class="sr-only">
<localize ng-if="column.hasTranslation" key="visuallyHiddenTexts_hasTranslation"></localize>
<localize ng-if="!column.hasTranslation" key="visuallyHiddenTexts_noTranslation"></localize>
</span>
</button>
</td>
</tr>
</tbody>
</table>
<umb-editor-sub-header>

<umb-editor-sub-header-content-left>
<umb-button button-style="outline"
type="button"
action="vm.createNewItem()"
label-key="dictionary_createNew">
</umb-button>
</umb-editor-sub-header-content-left>

</umb-editor-sub-header>

<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">
<caption class="sr-only"><localize key="visuallyHiddenTexts_dictionaryListCaption"></localize></caption>
<thead>
<tr>
<th><localize key="general_name">Name</localize></th>
<th ng-repeat="column in vm.items[0].translations | orderBy:'displayName'">{{column.displayName}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in vm.items track by item.id" style="cursor: pointer;">
<th>
<button type="button" ng-style="item.style" class="btn-reset bold" ng-click="vm.clickItem(item.id)">{{item.name}}</button>
</th>
<td ng-repeat="column in item.translations | orderBy:'displayName'">
<button type="button" class="btn-reset" ng-click="vm.clickItem(item.id)">
<umb-icon icon="{{ column.hasTranslation ? 'icon-check' : 'icon-alert' }}"
class="{{ column.hasTranslation ? 'color-green' : 'color-red' }}">
</umb-icon>
<span class="sr-only">
<localize ng-if="column.hasTranslation" key="visuallyHiddenTexts_hasTranslation"></localize>
<localize ng-if="!column.hasTranslation" key="visuallyHiddenTexts_noTranslation"></localize>
</span>
</button>
</td>
</tr>
</tbody>
</table>

</umb-editor-container>
</umb-editor-view>
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/Umbraco/config/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@
</area>
<area alias="dictionary">
<key alias="noItems">There are no dictionary items.</key>
<key alias="createNew">Create dictionary item</key>
</area>
<area alias="dictionaryItem">
<key alias="description"><![CDATA[
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@
</area>
<area alias="dictionary">
<key alias="noItems">There are no dictionary items.</key>
<key alias="createNew">Create dictionary item</key>
</area>
<area alias="dictionaryItem">
<key alias="description"><![CDATA[
Expand Down

0 comments on commit 8acf04c

Please sign in to comment.