diff --git a/zero.Core/Api/SpacesApi.cs b/zero.Core/Api/SpacesApi.cs
index e11065d8..e19dbc28 100644
--- a/zero.Core/Api/SpacesApi.cs
+++ b/zero.Core/Api/SpacesApi.cs
@@ -11,7 +11,6 @@ using zero.Core.Entities;
using zero.Core.Extensions;
using zero.Core.Options;
using zero.Core.Plugins;
-using zero.Core.Renderer;
namespace zero.Core.Api
{
@@ -46,27 +45,6 @@ namespace zero.Core.Api
}
- ///
- public RendererConfig GetEditorConfig(string alias)
- {
- Space space = GetByAlias(alias);
-
- if (space == null)
- {
- return null;
- }
-
- AbstractGenericRenderer renderer = Options.Renderers.GetAllItems().FirstOrDefault(x => x.TargetType == space.Type);
-
- if (renderer == null)
- {
- return null;
- }
-
- return renderer.Build();
- }
-
-
///
public async Task GetItem(string alias) where T : SpaceContent
{
@@ -125,7 +103,7 @@ namespace zero.Core.Api
public async Task> Save(string alias, T model) where T : SpaceContent
{
Space space = GetByAlias(alias);
- RendererConfig config = GetEditorConfig(alias);
+ //RendererConfig config = GetEditorConfig(alias);
//if (config.Validator != null)
//{
@@ -190,11 +168,6 @@ namespace zero.Core.Api
///
IReadOnlyCollection GetAll();
- ///
- /// Get editor configuration for a space
- ///
- RendererConfig GetEditorConfig(string alias);
-
///
/// Get editor item for a space
///
diff --git a/zero.Core/Api/UserApi.cs b/zero.Core/Api/UserApi.cs
index c892aa8b..aeba05f6 100644
--- a/zero.Core/Api/UserApi.cs
+++ b/zero.Core/Api/UserApi.cs
@@ -1,49 +1,46 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Identity;
using Raven.Client.Documents;
using Raven.Client.Documents.Session;
using System.Collections.Generic;
using System.Linq;
-using System.Security.Claims;
using System.Threading.Tasks;
using zero.Core.Entities;
using zero.Core.Extensions;
-using zero.Core.Identity;
namespace zero.Core.Api
{
- public class UserApi : AppAwareBackofficeApi, IUserApi
+ public class UserApi : AppAwareBackofficeApi, IUserApi where T : class, IUser
{
- protected UserManager UserManager { get; private set; }
+ protected UserManager UserManager { get; private set; }
- public UserApi(IBackofficeStore store, UserManager userManager) : base(store)
+ public UserApi(IBackofficeStore store, UserManager userManager) : base(store)
{
UserManager = userManager;
}
///
- public async Task GetUserById(string id)
+ public async Task GetUserById(string id)
{
- User user = await UserManager.FindByIdAsync(id);
+ T user = await UserManager.FindByIdAsync(id);
return user;
}
///
- public async Task GetUserByEmail(string email)
+ public async Task GetUserByEmail(string email)
{
- User user = await UserManager.FindByEmailAsync(email);
+ T user = await UserManager.FindByEmailAsync(email);
return user;
}
///
- public async Task> GetAll(string appId = null)
+ public async Task> GetAll(string appId = null)
{
using (IAsyncDocumentSession session = Raven.OpenAsyncSession())
{
- return await session.Query()
+ return await session.Query()
.Scope(appId)
.OrderByDescending(x => x.CreatedDate)
.ToListAsync();
@@ -52,13 +49,13 @@ namespace zero.Core.Api
///
- public async Task> GetByQuery(ListQuery query, string appId = null)
+ public async Task> GetByQuery(ListQuery query, string appId = null)
{
query.SearchSelector = user => user.Name;
using (IAsyncDocumentSession session = Raven.OpenAsyncSession())
{
- return await session.Query()
+ return await session.Query()
.Scope(appId)
.ToQueriedListAsync(query);
}
@@ -66,37 +63,37 @@ namespace zero.Core.Api
///
- public async Task> Save(User model)
+ public async Task> Save(T model)
{
return await SaveModel(model); //, new UserValidator());
}
///
- public async Task> Delete(string id)
+ public async Task> Delete(string id)
{
- return await DeleteById(id);
+ return await DeleteById(id);
}
///
- public async Task> UpdatePassword(User user, string currentPassword, string newPassword)
+ public async Task> UpdatePassword(T user, string currentPassword, string newPassword)
{
if (currentPassword.IsNullOrWhiteSpace() || newPassword.IsNullOrWhiteSpace())
{
- return EntityResult.Fail(nameof(currentPassword), "@errors.changepassword.emptyfields");
+ return EntityResult.Fail(nameof(currentPassword), "@errors.changepassword.emptyfields");
}
if (user == null)
{
- return EntityResult.Fail("@errors.changepassword.nouser");
+ return EntityResult.Fail("@errors.changepassword.nouser");
}
IdentityResult identityResult = await UserManager.ChangePasswordAsync(user, currentPassword, newPassword);
if (!identityResult.Succeeded)
{
- EntityResult result = EntityResult.Fail();
+ EntityResult result = EntityResult.Fail();
foreach (IdentityError error in identityResult.Errors)
{
@@ -106,19 +103,19 @@ namespace zero.Core.Api
return result;
}
- return EntityResult.Success(user);
+ return EntityResult.Success(user);
}
///
- public async Task> Enable(User user)
+ public async Task> Enable(T user)
{
return await UpdateActiveState(user, true);
}
///
- public async Task> Disable(User user)
+ public async Task> Disable(T user)
{
return await UpdateActiveState(user, false);
}
@@ -128,7 +125,7 @@ namespace zero.Core.Api
/// Updates the active state of user.
/// If IsActive=false, the user cannot login anymore
///
- async Task> UpdateActiveState(User user, bool isActive)
+ async Task> UpdateActiveState(T user, bool isActive)
{
user.IsActive = isActive;
@@ -136,7 +133,7 @@ namespace zero.Core.Api
if (!identityResult.Succeeded)
{
- EntityResult result = EntityResult.Fail();
+ EntityResult result = EntityResult.Fail();
foreach (IdentityError error in identityResult.Errors)
{
@@ -148,57 +145,57 @@ namespace zero.Core.Api
await UserManager.UpdateSecurityStampAsync(user);
- return EntityResult.Success(user);
+ return EntityResult.Success(user);
}
}
- public interface IUserApi : IAppAwareBackofficeApi
+ public interface IUserApi : IAppAwareBackofficeApi where T : class, IUser
{
///
/// Find user by id
///
- Task GetUserById(string id);
+ Task GetUserById(string id);
///
/// Find user by email
///
- Task GetUserByEmail(string email);
+ Task GetUserByEmail(string email);
///
/// Get all users for the selected application
///
- Task> GetAll(string appId = null);
+ Task> GetAll(string appId = null);
///
/// Get all available users (with query)
///
- Task> GetByQuery(ListQuery query, string appId = null);
+ Task> GetByQuery(ListQuery query, string appId = null);
///
/// Creates or updates a user
///
- Task> Save(User model);
+ Task> Save(T model);
///
/// Deletes a user
///
- Task> Delete(string id);
+ Task> Delete(string id);
///
/// Changes the password of the current user.
/// User is logged out if this operation succeeds.
///
- Task> UpdatePassword(User user, string currentPassword, string newPassword);
+ Task> UpdatePassword(T user, string currentPassword, string newPassword);
///
/// Enables a user
///
- Task> Enable(User user);
+ Task> Enable(T user);
///
/// Disables a user
///
- Task> Disable(User user);
+ Task> Disable(T user);
}
}
diff --git a/zero.Core/Entities/User/User.cs b/zero.Core/Entities/User/User.cs
index 52b6a6d6..118ffb0e 100644
--- a/zero.Core/Entities/User/User.cs
+++ b/zero.Core/Entities/User/User.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using zero.Core.Attributes;
namespace zero.Core.Entities
{
@@ -72,7 +73,7 @@ namespace zero.Core.Entities
}
-
+ [Collection("Users")]
public interface IUser : IZeroEntity, IAppAwareEntity, IZeroDbConventions
{
///
diff --git a/zero.Core/EntityMap.cs b/zero.Core/EntityMap.cs
deleted file mode 100644
index b1603502..00000000
--- a/zero.Core/EntityMap.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using FluentValidation;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using zero.Core.Renderer;
-
-namespace zero.Core
-{
- public static class EntityMap
- {
- static Dictionary Types = new Dictionary();
-
- public static void Use() where TImplementation : TService
- {
- Types[typeof(TService)] = typeof(TImplementation);
- }
-
-
- public static Type Get() => Get(typeof(T));
-
-
- public static Type Get(Type type)
- {
- if (!Types.ContainsKey(type))
- {
- return null;
- }
-
- return Types[type];
- }
- }
-
-
- public class EntityDefinition where TImplementation : TService
- {
- public Type ServiceType => typeof(TService);
-
- public Type ImplementationType => typeof(TImplementation);
-
- public IList Validators { get; set; } = new List();
-
- public AbstractRenderer Renderer { get; set; }
- }
-
- public class EntityDefinition
- {
- public Type ServiceType { get; protected set; }
-
- public Type ImplementationType { get; protected set; }
-
- public IList Validators { get; set; } = new List();
-
- public AbstractGenericRenderer Renderer { get; set; }
-
- public static EntityDefinition Convert(EntityDefinition definition) where TImplementation : TService
- {
- return new EntityDefinition()
- {
- ServiceType = definition.ServiceType,
- ImplementationType = definition.ImplementationType,
- Validators = definition.Validators,
- Renderer = definition.Renderer.ToGenericRenderer()
- };
- }
- }
-}
diff --git a/zero.Core/Options/RendererOptions.cs b/zero.Core/Options/RendererOptions.cs
deleted file mode 100644
index 4657c4d9..00000000
--- a/zero.Core/Options/RendererOptions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using zero.Core.Renderer;
-
-namespace zero.Core.Options
-{
- public class RendererOptions : ZeroBackofficeCollection, IZeroCollectionOptions
- {
- public RendererOptions()
- {
-
- }
-
-
- public void Add() where TRenderer : IRenderer, new()
- {
- Items.Add(new TRenderer().ToGenericRenderer());
- }
-
-
- public void Add(TRenderer renderer) where TRenderer : IRenderer, new()
- {
- Items.Add(renderer.ToGenericRenderer());
- }
- }
-}
diff --git a/zero.Core/Options/ZeroOptions.cs b/zero.Core/Options/ZeroOptions.cs
index 611bd3f9..24377353 100644
--- a/zero.Core/Options/ZeroOptions.cs
+++ b/zero.Core/Options/ZeroOptions.cs
@@ -18,7 +18,6 @@ namespace zero.Core.Options
Features = new FeatureOptions();
Pages = new PageOptions();
Permissions = new PermissionOptions();
- Renderers = new RendererOptions();
Settings = new SettingsOptions();
Spaces = new SpaceOptions();
Mapper = new MapperOptions();
@@ -57,9 +56,6 @@ namespace zero.Core.Options
///
public PermissionOptions Permissions { get; private set; }
- ///
- public RendererOptions Renderers { get; private set; }
-
///
public SettingsOptions Settings { get; private set; }
@@ -134,11 +130,6 @@ namespace zero.Core.Options
///
PermissionOptions Permissions { get; }
- ///
- ///
- ///
- RendererOptions Renderers { get; }
-
///
///
///
diff --git a/zero.Debug/TestData/Lists/SocialContentRenderer.cs b/zero.Debug/TestData/Lists/SocialContentRenderer.cs
deleted file mode 100644
index 50ebefbb..00000000
--- a/zero.Debug/TestData/Lists/SocialContentRenderer.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using FluentValidation;
-using zero.Core.Renderer;
-
-namespace zero.TestData.Lists
-{
- public class SocialContentRenderer : AbstractRenderer
- {
- public SocialContentRenderer()
- {
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.IsVisible).Toggle();
- Field(x => x.xIconPicker).IconPicker();
- Field(x => x.xTextarea).Textarea();
- //Field(x => x.Addresses, required: true).Nested(new SocialAddressRenderer(), opts =>
- //{
- // opts.Limit = 5;
- // opts.AddLabel = "Add address";
- //});
- Field(x => x.xRte).Rte();
- Field(x => x.xMedia).Media(opts => opts.Type = MediaOptionsType.Image);
- Field(x => x.xTextarea).Output();
- Field(x => x.xState).State(opts =>
- {
- opts.Add("Image", "image");
- opts.Add("Video" , "video");
- opts.Add("Other", "other");
- });
- Field(x => x.xCustom).Custom("MyPlugin/myplugineditor.vue", () => new
- {
- enabled = true,
- name = "tobi"
- });
- Tab("Networks", () => {
-
- Field(x => x.Facebook, required: true).Text(opts => opts.Placeholder = "Enter your facebook URL");
- Field(x => x.Youtube).Text();
- Field(x => x.Twitter).Text(opts => opts.Classes.Add("is-short"));
- });
- }
- }
-
-
- public class SocialAddressRenderer : AbstractRenderer
- {
- public SocialAddressRenderer()
- {
- LabelTemplate = "@_test.fields.address.{0}";
- DescriptionTemplate = "@{0}";
-
- Field(x => x.City, required: true).Text();
- Field(x => x.Street).Text();
- Field(x => x.No).Text(opts => opts.Classes.Add("is-short"));
- Field(x => x.Countries, required: true).Nested(new SocialAddressCountryRenderer(), opts =>
- {
- opts.Limit = 1;
- });
- //Field(x => x.CountryId).Custom("plugins/countryPicker/countrypicker", () => new
- //{
- // startId = 107
- //});
- }
- }
-
-
- public class SocialAddressCountryRenderer : AbstractRenderer
- {
- public SocialAddressCountryRenderer()
- {
- LabelTemplate = "@_test.fields.address.{0}";
- DescriptionTemplate = "@{0}";
-
- Field(x => x.Name, required: true).Text();
- Field(x => x.Iso, required: true).Text();
- }
- }
-
-
- public class SocialContentValidator : AbstractValidator
- {
- public SocialContentValidator()
- {
- RuleFor(x => x.Facebook).NotEmpty().MaximumLength(120);
- }
- }
-}
\ No newline at end of file
diff --git a/zero.Debug/TestData/Lists/TeamMemberRenderer.cs b/zero.Debug/TestData/Lists/TeamMemberRenderer.cs
deleted file mode 100644
index e8088b04..00000000
--- a/zero.Debug/TestData/Lists/TeamMemberRenderer.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using FluentValidation;
-using zero.Core.Renderer;
-
-namespace zero.TestData.Lists
-{
- public class TeamMemberRenderer : AbstractRenderer
- {
- public TeamMemberRenderer()
- {
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.Name, required: true).Text(opts => opts.Placeholder = "Enter your name");
- Field(x => x.Position, required: true).Text();
- Field(x => x.Image).Media(opts => opts.Type = MediaOptionsType.Image);
- Field(x => x.Email, required: true).Text(opts => opts.Classes.Add("email-field"));
- Field(x => x.VideoUri).Text();
- //Field(x => x.Addresses, required: true).Nested(new AddressRenderer(), opts =>
- //{
- // opts.Limit = 5;
- // opts.AddLabel = "Add address";
- //});
- }
- }
-
-
- public class AddressRenderer : AbstractRenderer
- {
- public AddressRenderer()
- {
- LabelTemplate = "@_test.fields.address.{0}";
- DescriptionTemplate = "@{0}";
-
- Field(x => x.City, required: true).Text();
- Field(x => x.Street).Text();
- Field(x => x.No).Text(opts => opts.Classes.Add("is-short"));
- //Field(x => x.CountryId).Custom("plugins/countryPicker/countrypicker", () => new
- //{
- // startId = 107
- //});
- }
- }
-
-
- public class TeamMemberValidator : AbstractValidator
- {
- public TeamMemberValidator()
- {
- RuleFor(x => x.Name).NotEmpty().MaximumLength(120);
- RuleFor(x => x.Position).NotEmpty().Length(3, 60);
- RuleFor(x => x.Email).NotEmpty().EmailAddress();
- }
- }
-}
\ No newline at end of file
diff --git a/zero.Debug/TestData/MyRedirectPageRenderer.cs b/zero.Debug/TestData/MyRedirectPageRenderer.cs
deleted file mode 100644
index 8495017a..00000000
--- a/zero.Debug/TestData/MyRedirectPageRenderer.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System.Linq;
-using zero.Commerce.Entities;
-using zero.Core.Renderer;
-using zero.Debug.Models;
-using zero.TestData;
-
-namespace zero.Debug.TestData
-{
- public class MyRedirectPageRenderer : RedirectPageRenderer
- {
- public MyRedirectPageRenderer() : base()
- {
- Field(x => x.Name).Text(opts => opts.MaxLength = 100);
- //Properties.FirstOrDefault(x => x.Method == "tab")
- }
- }
-}
diff --git a/zero.Debug/TestData/Renderers/ContentPageRenderer.cs b/zero.Debug/TestData/Renderers/ContentPageRenderer.cs
deleted file mode 100644
index a849c2d8..00000000
--- a/zero.Debug/TestData/Renderers/ContentPageRenderer.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using FluentValidation;
-using zero.Core.Renderer;
-
-namespace zero.TestData
-{
- public class ContentPageRenderer : AbstractRenderer
- {
- public ContentPageRenderer()
- {
- Alias = "debug.contentpage";
-
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.Name, required: true).Text();
-
- Tab("Options", () =>
- {
- Field(x => x.Options).Renderer(new OptionsPagePartialRenderer());
- });
-
- Tab("Meta", () =>
- {
- Field(x => x.Meta).Renderer(new MetaPagePartialRenderer());
- });
- }
- }
-
-
- public class ContentPageValidator : AbstractValidator
- {
- public ContentPageValidator()
- {
- RuleFor(x => x.Name).NotEmpty().MaximumLength(30);
- }
- }
-}
diff --git a/zero.Debug/TestData/Renderers/MetaPagePartialRenderer.cs b/zero.Debug/TestData/Renderers/MetaPagePartialRenderer.cs
deleted file mode 100644
index 5a8510c0..00000000
--- a/zero.Debug/TestData/Renderers/MetaPagePartialRenderer.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using FluentValidation;
-using zero.Core.Renderer;
-
-namespace zero.TestData
-{
- public class MetaPagePartialRenderer : AbstractRenderer
- {
- public MetaPagePartialRenderer()
- {
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.HideInTitle).Toggle();
- Field(x => x.TitleOverride).Text();
- Field(x => x.TitleOverrideAll).Text();
- Field(x => x.SeoDescription).Textarea(opts => opts.MaxLength = 160);
- Field(x => x.SeoImage).Media();
- Field(x => x.NoFollow).Toggle();
- Field(x => x.NoIndex).Toggle();
- }
- }
-
-
- public class MetaPagePartialValidator : AbstractValidator
- {
- public MetaPagePartialValidator()
- {
- RuleFor(x => x.SeoDescription).MaximumLength(160);
- }
- }
-}
diff --git a/zero.Debug/TestData/Renderers/NewsPageRenderer.cs b/zero.Debug/TestData/Renderers/NewsPageRenderer.cs
deleted file mode 100644
index 477276cf..00000000
--- a/zero.Debug/TestData/Renderers/NewsPageRenderer.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using FluentValidation;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using zero.Core.Renderer;
-
-namespace zero.TestData
-{
- public class NewsPageRenderer : AbstractRenderer
- {
- public NewsPageRenderer()
- {
- Alias = "debug.newspage";
-
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.Name, required: true).Text(opts => opts.Placeholder = "Enter your name");
- Field(x => x.Text, required: true).Rte();
- }
- }
-
-
- public class NewsPageValidator : AbstractValidator
- {
- public NewsPageValidator()
- {
- RuleFor(x => x.Name).NotEmpty().MaximumLength(30);
- RuleFor(x => x.Text).NotEmpty();
- }
- }
-}
diff --git a/zero.Debug/TestData/Renderers/OptionsPagePartialRenderer.cs b/zero.Debug/TestData/Renderers/OptionsPagePartialRenderer.cs
deleted file mode 100644
index fd221cc9..00000000
--- a/zero.Debug/TestData/Renderers/OptionsPagePartialRenderer.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FluentValidation;
-using zero.Core.Renderer;
-
-namespace zero.TestData
-{
- public class OptionsPagePartialRenderer : AbstractRenderer
- {
- public OptionsPagePartialRenderer()
- {
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.HideInNavigation).Toggle();
- }
- }
-
-
- public class OptionsPagePartialValidator : AbstractValidator
- {
- public OptionsPagePartialValidator()
- {
-
- }
- }
-}
diff --git a/zero.Debug/TestData/Renderers/RedirectPageRenderer.cs b/zero.Debug/TestData/Renderers/RedirectPageRenderer.cs
deleted file mode 100644
index 1639e96b..00000000
--- a/zero.Debug/TestData/Renderers/RedirectPageRenderer.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using FluentValidation;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using zero.Core.Renderer;
-
-namespace zero.TestData
-{
- public class RedirectPageRenderer : AbstractRenderer
- {
- public RedirectPageRenderer()
- {
- Alias = "debug.redirectpage";
-
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.Name, required: true).Text(opts => opts.Placeholder = "Enter your name");
- Field(x => x.Link, required: true).Text();
-
- Tab("Options", () =>
- {
- Field(x => x.Options).Renderer(new OptionsPagePartialRenderer(), opts => opts.HideLabel = true);
- });
- }
- }
-
-
- public class RedirectPageValidator : AbstractValidator
- {
- public RedirectPageValidator()
- {
- RuleFor(x => x.Name).NotEmpty().MaximumLength(30);
- }
- }
-}
diff --git a/zero.Debug/TestData/Renderers/TestRenderer.cs b/zero.Debug/TestData/Renderers/TestRenderer.cs
deleted file mode 100644
index 6d981575..00000000
--- a/zero.Debug/TestData/Renderers/TestRenderer.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using FluentValidation;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using zero.Core.Renderer;
-
-namespace zero.TestData
-{
- public class TestRenderer : AbstractRenderer
- {
- public TestRenderer()
- {
- Alias = "debug.redirectpage";
-
- LabelTemplate = "@_test.fields.{0}";
- DescriptionTemplate = "@_test.fields.{0}_text";
-
- Field(x => x.Name, required: true).Text();
-
- Field(x => x.Name, required: true).Text(opts => opts.Placeholder = "Enter your name");
- Field(x => x.Link, required: true).Text();
-
- Tab("Options", () =>
- {
- Field(x => x.Options).Renderer(new OptionsPagePartialRenderer(), opts => opts.HideLabel = true);
- });
- }
- }
-}
diff --git a/zero.Debug/TestData/TestPlugin.cs b/zero.Debug/TestData/TestPlugin.cs
index d10138cf..cb78f4d1 100644
--- a/zero.Debug/TestData/TestPlugin.cs
+++ b/zero.Debug/TestData/TestPlugin.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using zero.Core.Options;
using zero.Core.Plugins;
using zero.Debug.TestData;
-using zero.TestData.Lists;
namespace zero.TestData
{
@@ -21,14 +20,6 @@ namespace zero.TestData
zero.Features.Add(TestFeatures.Wishlist, "Wishlist", "Frontend wishlist for logged-in users");
zero.Features.Add(TestFeatures.SocialShopping, "Social shopping", "Integrate products into social media portals");
- zero.Renderers.Add();
- zero.Renderers.Add();
- zero.Renderers.Add();
- zero.Renderers.Add();
- zero.Renderers.Add();
- zero.Renderers.Add();
- zero.Renderers.Add();
-
zero.Pages.Add("news", "News", "News about the company", "fth-file-text");
zero.Pages.Add("content", "Page", "Page consisting of modules", "fth-box", allowAsRoot: true, allowAllChildrenTypes: true);
zero.Pages.Add("root", "Homepage", "Entry point for the website", "fth-home", allowAsRoot: true, allowAllChildrenTypes: true);
diff --git a/zero.Web.UI/App/components/forms/form-header.vue b/zero.Web.UI/App/components/forms/form-header.vue
index 8a75a651..6ded43a0 100644
--- a/zero.Web.UI/App/components/forms/form-header.vue
+++ b/zero.Web.UI/App/components/forms/form-header.vue
@@ -4,8 +4,8 @@
-
+
diff --git a/zero.Web.UI/App/editor/fields/culture.vue b/zero.Web.UI/App/editor/fields/culture.vue
new file mode 100644
index 00000000..4c2fb6cf
--- /dev/null
+++ b/zero.Web.UI/App/editor/fields/culture.vue
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zero.Web.UI/App/pages/settings/user.vue b/zero.Web.UI/App/pages/settings/user.vue
index 73db9323..13ef9696 100644
--- a/zero.Web.UI/App/pages/settings/user.vue
+++ b/zero.Web.UI/App/pages/settings/user.vue
@@ -1,90 +1,30 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/zero.Web.UI/App/renderers/user.js b/zero.Web.UI/App/renderers/user.js
index e9f7b34e..c7fb1599 100644
--- a/zero.Web.UI/App/renderers/user.js
+++ b/zero.Web.UI/App/renderers/user.js
@@ -44,6 +44,11 @@ export default {
display: 'text',
required: true
},
+ {
+ field: 'languageId',
+ display: 'culture',
+ required: true
+ },
{
field: 'avatarId',
display: 'media',
diff --git a/zero.Web.UI/App/resources/languages.js b/zero.Web.UI/App/resources/languages.js
index a6f0b081..ce00def4 100644
--- a/zero.Web.UI/App/resources/languages.js
+++ b/zero.Web.UI/App/resources/languages.js
@@ -26,6 +26,12 @@ export default {
return Axios.get('languages/getAllCultures').then(res => Promise.resolve(res.data));
},
+ // get all supported backoffice cultures
+ getSupportedCultures()
+ {
+ return Axios.get('languages/getSupportedCultures').then(res => Promise.resolve(res.data));
+ },
+
// save a language
save(model)
{
diff --git a/zero.Web/Controllers/LanguagesController.cs b/zero.Web/Controllers/LanguagesController.cs
index 69d20634..eecae652 100644
--- a/zero.Web/Controllers/LanguagesController.cs
+++ b/zero.Web/Controllers/LanguagesController.cs
@@ -3,7 +3,6 @@ using System.Threading.Tasks;
using zero.Core.Api;
using zero.Core.Entities;
using zero.Core.Identity;
-using zero.Core.Renderer;
using zero.Web.Filters;
namespace zero.Web.Controllers
@@ -32,12 +31,6 @@ namespace zero.Web.Controllers
public async Task GetById([FromQuery] string id) => Edit(await Api.GetById(id));
- ///
- /// Get language renderer
- ///
- public IActionResult GetRenderer([FromServices] IRenderer renderer) => Json(renderer.Build());
-
-
///
/// Get all languages
///
@@ -50,6 +43,12 @@ namespace zero.Web.Controllers
public IActionResult GetAllCultures() => Json(Api.GetAllCultures());
+ ///
+ /// Returns all available backoffice cultures.
+ ///
+ public IActionResult GetSupportedCultures() => Json(Api.GetAllCultures(Options.SupportedLanguages));
+
+
///
/// Save language
///
diff --git a/zero.Web/Controllers/SpacesController.cs b/zero.Web/Controllers/SpacesController.cs
index c4ecbca3..eb9525f4 100644
--- a/zero.Web/Controllers/SpacesController.cs
+++ b/zero.Web/Controllers/SpacesController.cs
@@ -86,7 +86,7 @@ namespace zero.Web.Controllers
//Id = model.Id,
Alias = alias,
//Model = model,
- Config = Api.GetEditorConfig(alias)
+ //Config = Api.GetEditorConfig(alias)
}, settings);
}
diff --git a/zero.Web/Controllers/UsersController.cs b/zero.Web/Controllers/UsersController.cs
index cc910b98..9206d727 100644
--- a/zero.Web/Controllers/UsersController.cs
+++ b/zero.Web/Controllers/UsersController.cs
@@ -8,16 +8,18 @@ using zero.Web.Models;
namespace zero.Web.Controllers
{
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Read)]
- public class UsersController : BackofficeController where TLanguage : ILanguage
+ public class UsersController : BackofficeController
+ where T : class, IUser
+ where TLanguage : ILanguage
{
- IUserApi Api;
+ IUserApi Api;
IAuthenticationApi AuthenticationApi;
IUserRolesApi RolesApi;
ILanguagesApi LanguagesApi;
IPermissionsApi PermissionsApi;
- public UsersController(IUserApi api, IAuthenticationApi authenticationApi, IUserRolesApi rolesApi, ILanguagesApi languagesApi, IPermissionsApi permissionsApi)
+ public UsersController(IUserApi api, IAuthenticationApi authenticationApi, IUserRolesApi rolesApi, ILanguagesApi languagesApi, IPermissionsApi permissionsApi)
{
Api = api;
AuthenticationApi = authenticationApi;
@@ -27,59 +29,31 @@ namespace zero.Web.Controllers
}
- ///
- /// Get user by id
- ///
- public async Task GetById([FromQuery] string id)
- {
- User user = await Api.GetUserById(id);
-
- if (user == null)
- {
- return new StatusCodeResult(404);
- }
-
- UserEditModel model = await Mapper.Map(user);
- model.SupportedCultures = LanguagesApi.GetAllCultures(Options.SupportedLanguages);
-
- return Json(model);
- }
+ public async Task GetById([FromQuery] string id) => Edit(await Api.GetUserById(id));
- ///
- /// Get all users
- ///
- public async Task GetAll([FromQuery] ListQuery query)
- {
- return await As(await Api.GetByQuery(query)); // TODO , "zero.applications.1-A"
- }
+ public IActionResult GetSupportedCultures() => Json(LanguagesApi.GetAllCultures(Options.SupportedLanguages));
- ///
- /// Get all permissions for selection
- ///
- public IActionResult GetAllPermissions()
- {
- return Json(PermissionsApi.GetAll());
- }
+ public async Task GetAll([FromQuery] ListQuery query) => Json(await Api.GetByQuery(query));
+
+
+ public IActionResult GetAllPermissions() => Json(PermissionsApi.GetAll());
- ///
- /// Updates a user password
- ///
[ZeroAuthorize]
public async Task UpdatePassword([FromBody] UserPasswordEditModel model)
{
- EntityResult result;
+ EntityResult result;
if (model.NewPassword != model.ConfirmNewPassword)
{
- result = EntityResult.Fail(nameof(model.NewPassword), "@errors.changepassword.newpasswordsnotmatching");
+ result = EntityResult.Fail(nameof(model.NewPassword), "@errors.changepassword.newpasswordsnotmatching");
}
else
{
User user = await AuthenticationApi.GetUser();
- result = await Api.UpdatePassword(user, model.CurrentPassword, model.NewPassword);
+ result = await Api.UpdatePassword(user as T, model.CurrentPassword, model.NewPassword);
if (result.IsSuccess)
{
@@ -88,62 +62,35 @@ namespace zero.Web.Controllers
}
return Json(result);
- //return await As(await Api.);
}
- ///
- /// Disables a user
- ///
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Write)]
- public async Task Disable([FromBody] UserEditModel model)
+ public async Task Disable([FromBody] T model)
{
- User entity = await Api.GetUserById(model.Id);
- return await As(await Api.Disable(entity));
+ T entity = await Api.GetUserById(model.Id);
+ return Json(await Api.Disable(entity));
}
- ///
- /// Enables a user
- ///
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Write)]
- public async Task Enable([FromBody] UserEditModel model)
+ public async Task Enable([FromBody] T model)
{
- User entity = await Api.GetUserById(model.Id);
- return await As(await Api.Enable(entity));
+ T entity = await Api.GetUserById(model.Id);
+ return Json(await Api.Enable(entity));
}
- ///
- /// Save user
- ///
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Write)]
- public async Task Save([FromBody] UserEditModel model)
- {
- User entity = await Mapper.Map(model, await Api.GetUserById(model.Id));
- return await As(await Api.Save(entity));
- }
+ public async Task Save([FromBody] T model) => Json(await Api.Save(model));
- ///
- /// Update current user
- ///
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Write)]
// TODO do not need settings.users authorization for editing current user profiles
- public async Task SaveCurrent([FromBody] UserEditModel model)
- {
- User entity = await Mapper.Map(model, await Api.GetUserById(model.Id));
- return await As(await Api.Save(entity));
- }
+ public async Task SaveCurrent([FromBody] T model) => Json(await Api.Save(model));
- ///
- /// Deletes a user
- ///
[ZeroAuthorize(Permissions.Settings.Users, PermissionsValue.Write)]
- public async Task Delete([FromQuery] string id)
- {
- return await As(await Api.Delete(id));
- }
+ public async Task Delete([FromQuery] string id) => Json(await Api.Delete(id));
}
}
diff --git a/zero.Web/Defaults/ZeroBackofficePlugin.cs b/zero.Web/Defaults/ZeroBackofficePlugin.cs
index 041ad37c..799eb36a 100644
--- a/zero.Web/Defaults/ZeroBackofficePlugin.cs
+++ b/zero.Web/Defaults/ZeroBackofficePlugin.cs
@@ -7,7 +7,6 @@ using zero.Core.Entities;
using zero.Core.Extensions;
using zero.Core.Options;
using zero.Core.Plugins;
-using zero.Core.Renderer;
using zero.Web.Mapper;
using zero.Web.Sections;
@@ -19,8 +18,6 @@ namespace zero.Web.Defaults
{
services.AddAll(typeof(IValidator<>), ServiceLifetime.Scoped);
services.AddAll(typeof(IValidator), ServiceLifetime.Scoped);
- services.AddAll(typeof(IRenderer<>), ServiceLifetime.Scoped);
- services.AddAll(typeof(IRenderer), ServiceLifetime.Scoped);
services.AddTransient();
services.AddTransient();
@@ -36,12 +33,12 @@ namespace zero.Web.Defaults
services.AddTransient(typeof(ITranslationsApiFacade), typeof(TranslationsApiFacade));
services.AddTransient(typeof(IPagesApi<>), typeof(PagesApi<>));
services.AddTransient(typeof(IPageTreeApi<>), typeof(PageTreeApi<>));
+ services.AddTransient(typeof(IUserApi<>), typeof(UserApi<>));
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
diff --git a/zero.Web/Models/ObsoleteEditModel.cs b/zero.Web/Models/ObsoleteEditModel.cs
index 2bb8c91f..1f595cf2 100644
--- a/zero.Web/Models/ObsoleteEditModel.cs
+++ b/zero.Web/Models/ObsoleteEditModel.cs
@@ -1,5 +1,4 @@
using System;
-using zero.Core.Renderer;
namespace zero.Web.Models
{
@@ -49,11 +48,6 @@ namespace zero.Web.Models
/// // TODO expiration expiry session.Advanced.GetMetadataFor(user)[Raven.Client.Constants.Documents.Metadata.Expires] = DateTime.UtcNow.AddMinutes(60);
///
public string Token { get; set; }
-
- ///
- /// Submits the renderer configuration which is used to create the editor
- ///
- public RendererConfig Renderer { get; set; }
}
diff --git a/zero.Web/Models/SpaceContentEditModel.cs b/zero.Web/Models/SpaceContentEditModel.cs
index c3a5bcc0..485f187e 100644
--- a/zero.Web/Models/SpaceContentEditModel.cs
+++ b/zero.Web/Models/SpaceContentEditModel.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using zero.Core.Entities;
-using zero.Core.Renderer;
namespace zero.Web.Models
{
@@ -10,7 +9,5 @@ namespace zero.Web.Models
public string Alias { get; set; }
public SpaceContent Model { get; set; }
-
- public RendererConfig Config { get; set; }
}
}
diff --git a/zero.Web/Resources/Localization/zero.en-us.json b/zero.Web/Resources/Localization/zero.en-us.json
index c63ab9db..d19cabf0 100644
--- a/zero.Web/Resources/Localization/zero.en-us.json
+++ b/zero.Web/Resources/Localization/zero.en-us.json
@@ -206,8 +206,8 @@
"email_placeholder": "Enter your email address",
"avatarId": "Avatar",
"avatarId_text": "Upload a user image",
- "language": "Language",
- "language_text": "Set the backoffice language for this user",
+ "languageId": "Language",
+ "languageId_text": "Set the backoffice language for this user",
"roles": "Roles",
"roles_text": "Add default permissions from roles",
"sections": "Sections",