public override void OnFinish(object sender, EventArgs e) { var formToken = GetBinding <DataEntityToken>("BoundToken"); var modelReference = (IModelReference)formToken.Data; var definition = DynamicFormsFacade.GetFormByName(modelReference.Name); var submitButtonLabel = GetBinding <string>("SubmitButtonLabel"); SwitchAttribute <RequiresCaptchaAttribute>("RequiresCaptcha", definition.Model.Attributes); SwitchAttribute <ForceHttpsConnectionAttribute>("ForceHttpsConnection", definition.Model.Attributes); var submitButtonLabelAttr = definition.Model.Attributes.OfType <SubmitButtonLabelAttribute>().SingleOrDefault(); if (submitButtonLabel != null) { definition.Model.Attributes.Remove(submitButtonLabelAttr); } if (!String.IsNullOrEmpty(submitButtonLabel)) { submitButtonLabelAttr = new SubmitButtonLabelAttribute(submitButtonLabel); definition.Model.Attributes.Add(submitButtonLabelAttr); using (var writer = ResourceFacade.GetResourceWriter()) { writer.AddResource(GetKey("SubmitButtonLabel"), submitButtonLabel); } } Save(definition); }
public override void OnFinish(object sender, EventArgs e) { var token = (FieldValidatorsEntityToken)EntityToken; var definition = DynamicFormsFacade.GetFormByName(token.FormName); var field = definition.Model.Fields.Get(token.FieldName); var validatorType = Type.GetType(GetBinding <string>("ValidatorType")); var message = GetBinding <string>("Message"); var attribute = (FormValidationAttribute)Activator.CreateInstance(validatorType, message); field.Attributes.Add(attribute); DynamicFormsFacade.SaveForm(definition); using (var writer = ResourceFacade.GetResourceWriter()) { var setting = token.FieldName + ".Validation." + attribute.GetType().Name; var key = Localization.GenerateKey(token.FormName, setting); writer.AddResource(key, message); } var editToken = new FieldValidatorsEntityToken(token.FormName, token.FieldName, validatorType); var workflowToken = new WorkflowActionToken(typeof(EditFieldValidatorWorkflow)); CreateSpecificTreeRefresher().PostRefreshMessages(EntityToken); ExecuteAction(editToken, workflowToken); }
public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token) { var validatorToken = (FieldValidatorsEntityToken)token; var form = DynamicFormsFacade.GetFormByName(validatorToken.FormName); if (String.IsNullOrEmpty(validatorToken.Type)) { if (form != null) { var field = form.Model.Fields.Get(validatorToken.FieldName); if (field != null) { foreach (var validator in field.ValidationAttributes) { var validatorType = validator.GetType(); var fieldValidatorElementHandle = context.CreateElementHandle(new FieldValidatorsEntityToken(form.Name, field.Name, validator.GetType())); var fieldValidatorElement = new Element(fieldValidatorElementHandle) { VisualData = new ElementVisualizedData { Label = validator.AttributeName(), ToolTip = validator.AttributeName(), HasChildren = false, Icon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"), OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root") } }; var editActionToken = new WorkflowActionToken(typeof(EditFieldValidatorWorkflow)); fieldValidatorElement.AddAction(new ElementAction(new ActionHandle(editActionToken)) { VisualData = new ActionVisualizedData { Label = "Edit", ToolTip = "Edit", Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"), ActionLocation = ActionLocation } }); var deleteActionToken = new ConfirmWorkflowActionToken("Delete: " + validator.AttributeName(), typeof(DeleteFieldValidatorActionToken)); fieldValidatorElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken)) { VisualData = new ActionVisualizedData { Label = "Delete", ToolTip = "Delete", Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-delete"), ActionLocation = ActionLocation } }); yield return(fieldValidatorElement); } } } } }
public static void UpdateOrder(string formName, string consoleId, string entityToken, string serializedOrder) { var formDefinition = DynamicFormsFacade.GetFormByName(formName); UpdateOrder(formDefinition, serializedOrder); var serializedEntityToken = HttpUtility.UrlDecode(entityToken); if (!String.IsNullOrEmpty(serializedEntityToken)) { UpdateParents(serializedEntityToken, consoleId); } }
private static void UpdateOrder(DynamicFormDefinition formDefinition, string serializedOrder) { var newOrder = ParseNewOrder(serializedOrder); var tmpList = newOrder.OrderBy(i => i.Value).Select(itm => formDefinition.Model.Fields.Get(itm.Key)).ToList(); formDefinition.Model.Fields.Clear(); foreach (var f in tmpList) { formDefinition.Model.Fields.Add(f); } DynamicFormsFacade.SaveForm(formDefinition); }
public override void OnFinish(object sender, EventArgs e) { var name = GetBinding <string>("Name"); var model = new DynamicFormDefinition(name); DynamicFormsFacade.SaveForm(model); var data = ModelReferenceFacade.GetModelReference(name); var token = data.GetDataEntityToken(); var workflowToken = new WorkflowActionToken(typeof(EditFormWorkflow)); CreateSpecificTreeRefresher().PostRefreshMessages(EntityToken); ExecuteAction(token, workflowToken); }
public override void OnInitialize(object sender, EventArgs e) { if (BindingExist("BoundToken")) { return; } Bindings.Add("BoundToken", EntityToken); Bindings.Add("SubmitButtonLabel", GetValue("SubmitButtonLabel")); var modelReference = (IModelReference)((DataEntityToken)EntityToken).Data; var definition = DynamicFormsFacade.GetFormByName(modelReference.Name); SetupFormData(definition, definition.Model); }
public override void OnInitialize(object sender, EventArgs e) { if (BindingExist("Message")) { return; } var token = (FieldValidatorsEntityToken)EntityToken; var definition = DynamicFormsFacade.GetFormByName(token.FormName); var field = definition.Model.Fields.Get(token.FieldName); var validator = field.ValidationAttributes.Single(v => v.GetType().AssemblyQualifiedName == token.Type); Bindings.Add("FieldName", token.FieldName); Bindings.Add("Message", validator.GetValidationMessage(field)); }
public override bool Validate() { var token = (FieldValidatorsEntityToken)EntityToken; var definition = DynamicFormsFacade.GetFormByName(token.FormName); var field = definition.Model.Fields.Get(token.FieldName); var validatorType = Type.GetType(GetBinding <string>("ValidatorType")); if (field.ValidationAttributes.Any(f => f.GetType() == validatorType)) { ShowFieldMessage("ValidatorType", "Validator already exists"); return(false); } return(true); }
public override bool Validate() { var dataSourceToken = (DataSourceEntityToken)EntityToken; var entryValue = GetBinding <string>("EntryValue"); var definition = DynamicFormsFacade.GetFormByName(dataSourceToken.FormName); var field = definition.Model.Fields.Get(dataSourceToken.FieldName); var datasSource = field.DataSource.Select(itm => itm.Key).ToList(); if (datasSource.Any(itm => itm == entryValue)) { ShowFieldMessage("Entry value", "Entry value is not unique"); return(false); } return(true); }
public override void OnFinish(object sender, EventArgs e) { var token = (FieldValidatorsEntityToken)EntityToken; var message = GetBinding <string>("Message"); var definition = DynamicFormsFacade.GetFormByName(token.FormName); var field = definition.Model.Fields.Get(token.FieldName); var validator = field.ValidationAttributes.Single(v => v.GetType().AssemblyQualifiedName == token.Type); using (var writer = ResourceFacade.GetResourceWriter()) { var setting = token.FieldName + ".Validation." + validator.GetType().Name; var key = Localization.GenerateKey(token.FormName, setting); writer.AddResource(key, message); } CreateSpecificTreeRefresher().PostRefreshMessages(EntityToken); SetSaveStatus(true); }
protected override void OnLoad(EventArgs e) { var formName = Request.QueryString["formName"]; if (Request.HttpMethod == "POST") { formName = Request.Form["formName"]; } var formDefinition = DynamicFormsFacade.GetFormByName(formName); Master.CustomJsonDataName = "formName"; Master.CustomJsonDataValue = formName; Master.SortableItems = formDefinition.Model.Fields.Select(i => new SortableItem { Id = i.Name, Name = i.Name }); base.OnLoad(e); }
public override void OnFinish(object sender, EventArgs e) { var dataSourceToken = (DataSourceEntityToken)EntityToken; var entryValue = GetBinding <string>("EntryValue"); var definition = DynamicFormsFacade.GetFormByName(dataSourceToken.FormName); var field = definition.Model.Fields.Get(dataSourceToken.FieldName); var datasSource = field.DataSource.Select(itm => itm.Key).ToList(); datasSource.Add(entryValue); var dataSourceAttribute = field.Attributes.OfType <StringBasedDataSourceAttribute>().First(); field.Attributes.Remove(dataSourceAttribute); dataSourceAttribute = new StringBasedDataSourceAttribute(datasSource.ToArray()); field.Attributes.Add(dataSourceAttribute); DynamicFormsFacade.SaveForm(definition); CreateAddNewTreeRefresher(EntityToken).PostRefreshMessages(new StringBasedDataSourceEntryEntityToken(dataSourceToken.FormName, dataSourceToken.FieldName, entryValue)); }