public override IDictionary <string, VueComponentDefinition[]> ConvertFormToVues( IDictionary <string, ContentModifierForm> modifierForm, ApplicationRole datum, DatumModifyOperation operation, Type datumType) { if (operation.IsCreateOrUpdateOperation()) { return(new Dictionary <string, VueComponentDefinition[]> { [FORM_KEY] = new[] { new VueComponentDefinition { Name = "cms-form-field-hidden", Props = new { valuePath = nameof(RoleDatumModifierForm.Id) } }, new VueComponentDefinition { Name = "cms-form-field-text", Props = new { label = "Name", valuePath = nameof(RoleDatumModifierForm.Name) } }, new VueComponentDefinition { Name = "cms-form-field-textarea", Props = new { label = "Description", valuePath = nameof(RoleDatumModifierForm.Description) } }, new VueComponentDefinition { Name = "cms-form-field-select", Props = new { label = "Permissions", valuePath = nameof(RoleDatumModifierForm.Permissions), isMultiSelect = true, optionsHandlerId = DatumSelectFieldOptionsHandler.HANDLER_ID, optionsHandlerParam = Jsonizer.Convert(new DatumSelectFieldOptionsHandlerParam { DatumTypeId = "permission" }) } } } }); } if (operation.IsDeleteOperation()) { return(new Dictionary <string, VueComponentDefinition[]> { [FORM_KEY] = new VueComponentDefinition[] { new VueHtmlWidget("Proceed to delete?") } }); } return(null); }
public override IDictionary <string, VueComponentDefinition[]> ConvertFormToVues( IDictionary <string, ContentModifierForm> modifierForm, ApplicationUser datum, DatumModifyOperation operation, Type datumType) { if (operation.IsCreateOrUpdateOperation()) { var vues = new List <VueComponentDefinition>(); vues.AddRange(new[] { new VueComponentDefinition { Name = "cms-form-field-hidden", Props = new { valuePath = nameof(UserDatumModifierForm.Id) } }, new VueComponentDefinition { Name = "cms-form-field-text", Props = new { label = "UserName", valuePath = nameof(UserDatumModifierForm.UserName) } }, new VueComponentDefinition { Name = "cms-form-field-checkbox", Props = new { label = "Activated?", valuePath = nameof(UserDatumModifierForm.IsActivated), yesLabel = "Activated", noLabel = "Deactivated" } } }); if (operation.IsUpdateOperation()) { vues.Add(new VueComponentDefinition { Name = "cms-form-field-checkbox", Props = new { label = "Change Password?", valuePath = nameof(UserDatumModifierForm.ChangePassword), helpText = "Enable this to also change user password when updating data.", yesLabel = "Change", noLabel = "Don't Change" } }); } vues.AddRange(new[] { new VueComponentDefinition { Name = "cms-form-field-password", Props = new { label = "Password", valuePath = nameof(UserDatumModifierForm.Password) } }, new VueComponentDefinition { Name = "cms-form-field-password", Props = new { label = "Password Confirmation", valuePath = nameof(UserDatumModifierForm.PasswordConfirmation) } }, new VueComponentDefinition { Name = "cms-form-field-text", Props = new { label = "Display Name", valuePath = nameof(UserDatumModifierForm.DisplayName) } }, new VueComponentDefinition { Name = "cms-form-field-file-picker", Props = new { label = "Photo", valuePath = nameof(UserDatumModifierForm.PhotoUrl), fileExplorerPageUrl = _urlProv.GenerateManageFileExplorerUrl() } }, new VueComponentDefinition { Name = "cms-form-field-text", Props = new { label = "Email", valuePath = nameof(UserDatumModifierForm.Email) } }, new VueComponentDefinition { Name = "cms-form-field-checkbox", Props = new { label = "Email Confirmed?", valuePath = nameof(UserDatumModifierForm.EmailConfirmed), yesLabel = "Confirmed", noLabel = "Not Confirmed" } }, new VueComponentDefinition { Name = "cms-form-field-text", Props = new { label = "Phone No.", valuePath = nameof(UserDatumModifierForm.PhoneNumber) } }, new VueComponentDefinition { Name = "cms-form-field-checkbox", Props = new { label = "Phone No. Confirmed?", valuePath = nameof(UserDatumModifierForm.PhoneNumberConfirmed), yesLabel = "Confirmed", noLabel = "Not Confirmed" } }, new VueComponentDefinition { Name = "cms-form-field-select", Props = new { label = "Roles", valuePath = nameof(UserDatumModifierForm.RoleIds), isMultiSelect = true, optionsHandlerId = DatumSelectFieldOptionsHandler.HANDLER_ID, optionsHandlerParam = Jsonizer.Convert(new DatumSelectFieldOptionsHandlerParam { DatumTypeId = "role", SortInfos = new[] { Tuple.Create("Name", false) } }) } } }); return(new Dictionary <string, VueComponentDefinition[]> { [FORM_KEY] = vues.ToArray() }); } if (operation.IsDeleteOperation()) { return(new Dictionary <string, VueComponentDefinition[]> { [FORM_KEY] = new VueComponentDefinition[] { new VueHtmlWidget("Proceed to delete?") } }); } return(null); }
public IEnumerable <ContentType> DefineContentTypes() { yield return(new ContentType( "sample-article", "Sample Article", "A sample article content.", new[] { new ContentFieldDefinition("KataKata", typeof(TextField), new TextFieldConfiguration { Label = "Title", Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null, ["regex"] = new TextFieldRegexValidatorConfiguration { Pattern = @"^[a-zA-Z0-9\ ]+$" }, ["length"] = new TextFieldLengthValidatorConfiguration { MaxLength = 256 } } }), new ContentFieldDefinition("IsPowerful", typeof(BooleanField), new BooleanFieldConfiguration { Label = "Does it happen?", InitialValue = false, TrueBoolLabel = "Indeed", FalseBoolLabel = "Never", Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null } }), new ContentFieldDefinition("MagicUtc", typeof(ChronoField), new ChronoFieldConfiguration { Label = "When It Happen", Kind = DateTimeKind.Local, Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null } }), new ContentFieldDefinition("AngkaMantab", typeof(NumberField), new NumberFieldConfiguration { Label = "Magic Number", DefaultValue = 250, NumberKind = NumberValueKind.Integer, Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null, ["range"] = new NumberFieldRangeValidatorConfiguration { MinValue = 100, MaxValue = 1000000 } } }), new ContentFieldDefinition("UrlSlug", typeof(FauxUrlSlugField), new FauxUrlSlugFieldConfiguration { Label = "URL Slug", ContentIdSlugPartLength = 8, SlugPattern = "mantab/[###]/[MagicUtc:year]/[MagicUtc:month]/[KataKata:lowercase]" }), new ContentFieldDefinition("MyStuffs", typeof(SelectField), new SelectFieldConfiguration { Label = "My Stuffs", IsMultiSelect = true, OptionsHandlerId = ContentSelectFieldOptionsHandler.HANDLER_ID, OptionsHandlerParam = Jsonizer.Convert(new ContentSelectFieldOptionsHandlerParam { ContentTypeIds = new[] { "sample-article" }, SortInfos = new[] { Tuple.Create("KataKata.Val", true) } }) }), new ContentFieldDefinition("MyFavArticle", typeof(SelectField), new SelectFieldConfiguration { Label = "My Fav Article", IsMultiSelect = false, OptionsHandlerId = ContentSelectFieldOptionsHandler.HANDLER_ID, OptionsHandlerParam = Jsonizer.Convert(new ContentSelectFieldOptionsHandlerParam { ContentTypeIds = new[] { "sample-article" } }), Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null } }), new ContentFieldDefinition("File", typeof(FilePickerField), new FilePickerFieldConfiguration { Label = "File", IsMultiSelect = false, Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null, ["file-extension"] = new FileExtensionValidatorConfiguration { AllowedFileExtensions = new[] { "jpg", "png", "gif" } } } }), new ContentFieldDefinition("Files", typeof(FilePickerField), new FilePickerFieldConfiguration { Label = "Files", IsMultiSelect = true, Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null, ["file-extension"] = new FileExtensionValidatorConfiguration { AllowedFileExtensions = new[] { "jpg", "png", "gif" } } } }), new ContentFieldDefinition("BestMantapMan", typeof(SelectField), new SelectFieldConfiguration { Label = "Best Mantap Man", IsMultiSelect = false, OptionsHandlerId = DatumSelectFieldOptionsHandler.HANDLER_ID, OptionsHandlerParam = Jsonizer.Convert(new DatumSelectFieldOptionsHandlerParam { DatumTypeId = "user", WhereConditions = new[] { Tuple.Create("IsInRole", (object)new[] { "Mantap" }) } }), Validators = new Dictionary <string, ContentFieldValidatorConfiguration> { ["required"] = null } }) }, new[] { "KataKata" }, new[] { "KataKata", "IsPowerful", "MagicUtc", "AngkaMantab", "UrlSlug", "MyStuffs", "MyFavArticle", "File.Val", "Files.Val", "BestMantapMan", $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.IsPublished", $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.IsDraft", $"{ContentType.FIELD_NAME_TRASH_STATUS}.IsTrashed", $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.PublishedAt", $"{ContentType.FIELD_NAME_PUBLISH_STATUS}.UnpublishedAt", $"{ContentType.FIELD_NAME_COMMON_META}.UpdatedAt", $"{ContentType.FIELD_NAME_COMMON_META}.CreatedAt", $"{ContentType.FIELD_NAME_COMMON_META}.Id" }, "KataKata.Val", false, null, null ) { PreModifyOperationFormVues = new GetExtraModifyOperationFormVues[] { (contentType, content, operation) => { if (operation.IsCreateOperation()) { return new VueComponentDefinition[] { new VueHtmlWidget($"<p class='note note-info'>Let the creating magic happen!</p>") }; } if (operation.IsUpdateOperation()) { return new VueComponentDefinition[] { new VueHtmlWidget($"<p class='note note-info'>Let the updating magic happen!</p>") }; } return null; } } }); }