/// <summary> /// Creates and returns the <see cref="BaseItemsControlPage{TClass}.DataPresenter"/> /// </summary> /// <returns></returns> protected override IItemsControl <PropertyMap> CreateItemsControl() { return(new CollapsibleDataGrid <PropertyMap>() { Mapper = CeidDiplomatikiDataModelHelpers.PropertyMapMapper.Value } .ShowData(x => x.TableName) .ShowData(x => x.ColumnName) .ShowData(x => x.ValueType) .ShowData(x => x.Name) .ShowData(x => x.Description) .ShowData(x => x.Attributes) .ShowData(x => x.Color) .ShowData(x => x.DefaultValue) .ShowData(x => x.Order) .ShowData(x => x.IsEditable) .ShowData(x => x.IsRequired) .ShowData(x => x.IsPreview) .SetColorUIElement(x => x.Color) .SetLabelUIElement(x => x.ValueType, model => model.ValueType.ToLocalizedString(), model => model.ValueType.ToColorHex()) .SetBooleanUIElement(x => x.IsEditable) .SetBooleanUIElement(x => x.IsRequired) .SetBooleanUIElement(x => x.IsPreview) .SetSubElement(x => x.Attributes, model => model.Attributes?.Count().ToString("attribute", "attributes", "No attributes"), async(row, model) => { var itemsControl = new WrapPanelItemsControl <ColumnAttribute, BorderedTextBlock>(x => { var label = ControlsFactory.CreateLabelTag(x.Name, x.Color); label.Margin = new Thickness(NormalUniformMargin); return label; }) { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center }; itemsControl.SetItemsSource(model.Attributes); return await Task.FromResult(itemsControl); }, (row, model, element) => element.SetItemsSource(model.Attributes)) .SetTextInputUIElement(x => x.Order, async(row, model, value) => { var result = await CeidDiplomatikiDI.GetCeidDiplomatikiManager.SaveChangesAsync(); return new Failable <PropertyMap>() { ErrorMessage = result.ErrorMessage }; }) .ConfigureOptions((container, grid, row, model) => { container.AddEditOption("Property map modification", null, () => { return new DataForm <PropertyMap>() { Mapper = CeidDiplomatikiDataModelHelpers.PropertyMapMapper.Value } .ShowInput(x => x.Name, settings => settings.IsRequired = true) .ShowInput(x => x.Description) .ShowStringColorInput(x => x.Color) .ShowSelectMultipleOptionsInput(x => x.Attributes, (form, propertyInfo) => new DropDownMenuOptionsFormInput <ColumnAttribute>(form, propertyInfo, ColumnAttributes.Data.Value, x => x.Name), settings => settings.IsRequired = true) .ShowNumericInput(x => x.Order) .ShowInput(x => x.DefaultValue) .ShowInput(x => x.IsEditable) .ShowInput(x => x.IsRequired) .ShowInput(x => x.IsPreview); }, async(model) => await CeidDiplomatikiDI.GetCeidDiplomatikiManager.SaveChangesAsync(), null, IconPaths.TableColumnPath); container.AddDeleteOption("Property map deletion", null, async(model) => { // Get the manager var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager; // Unregister the map QueryMap.Remove(model); // Save the changes return await manager.SaveChangesAsync(); }, null, IconPaths.TableColumnPath); })); }