Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U4-5683 Migrate Dictionary tree & editor to angular #2159

Merged
merged 134 commits into from Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
c175c72
Added new treecontroller for dictionairy and marked legacy tree as ob…
dawoe Jul 20, 2017
2799f2c
Load root dictionairy items in tree
dawoe Jul 20, 2017
934666f
Enabled loading of sub dictionary items in dictionary tree
dawoe Jul 20, 2017
9821f7f
Added the reload nodes menu action to dictionairy nodes
dawoe Jul 20, 2017
3baaa41
Added delete action to items in dictionary tree
dawoe Jul 20, 2017
f51604e
Added delete view for dictionary with needed markup
dawoe Jul 21, 2017
b51bc09
Added angular dictionary resource
dawoe Jul 21, 2017
0baae65
Added new treecontroller for dictionairy and marked legacy tree as ob…
dawoe Jul 20, 2017
cb33ef0
Load root dictionairy items in tree
dawoe Jul 20, 2017
f7d72bc
Enabled loading of sub dictionary items in dictionary tree
dawoe Jul 20, 2017
7eb7d1d
Added the reload nodes menu action to dictionairy nodes
dawoe Jul 20, 2017
f62e466
Added delete action to items in dictionary tree
dawoe Jul 20, 2017
fa9044c
Added delete view for dictionary with needed markup
dawoe Jul 21, 2017
552198c
Added angular dictionary resource
dawoe Jul 21, 2017
1810500
Merge branch 'U4-5863' of https://github.com/dawoe/Umbraco-CMS into U…
dawoe Jul 24, 2017
109810f
Added dictionary api controller with method to delete dictionary items
dawoe Jul 28, 2017
df370ed
Added dictionary api base url to server variables
dawoe Jul 28, 2017
99334c4
Added delete by id method to dictionary resource
dawoe Aug 4, 2017
7818450
Fix create dialog on old dictionary tree
dawoe Aug 4, 2017
7f058d2
Added dictionary delelte controller and added cancel method
dawoe Aug 4, 2017
136f154
Order items in dictionairy tree by key
dawoe Aug 4, 2017
8330986
Added detele function to angular controller
dawoe Aug 18, 2017
d177acb
Added new treecontroller for dictionairy and marked legacy tree as ob…
dawoe Jul 20, 2017
9751b2e
Load root dictionairy items in tree
dawoe Jul 20, 2017
55128fc
Enabled loading of sub dictionary items in dictionary tree
dawoe Jul 20, 2017
f9c0f2e
Added the reload nodes menu action to dictionairy nodes
dawoe Jul 20, 2017
447a6da
Added delete action to items in dictionary tree
dawoe Jul 20, 2017
0946fa9
Added delete view for dictionary with needed markup
dawoe Jul 21, 2017
40a62c6
Added angular dictionary resource
dawoe Jul 21, 2017
f135911
Added new treecontroller for dictionairy and marked legacy tree as ob…
dawoe Jul 20, 2017
1560239
Load root dictionairy items in tree
dawoe Jul 20, 2017
a971dd3
Added dictionary api controller with method to delete dictionary items
dawoe Jul 28, 2017
52c0a48
Added dictionary api base url to server variables
dawoe Jul 28, 2017
64b301f
Added delete by id method to dictionary resource
dawoe Aug 4, 2017
d00f4a5
Fix create dialog on old dictionary tree
dawoe Aug 4, 2017
3313f57
Added dictionary delelte controller and added cancel method
dawoe Aug 4, 2017
ecb48fd
Order items in dictionairy tree by key
dawoe Aug 4, 2017
9ac95e4
Added detele function to angular controller
dawoe Aug 18, 2017
afda2a9
Merge branch 'U4-5863' of https://github.com/dawoe/Umbraco-CMS into U…
dawoe Aug 21, 2017
1abf355
Order dictoinairy items in tree by key descending
dawoe Aug 21, 2017
b901fb6
Removed setting of current tree item
dawoe Aug 25, 2017
8b7b51f
Added emtpy edit view and angular controller
dawoe Aug 25, 2017
82c280b
Added create action to dictionary tree controller
dawoe Aug 25, 2017
8a539ce
Added dictoinairy angular create controller and view
dawoe Aug 25, 2017
65e8797
Added markup to create dialog ans wired up controller
dawoe Aug 25, 2017
2c7e78f
Added method to api controller to create new dictionary item
dawoe Aug 28, 2017
7da5ba0
Added method to dictionary resouce for creating item
dawoe Aug 28, 2017
9b6e800
Implemented create handling in angular controller
dawoe Aug 30, 2017
9f2bc8e
Show error notification in case of error
dawoe Aug 30, 2017
0bb475b
Handle success state of creating dictionary item
dawoe Aug 30, 2017
7ff2a18
Added new treecontroller for dictionairy and marked legacy tree as ob…
dawoe Jul 20, 2017
3bed7d4
Load root dictionairy items in tree
dawoe Jul 20, 2017
d0a8d0b
Enabled loading of sub dictionary items in dictionary tree
dawoe Jul 20, 2017
ca72575
Added the reload nodes menu action to dictionairy nodes
dawoe Jul 20, 2017
f608f9e
Added delete action to items in dictionary tree
dawoe Jul 20, 2017
9bc8704
Added delete view for dictionary with needed markup
dawoe Jul 21, 2017
2106917
Added angular dictionary resource
dawoe Jul 21, 2017
2af9377
Added dictionary api controller with method to delete dictionary items
dawoe Jul 28, 2017
6de234f
Added dictionary api base url to server variables
dawoe Jul 28, 2017
e46e263
Added delete by id method to dictionary resource
dawoe Aug 4, 2017
f9760b6
Fix create dialog on old dictionary tree
dawoe Aug 4, 2017
fad61af
Added dictionary delelte controller and added cancel method
dawoe Aug 4, 2017
4b8d305
Order items in dictionairy tree by key
dawoe Aug 4, 2017
f31a378
Added detele function to angular controller
dawoe Aug 18, 2017
3a218eb
Added new treecontroller for dictionairy and marked legacy tree as ob…
dawoe Jul 20, 2017
f7224be
Load root dictionairy items in tree
dawoe Jul 20, 2017
d861695
Order dictoinairy items in tree by key descending
dawoe Aug 21, 2017
193866c
Removed setting of current tree item
dawoe Aug 25, 2017
45eeddd
Added emtpy edit view and angular controller
dawoe Aug 25, 2017
10849bf
Added create action to dictionary tree controller
dawoe Aug 25, 2017
8c9588f
Added dictoinairy angular create controller and view
dawoe Aug 25, 2017
cc619d6
Added markup to create dialog ans wired up controller
dawoe Aug 25, 2017
0d29801
Added method to api controller to create new dictionary item
dawoe Aug 28, 2017
f3a0f76
Added method to dictionary resouce for creating item
dawoe Aug 28, 2017
7bebfa1
Implemented create handling in angular controller
dawoe Aug 30, 2017
541c796
Show error notification in case of error
dawoe Aug 30, 2017
35a547c
Handle success state of creating dictionary item
dawoe Aug 30, 2017
a063655
Merge branch 'U4-5863' of https://github.com/dawoe/Umbraco-CMS into U…
dawoe Aug 30, 2017
c574b27
Merge branch 'dev-v7' into U4-5863
dawoe Oct 20, 2017
aedc95b
U4-5863 register api for dictionary again using new methods
dawoe Oct 20, 2017
5d20a8e
U4-5863 added dictionary display model
dawoe Oct 27, 2017
e4127a9
U4-5863 added basic mapping for dictionary display model
dawoe Oct 27, 2017
47152e4
U4-5863 added api method to get a dictionary item by id
dawoe Oct 27, 2017
e07f551
U4-5863 added method to dictionary resource to get a dictionary item …
dawoe Oct 27, 2017
18d8fd5
Merge branch 'dev-v7' into U4-5863
dawoe Nov 2, 2017
91d581b
U4-5863 load basic details in to edit view
dawoe Nov 6, 2017
e405d77
U4-5863 show name of current item being edited
dawoe Nov 6, 2017
b5cbc87
U4-5863 make current item active in the tree
dawoe Nov 10, 2017
2691b7a
U4-5863 added translations to display model
dawoe Nov 10, 2017
0de837f
Merge branch 'dev-v7' into U4-5863
dawoe Nov 10, 2017
59b49bd
U4-5863 fixed mapping so unit test passes
dawoe Nov 10, 2017
f570d95
U4-5863 bind translation to input fields
dawoe Nov 13, 2017
fb31122
U4-5863 fix display name of culture
dawoe Nov 13, 2017
631933c
U4-5863 fix issue in mapping of path
dawoe Dec 4, 2017
016a372
U4-5863 refactored how property data is set to avoid console errors
dawoe Dec 4, 2017
038720d
U4-5863 set to correct item view after delete
dawoe Dec 4, 2017
e293d37
U4-5863 added handler for saving dictionary item
dawoe Dec 4, 2017
32f4384
Merge branch 'dev-v7' into U4-5863
dawoe Dec 4, 2017
18ef52a
U4-5863 added models for dictionary save
dawoe Dec 4, 2017
aeddd6d
U4-5863 added api controller method to save dictionary item
dawoe Dec 4, 2017
24e658e
U4-5863 added method to resource to save dictionary
dawoe Dec 4, 2017
c6aa517
U4-5863 make sure data is formatted correct when calling save method
dawoe Dec 4, 2017
cb494ba
U4-5863 set the name dirty when it's changed..so we can check on it w…
dawoe Dec 4, 2017
90c44bc
U4-5863 added language id to models because we need it when saving th…
dawoe Dec 5, 2017
6e476f5
U4-5863 pass key as well, probably need this when saving
dawoe Dec 5, 2017
873a22a
U4-5863 added mapping for dictionary save to IDictionaryItem
dawoe Dec 5, 2017
285ae3b
U4-5863 show message when something goes wrong
dawoe Dec 5, 2017
717683a
U4-5863 first attempt at saving dictionary
dawoe Dec 5, 2017
1a2458d
U4-5863 removed unneeded mapping
dawoe Dec 5, 2017
08bae8b
U4-5863 add notification when saved successfully
dawoe Dec 5, 2017
9169199
U4-5863 rebind data on saving
dawoe Dec 5, 2017
1add660
U4-5863 check for existing dictionary key when saving
dawoe Dec 5, 2017
6e0266e
U4-5863 added description to added view
dawoe Dec 5, 2017
390ad4d
U4-5863 localize key alreaydy exists message
dawoe Dec 5, 2017
f691ec7
U4-5863 make sure name field is required
dawoe Dec 5, 2017
b34e3f9
U4-5863 localized save message
dawoe Dec 5, 2017
f69d7fa
U4-5863 set a custom view for dictionary tree root node
dawoe Dec 5, 2017
41b857d
U4-5863 added view and controller for overview
dawoe Dec 5, 2017
6252e09
U4-5863 added some basic markup to view
dawoe Dec 5, 2017
77bffd9
U4-5683 renamed to list controller
dawoe Dec 12, 2017
c6c3e14
U4-5683 added models for dictionary overview
dawoe Dec 12, 2017
4c926fb
U4-5683 added mapping for overview model
dawoe Dec 12, 2017
98833af
U4-5683 added method to get list of dictionary items
dawoe Dec 12, 2017
fc9422d
U4-5683 added method to resource to get list
dawoe Dec 12, 2017
e3a235c
U4-5683 fixed retreiving of data
dawoe Dec 12, 2017
0cd25bc
U4-5863 retreive data for overview
dawoe Dec 12, 2017
9d22355
U4-5683 show list of dictionary items
dawoe Dec 12, 2017
726f3e1
U4-5683 show icons for translated languages
dawoe Dec 12, 2017
4e3ac5d
U4-5683 make items in overview clickable
dawoe Dec 12, 2017
5ceb16c
U4-5683 fix recursive function
dawoe Dec 12, 2017
6dab110
Merge branch 'dev-v7' into U4-5863
dawoe Dec 12, 2017
fc25e3f
U4-5683 localized dictionary overview title
dawoe Dec 12, 2017
64fb757
U4-5683 fixed mapping so tests pass
dawoe Dec 12, 2017
f3335ec
Merge branch 'dev-v7' into U4-5863
dawoe Mar 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Umbraco.Core/Constants-Applications.cs
Expand Up @@ -93,6 +93,11 @@ public static class Trees
/// </summary>
public const string Dictionary = "dictionary";

