From ee20eb16e111375a296c8bb04f2d289ef0e7fa2c Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Wed, 29 Dec 2021 01:25:35 +0100 Subject: [PATCH] vue plugin system somehow works --- .../ZeroApiTreeEntityStoreController.cs | 26 ++++++++++++------- zero.Api/Endpoints/Media/MediaController.cs | 6 ----- zero.Api/Endpoints/Pages/PagesController.cs | 8 ------ zero.Backoffice.UI/app/core/zeroRuntime.ts | 6 +++++ .../app/modules/settings/settings.vue | 2 +- zero.Backoffice.UI/app/plugins.generated.js | 1 - zero.Backoffice.UI/app/plugins.generated.ts | 2 ++ zero.Backoffice.UI/package.json | 3 +++ zero.Backoffice.UI/tsconfig.json | 3 ++- zero.Backoffice.UI/vite.config.js | 10 ++++--- .../Services/Sections/SectionService.cs | 4 +-- .../Sections/BackofficeSection.cs | 6 ++++- .../Sections/DashboardSection.cs | 3 +++ .../Sections/IBackofficeSection.cs | 5 ++++ .../UIComposition/Sections/MediaSection.cs | 3 +++ .../UIComposition/Sections/PagesSection.cs | 3 +++ .../UIComposition/Sections/SettingsSection.cs | 3 +++ .../UIComposition/Sections/SpacesSection.cs | 3 +++ .../Communication/CommunicationModule.cs | 1 + .../Interceptors/InterceptorInstruction.cs | 7 +++-- .../Interceptors/Interceptors.cs | 4 +-- zero.Core/Communication/LazilyResolved.cs | 11 ++++++++ zero.Core/Media/MediaStore.cs | 5 +--- zero.Core/Media/Models/Media.cs | 2 +- zero.Core/Models/IAlwaysActive.cs | 12 +++++++++ zero.Core/Models/Results/Paged.cs | 2 ++ zero.Core/Stores/StoreOperations.cs | 11 +++++--- zero.Demo/Program.cs | 9 +++++-- zero.Demo/zero.Demo.csproj | 1 + zero.sln | 25 ++++++++++++++++++ 30 files changed, 136 insertions(+), 51 deletions(-) delete mode 100644 zero.Backoffice.UI/app/plugins.generated.js create mode 100644 zero.Backoffice.UI/app/plugins.generated.ts create mode 100644 zero.Core/Communication/LazilyResolved.cs create mode 100644 zero.Core/Models/IAlwaysActive.cs diff --git a/zero.Api/Abstractions/ZeroApiTreeEntityStoreController.cs b/zero.Api/Abstractions/ZeroApiTreeEntityStoreController.cs index 0acc5b55..90fe8710 100644 --- a/zero.Api/Abstractions/ZeroApiTreeEntityStoreController.cs +++ b/zero.Api/Abstractions/ZeroApiTreeEntityStoreController.cs @@ -13,7 +13,7 @@ public abstract class ZeroApiTreeEntityStoreController : ZeroApi protected async Task> GetChildModels(string parentId, ListQuery query) { query.OrderQuery ??= q => q.OrderByDescending(x => x.CreatedDate); - Paged result = await Store.LoadChildren(parentId, query.Page, query.PageSize, q => q.Filter(query)); + Paged result = await Store.LoadChildren(NormalizeParentId(parentId), query.Page, query.PageSize, q => q.Filter(query)); return Mapper.Map(result); } @@ -22,7 +22,7 @@ public abstract class ZeroApiTreeEntityStoreController : ZeroApi protected async Task> GetChildModels(string parentId, ListQuery query) { query.OrderQuery ??= q => q.OrderByDescending(x => x.CreatedDate); - Paged result = await Store.LoadChildren(parentId, query.Page, query.PageSize, q => q.Filter(query)); + Paged result = await Store.LoadChildren(NormalizeParentId(parentId), query.Page, query.PageSize, q => q.Filter(query)); return result; } @@ -31,7 +31,7 @@ public abstract class ZeroApiTreeEntityStoreController : ZeroApi protected async Task> GetChildModelsByIndex(string parentId, ListQuery query) where TIndex : AbstractCommonApiForIndexes, new() { query.OrderQuery ??= q => q.OrderByDescending(x => x.CreatedDate); - Paged result = await Store.LoadChildren(parentId, query.Page, query.PageSize, q => q.Filter(query)); + Paged result = await Store.LoadChildren(NormalizeParentId(parentId), query.Page, query.PageSize, q => q.Filter(query)); return Mapper.Map(result); } @@ -40,7 +40,7 @@ public abstract class ZeroApiTreeEntityStoreController : ZeroApi protected async Task> GetChildModelsByIndex(string parentId, ListQuery query) where TIndex : AbstractCommonApiForIndexes, new() { query.OrderQuery ??= q => q.OrderByDescending(x => x.CreatedDate); - Paged result = await Store.LoadChildren(parentId, query.Page, query.PageSize, q => q.Filter(query)); + Paged result = await Store.LoadChildren(NormalizeParentId(parentId), query.Page, query.PageSize, q => q.Filter(query)); return result; } @@ -54,37 +54,37 @@ public abstract class ZeroApiTreeEntityStoreController : ZeroApi protected async Task> MoveModel(string id, string newParentId) { - return await PutOperation(async () => await Store.Move(id, newParentId)); + return await PutOperation(async () => await Store.Move(id, NormalizeParentId(newParentId))); } protected async Task> MoveModel(string id, string newParentId) { - return await PutOperation(async () => await Store.Move(id, newParentId)); + return await PutOperation(async () => await Store.Move(id, NormalizeParentId(newParentId))); } protected async Task> CopyModel(string id, string newParentId) { - return await PutOperation(async () => await Store.Copy(id, newParentId)); + return await PutOperation(async () => await Store.Copy(id, NormalizeParentId(newParentId))); } protected async Task> CopyModel(string id, string newParentId) { - return await PutOperation(async () => await Store.Copy(id, newParentId)); + return await PutOperation(async () => await Store.Copy(id, NormalizeParentId(newParentId))); } protected async Task> CopyModelWithDescendants(string id, string newParentId) { - return await PutOperation(async () => await Store.CopyWithDescendants(id, newParentId)); + return await PutOperation(async () => await Store.CopyWithDescendants(id, NormalizeParentId(newParentId))); } protected async Task> CopyModelWithDescendants(string id, string newParentId) { - return await PutOperation(async () => await Store.CopyWithDescendants(id, newParentId)); + return await PutOperation(async () => await Store.CopyWithDescendants(id, NormalizeParentId(newParentId))); } @@ -127,4 +127,10 @@ public abstract class ZeroApiTreeEntityStoreController : ZeroApi return result; } + + + protected string NormalizeParentId(string id) + { + return id == "root" ? null : id; + } } diff --git a/zero.Api/Endpoints/Media/MediaController.cs b/zero.Api/Endpoints/Media/MediaController.cs index b8d32914..d342563f 100644 --- a/zero.Api/Endpoints/Media/MediaController.cs +++ b/zero.Api/Endpoints/Media/MediaController.cs @@ -286,10 +286,4 @@ public class MediaController : ZeroApiTreeEntityStoreController> GetChildren(string id, [FromQuery] ListQuery query) { - id = NormalizeParentId(id); - query.SearchFor(x => x.Name); query.OrderQuery = q => q.OrderByDescending(x => x.Sort).ThenByDescending(x => x.CreatedDate); Paged result = await Store.LoadChildren(id, query.Page, query.PageSize, q => q.Filter(query)); @@ -82,12 +80,6 @@ public class PagesController : ZeroApiTreeEntityStoreController> Create(MailSave saveModel) => CreateModel(saveModel); diff --git a/zero.Backoffice.UI/app/core/zeroRuntime.ts b/zero.Backoffice.UI/app/core/zeroRuntime.ts index b306b756..bf6e7f7e 100644 --- a/zero.Backoffice.UI/app/core/zeroRuntime.ts +++ b/zero.Backoffice.UI/app/core/zeroRuntime.ts @@ -26,6 +26,7 @@ import editorPlugin from '../editor/plugin'; import { ZeroSchema } from 'zero/schemas'; import { ZeroSchemaProp } from './zero'; import * as zeroOptions from '../options'; +import plugins from '../plugins.generated'; export class ZeroRuntime implements Zero { @@ -113,6 +114,11 @@ export class ZeroRuntime implements Zero translationPlugin.install(pluginOptions); integrationPlugin.install(pluginOptions); userPlugin.install(pluginOptions); + + plugins.forEach(plugin => + { + plugin.install(pluginOptions); + }); } diff --git a/zero.Backoffice.UI/app/modules/settings/settings.vue b/zero.Backoffice.UI/app/modules/settings/settings.vue index 207ad27e..3376e381 100644 --- a/zero.Backoffice.UI/app/modules/settings/settings.vue +++ b/zero.Backoffice.UI/app/modules/settings/settings.vue @@ -122,7 +122,7 @@ strong { display: inline-block; - margin-bottom: 5px; + margin-bottom: 3px; color: var(--color-text); } } diff --git a/zero.Backoffice.UI/app/plugins.generated.js b/zero.Backoffice.UI/app/plugins.generated.js deleted file mode 100644 index c3b2f775..00000000 --- a/zero.Backoffice.UI/app/plugins.generated.js +++ /dev/null @@ -1 +0,0 @@ -export default [ ]; \ No newline at end of file diff --git a/zero.Backoffice.UI/app/plugins.generated.ts b/zero.Backoffice.UI/app/plugins.generated.ts new file mode 100644 index 00000000..be78f958 --- /dev/null +++ b/zero.Backoffice.UI/app/plugins.generated.ts @@ -0,0 +1,2 @@ +import zeroPlugin0 from '@zeroplugin0/plugin'; +export default [ zeroPlugin0 ]; \ No newline at end of file diff --git a/zero.Backoffice.UI/package.json b/zero.Backoffice.UI/package.json index 2991815a..2c181a11 100644 --- a/zero.Backoffice.UI/package.json +++ b/zero.Backoffice.UI/package.json @@ -6,6 +6,9 @@ "dev": "vite", "build": "vite build" }, + "workspaces": [ + "../plugins/zero.Commerce/zero.Commerce.Plugin" + ], "dependencies": { "axios": "^0.24.0", "dayjs": "^1.10.7", diff --git a/zero.Backoffice.UI/tsconfig.json b/zero.Backoffice.UI/tsconfig.json index 83f331e7..93f7d93e 100644 --- a/zero.Backoffice.UI/tsconfig.json +++ b/zero.Backoffice.UI/tsconfig.json @@ -11,5 +11,6 @@ "esModuleInterop": true, "lib": [ "esnext", "dom" ] }, - "include": [ "app/**/*.ts", "app/**/*.d.ts", "app/**/*.tsx", "app/**/*.vue" ] + "include": [ "app/**/*.ts", "app/**/*.d.ts", "app/**/*.tsx", "app/**/*.vue" ], + "exclude": [ "node_modules" ] } \ No newline at end of file diff --git a/zero.Backoffice.UI/vite.config.js b/zero.Backoffice.UI/vite.config.js index 2c7ed289..ef962ebd 100644 --- a/zero.Backoffice.UI/vite.config.js +++ b/zero.Backoffice.UI/vite.config.js @@ -10,7 +10,8 @@ let loadedPlugins = JSON.parse(process.env.ZERO_PLUGINS || "[]"); if (!process.env.ZERO_PLUGINS) { //loadedPlugins = ["../zero.Commerce/Plugin", "../zero.Stories/Plugin", "../zero.Forms/Plugin", "../../Laola/Laola.Backoffice/Plugin"]; - loadedPlugins = []; + loadedPlugins = ["../plugins/zero.Commerce/zero.Commerce.Plugin"] + //loadedPlugins = []; } let zeroPlugins = []; @@ -40,12 +41,12 @@ loadedPlugins.forEach(pluginPath => } pluginNames.push(name); - pluginFileContent += "import " + name + " from '" + alias + "/plugin.js';\n"; + pluginFileContent += "import " + name + " from '" + alias + "/plugin';\n"; }); pluginFileContent += "export default [ " + pluginNames.join(', ') + " ];"; -fs.writeFile(path.resolve(__dirname, 'app/plugins.generated.js'), pluginFileContent, err => +fs.writeFile(path.resolve(__dirname, 'app/plugins.generated.ts'), pluginFileContent, err => { if (err) { @@ -76,7 +77,8 @@ let config = defineConfig({ }, resolve: { alias: { - vue: '@vue/compat' + vue: '@vue/compat', + ...pluginAliases, } }, plugins: [ diff --git a/zero.Backoffice/Services/Sections/SectionService.cs b/zero.Backoffice/Services/Sections/SectionService.cs index 6df2a2b9..f7844491 100644 --- a/zero.Backoffice/Services/Sections/SectionService.cs +++ b/zero.Backoffice/Services/Sections/SectionService.cs @@ -34,7 +34,7 @@ public class SectionService : ISectionService List sections = new(); - foreach (IBackofficeSection section in Sections) + foreach (IBackofficeSection section in Sections.OrderBy(x => x.Sort)) { //if (!isSuperUser && !Permission.CanReadKey(permissions, section.Alias, true)) //{ @@ -114,7 +114,7 @@ public class SectionService : ISectionService Name = area.Name, Description = area.Description, Icon = area.Icon, - Url = Constants.Sections.Settings.EnsureStartsWith('/') + Safenames.Alias(area.Alias).EnsureStartsWith('/'), + Url = Constants.Sections.Settings.EnsureStartsWith('/') + area.CustomUrl.Or(Safenames.Alias(area.Alias)).EnsureStartsWith('/'), IsPlugin = true }; diff --git a/zero.Backoffice/UIComposition/Sections/BackofficeSection.cs b/zero.Backoffice/UIComposition/Sections/BackofficeSection.cs index 311d2c13..6b0e5e00 100644 --- a/zero.Backoffice/UIComposition/Sections/BackofficeSection.cs +++ b/zero.Backoffice/UIComposition/Sections/BackofficeSection.cs @@ -14,6 +14,9 @@ public class BackofficeSection : IBackofficeSection, IChildBackofficeSection /// public string Icon { get; set; } + /// + public int Sort { get; set; } + /// /// HEX color (#aabbcc or #abc). Defaults to a neutral color /// @@ -25,11 +28,12 @@ public class BackofficeSection : IBackofficeSection, IChildBackofficeSection public BackofficeSection() { } - public BackofficeSection(string alias, string name, string icon = null, string color = null) + public BackofficeSection(string alias, string name, string icon = null, string color = null, int sort = 0) { Alias = alias; Name = name; Icon = icon; Color = color; + Sort = sort; } } diff --git a/zero.Backoffice/UIComposition/Sections/DashboardSection.cs b/zero.Backoffice/UIComposition/Sections/DashboardSection.cs index 0768ad2a..b13eca02 100644 --- a/zero.Backoffice/UIComposition/Sections/DashboardSection.cs +++ b/zero.Backoffice/UIComposition/Sections/DashboardSection.cs @@ -17,6 +17,9 @@ public class DashboardSection : IInternalBackofficeSection /// public string Color => null; + /// + public int Sort => 0; + /// public IList Children => new List(); } \ No newline at end of file diff --git a/zero.Backoffice/UIComposition/Sections/IBackofficeSection.cs b/zero.Backoffice/UIComposition/Sections/IBackofficeSection.cs index 6f0f8c28..549593f4 100644 --- a/zero.Backoffice/UIComposition/Sections/IBackofficeSection.cs +++ b/zero.Backoffice/UIComposition/Sections/IBackofficeSection.cs @@ -34,4 +34,9 @@ public interface IBackofficeSection /// Children are displayed as a sub-navigation in the main nav area /// IList Children { get; } + + /// + /// Sort order + /// + int Sort { get; } } \ No newline at end of file diff --git a/zero.Backoffice/UIComposition/Sections/MediaSection.cs b/zero.Backoffice/UIComposition/Sections/MediaSection.cs index 7ec463ae..2e48859a 100644 --- a/zero.Backoffice/UIComposition/Sections/MediaSection.cs +++ b/zero.Backoffice/UIComposition/Sections/MediaSection.cs @@ -17,6 +17,9 @@ public class MediaSection : IInternalBackofficeSection /// public string Color => "#d82853"; + /// + public int Sort => 300; + /// public IList Children => new List(); } \ No newline at end of file diff --git a/zero.Backoffice/UIComposition/Sections/PagesSection.cs b/zero.Backoffice/UIComposition/Sections/PagesSection.cs index 46ba5fa3..1f47b113 100644 --- a/zero.Backoffice/UIComposition/Sections/PagesSection.cs +++ b/zero.Backoffice/UIComposition/Sections/PagesSection.cs @@ -17,6 +17,9 @@ public class PagesSection : IInternalBackofficeSection /// public string Color => "#0cb0f5"; + /// + public int Sort => 100; + /// public IList Children => new List(); } \ No newline at end of file diff --git a/zero.Backoffice/UIComposition/Sections/SettingsSection.cs b/zero.Backoffice/UIComposition/Sections/SettingsSection.cs index c6c80462..1d5152ca 100644 --- a/zero.Backoffice/UIComposition/Sections/SettingsSection.cs +++ b/zero.Backoffice/UIComposition/Sections/SettingsSection.cs @@ -17,6 +17,9 @@ public class SettingsSection : IInternalBackofficeSection /// public string Color => null; + /// + public int Sort => 1000; + /// public IList Children => new List(); } diff --git a/zero.Backoffice/UIComposition/Sections/SpacesSection.cs b/zero.Backoffice/UIComposition/Sections/SpacesSection.cs index 934ddae0..a0b471dd 100644 --- a/zero.Backoffice/UIComposition/Sections/SpacesSection.cs +++ b/zero.Backoffice/UIComposition/Sections/SpacesSection.cs @@ -17,6 +17,9 @@ public class SpacesSection : IInternalBackofficeSection /// public string Color => "#f9c202"; + /// + public int Sort => 200; + /// public IList Children => new List(); } \ No newline at end of file diff --git a/zero.Core/Communication/CommunicationModule.cs b/zero.Core/Communication/CommunicationModule.cs index 439f0059..eb05a0fb 100644 --- a/zero.Core/Communication/CommunicationModule.cs +++ b/zero.Core/Communication/CommunicationModule.cs @@ -10,5 +10,6 @@ public class CommunicationModule : ZeroModule services.AddScoped(); services.AddSingleton(); services.AddTransient(); + services.AddTransient(typeof(Lazy<>), typeof(LazilyResolved<>)); } } \ No newline at end of file diff --git a/zero.Core/Communication/Interceptors/InterceptorInstruction.cs b/zero.Core/Communication/Interceptors/InterceptorInstruction.cs index 186fe57b..63624660 100644 --- a/zero.Core/Communication/Interceptors/InterceptorInstruction.cs +++ b/zero.Core/Communication/Interceptors/InterceptorInstruction.cs @@ -16,7 +16,7 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() protected IZeroContext Context { get; private set; } - protected IEnumerable Interceptors { get; private set; } + protected Lazy> Interceptors { get; private set; } protected Dictionary InterceptorCache { get; private set; } = new(); @@ -27,7 +27,7 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() protected Func InterceptorFilter { get; private set; } = x => true; - internal InterceptorInstruction(IInterceptors interceptors, IZeroContext context, IEnumerable registrations, ILogger logger, InterceptorRunType runtype, T model) + internal InterceptorInstruction(IInterceptors interceptors, IZeroContext context, Lazy> registrations, ILogger logger, InterceptorRunType runtype, T model) { InterceptorHandler = interceptors; Context = context; @@ -37,7 +37,6 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() Model = model; ModelType = model.GetType(); - Interceptors = registrations.OrderByDescending(x => x.Gravity); } @@ -115,7 +114,7 @@ public class InterceptorInstruction where T : ZeroIdEntity, new() protected IEnumerable GetInterceptors() { - return Interceptors.Where(InterceptorFilter).OrderByDescending(x => x.Gravity); + return Interceptors.Value.Where(InterceptorFilter).OrderByDescending(x => x.Gravity); } diff --git a/zero.Core/Communication/Interceptors/Interceptors.cs b/zero.Core/Communication/Interceptors/Interceptors.cs index bb1ebd7d..915c1dd6 100644 --- a/zero.Core/Communication/Interceptors/Interceptors.cs +++ b/zero.Core/Communication/Interceptors/Interceptors.cs @@ -6,12 +6,12 @@ public class Interceptors : IInterceptors { protected IZeroContext Context { get; set; } - protected IEnumerable Registrations { get; set; } + protected Lazy> Registrations { get; set; } protected ILogger Logger { get; set; } - public Interceptors(IZeroContext context, IEnumerable registrations, ILogger logger) + public Interceptors(IZeroContext context, Lazy> registrations, ILogger logger) { Context = context; Registrations = registrations; diff --git a/zero.Core/Communication/LazilyResolved.cs b/zero.Core/Communication/LazilyResolved.cs new file mode 100644 index 00000000..0666dae4 --- /dev/null +++ b/zero.Core/Communication/LazilyResolved.cs @@ -0,0 +1,11 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace zero.Communication; + +public class LazilyResolved : Lazy +{ + public LazilyResolved(IServiceProvider serviceProvider): base(serviceProvider.GetRequiredService) + { + + } +} \ No newline at end of file diff --git a/zero.Core/Media/MediaStore.cs b/zero.Core/Media/MediaStore.cs index 9d3f6511..fc7e494f 100644 --- a/zero.Core/Media/MediaStore.cs +++ b/zero.Core/Media/MediaStore.cs @@ -4,10 +4,7 @@ namespace zero.Media; public class MediaStore : TreeEntityStore, IMediaStore { - public MediaStore(IStoreContext context) : base(context) - { - Config.IncludeInactive = true; - } + public MediaStore(IStoreContext context) : base(context) { } /// /// A media (either file or folder) can only be saved for the following circumstances: diff --git a/zero.Core/Media/Models/Media.cs b/zero.Core/Media/Models/Media.cs index b659380f..13184b15 100644 --- a/zero.Core/Media/Models/Media.cs +++ b/zero.Core/Media/Models/Media.cs @@ -4,7 +4,7 @@ /// A media file (can contain an image or other media like videos and documents) /// [RavenCollection("Media")] -public class Media : ZeroEntity, ISupportsTrees +public class Media : ZeroEntity, ISupportsTrees, IAlwaysActive { public Media() { diff --git a/zero.Core/Models/IAlwaysActive.cs b/zero.Core/Models/IAlwaysActive.cs new file mode 100644 index 00000000..34f7dbce --- /dev/null +++ b/zero.Core/Models/IAlwaysActive.cs @@ -0,0 +1,12 @@ +namespace zero.Models; + +/// +/// Entities decorated with this interface are always set to IsActive=true +/// +public interface IAlwaysActive +{ + /// + /// Whether the entity is visible in the frontend + /// + bool IsActive { get; set; } +} \ No newline at end of file diff --git a/zero.Core/Models/Results/Paged.cs b/zero.Core/Models/Results/Paged.cs index d25d347c..4be02b98 100644 --- a/zero.Core/Models/Results/Paged.cs +++ b/zero.Core/Models/Results/Paged.cs @@ -9,6 +9,8 @@ public class Paged : Paged Items = items; } + public Paged(long totalItems, long pageNumber, long pageSize) : base(totalItems, pageNumber, pageSize) { } + public Paged MapTo(Func convertItem) { return new Paged(Items.Select(x => convertItem(x)).Where(x => x != null).ToList(), TotalItems, Page, PageSize); diff --git a/zero.Core/Stores/StoreOperations.cs b/zero.Core/Stores/StoreOperations.cs index 2616edeb..93f516d1 100644 --- a/zero.Core/Stores/StoreOperations.cs +++ b/zero.Core/Stores/StoreOperations.cs @@ -72,10 +72,8 @@ public partial class StoreOperations : // set IDs AutoSetIds(model); - if (model is ZeroEntity) + if (model is ZeroEntity zeroModel) { - ZeroEntity zeroModel = model as ZeroEntity; - // get current user string userId = Context.BackofficeUser.FindFirstValue(Constants.Auth.Claims.UserId); @@ -101,6 +99,11 @@ public partial class StoreOperations : zeroModel.Hash ??= IdGenerator.Create(); } + if (model is IAlwaysActive activeModel) + { + activeModel.IsActive = true; + } + return model; } @@ -110,7 +113,7 @@ public partial class StoreOperations : /// protected virtual T WhenActive(T model) where T : ZeroIdEntity, new() { - return model != null && (Config.IncludeInactive || model is not ZeroEntity || (model as ZeroEntity).IsActive) ? model : default; + return model != null && (Config.IncludeInactive || model is IAlwaysActive || model is not ZeroEntity || (model as ZeroEntity).IsActive) ? model : default; } } diff --git a/zero.Demo/Program.cs b/zero.Demo/Program.cs index c69970e7..49d02b95 100644 --- a/zero.Demo/Program.cs +++ b/zero.Demo/Program.cs @@ -4,6 +4,7 @@ using zero.Applications; using zero.Architecture; using zero.Backoffice; using zero.Backoffice.DevServer; +using zero.Commerce; using zero.Configuration; using zero.Demo; using zero.Localization; @@ -17,9 +18,13 @@ builder.Services.AddRazorPages(); builder.Services.AddTransient(); builder.Services - .AddZero(builder.Configuration) + .AddZero(builder.Configuration, cfg => + { + cfg.Mvc.AddApplicationPart(typeof(CommercePlugin).Assembly); + }) .AddApi() - .AddBackoffice(); + .AddBackoffice() + .AddCommerce(); builder.Services.Configure(opts => { diff --git a/zero.Demo/zero.Demo.csproj b/zero.Demo/zero.Demo.csproj index 062c5f5e..c43da96a 100644 --- a/zero.Demo/zero.Demo.csproj +++ b/zero.Demo/zero.Demo.csproj @@ -10,6 +10,7 @@ + diff --git a/zero.sln b/zero.sln index e8fcad10..df5a52ab 100644 --- a/zero.sln +++ b/zero.sln @@ -49,6 +49,26 @@ Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "zero.Backoffice.UI", "zero. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "zero.Demo", "zero.Demo\zero.Demo.csproj", "{8AD56129-2104-4DF5-A08E-1A94A8EC205B}" EndProject +Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "zero.Commerce.Plugin", "plugins\zero.Commerce\zero.Commerce.Plugin\", "{645DAEC9-73CA-41C3-ADFA-7576E2D6B216}" + ProjectSection(WebsiteProperties) = preProject + TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0" + Debug.AspNetCompiler.VirtualPath = "/localhost_64677" + Debug.AspNetCompiler.PhysicalPath = "plugins\zero.Commerce\zero.Commerce.Plugin\" + Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_64677\" + Debug.AspNetCompiler.Updateable = "true" + Debug.AspNetCompiler.ForceOverwrite = "true" + Debug.AspNetCompiler.FixedNames = "false" + Debug.AspNetCompiler.Debug = "True" + Release.AspNetCompiler.VirtualPath = "/localhost_64677" + Release.AspNetCompiler.PhysicalPath = "plugins\zero.Commerce\zero.Commerce.Plugin\" + Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_64677\" + Release.AspNetCompiler.Updateable = "true" + Release.AspNetCompiler.ForceOverwrite = "true" + Release.AspNetCompiler.FixedNames = "false" + Release.AspNetCompiler.Debug = "False" + VWDPort = "64677" + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -91,6 +111,10 @@ Global {8AD56129-2104-4DF5-A08E-1A94A8EC205B}.Debug|Any CPU.Build.0 = Debug|Any CPU {8AD56129-2104-4DF5-A08E-1A94A8EC205B}.Release|Any CPU.ActiveCfg = Release|Any CPU {8AD56129-2104-4DF5-A08E-1A94A8EC205B}.Release|Any CPU.Build.0 = Release|Any CPU + {645DAEC9-73CA-41C3-ADFA-7576E2D6B216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {645DAEC9-73CA-41C3-ADFA-7576E2D6B216}.Debug|Any CPU.Build.0 = Debug|Any CPU + {645DAEC9-73CA-41C3-ADFA-7576E2D6B216}.Release|Any CPU.ActiveCfg = Debug|Any CPU + {645DAEC9-73CA-41C3-ADFA-7576E2D6B216}.Release|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -99,6 +123,7 @@ Global {63A8AD15-15F0-4555-BD62-C38B4465FFC1} = {6FAA92A8-CA1A-48EA-9857-C9092971B4D1} {C23CF90A-DB90-427F-816C-0E2FE20E29D0} = {6FAA92A8-CA1A-48EA-9857-C9092971B4D1} {A8E5F34F-5400-4F92-96C6-7F91645BC220} = {6FAA92A8-CA1A-48EA-9857-C9092971B4D1} + {645DAEC9-73CA-41C3-ADFA-7576E2D6B216} = {6FAA92A8-CA1A-48EA-9857-C9092971B4D1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AD3F31B9-8BBB-4334-9571-F556B9E632C9}