public static Element CreateErrorElement(string label, string toolTip, string message)
        {
            Element errorElement = new Element(new ElementHandle("DUMMYPROVIDER", new NoSecurityEntityToken()))
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = label,
                    ToolTip     = toolTip,
                    Icon        = ResourceHandle.BuildIconFromDefaultProvider("close"),
                    OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("close"),
                    HasChildren = false
                }
            };


            errorElement.AddAction(new ElementAction(new ActionHandle(new MessageBoxActionToken(
                                                                          label,
                                                                          message,
                                                                          C1Console.Events.DialogType.Error
                                                                          )))
            {
                VisualData = new ActionVisualizedData()
                {
                    Label          = label,
                    ToolTip        = toolTip,
                    Icon           = ResourceHandle.BuildIconFromDefaultProvider("close"),
                    ActionLocation = ActionLocation.OtherPrimaryActionLocation
                }
            });


            return(errorElement);
        }
        private static Element CreateResourceElement(string resourceSet, string label, ElementHandle elementHandle)
        {
            if (String.IsNullOrEmpty(resourceSet))
            {
                var dragAndDropInfo = new ElementDragAndDropInfo(typeof(IResourceKey));

                dragAndDropInfo.AddDropType(typeof(NamespaceFolderEntityToken));
                dragAndDropInfo.SupportsIndexedPosition = false;

                return(new Element(elementHandle, dragAndDropInfo)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label = label,
                        ToolTip = label,
                        HasChildren = false,
                        Icon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                });
            }

            return(new Element(elementHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label = label,
                    ToolTip = label,
                    HasChildren = false,
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                    OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                }
            });
        }
        public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token)
        {
            var dataToken = (DataEntityToken)token;

            if (!(dataToken.Data is IModelReference modelReference))
            {
                yield break;
            }

            var dataId = (ModelReferenceId)modelReference.DataSourceId.DataId;

            if (dataId.Source != typeof(POCOModelsProvider).Name)
            {
                yield break;
            }

            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")
                }
            };

            yield return(fieldsElement);
        }
Пример #4
0
        public IEnumerable <ElementAction> Provide(EntityToken entityToken)
        {
            var addFormActionToken = new WorkflowActionToken(typeof(AddFormWorkflow), new[] { PermissionType.Add });

            yield return(new ElementAction(new ActionHandle(addFormActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = "Add form",
                    ToolTip = "Add form",
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                    ActionLocation = ActionLocation
                }
            });

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

            yield return(new ElementAction(new ActionHandle(addWizardActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = "Add wizard",
                    ToolTip = "Add wizard",
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                    ActionLocation = ActionLocation
                }
            });
        }
Пример #5
0
        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);
                        }
                    }
                }
            }
        }
        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);
            }
        }
Пример #7
0
        private Tree CreateErrorTree(string treeId, string errorMessage)
        {
            var tree = new Tree("ERRORTREE:" + treeId)
            {
                BuildProcessContext = new BuildProcessContext(),
                BuildResult         = new BuildResult()
            };

            tree.AttachmentPoints.Add(
                new EntityTokenAttachmentPoint
            {
                EntityToken = new DeveloperApplicationProviderEntityToken(DeveloperApplicationProviderEntityToken.TreeDefinitionId, treeId),
                Position    = ElementAttachingProviderPosition.Top
            }
                );

            tree.RootTreeNode = new RootTreeNode()
            {
                Id   = "ERRORTREEROOT",
                Tree = tree
            };

            var simpleElementTreeNode = new SimpleElementTreeNode()
            {
                Label   = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "KeyFacade.ErrorTreeNode.Label"),
                Id      = "ERROR",
                ToolTip = errorMessage,
                Icon    = ResourceHandle.BuildIconFromDefaultProvider("close"),
                Tree    = tree
            };

            var messageBoxActionNode = new MessageBoxActionNode
            {
                Id              = 1,
                OwnerNode       = simpleElementTreeNode,
                Label           = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "KeyFacade.ErrorTreeNode.ShowMessage.Label"),
                ToolTip         = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "KeyFacade.ErrorTreeNode.ShowMessage.ToolTip"),
                Icon            = ResourceHandle.BuildIconFromDefaultProvider("log-showlog"),
                Title           = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "KeyFacade.ErrorTreeNode.ShowMessage.Title"),
                Message         = errorMessage,
                DialogType      = DialogType.Error,
                PermissionTypes = new List <PermissionType> {
                    PermissionType.Administrate
                }
            };

            simpleElementTreeNode.AddActionNode(messageBoxActionNode);

            tree.RootTreeNode.AddChildTreeNode(simpleElementTreeNode);

            return(tree);
        }
        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 static Element CreateElement(ElementProviderContext context, string label, string ns)
        {
            var folderHandle  = context.CreateElementHandle(new NamespaceFolderEntityToken(ns));
            var folderElement = new Element(folderHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = label,
                    ToolTip     = label,
                    HasChildren = true,
                    Icon        = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-closed"),
                    OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-open")
                }
            };

            return(folderElement);
        }