/// <summary>
/// The dictionary obsolete.
/// </summary>
public const string DictionaryObsolete = "dictionary-obsolete";

public const string Stylesheets = "stylesheets";

/// <summary>
Expand Down
162 changes: 162 additions & 0 deletions src/Umbraco.Web.UI.Client/src/common/resources/dictionary.resource.js
@@ -0,0 +1,162 @@
/**
* @ngdoc service
* @name umbraco.resources.dictionaryResource
* @description Loads in data for dictionary items
**/
function dictionaryResource($q, $http, umbRequestHelper, umbDataFormatter) {

/**
* @ngdoc method
* @name umbraco.resources.dictionaryResource#deleteById
* @methodOf umbraco.resources.dictionaryResource
*
* @description
* Deletes a dictionary item with a given id
*
* ##usage
* <pre>
* dictionaryResource.deleteById(1234)
* .then(function() {
* alert('its gone!');
* });
* </pre>
*
* @param {Int} id id of dictionary item to delete
* @returns {Promise} resourcePromise object.
*
**/
function deleteById(id) {
return umbRequestHelper.resourcePromise(
$http.post(
umbRequestHelper.getApiUrl(
"dictionaryApiBaseUrl",
"DeleteById",
[{ id: id }])),
"Failed to delete item " + id);
}

/**
* @ngdoc method
* @name umbraco.resources.dictionaryResource#create
* @methodOf umbraco.resources.dictionaryResource
*
* @description
* Creates a dictionary item with the gieven key and parent id
*
* ##usage
* <pre>
* dictionaryResource.create(1234,"Item key")
* .then(function() {
* alert('its created!');
* });
* </pre>
*
* @param {Int} parentid the parentid of the new dictionary item
* @param {String} key the key of the new dictionary item
* @returns {Promise} resourcePromise object.
*
**/
function create(parentid, key) {
return umbRequestHelper.resourcePromise(
$http.post(
umbRequestHelper.getApiUrl(
"dictionaryApiBaseUrl",
"Create",
{ parentId: parentid, key : key })),
"Failed to create item ");
}

/**
* @ngdoc method
* @name umbraco.resources.dictionaryResource#deleteById
* @methodOf umbraco.resources.dictionaryResource
*
* @description
* Gets a dictionary item with a given id
*
* ##usage
* <pre>
* dictionaryResource.getById(1234)
* .then(function() {
* alert('Found it!');
* });
* </pre>
*
* @param {Int} id id of dictionary item to get
* @returns {Promise} resourcePromise object.
*
**/
function getById(id) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dictionaryApiBaseUrl",
"GetById",
[{ id: id }])),
"Failed to get item " + id);
}

