public override void Configure(FluidityConfig config) { config.AddSection("Database", "icon-server-alt", sectionConfig => { sectionConfig.SetTree("Database", treeConfig => { treeConfig.AddCollection <Person>(p => p.Id, "Person", "People", "A collection of people", "icon-umb-users", "icon-umb-users", collectionConfig => { collectionConfig.SetNameProperty(p => p.Name); collectionConfig.SetViewMode(FluidityViewMode.List); collectionConfig.ListView(listViewConfig => { listViewConfig.AddField(p => p.JobTitle); listViewConfig.AddField(p => p.Email); }); collectionConfig.Editor(editorConfig => { editorConfig.AddTab("General", tabConfig => { tabConfig.AddField(p => p.JobTitle).MakeRequired(); tabConfig.AddField(p => p.Email).SetValidationRegex("[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+"); tabConfig.AddField(p => p.Telephone).SetDescription("inc area code"); tabConfig.AddField(p => p.Age); }); editorConfig.AddTab("Media", tabConfig => { tabConfig.AddField(p => p.Avatar).SetDataType("Upload"); }); }); }); }); }); }
internal static FluidityContext EnsureContext(FluidityConfig config, FluidityDataContext data, FluidityServiceContext services, bool replaceContext = false) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } if (services == null) { throw new ArgumentNullException(nameof(services)); } // if there's already a singleton, and we're not replacing then there's no need to ensure anything if (Current != null) { if (replaceContext == false) { return(Current); } } var fluidityContext = new FluidityContext(config, data, services); // assign the singleton Current = fluidityContext; return(Current); }
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { // Build a configuration var config = new FluidityConfig(); var args = new FluidityStartingEventArgs { Config = config }; OnFluidityStarting(this, args); config = args.Config; config.PostProcess(); // Configure the fluidity context FluidityContext.EnsureContext(config, new FluidityDataContext( new FluidityRepositoryFactory() ), new FluidityServiceContext( new FluidityEntityService() ) ); // Create the sections / trees new UmbracoUiHelper().Build(FluidityContext.Current); //TODO: Cleanup any orphan sections / trees that may be left over from renames }
internal FluidityContext(FluidityConfig config, FluidityDataContext data, FluidityServiceContext services) { Config = config; Data = data; Services = services; }
public override void Configure(FluidityConfig config) { // Create the Printer Admin section config.AddSection("Printer Admin", "icon-print", sectionConfig => { // Create the tree for the Printer Admin section sectionConfig.SetTree("Printer Admin", treeConfig => { // Create the collection that will hold the Printers that are to be listed treeConfig.AddCollection <Printer>(x => x.Id, "Printer", "Printers", "A collection of printers", "icon-print", "icon-folder", collectionConfig => { collectionConfig.SetNameFormat(x => { return($"{x.FriendlyName} ({x.IpAddress})"); }); collectionConfig.SetRepositoryType <PrinterRepository>(); // Create the editor that will allow a user to update the Printer details collectionConfig.Editor(editorConfig => { editorConfig.AddTab("General", tabConfig => { tabConfig.AddField(x => x.Name, field => { field.SetLabel("Name") .SetDescription("Specify the name of the entity that is used internally") .MakeRequired(); }); tabConfig.AddField(x => x.FriendlyName, field => { field.SetLabel("Friendly Name") .SetDescription("The friendly name of the printer") .MakeRequired(); }); tabConfig.AddField(x => x.IpAddress, field => { field.SetLabel("IP Address") .SetDescription("The IP Address that the printer can be accessed on") .MakeRequired(); }); }); }); }); }); }); }