Пример #10
0
        protected override IEnumerable <Element> GetRootsImpl(SearchToken searchToken)
        {
            var elementHandle = Context.CreateElementHandle(new FormElementProviderEntityToken());
            var rootElement   = new Element(elementHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = "Forms",
                    ToolTip     = "Forms",
                    HasChildren = true,
                    Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                    OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                }
            };

            return(new[] { rootElement });
        }
Пример #11
0
        public static Element CreateElement(ElementProviderContext context, string source, string label, string ns)
        {
            using (var data = new DataConnection())
            {
                var folderHandle  = context.CreateElementHandle(new NamespaceFolderEntityToken(source, ns));
                var folderElement = new Element(folderHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = label,
                        ToolTip     = label,
                        HasChildren = data.Get <IModelReference>().Any(m => m.Name.StartsWith(ns + ".")),
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-closed"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-open")
                    }
                };

                return(folderElement);
            }
        }
        public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token)
        {
            var folder = (FormFolderEntityToken)token;

            if (folder.FolderType != "Fields")
            {
                yield break;
            }

            var form = ModelsFacade.GetModel(folder.FormName);

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

            if (_entityTokenHandlers == null)
            {
                _entityTokenHandlers = new ProviderContainer <IElementProviderFor>("FormBuilder");
            }

            foreach (var field in form.Fields)
            {
                var elementHandle = context.CreateElementHandle(new FormFieldEntityToken(form.Name, field.Name));
                var fieldElement  = new Element(elementHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = field.Name,
                        ToolTip     = field.Name,
                        HasChildren = _entityTokenHandlers.GetProvidersFor(elementHandle.EntityToken).Any(),
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                };

                yield return(fieldElement);
            }
        }
        public static Element CreateElement(ElementProviderContext context, string label, string resourceSet, string ns)
        {
            var folderHandle = context.CreateElementHandle(new NamespaceFolderEntityToken(resourceSet, ns));

            if (String.IsNullOrEmpty(resourceSet))
            {
                var dragAndDropInfo = new ElementDragAndDropInfo(typeof(NamespaceFolderEntityToken));

                dragAndDropInfo.AddDropType(typeof(NamespaceFolderEntityToken));
                dragAndDropInfo.AddDropType(typeof(IResourceKey));

                dragAndDropInfo.SupportsIndexedPosition = false;

                return(new Element(folderHandle, dragAndDropInfo)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label = label,
                        ToolTip = label,
                        HasChildren = true,
                        Icon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-closed"),
                        OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-open")
                    }
                });
            }

            return(new Element(folderHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label = label,
                    ToolTip = label,
                    HasChildren = true,
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-closed"),
                    OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-open")
                }
            });
        }
Пример #14
0
        public IEnumerable <ElementAction> Provide(EntityToken entityToken)
        {
            var token = (FormSubmitHandlerEntityToken)entityToken;

            var type = Type.GetType(token.Type);

            if (type == null || type != typeof(SaveFormSubmitHandler))
            {
                yield break;
            }

            var downloadActionToken = new DownloadSubmittedFormsActionToken(token.FormName, ".csv");

            yield return(new ElementAction(new ActionHandle(downloadActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = "Download saved forms",
                    ToolTip = "Download saved forms",
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                    ActionLocation = ActionLocation
                }
            });
        }
