Updates EntityController to support stylesheets, languages and dictionary items GetAll so we can use it for the packager without worrying about security access to sections
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function EditController($scope, $location, $routeParams, umbRequestHelper, entityResource, stylesheetResource, languageResource, packageResource, dictionaryResource, editorService, formHelper) {
|
||||
function EditController($scope, $location, $routeParams, umbRequestHelper, entityResource, packageResource, editorService, formHelper) {
|
||||
|
||||
const vm = this;
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
});
|
||||
|
||||
// get all stylesheets
|
||||
stylesheetResource.getAll().then(stylesheets => {
|
||||
entityResource.getAll("Stylesheet").then(stylesheets => {
|
||||
vm.stylesheets = stylesheets;
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
});
|
||||
|
||||
// get all languages
|
||||
languageResource.getAll().then(languages => {
|
||||
entityResource.getAll("Language").then(languages => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
languages.forEach(language => {
|
||||
@@ -97,7 +97,7 @@
|
||||
});
|
||||
|
||||
// get all dictionary items
|
||||
dictionaryResource.getList().then(dictionaryItems => {
|
||||
entityResource.getAll("DictionaryItem").then(dictionaryItems => {
|
||||
// a package stores the id as a string so we
|
||||
// need to convert all ids to string for comparison
|
||||
dictionaryItems.forEach(dictionaryItem => {
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Umbraco.Web.Editors
|
||||
/// <param name="list">
|
||||
/// The list.
|
||||
/// </param>
|
||||
private void GetChildItemsForList(IDictionaryItem dictionaryItem, int level, List<DictionaryOverviewDisplay> list)
|
||||
private void GetChildItemsForList(IDictionaryItem dictionaryItem, int level, ICollection<DictionaryOverviewDisplay> list)
|
||||
{
|
||||
foreach (var childItem in Services.LocalizationService.GetDictionaryItemChildren(dictionaryItem.Key).OrderBy(ItemSort()))
|
||||
{
|
||||
@@ -231,6 +231,6 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
}
|
||||
|
||||
private Func<IDictionaryItem, string> ItemSort() => item => item.ItemKey;
|
||||
private static Func<IDictionaryItem, string> ItemSort() => item => item.ItemKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,8 +839,6 @@ namespace Umbraco.Web.Editors
|
||||
return UmbracoObjectTypes.MediaType;
|
||||
case UmbracoEntityTypes.DocumentType:
|
||||
return UmbracoObjectTypes.DocumentType;
|
||||
case UmbracoEntityTypes.Stylesheet:
|
||||
return UmbracoObjectTypes.Stylesheet;
|
||||
case UmbracoEntityTypes.Member:
|
||||
return UmbracoObjectTypes.Member;
|
||||
case UmbracoEntityTypes.DataType:
|
||||
@@ -912,13 +910,31 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
case UmbracoEntityTypes.User:
|
||||
|
||||
long total;
|
||||
var users = Services.UserService.GetAll(0, int.MaxValue, out total);
|
||||
var users = Services.UserService.GetAll(0, int.MaxValue, out _);
|
||||
var filteredUsers = ExecutePostFilter(users, postFilter, postFilterParams);
|
||||
return Mapper.Map<IEnumerable<IUser>, IEnumerable<EntityBasic>>(filteredUsers);
|
||||
|
||||
case UmbracoEntityTypes.Domain:
|
||||
case UmbracoEntityTypes.Stylesheet:
|
||||
|
||||
if (!postFilter.IsNullOrWhiteSpace() || (postFilterParams != null && postFilterParams.Count > 0))
|
||||
throw new NotSupportedException("Filtering on stylesheets is not currently supported");
|
||||
|
||||
return Services.FileService.GetStylesheets().Select(Mapper.Map<EntityBasic>);
|
||||
|
||||
case UmbracoEntityTypes.Language:
|
||||
|
||||
if (!postFilter.IsNullOrWhiteSpace() || (postFilterParams != null && postFilterParams.Count > 0))
|
||||
throw new NotSupportedException("Filtering on languages is not currently supported");
|
||||
|
||||
return Services.LocalizationService.GetAllLanguages().Select(Mapper.Map<EntityBasic>);
|
||||
case UmbracoEntityTypes.DictionaryItem:
|
||||
|
||||
if (!postFilter.IsNullOrWhiteSpace() || (postFilterParams != null && postFilterParams.Count > 0))
|
||||
throw new NotSupportedException("Filtering on languages is not currently supported");
|
||||
|
||||
return GetAllDictionaryItems();
|
||||
|
||||
case UmbracoEntityTypes.Domain:
|
||||
default:
|
||||
throw new NotSupportedException("The " + typeof(EntityController) + " does not currently support data for the type " + entityType);
|
||||
}
|
||||
@@ -937,5 +953,36 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
|
||||
#region Methods to get all dictionary items
|
||||
private IEnumerable<EntityBasic> GetAllDictionaryItems()
|
||||
{
|
||||
var list = new List<EntityBasic>();
|
||||
|
||||
foreach (var dictionaryItem in Services.LocalizationService.GetRootDictionaryItems().OrderBy(DictionaryItemSort()))
|
||||
{
|
||||
var item = Mapper.Map<IDictionaryItem, EntityBasic>(dictionaryItem);
|
||||
list.Add(item);
|
||||
GetChildItemsForList(dictionaryItem, list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static Func<IDictionaryItem, string> DictionaryItemSort() => item => item.ItemKey;
|
||||
|
||||
private void GetChildItemsForList(IDictionaryItem dictionaryItem, ICollection<EntityBasic> list)
|
||||
{
|
||||
foreach (var childItem in Services.LocalizationService.GetDictionaryItemChildren(dictionaryItem.Key).OrderBy(DictionaryItemSort()))
|
||||
{
|
||||
var item = Mapper.Map<IDictionaryItem, EntityBasic>(childItem);
|
||||
list.Add(item);
|
||||
|
||||
GetChildItemsForList(childItem, list);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,11 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// <summary>
|
||||
/// Property Group
|
||||
/// </summary>
|
||||
PropertyGroup
|
||||
PropertyGroup,
|
||||
|
||||
//TODO: Dictionary?
|
||||
/// <summary>
|
||||
/// Dictionary Item
|
||||
/// </summary>
|
||||
DictionaryItem
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,18 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public CodeFileMapperProfile()
|
||||
{
|
||||
CreateMap<Stylesheet, EntityBasic>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(sheet => sheet.Id))
|
||||
.ForMember(dest => dest.Alias, opt => opt.MapFrom(sheet => sheet.Alias))
|
||||
.ForMember(dest => dest.Key, opt => opt.MapFrom(sheet => sheet.Key))
|
||||
.ForMember(dest => dest.Name, opt => opt.MapFrom(sheet => sheet.Name))
|
||||
.ForMember(dest => dest.ParentId, opt => opt.UseValue(-1))
|
||||
.ForMember(dest => dest.Path, opt => opt.MapFrom(sheet => sheet.Path))
|
||||
.ForMember(dest => dest.Trashed, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Udi, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Icon, opt => opt.Ignore());
|
||||
|
||||
CreateMap<IPartialView, CodeFileDisplay>()
|
||||
.ForMember(dest => dest.FileType, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Notifications, opt => opt.Ignore())
|
||||
|
||||
@@ -17,6 +17,18 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public DictionaryMapperProfile(ILocalizationService localizationService)
|
||||
{
|
||||
CreateMap<IDictionaryItem, EntityBasic>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(sheet => sheet.Id))
|
||||
.ForMember(dest => dest.Alias, opt => opt.MapFrom(sheet => sheet.ItemKey))
|
||||
.ForMember(dest => dest.Key, opt => opt.MapFrom(sheet => sheet.Key))
|
||||
.ForMember(dest => dest.Name, opt => opt.MapFrom(sheet => sheet.ItemKey))
|
||||
.ForMember(dest => dest.ParentId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Path, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Trashed, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Udi, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Icon, opt => opt.Ignore());
|
||||
|
||||
CreateMap<IDictionaryItem, DictionaryDisplay>()
|
||||
.ForMember(x => x.Translations, expression => expression.Ignore())
|
||||
.ForMember(x => x.Notifications, expression => expression.Ignore())
|
||||
|
||||
@@ -12,6 +12,18 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public LanguageMapperProfile()
|
||||
{
|
||||
CreateMap<ILanguage, EntityBasic>()
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(x => x.Id))
|
||||
.ForMember(dest => dest.Name, opt => opt.MapFrom(x => x.CultureName))
|
||||
.ForMember(dest => dest.Key, opt => opt.MapFrom(x => x.Key))
|
||||
.ForMember(dest => dest.Alias, opt => opt.MapFrom(x => x.IsoCode))
|
||||
.ForMember(dest => dest.ParentId, opt => opt.UseValue(-1))
|
||||
.ForMember(dest => dest.Path, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Trashed, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Udi, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Icon, opt => opt.Ignore());
|
||||
|
||||
CreateMap<ILanguage, Language>()
|
||||
.ForMember(l => l.Name, expression => expression.MapFrom(x => x.CultureInfo.DisplayName));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user