public override void OnFinish(object sender, EventArgs e)
        {
            var token = (FormFolderEntityToken)EntityToken;

            var name = GetBinding <string>("Name");
            var type = GetBinding <string>("SubmitHandlerType");

            var definition  = DefinitionsFacade.GetDefinition(token.FormName);
            var handlerType = Type.GetType(type);
            var instance    = (FormSubmitHandler)Activator.CreateInstance(handlerType);

            instance.Name = name;

            definition.SubmitHandlers.Add(instance);

            DefinitionsFacade.Save(definition);

            CreateSpecificTreeRefresher().PostRefreshMessages(token);

            var editWorkFlowAttribute = handlerType.GetCustomAttribute <EditWorkflowAttribute>();

            if (editWorkFlowAttribute != null)
            {
                var workflowToken = new WorkflowActionToken(editWorkFlowAttribute.EditWorkflowType);

                ExecuteAction(new FormSubmitHandlerEntityToken(handlerType, token.FormName, name), workflowToken);
            }
        }
        public override bool Validate()
        {
            var token      = (FormFolderEntityToken)EntityToken;
            var definition = DefinitionsFacade.GetDefinition(token.FormName);

            var name = GetBinding <string>("Name");

            if (definition.SubmitHandlers.Any(e => e.Name == name))
            {
                ShowFieldMessage("Name", "A handler with this name already exists");

                return(false);
            }

            var type        = GetBinding <string>("SubmitHandlerType");
            var handlerType = Type.GetType(type);
            var element     = Handlers.Single(e => e.Type == handlerType);

            if (element.AllowMultiple)
            {
                return(true);
            }

            if (definition.SubmitHandlers.Any(handler => handler.GetType() == handlerType))
            {
                ShowFieldMessage("SubmitHandlerType", "The chosen handler is only allowed once");

                return(false);
            }

            return(true);
        }