Пример #15
0
        public IEnumerable <ElementAction> Provide(EntityToken entityToken)
        {
            var token = (FormFieldEntityToken)entityToken;

            var defintion = DynamicFormsFacade.GetFormByName(token.FormName);

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

            var field = defintion.Model.Fields.Get(token.FieldName);

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

            var editActionToken = new WorkflowActionToken(typeof(EditFormFieldWorkflow));

            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 deleteActionToken = new ConfirmWorkflowActionToken("Delete: " + field.Name, typeof(DeleteFormFieldActionToken));

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

            if (!field.Attributes.OfType <DataSourceAttribute>().Any())
            {
                var addDataSourceActionToken = new WorkflowActionToken(typeof(AddDataSourceWorkflow));
                yield return(new ElementAction(new ActionHandle(addDataSourceActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = "Add datasource",
                        ToolTip = "Add datasource",
                        Icon = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                        ActionLocation = ActionLocation
                    }
                });
            }
        }
        private static IEnumerable <Element> GetNamespaceAndResourceElements(ElementProviderContext context, string ns)
        {
            var resources = LocalizationsFacade.GetResourceKeys(ns);

            var folders  = new List <string>();
            var elements = new List <Element>();

            foreach (var key in resources)
            {
                var label = key.Key;

                if (label == ns)
                {
                    continue;
                }

                var labelParts = label.Split('.');

                if (!String.IsNullOrEmpty(ns))
                {
                    var nsParts = ns.Split('.');

                    if (nsParts.Length > labelParts.Length)
                    {
                        continue;
                    }

                    labelParts = labelParts.Skip(nsParts.Length).ToArray();
                    label      = String.Join(".", labelParts);
                }

                if (labelParts.Length > 1)
                {
                    var folder = labelParts[0];

                    if (!folders.Contains(folder))
                    {
                        folders.Add(folder);
                    }
                }
                else if (labelParts.Length == 1)
                {
                    var token = key.GetDataEntityToken();

                    var dragAndDropInfo = new ElementDragAndDropInfo(typeof(IResourceKey));

                    dragAndDropInfo.AddDropType(typeof(NamespaceFolderEntityToken));
                    dragAndDropInfo.SupportsIndexedPosition = false;

                    var elementHandle = context.CreateElementHandle(token);
                    var element       = new Element(elementHandle, dragAndDropInfo)
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label       = label,
                            ToolTip     = label,
                            HasChildren = false,
                            Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                            OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                        }
                    };

                    var editActionToken = new WorkflowActionToken(typeof(EditResourceWorkflow), new[] { PermissionType.Edit });
                    element.AddAction(new ElementAction(new ActionHandle(editActionToken))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = "Edit",
                            ToolTip        = "Edit",
                            Icon           = new ResourceHandle("Composite.Icons", "generated-type-data-edit"),
                            ActionLocation = Actions.ActionLocation
                        }
                    });

                    var deleteActionToken = new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteResourceActionToken));
                    element.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = "Delete",
                            ToolTip        = "Delete",
                            Icon           = new ResourceHandle("Composite.Icons", "generated-type-data-delete"),
                            ActionLocation = Actions.ActionLocation
                        }
                    });

                    elements.Add(element);
                }
            }

            foreach (var folder in folders.OrderBy(f => f))
            {
                var handleNamespace = folder;
                if (!String.IsNullOrEmpty(ns))
                {
                    handleNamespace = ns + "." + handleNamespace;
                }

                var folderElement = NamespaceFolderEntityToken.CreateElement(context, folder, handleNamespace);

                var deleteActionToken = new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteNamespaceActionToken));
                folderElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Delete",
                        ToolTip        = "Delete",
                        Icon           = new ResourceHandle("Composite.Icons", "generated-type-data-delete"),
                        ActionLocation = Actions.ActionLocation
                    }
                });

                folderElement.AddAction(Actions.GetAddAction());
                folderElement.AddAction(Actions.GetExportAction());

                yield return(folderElement);
            }

            foreach (var el in elements)
            {
                yield return(el);
            }
        }
        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
                }
            });
        }
        public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token)
        {
            var dependencyToken = (FieldDependencyEntityToken)token;
            var form            = DynamicFormsFacade.GetFormByName(dependencyToken.FormName);

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

            var field = form.Model.Fields.Get(dependencyToken.FieldName);

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

            if (String.IsNullOrEmpty(dependencyToken.FromFieldName))
            {
                foreach (var dependency in field.DependencyAttributes)
                {
                    var fromFieldName = dependency.ReadFromFieldName;

                    var fieldDependencyElementHandle = context.CreateElementHandle(new FieldDependencyEntityToken(form.Name, field.Name, fromFieldName));
                    var fieldDependencyElement       = new Element(fieldDependencyElementHandle)
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label       = fromFieldName,
                            ToolTip     = fromFieldName,
                            HasChildren = dependency.ResolveRequiredFieldValues().Any(),
                            Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                            OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                        }
                    };

                    var editActionToken = new WorkflowActionToken(typeof(EditFieldDependencyWorkflow), new[] { PermissionType.Edit });
                    fieldDependencyElement.AddAction(new ElementAction(new ActionHandle(editActionToken))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = "Edit dependency",
                            ToolTip        = "Edit dependency",
                            Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                            ActionLocation = ActionLocation
                        }
                    });

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

                    var deleteActionToken = new ConfirmWorkflowActionToken("Delete: " + fromFieldName, typeof(DeleteFieldDependencyActionToken));
                    fieldDependencyElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = "Delete",
                            ToolTip        = "Delete",
                            Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-delete"),
                            ActionLocation = ActionLocation
                        }
                    });

                    yield return(fieldDependencyElement);
                }
            }
            else
            {
                var dependency = field.DependencyAttributes.SingleOrDefault(d => d.ReadFromFieldName == dependencyToken.FromFieldName);
                if (dependency == null)
                {
                    yield break;
                }

                foreach (var value in dependency.ResolveRequiredFieldValues())
                {
                    var fieldDependencyValueElementHandle = context.CreateElementHandle(new FieldDependencyValueEntityToken(form.Name, field.Name, dependency.ReadFromFieldName, value.ToString()));
                    var fieldDependencyValueElement       = new Element(fieldDependencyValueElementHandle)
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label       = value.ToString(),
                            ToolTip     = value.ToString(),
                            HasChildren = false,
                            Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                            OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                        }
                    };

                    var deleteActionToken = new ConfirmWorkflowActionToken("Delete: " + value, typeof(DeleteFieldDependencyValueActionToken));
                    fieldDependencyValueElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = "Delete",
                            ToolTip        = "Delete",
                            Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-delete"),
                            ActionLocation = ActionLocation
                        }
                    });

                    yield return(fieldDependencyValueElement);
                }
            }
        }
        public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token)
        {
            var fieldToken = (FormFieldEntityToken)token;
            var form       = DynamicFormsFacade.GetFormByName(fieldToken.FormName);

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

            var field = form.Model.Fields.Get(fieldToken.FieldName);

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

            var fieldValidatorsElementHandle = context.CreateElementHandle(new FieldValidatorsEntityToken(form.Name, field.Name));
            var fieldValidatorsElement       = new Element(fieldValidatorsElementHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = "Validators",
                    ToolTip     = "Validators",
                    HasChildren = field.ValidationAttributes.Any(),
                    Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                    OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                }
            };

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

            fieldValidatorsElement.AddAction(new ElementAction(new ActionHandle(addValidatorActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = "Add validator",
                    ToolTip        = "Add validator",
                    Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                    ActionLocation = ActionLocation
                }
            });

            yield return(fieldValidatorsElement);

            var fieldDependencyElementHandle = context.CreateElementHandle(new FieldDependencyEntityToken(form.Name, field.Name));
            var fieldDependencyElement       = new Element(fieldDependencyElementHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = "Dependencies",
                    ToolTip     = "Dependencies",
                    HasChildren = field.DependencyAttributes.Any(),
                    Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                    OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                }
            };

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

            fieldDependencyElement.AddAction(new ElementAction(new ActionHandle(addDependencyActionToken))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = "Add dependency",
                    ToolTip        = "Add dependency",
                    Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                    ActionLocation = ActionLocation
                }
            });

            yield return(fieldDependencyElement);

            var datasourceAttribute = field.Attributes.OfType <DataSourceAttribute>().FirstOrDefault();

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

            var fieldsElementHandle = context.CreateElementHandle(new DataSourceEntityToken(datasourceAttribute.GetType(), form.Name, field.Name));
            var fieldElement        = new Element(fieldsElementHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = "Datasource",
                    ToolTip     = "Datasource",
                    HasChildren = true,
                    Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                    OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                }
            };

            var deleteActionToken = new ConfirmWorkflowActionToken("Delete datasource", typeof(DeleteDataSourceActionToken));

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

            if (datasourceAttribute.GetType() == typeof(StringBasedDataSourceAttribute))
            {
                var addActionToken = new WorkflowActionToken(typeof(AddStringBasedDataSourceEntryWorkflow), new[] { PermissionType.Add });
                fieldElement.AddAction(new ElementAction(new ActionHandle(addActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Add value",
                        ToolTip        = "Add value",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-edit"),
                        ActionLocation = ActionLocation
                    }
                });
            }

            yield return(fieldElement);
        }