/**
* @ngdoc method
* @name umbraco.resources.dictionaryResource#save
* @methodOf umbraco.resources.dictionaryResource
*
* @description
* Updates a dictionary
*
* @param {Object} dictionary dictionary object to update
* @param {Bool} nameIsDirty set to true if the name has been changed
* @returns {Promise} resourcePromise object.
*
*/
function save(dictionary, nameIsDirty) {

var saveModel = umbDataFormatter.formatDictionaryPostData(dictionary, nameIsDirty);

return umbRequestHelper.resourcePromise(
$http.post(umbRequestHelper.getApiUrl("dictionaryApiBaseUrl", "PostSave"), saveModel),
"Failed to save data for dictionary id " + dictionary.id);
}

/**
* @ngdoc method
* @name umbraco.resources.dictionaryResource#getList
* @methodOf umbraco.resources.dictionaryResource
*
* @description
* Gets a list of all dictionary items
*
* ##usage
* <pre>
* dictionaryResource.getList()
* .then(function() {
* alert('Found it!');
* });
* </pre>
*
* @returns {Promise} resourcePromise object.
*
**/
function getList() {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"dictionaryApiBaseUrl",
"getList")),
"Failed to get list");
}

var resource = {
deleteById: deleteById,
create: create,
getById: getById,
save: save,
getList : getList
};