Exemple #3
0
        private EmailSubmitHandler GetHandler()
        {
            var token      = (FormSubmitHandlerEntityToken)EntityToken;
            var definition = DefinitionsFacade.GetDefinition(token.FormName);

            return((EmailSubmitHandler)definition.SubmitHandlers.Single(h => h.Name == token.Name));
        }
        private IEnumerable <Element> getFormSubmitHandlerElements(ElementProviderContext context, FormFolderEntityToken folder)
        {
            var definition = DefinitionsFacade.GetDefinition(folder.FormName);

            if (definition == null)
            {
                yield break;
            }

            foreach (var handler in definition.SubmitHandlers)
            {
                var elementHandle  = context.CreateElementHandle(new FormSubmitHandlerEntityToken(handler.GetType(), folder.FormName, handler.Name));
                var handlerElement = new Element(elementHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = handler.Name,
                        ToolTip     = handler.Name,
                        HasChildren = false,
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                };

                var editWorkflowAttribute = handler.GetType().GetCustomAttributes(true).OfType <EditWorkflowAttribute>().FirstOrDefault();
                if (editWorkflowAttribute != null)
                {
                    var editActionToken = new WorkflowActionToken(editWorkflowAttribute.EditWorkflowType);
                    handlerElement.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: " + handler.Name, typeof(DeleteSubmitHandlerActionToken));
                handlerElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Delete",
                        ToolTip        = "Delete",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-delete"),
                        ActionLocation = ActionLocation
                    }
                });

                yield return(handlerElement);
            }
        }
        public override void OnFinish(object sender, EventArgs e)
        {
            var modelReference = (IModelReference)((DataEntityToken)EntityToken).Data;
            var newName        = GetBinding <string>("Name");
            var definition     = DefinitionsFacade.GetDefinition(modelReference.Name);

            DefinitionsFacade.Copy(definition, newName);

            LocalizationsFacade.CopyNamespace(Localization.KeyPrefix + "." + modelReference.Name, Localization.KeyPrefix + "." + newName, Localization.ResourceSet);

            CreateSpecificTreeRefresher().PostRefreshMessages(new FormElementProviderEntityToken());
        }
        private IEnumerable <Element> getWizardStepElements(ElementProviderContext context, FormFolderEntityToken folder)
        {
            var wizard = (DynamicWizardDefinition)DefinitionsFacade.GetDefinition(folder.FormName);

            if (wizard == null)
            {
                yield break;
            }

            foreach (var step in wizard.Model.Steps)
            {
                var elementHandle     = context.CreateElementHandle(new FormWizardStepEntityToken(wizard.Name, step.Name));
                var wizardStepElement = new Element(elementHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = step.Name,
                        ToolTip     = step.Name,
                        HasChildren = false,
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                };

                var editActionToken = new WorkflowActionToken(typeof(EditWizardStepWorkflow));
                wizardStepElement.AddAction(new ElementAction(new ActionHandle(editActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Edit step",
                        ToolTip        = "Edit step",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                        ActionLocation = ActionLocation
                    }
                });

                var deleteActionToken = new ConfirmWorkflowActionToken("Delete step", typeof(DeleteFormWizardStepActionToken));
                wizardStepElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Delete step",
                        ToolTip        = "Delete step",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-delete"),
                        ActionLocation = ActionLocation
                    }
                });

                yield return(wizardStepElement);
            }
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var modelReference = (IModelReference)((DataEntityToken)entityToken).Data;
            var definition     = DefinitionsFacade.GetDefinition(modelReference.Name);

            DefinitionsFacade.Delete(definition);
            LocalizationsFacade.DeleteNamespace(Localization.GenerateKey(modelReference.Name));

            var ns = modelReference.Name.Substring(0, modelReference.Name.LastIndexOf("."));

            new SpecificTreeRefresher(flowControllerServicesContainer).PostRefreshMessages(new NamespaceFolderEntityToken(typeof(FormBuilderElementProvider).Name, ns));

            return(null);
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var token      = (FormSubmitHandlerEntityToken)entityToken;
            var definition = DefinitionsFacade.GetDefinition(token.FormName);
            var handler    = definition.SubmitHandlers.Single(h => h.Name == token.Name);

            definition.SubmitHandlers.Remove(handler);

            handler.Delete(definition);

            var serializer = XmlDefinitionSerializer.GetSerializer(definition.Name);

            serializer.Save(definition);

            new ParentTreeRefresher(flowControllerServicesContainer).PostRefreshMessages(entityToken);

            return(null);
        }
        public IEnumerable <ElementAction> Provide(EntityToken entityToken)
        {
            var dataEntityToken = (DataEntityToken)entityToken;

            var modelReference = dataEntityToken.Data as IModelReference;

            if (modelReference == null)
            {
                yield break;
            }

            var def = DefinitionsFacade.GetDefinition(modelReference.Name);

            if (def == null)
            {
                yield break;
            }

            if (def is DynamicFormDefinition)
            {
                var editActionToken = new WorkflowActionToken(typeof(EditFormWorkflow));
                yield return(new ElementAction(new ActionHandle(editActionToken))
                {
                    TagValue = "edit",

                    VisualData = new ActionVisualizedData
                    {
                        Label = "Edit",
                        ToolTip = "Edit",
                        Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                        ActionLocation = ActionLocation
                    }
                });

                var editRenderingLayoutActionToken = new WorkflowActionToken(typeof(EditFormRenderingLayoutWorkflow));
                yield return(new ElementAction(new ActionHandle(editRenderingLayoutActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = "Edit rendering layout",
                        ToolTip = "Edit rendering layout",
                        Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                        ActionLocation = ActionLocation
                    }
                });
            }

            if (def is DynamicWizardDefinition)
            {
                var editActionToken = new WorkflowActionToken(typeof(EditFormWizardWorkflow));
                yield return(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: " + modelReference.Name, typeof(DeleteFormActionToken));

            yield return(new ElementAction(new ActionHandle(deleteActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = "Delete",
                    ToolTip = "Delete",
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-delete"),
                    ActionLocation = ActionLocation
                }
            });

            var copyActionToken = new WorkflowActionToken(typeof(CopyFormWorkflow));

            yield return(new ElementAction(new ActionHandle(copyActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = "Copy",
                    ToolTip = "Copy",
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                    ActionLocation = ActionLocation
                }
            });
        }
Exemple #10
0
        public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token)
        {
            var modelReference = (IModelReference)((DataEntityToken)token).Data;

            if (modelReference == null)
            {
                yield break;
            }

            var def = DefinitionsFacade.GetDefinition(modelReference.Name);

            if (def == null)
            {
                yield break;
            }

            if (def is DynamicFormDefinition)
            {
                var fieldsElementHandle = context.CreateElementHandle(new FormFolderEntityToken(modelReference.Name, "Fields"));
                var fieldsElement       = new Element(fieldsElementHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = "Fields",
                        ToolTip     = "Fields",
                        HasChildren = true,
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                };

                var addActionToken = new WorkflowActionToken(typeof(AddFormFieldWorkflow), new[] { PermissionType.Add });
                fieldsElement.AddAction(new ElementAction(new ActionHandle(addActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Add field",
                        ToolTip        = "Add field",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                        ActionLocation = ActionLocation
                    }
                });

                var url             = String.Format("InstalledPackages/CompositeC1Contrib.FormBuilder.Dynamic/SortFormFields.aspx?formName={0}", modelReference.Name);
                var sortActionToken = new UrlActionToken("Sort fields", UrlUtils.ResolveAdminUrl(url), new[] { PermissionType.Edit });
                fieldsElement.AddAction(new ElementAction(new ActionHandle(sortActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Sort fields",
                        ToolTip        = "Sort fields",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("cut"),
                        ActionLocation = ActionLocation
                    }
                });

                yield return(fieldsElement);
            }

            if (def is DynamicWizardDefinition)
            {
                var stepsFolderElementHandle = context.CreateElementHandle(new FormFolderEntityToken(modelReference.Name, "Steps"));
                var stepsFolderElement       = new Element(stepsFolderElementHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = "Steps",
                        ToolTip     = "Steps",
                        HasChildren = true,
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                };

                var addActionToken = new WorkflowActionToken(typeof(AddWizardStepWorkflow), new[] { PermissionType.Add });
                stepsFolderElement.AddAction(new ElementAction(new ActionHandle(addActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Add step",
                        ToolTip        = "Add step",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                        ActionLocation = ActionLocation
                    }
                });

                var url             = String.Format("InstalledPackages/CompositeC1Contrib.FormBuilder.Dynamic/SortWizardSteps.aspx?wizardName={0}", modelReference.Name);
                var sortActionToken = new UrlActionToken("Sort fields", UrlUtils.ResolveAdminUrl(url), new[] { PermissionType.Edit });
                stepsFolderElement.AddAction(new ElementAction(new ActionHandle(sortActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Sort steps",
                        ToolTip        = "Sort steps",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("cut"),
                        ActionLocation = ActionLocation
                    }
                });

                yield return(stepsFolderElement);
            }

            var submitHandlersElementHandle = context.CreateElementHandle(new FormFolderEntityToken(modelReference.Name, "SubmitHandlers"));
            var submitHandlersElement       = new Element(submitHandlersElementHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = "Submit handlers",
                    ToolTip     = "Submit handlers",
                    HasChildren = true,
                    Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                    OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                }
            };

            var submitHandlerActionToken = new WorkflowActionToken(typeof(AddSubmitHandlerWorkflow), new[] { PermissionType.Add });

            submitHandlersElement.AddAction(new ElementAction(new ActionHandle(submitHandlerActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = "Add submit handler",
                    ToolTip        = "Add submit handler",
                    Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                    ActionLocation = ActionLocation
                }
            });

            yield return(submitHandlersElement);
        }
Exemple #11
0
        private IDynamicDefinition GetDefinition()
        {
            var token = (FormSubmitHandlerEntityToken)EntityToken;

            return(DefinitionsFacade.GetDefinition(token.FormName));
        }