Пример #20
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);
        }
        public static IEnumerable <Element> GetNamespaceAndFormElements(ElementProviderContext context, string ns)
        {
            using (var data = new DataConnection())
            {
                var allModelReferences = data.Get <IModelReference>();

                var folders      = new List <string>();
                var formElements = new List <Element>();

                if (String.IsNullOrEmpty(ns))
                {
                    var homepageIds = data.Get <IPageStructure>().Where(s => s.ParentId == Guid.Empty).Select(s => s.Id);
                    if (homepageIds.Count() > 1)
                    {
                        folders.AddRange(homepageIds
                                         .Select(id => PageManager.GetPageById(id))
                                         .Select(page => SanatizeFormName(page.Title)));
                    }
                }
                else
                {
                    allModelReferences = allModelReferences.Where(def => def.Name.StartsWith(ns + "."));
                }

                foreach (var modelReference in allModelReferences)
                {
                    var label = modelReference.Name;

                    if (!String.IsNullOrEmpty(ns))
                    {
                        label = label.Remove(0, ns.Length + 1);
                    }

                    var split = label.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                    if (split.Length > 1)
                    {
                        var folder = split[0];

                        if (!folders.Contains(folder))
                        {
                            folders.Add(folder);
                        }
                    }
                    else if (split.Length == 1)
                    {
                        var token = modelReference.GetDataEntityToken();

                        var elementHandle = context.CreateElementHandle(token);
                        var formElement   = new Element(elementHandle)
                        {
                            VisualData = new ElementVisualizedData
                            {
                                Label       = label,
                                ToolTip     = label,
                                HasChildren = true,
                                Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                                OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                            }
                        };

                        formElements.Add(formElement);
                    }
                }

                foreach (var folder in folders.OrderBy(f => f))
                {
                    var handleNamespace = folder;
                    if (!String.IsNullOrEmpty(ns))
                    {
                        handleNamespace = ns + "." + handleNamespace;
                    }

                    var folderElement = NamespaceFolderEntityToken.CreateElement(context, typeof(FormBuilderElementProvider).Name, folder, handleNamespace);

                    yield return(folderElement);
                }

                foreach (var form in formElements)
                {
                    yield return(form);
                }
            }
        }
        public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token)
        {
            var returnList = new List <Element>();

            var dataSourceToken = (DataSourceEntityToken)token;
            var type            = Type.GetType(dataSourceToken.Type);

            if (type != typeof(StringBasedDataSourceAttribute))
            {
                return(returnList);
            }

            var form = DynamicFormsFacade.GetFormByName(dataSourceToken.FormName);

            if (form == null)
            {
                return(returnList);
            }

            var field = form.Model.Fields.Get(dataSourceToken.FieldName);

            if (field == null)
            {
                return(returnList);
            }

            var dataSource = field.DataSource;

            if (dataSource == null)
            {
                return(returnList);
            }

            foreach (var entry in dataSource)
            {
                var fieldsElementHandle = context.CreateElementHandle(new StringBasedDataSourceEntryEntityToken(form.Name, field.Name, entry.Key));
                var fieldElement        = new Element(fieldsElementHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = entry.Key,
                        ToolTip     = entry.Key,
                        HasChildren = false,
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                };

                var deleteActionToken = new ConfirmWorkflowActionToken("Delete: " + entry.Key, typeof(DeleteStringBasedDataSourceEntryActionToken));
                fieldElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Delete",
                        ToolTip        = "Delete",
                        Icon           = ResourceHandle.BuildIconFromDefaultProvider("generated-type-data-delete"),
                        ActionLocation = ActionLocation
                    }
                });

                returnList.Add(fieldElement);
            }

            return(returnList);
        }