Skip to content

Commit

Permalink
Update content type icon on save (#8585)
Browse files Browse the repository at this point in the history
* Emit event when content type icon/color change

* Allow node css class to change when icon change

* Cleanup unused injected services

* Add missing aria-hidden attribute in tree

* Fix typo
  • Loading branch information
bjarnef authored Aug 20, 2020
1 parent 8db0967 commit 55c37e0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,21 @@ angular.module("umbraco.directives")

var evts = [];

//listen for section changes
// Listen for section changes
evts.push(eventsService.on("appState.sectionState.changed", function(e, args) {
if (args.key === "currentSection") {
//when the section changes disable all delete animations
scope.node.deleteAnimations = false;
}
}));

// Update tree icon if changed
evts.push(eventsService.on("editors.tree.icon.changed", function (e, args) {
if (args.icon !== scope.node.icon && args.id === scope.node.id) {
scope.node.icon = args.icon;
}
}));

/** Depending on if any menu is shown and if the menu is shown for the current node, toggle delete animations */
function toggleDeleteAnimations() {
//if both are false then remove animations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<span class="sr-only">Expand child items for {{node.name}}</span>
</button>

<i class="icon umb-tree-icon sprTree" ng-class="::node.cssClass" title="{{::node.title}}" ng-click="select(node, $event)" ng-style="::node.style" tabindex="-1"></i>
<i class="icon umb-tree-icon sprTree" ng-class="node.cssClass" title="{{::node.title}}" ng-click="select(node, $event)" ng-style="::node.style" tabindex="-1" aria-hidden="true"></i>
<span class="umb-tree-item__annotation"></span>
<a class="umb-tree-item__label" ng-href="#/{{::node.routePath}}" ng-click="select(node, $event)" title="{{::node.title}}">{{node.name}}</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="umb-tree-root" data-element="tree-root" ng-class="getNodeCssClass(tree.root)" ng-hide="hideheader === 'true'" on-right-click="altSelect(tree.root, $event)">
<h5>
<a ng-href="#/{{section}}" ng-click="select(tree.root, $event)" class="umb-tree-root-link umb-outline" data-element="tree-root-link">
<i ng-if="enablecheckboxes === 'true'" ng-class="selectEnabledNodeClass(tree.root)"></i>
<i ng-if="enablecheckboxes === 'true'" ng-class="selectEnabledNodeClass(tree.root)" aria-hidden="true"></i>
{{tree.name}}
</a>
</h5>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
(function () {
"use strict";

function DocumentTypesEditController($scope, $routeParams, contentTypeResource, dataTypeResource, editorState, contentEditingHelper, formHelper, navigationService, iconHelper, contentTypeHelper, notificationsService, $q, localizationService, overlayHelper, eventsService, angularHelper, editorService) {
function DocumentTypesEditController($scope, $routeParams, $q,
contentTypeResource, editorState, contentEditingHelper,
navigationService, iconHelper, contentTypeHelper, notificationsService,
localizationService, overlayHelper, eventsService, angularHelper, editorService) {

var vm = this;
var evts = [];
Expand All @@ -21,6 +24,7 @@
var isElement = $routeParams.iselement;
var allowVaryByCulture = $routeParams.culturevary;
var infiniteMode = $scope.model && $scope.model.infiniteMode;
var documentTypeIcon = "";

vm.save = save;
vm.close = close;
Expand Down Expand Up @@ -354,6 +358,10 @@
// emit event
var args = { documentType: vm.contentType };
eventsService.emit("editors.documentType.saved", args);

if (documentTypeIcon !== vm.contentType.icon) {
eventsService.emit("editors.tree.icon.changed", args);
}

vm.page.saveButtonState = "success";

Expand Down Expand Up @@ -403,10 +411,12 @@
// convert icons for content type
convertLegacyIcons(contentType);

vm.contentType = contentType;

//set a shared state
editorState.set(vm.contentType);
editorState.set(contentType);

vm.contentType = contentType;

documentTypeIcon = contentType.icon;

loadButtons();
}
Expand Down
13 changes: 10 additions & 3 deletions src/Umbraco.Web.UI.Client/src/views/mediatypes/edit.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"use strict";

function MediaTypesEditController($scope, $routeParams, $q,
mediaTypeResource, dataTypeResource, editorState, contentEditingHelper,
mediaTypeResource, editorState, contentEditingHelper,
navigationService, iconHelper, contentTypeHelper, notificationsService,
localizationService, overlayHelper, eventsService, angularHelper) {

Expand All @@ -19,6 +19,7 @@
var mediaTypeId = $routeParams.id;
var create = $routeParams.create;
var infiniteMode = $scope.model && $scope.model.infiniteMode;
var mediaTypeIcon = "";

vm.save = save;
vm.close = close;
Expand Down Expand Up @@ -282,7 +283,7 @@
function save() {

// only save if there is no overlays open
if(overlayHelper.getNumberOfOverlays() === 0) {
if (overlayHelper.getNumberOfOverlays() === 0) {

var deferred = $q.defer();

Expand Down Expand Up @@ -339,9 +340,13 @@
var args = { mediaType: vm.contentType };
eventsService.emit("editors.mediaType.saved", args);

if (mediaTypeIcon !== vm.contentType.icon) {
eventsService.emit("editors.tree.icon.changed", args);
}

vm.page.saveButtonState = "success";

if(infiniteMode && $scope.model.submit) {
if (infiniteMode && $scope.model.submit) {
$scope.model.submit();
}

Expand Down Expand Up @@ -378,6 +383,8 @@
editorState.set(contentType);

vm.contentType = contentType;

mediaTypeIcon = contentType.icon;
}

function convertLegacyIcons(contentType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"use strict";

function MemberTypesEditController($scope, $routeParams, $q,
memberTypeResource, dataTypeResource, editorState, iconHelper,
memberTypeResource, editorState, iconHelper,
navigationService, contentEditingHelper, notificationsService, localizationService,
overlayHelper, contentTypeHelper, angularHelper, eventsService) {

Expand All @@ -19,6 +19,7 @@
var infiniteMode = $scope.model && $scope.model.infiniteMode;
var memberTypeId = $routeParams.id;
var create = $routeParams.create;
var memberTypeIcon = "";

vm.save = save;
vm.close = close;
Expand Down Expand Up @@ -259,6 +260,10 @@
var args = { memberType: vm.contentType };
eventsService.emit("editors.memberType.saved", args);

if (memberTypeIcon !== vm.contentType.icon) {
eventsService.emit("editors.tree.icon.changed", args);
}

vm.page.saveButtonState = "success";

if(infiniteMode && $scope.model.submit) {
Expand Down Expand Up @@ -299,6 +304,8 @@
editorState.set(contentType);

vm.contentType = contentType;

memberTypeIcon = contentType.icon;
}

function convertLegacyIcons(contentType) {
Expand Down

0 comments on commit 55c37e0

Please sign in to comment.