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); } }
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 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); }
public IEnumerable <Element> GetChildren(EntityToken entityToken, SearchToken searchToken) { var monitoringApi = JobStorage.Current.GetMonitoringApi(); var connection = JobStorage.Current.GetConnection(); var statistics = monitoringApi.GetStatistics(); var folderToken = entityToken as FolderEntityToken; if (folderToken != null) { if (folderToken.TaskType == TaskType.Recurring) { foreach (var job in connection.GetRecurringJobs()) { var recurringTaskElementHandle = _context.CreateElementHandle(new TaskEntityToken(TaskType.Recurring, job.Id)); var recurringTaskElement = new Element(recurringTaskElementHandle) { VisualData = new ElementVisualizedData { Label = job.Id, ToolTip = job.Id, HasChildren = false, Icon = new ResourceHandle("Composite.Icons", "localization-element-closed-root"), OpenedIcon = new ResourceHandle("Composite.Icons", "localization-element-opened-root") } }; var triggerActionToken = new TriggerRecurringTaskActionToken(); recurringTaskElement.AddAction(new ElementAction(new ActionHandle(triggerActionToken)) { VisualData = new ActionVisualizedData { Label = "Trigger now", ToolTip = "Trigger now", Icon = new ResourceHandle("Composite.Icons", "localization-element-closed-root"), ActionLocation = ActionLocation } }); var deleteActionToken = new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteRecurringTaskActionToken)); recurringTaskElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken)) { VisualData = new ActionVisualizedData { Label = "Delete", ToolTip = "Delete", Icon = new ResourceHandle("Composite.Icons", "generated-type-data-delete"), ActionLocation = ActionLocation } }); yield return(recurringTaskElement); } } if (folderToken.TaskType == TaskType.Scheduled) { foreach (var job in monitoringApi.ScheduledJobs(0, int.MaxValue)) { var scheduledTaskElementHandle = _context.CreateElementHandle(new TaskEntityToken(TaskType.Scheduled, job.Key)); var scheduledTaskElement = new Element(scheduledTaskElementHandle) { VisualData = new ElementVisualizedData { Label = DisplayJob(job.Value.Job), ToolTip = DisplayJob(job.Value.Job), HasChildren = false, Icon = new ResourceHandle("Composite.Icons", "localization-element-closed-root"), OpenedIcon = new ResourceHandle("Composite.Icons", "localization-element-opened-root") } }; var requeueActionToken = new RequeueScheduledTaskActionToken(); scheduledTaskElement.AddAction(new ElementAction(new ActionHandle(requeueActionToken)) { VisualData = new ActionVisualizedData { Label = "Enqueue now", ToolTip = "Enqueue now", Icon = new ResourceHandle("Composite.Icons", "localization-element-closed-root"), ActionLocation = ActionLocation } }); var deleteActionToken = new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteScheduledTaskActionToken)); scheduledTaskElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken)) { VisualData = new ActionVisualizedData { Label = "Delete", ToolTip = "Delete", Icon = new ResourceHandle("Composite.Icons", "generated-type-data-delete"), ActionLocation = ActionLocation } }); yield return(scheduledTaskElement); } } } if (entityToken is ScheduledTasksElementProviderEntityToken) { var recurringTasksElementHandle = _context.CreateElementHandle(new FolderEntityToken(TaskType.Recurring)); var recurringTasksElement = new Element(recurringTasksElementHandle) { VisualData = new ElementVisualizedData { Label = "Recurring tasks", ToolTip = "Recurring tasks", HasChildren = statistics.Recurring > 0, Icon = new ResourceHandle("Composite.Icons", "localization-element-closed-root"), OpenedIcon = new ResourceHandle("Composite.Icons", "localization-element-opened-root") } }; if (statistics.Recurring > 0) { recurringTasksElement.VisualData.Label += " (" + statistics.Recurring + ")"; } AddViewAction(TaskType.Recurring, recurringTasksElement); yield return(recurringTasksElement); var scheduledTasksElementHandle = _context.CreateElementHandle(new FolderEntityToken(TaskType.Scheduled)); var scheduledTasksElement = new Element(scheduledTasksElementHandle) { VisualData = new ElementVisualizedData { Label = "Scheduled tasks", ToolTip = "Scheduled tasks", HasChildren = statistics.Scheduled > 0, Icon = new ResourceHandle("Composite.Icons", "localization-element-closed-root"), OpenedIcon = new ResourceHandle("Composite.Icons", "localization-element-opened-root") } }; if (statistics.Scheduled > 0) { scheduledTasksElement.VisualData.Label += " (" + statistics.Scheduled + " )"; } AddViewAction(TaskType.Scheduled, scheduledTasksElement); yield return(scheduledTasksElement); } }
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); }
private void AddTeaserInstances(EntityToken entityToken, List <Element> list, PageTeaserPositionFolderEntityToken folderToken) { var page = PageManager.GetPageById(new Guid(entityToken.Source)); var instances = TeaserFacade.GetPageTeasers(page, folderToken.Id, false); foreach (var instance in instances) { var attributes = instance.DataSourceId.InterfaceType.GetCustomAttributes(true).ToList(); var icon = new ResourceHandle("Composite.Icons", "dataassociation-rootfolder-closed"); var openedIcon = new ResourceHandle("Composite.Icons", "dataassociation-rootfolder-open"); var iconAttribute = attributes.OfType <IconAttribute>().FirstOrDefault(); if (iconAttribute != null) { icon = new ResourceHandle("Composite.Icons", iconAttribute.Name); if (!String.IsNullOrEmpty(iconAttribute.OpenedName)) { openedIcon = new ResourceHandle("Composite.Icons", iconAttribute.OpenedName); } } var label = StringResourceSystemFacade.GetString("CompositeC1Contrib.Teasers", "TeaserElementAttachingProvider.NoLabel"); try { label = instance.GetLabel(); } catch (Exception) { } var elementHandle = _context.CreateElementHandle(new PageTeaserInstanceEntityToken(page, instance)); var teaserElement = new Element(elementHandle) { VisualData = new ElementVisualizedData { Label = label, ToolTip = label, HasChildren = false, Icon = icon, OpenedIcon = openedIcon } }; var editWorkflowAttribute = attributes.OfType <EditWorkflowAttribute>().FirstOrDefault(); if (editWorkflowAttribute != null) { var editActionToken = new WorkflowActionToken(editWorkflowAttribute.EditWorkflowType, new[] { PermissionType.Edit }); teaserElement.AddAction(new ElementAction(new ActionHandle(editActionToken)) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("CompositeC1Contrib.Teasers", "TeaserElementAttachingProvider.Edit.Label"), ToolTip = StringResourceSystemFacade.GetString("CompositeC1Contrib.Teasers", "TeaserElementAttachingProvider.Edit.ToolTip"), Icon = new ResourceHandle("Composite.Icons", "generated-type-data-edit"), ActionLocation = ActionLocation } }); } var deleteActionToken = new ConfirmWorkflowActionToken(StringResourceSystemFacade.GetString("CompositeC1Contrib.Teasers", "TeaserElementAttachingProvider.DeleteItem") + label, typeof(DeletePageTeaserActionToken)); teaserElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken)) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("CompositeC1Contrib.Teasers", "TeaserElementAttachingProvider.Delete.Label"), ToolTip = StringResourceSystemFacade.GetString("CompositeC1Contrib.Teasers", "TeaserElementAttachingProvider.Delete.ToolTip"), Icon = new ResourceHandle("Composite.Icons", "generated-type-data-delete"), ActionLocation = ActionLocation } }); list.Add(teaserElement); } }
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 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 } }); } }