Skip to content

Commit

Permalink
Revert "Content app for dictionary items"
Browse files Browse the repository at this point in the history
This reverts commit 1d2272f.
  • Loading branch information
nul800sebastiaan committed Oct 24, 2021
1 parent 2d34624 commit 27f50e7
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 221 deletions.
32 changes: 0 additions & 32 deletions src/Umbraco.Core/ContentApps/DictionaryContentAppFactory.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ internal static void AddAllCoreCollectionBuilders(this IUmbracoBuilder builder)
.Append<ContentTypeDesignContentAppFactory>()
.Append<ContentTypeListViewContentAppFactory>()
.Append<ContentTypePermissionsContentAppFactory>()
.Append<ContentTypeTemplatesContentAppFactory>()
.Append<DictionaryContentAppFactory>();
.Append<ContentTypeTemplatesContentAppFactory>();

// all built-in finders in the correct order,
// devs can then modify this list on application startup
Expand Down
6 changes: 1 addition & 5 deletions src/Umbraco.Core/Manifest/ManifestContentAppFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -70,10 +70,6 @@ public ContentApp GetContentAppFor(object o,IEnumerable<IReadOnlyUserGroup> user
partA = "contentType";
partB = contentType.Alias;
break;
case IDictionaryItem _:
partA = "dictionary";
partB = "*"; //Not really a different type for dictionary items
break;

default:
return null;
Expand Down
9 changes: 1 addition & 8 deletions src/Umbraco.Core/Models/ContentEditing/DictionaryDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

Expand All @@ -17,7 +17,6 @@ public DictionaryDisplay()
{
Notifications = new List<BackOfficeNotification>();
Translations = new List<DictionaryTranslationDisplay>();
ContentApps = new List<ContentApp>();
}

/// <inheritdoc />
Expand All @@ -38,11 +37,5 @@ public DictionaryDisplay()
/// </summary>
[DataMember(Name = "translations")]
public List<DictionaryTranslationDisplay> Translations { get; private set; }

/// <summary>
/// Apps for the dictionary item
/// </summary>
[DataMember(Name = "apps")]
public List<ContentApp> ContentApps { get; private set; }
}
}
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Models/Mapping/CommonMapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.ContentApps;
Expand Down Expand Up @@ -47,7 +47,7 @@ public ContentTypeBasic GetContentType(IContentBase source, MapperContext contex
return contentTypeBasic;
}

public IEnumerable<ContentApp> GetContentApps(IEntity source)
public IEnumerable<ContentApp> GetContentApps(IUmbracoEntity source)
{
var apps = _contentAppDefinitions.GetContentAppsFor(source).ToArray();

Expand Down
7 changes: 2 additions & 5 deletions src/Umbraco.Core/Models/Mapping/DictionaryMapDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.Mapping;
Expand All @@ -14,12 +14,10 @@ namespace Umbraco.Cms.Core.Models.Mapping
public class DictionaryMapDefinition : IMapDefinition
{
private readonly ILocalizationService _localizationService;
private readonly CommonMapper _commonMapper;

public DictionaryMapDefinition(ILocalizationService localizationService, CommonMapper commonMapper)
public DictionaryMapDefinition(ILocalizationService localizationService)
{
_localizationService = localizationService;
_commonMapper = commonMapper;
}

public void DefineMaps(IUmbracoMapper mapper)
Expand All @@ -46,7 +44,6 @@ private void Map(IDictionaryItem source, DictionaryDisplay target, MapperContext
target.Name = source.ItemKey;
target.ParentId = source.ParentId ?? Guid.Empty;
target.Udi = Udi.Create(Constants.UdiEntityType.DictionaryItem, source.Key);
target.ContentApps.AddRange(_commonMapper.GetContentApps(source));

// build up the path to make it possible to set active item in tree
// TODO: check if there is a better way
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @ngdoc controller
* @name Umbraco.Editors.Dictionary.EditController
* @function
Expand All @@ -7,131 +7,128 @@
* The controller for editing dictionary items
*/
function DictionaryEditController($scope, $routeParams, $location, dictionaryResource, navigationService, appState, editorState, contentEditingHelper, formHelper, notificationsService, localizationService) {

var vm = this;

//setup scope vars
vm.nameDirty = false;
vm.header = {};
vm.header.editorfor = "template_insertDictionaryItem";
vm.header.setPageTitle = true;

vm.page = {};
vm.page.navigation = {};
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 = "";
vm.showBackButton = true;
vm.maxlength = 1000;

vm.save = saveDictionary;
vm.back = back;
vm.change = change;

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.navigation = data.apps;
data.apps[0].active = true;
vm.page.loading = false;
});
}

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

var vm = this;

//setup scope vars
vm.nameDirty = false;
vm.header = {};
vm.header.editorfor = "template_insertDictionaryItem";
vm.header.setPageTitle = true;

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 = "";
vm.showBackButton = true;
vm.maxlength = 1000;

vm.save = saveDictionary;
vm.back = back;
vm.change = change;

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 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]);
change(data.translations[i]);
function createTranslationProperty(translation) {
return {
alias: translation.isoCode,
label: translation.displayName,
hideLabel : false
}
}

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

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

//share state
editorState.set(vm.content);
// create data for umb-property displaying
for (var i = 0; i < data.translations.length; i++) {
data.translations[i].property = createTranslationProperty(data.translations[i]);
change(data.translations[i]);
}

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

function onInit() {
loadDictionary();
}
// set content
vm.content = data;

function saveDictionary() {
if (formHelper.submitForm({ scope: $scope, statusMessage: "Saving..." })) {
//share state
editorState.set(vm.content);

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

dictionaryResource.save(vm.content, vm.nameDirty)
.then(function (data) {
function onInit() {
loadDictionary();
}

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

bindDictionary(data);
vm.page.saveButtonState = "busy";

vm.page.saveButtonState = "success";
},
function (err) {
dictionaryResource.save(vm.content, vm.nameDirty)
.then(function (data) {

formHelper.resetForm({ scope: $scope, hasErrors: true });
formHelper.resetForm({ scope: $scope });

contentEditingHelper.handleSaveError({
err: err
});
bindDictionary(data);

notificationsService.error(err.data.message);
vm.page.saveButtonState = "success";
},
function (err) {

vm.page.saveButtonState = "error";
});
}
}
formHelper.resetForm({ scope: $scope, hasErrors: true });

function back() {
$location.path(vm.page.menu.currentSection + "/dictionary/list");
}
contentEditingHelper.handleSaveError({
err: err
});

notificationsService.error(err.data.message);

function change(translation) {
if (translation.translation) {
var charsCount = translation.translation.length;
translation.nearMaxLimit = charsCount > Math.max(vm.maxlength * .8, vm.maxlength - 50);
vm.page.saveButtonState = "error";
});
}
}

function back() {
$location.path(vm.page.menu.currentSection + "/dictionary/list");
}
}

$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;
function change(translation) {
if (translation.translation) {
var charsCount = translation.translation.length;
translation.nearMaxLimit = charsCount > Math.max(vm.maxlength * .8, vm.maxlength - 50);
}
}
});

onInit();
$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);
Loading

0 comments on commit 27f50e7

Please sign in to comment.