return resource;


}

angular.module("umbraco.resources").factory("dictionaryResource", dictionaryResource);
Expand Up @@ -99,6 +99,28 @@
return saveModel;
},

/** formats the display model used to display the dictionary to the model used to save the dictionary */
formatDictionaryPostData : function(dictionary, nameIsDirty) {
var saveModel = {
parentId: dictionary.parentId,
id: dictionary.id,
name: dictionary.name,
nameIsDirty: nameIsDirty,
translations: [],
key : dictionary.key
};

for(var i = 0; i < dictionary.translations.length; i++) {
saveModel.translations.push({
isoCode: dictionary.translations[i].isoCode,
languageId: dictionary.translations[i].languageId,
translation: dictionary.translations[i].translation
});
}

return saveModel;
},

/** formats the display model used to display the user to the model used to save the user */
formatUserPostData: function (displayModel) {

Expand Down
19 changes: 19 additions & 0 deletions src/Umbraco.Web.UI.Client/src/views/dictionary/create.html
@@ -0,0 +1,19 @@
<div 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>

<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>

<button type="submit" class="btn btn-primary"><localize key="general_create">Create</localize></button>
</form>
</div>
</div>
12 changes: 12 additions & 0 deletions src/Umbraco.Web.UI.Client/src/views/dictionary/delete.html
@@ -0,0 +1,12 @@
<div class="umb-dialog umb-pane" ng-controller="Umbraco.Editors.Dictionary.DeleteController as vm" >
<div class="umb-dialog-body" auto-scale="90">

<p class="umb-abstract">
<localize key="defaultdialogs_confirmdelete">Are you sure you want to delete</localize> <strong>{{currentNode.name}}</strong> ?
</p>

<umb-confirm on-confirm="vm.performDelete" on-cancel="vm.cancel">
</umb-confirm>

</div>
</div>
@@ -0,0 +1,115 @@
/**
* @ngdoc controller
* @name Umbraco.Editors.Dictionary.EditController
* @function
*
* @description
* The controller for editing dictionary items
*/
function DictionaryEditController($scope, $routeParams, dictionaryResource, treeService, navigationService, appState, editorState, contentEditingHelper, formHelper, notificationsService, localizationService) {
vm = this;

//setup scope vars
vm.nameDirty = false;
vm.page = {};
vm.page.loading = false;
vm.page.nameLocked = false;
vm.page.menu = {};
vm.page.menu.currentSection = appState.getSectionState("currentSection");
vm.page.menu.currentNode = null;
vm.description = '';

function loadDictionary() {

vm.page.loading = true;

//we are editing so get the content item from the server
dictionaryResource.getById($routeParams.id)
.then(function (data) {

bindDictionary(data);

vm.page.loading = false;
});
}

function createTranslationProperty(translation) {
return {
alias: translation.isoCode,
label: translation.displayName,
hideLabel : false
}
}

function bindDictionary(data) {
localizationService.localize('dictionaryItem_description').then(function (value) {
vm.description = value.replace('%0%', data.name);
});

// create data for umb-property displaying
for (var i = 0; i < data.translations.length; i++) {
data.translations[i].property = createTranslationProperty(data.translations[i]);
}

contentEditingHelper.handleSuccessfulSave({
scope: $scope,
savedContent: data
});

// set content
vm.content = data;

//share state
editorState.set(vm.content);

navigationService.syncTree({ tree: "dictionary", path: data.path, forceReload: true }).then(function (syncArgs) {
vm.page.menu.currentNode = syncArgs.node;
});
}

function onInit() {
loadDictionary();
}

function saveDictionary() {
if (formHelper.submitForm({ scope: $scope, statusMessage: "Saving..." })) {

vm.page.saveButtonState = "busy";

dictionaryResource.save(vm.content, vm.nameDirty)
.then(function (data) {

formHelper.resetForm({ scope: $scope, notifications: data.notifications });

bindDictionary(data);


vm.page.saveButtonState = "success";
},
function (err) {

contentEditingHelper.handleSaveError({
redirectOnFailure: false,
err: err
});

notificationsService.error(err.data.message);

vm.page.saveButtonState = "error";
});
}
}

vm.save = saveDictionary;

$scope.$watch("vm.content.name", function (newVal, oldVal) {
//when the value changes, we need to set the name dirty
if (newVal && (newVal !== oldVal) && typeof(oldVal) !== 'undefined') {
vm.nameDirty = true;
}
});

onInit();
}

angular.module("umbraco").controller("Umbraco.Editors.Dictionary.EditController", DictionaryEditController);