Ejemplo n.º 1
0
 public override IDisplayResult Edit(TimeField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditTimeFieldViewModel>(GetEditorShapeType(context), model =>
     {
         model.Value = field.Value;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
Ejemplo n.º 2
0
        // NEXT STATION: Take a look at the Views/ColorField.cshtml shape to see how our field should display the given
        // color and then come back here.

        public override IDisplayResult Edit(ColorField field, BuildFieldEditorContext context) =>
        // Nothing new here, the Initialize shape helper is being used to generate an editor shape.
        Initialize <EditColorFieldViewModel>(GetEditorShapeType(context), model =>
        {
            model.Value               = field.Value;
            model.ColorName           = field.ColorName;
            model.Field               = field;
            model.Part                = context.ContentPart;
            model.PartFieldDefinition = context.PartFieldDefinition;
        });
Ejemplo n.º 3
0
 public override IDisplayResult Edit(HtmlField field, BuildFieldEditorContext context)
 {
     return(Shape <EditHtmlFieldViewModel>("HtmlField_Edit", model =>
     {
         model.Html = field.Html;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
 public override IDisplayResult Edit(DateTimeField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditDateTimeFieldViewModel>(GetEditorShapeType(context), async model =>
     {
         model.LocalDateTime = field.Value == null ? (DateTime?)null : (await _localClock.ConvertToLocalAsync(field.Value.Value)).DateTime;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
 public override IDisplayResult Edit(BooleanField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditBooleanFieldViewModel>("BooleanField_Edit", model =>
     {
         model.Value = field.Value;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
Ejemplo n.º 6
0
 public override IDisplayResult Edit(MarkdownField field, BuildFieldEditorContext context)
 {
     return(Shape <EditMarkdownFieldViewModel>("MarkdownField_Edit", model =>
     {
         model.Markdown = field.Markdown;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
Ejemplo n.º 7
0
        private IList <DictionaryItem> GetDefaults(BuildFieldEditorContext context)
        {
            var settingsValue = GetSettings(context)?.DefaultData;

            if (settingsValue != null)
            {
                return(JsonConvert.DeserializeObject <IList <DictionaryItem> >(settingsValue));
            }
            return(new List <DictionaryItem>());
        }
        public override IDisplayResult Edit(MultiSelectField field, BuildFieldEditorContext context)
        {
            return(Initialize <EditMultiSelectFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;

                model.SelectedValues = field.SelectedValues;
            }));
        }
        public override IDisplayResult Edit(UniqueIdentifierField field, BuildFieldEditorContext context)
        {
            return(Initialize <UniqueIdentifierFieldViewModel>("UniqueIdentifierField_Edit", model =>
            {
                model.IdentifierValue = field.IdentifierValue;

                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
 public override IDisplayResult Edit(GeoPointField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditGeoPointFieldViewModel>(GetEditorShapeType(context), model =>
     {
         model.Latitude = Convert.ToString(field.Latitude, CultureInfo.InvariantCulture);
         model.Longitude = Convert.ToString(field.Longitude, CultureInfo.InvariantCulture);
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
 public override IDisplayResult Edit(YoutubeField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditYoutubeFieldViewModel>(GetEditorShapeType(context), model =>
     {
         model.RawAddress = field.RawAddress;
         model.EmbeddedAddress = field.EmbeddedAddress;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
Ejemplo n.º 12
0
        public override IDisplayResult Edit(MediaField field, BuildFieldEditorContext context)
        {
            return(Initialize <EditMediaFieldViewModel>("MediaField_Edit", model =>
            {
                model.Paths = JsonConvert.SerializeObject(field.Paths);

                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
        public override IDisplayResult Edit(ValuesField field, BuildFieldEditorContext context)
        {
            return(Initialize <EditValuesFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;

                model.Data = JsonConvert.SerializeObject(field.Data);
            }));
        }
Ejemplo n.º 14
0
        public override IDisplayResult Edit(DateTimeField field, BuildFieldEditorContext context)
        {
            var settings = context.PartFieldDefinition.Settings.ToObject <DateTimeFieldSettings>();

            return(Shape <EditDateTimeFieldViewModel>("DateTimeField_Edit", model =>
            {
                model.Value = field.Value.HasValue ? field.Value.Value.ToString(settings.Format, CultureInfo.InvariantCulture) : "";
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
Ejemplo n.º 15
0
 public override IDisplayResult Edit(TField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditProductAttributeFieldViewModel <TField, TFieldSettings> >(
                GetEditorShapeType(context), model =>
     {
         var settings = context.PartFieldDefinition.Settings.ToObject <TFieldSettings>();
         model.Field = field;
         model.Settings = settings;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
 public override IDisplayResult Edit(LinkField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditLinkFieldViewModel>(GetEditorShapeType(context), model =>
     {
         var settings = context.PartFieldDefinition.GetSettings <LinkFieldSettings>();
         model.Url = context.IsNew ? settings.DefaultUrl : field.Url;
         model.Text = context.IsNew ? settings.DefaultText : field.Text;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
Ejemplo n.º 17
0
        public override IDisplayResult Edit(ColourField field, BuildFieldEditorContext context)
        {
            var settings = context.PartFieldDefinition.GetSettings <ColourFieldSettings>();

            return(Initialize <EditColourFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
                model.Value = string.IsNullOrWhiteSpace(field.Value) ? settings.DefaultValue : field.Value;
            }));
        }
Ejemplo n.º 18
0
        public override IDisplayResult Edit(NumericField field, BuildFieldEditorContext context)
        {
            return(Shape <EditNumericFieldViewModel>("NumericField_Edit", model =>
            {
                var settings = context.PartFieldDefinition.Settings.ToObject <NumericFieldSettings>();
                model.Value = context.IsNew ? settings.DefaultValue : Convert.ToString(field.Value, _cultureInfo);

                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
Ejemplo n.º 19
0
        public override IDisplayResult Edit(BooleanField field, BuildFieldEditorContext context)
        {
            return(Initialize <EditBooleanFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Value = (context.IsNew == false) ?
                              field.Value : context.PartFieldDefinition.GetSettings <BooleanFieldSettings>().DefaultValue;

                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
        public override IDisplayResult Edit(RenderAliasField field, BuildFieldEditorContext context)
        {
            return(Initialize <EditRenderAliasFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;

                model.Alias = field.Alias;
                model.DisplayType = field.DisplayType;
            }));
        }
Ejemplo n.º 21
0
 public override IDisplayResult Edit(LinkField field, BuildFieldEditorContext context)
 {
     return(Shape <EditLinkFieldViewModel>("LinkField_Edit", model =>
     {
         var settings = context.PartFieldDefinition.Settings.ToObject <LinkFieldSettings>();
         model.Url = (field.IsNew()) ? settings.DefaultUrl : field.Url;
         model.Text = (field.IsNew()) ? settings.DefaultText : field.Text;
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }
        public override IDisplayResult Edit(NumericField field, BuildFieldEditorContext context)
        {
            return(Initialize <EditNumericFieldViewModel>(GetEditorShapeType(context), model =>
            {
                var settings = context.PartFieldDefinition.GetSettings <NumericFieldSettings>();
                model.Value = context.IsNew ? settings.DefaultValue : Convert.ToString(field.Value, CultureInfo.CurrentUICulture);

                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
Ejemplo n.º 23
0
        public override IDisplayResult Edit(AddressField field, BuildFieldEditorContext context)
        {
            return(Initialize <AddressFieldViewModel>("AddressField_Edit", model =>
            {
                model.Key = field.Key;
                model.Value = field.Value;
                model.ExtensionValue = field.ExtensionValue;

                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
Ejemplo n.º 24
0
        public override async Task <IDisplayResult> EditAsync(QueryField field, BuildFieldEditorContext context)
        {
            var queries = (await _queryManager.ListQueriesAsync()).Select(x => x.Name);

            return(Initialize <EditQueryFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
                model.Value = field.Value;
                model.Queries = queries;
            }));
        }
        private Task BuildViewModel(AddressFieldViewModel model, AddressField field, BuildFieldEditorContext context)
        {
            model.Address = field.Address;
            model.AddressHtml
                                      = new HtmlString(_addressFormatterProvider.Format(field.Address).Replace(System.Environment.NewLine, "<br/>"));
            model.Regions             = Regions.All;
            model.Provinces           = Regions.Provinces;
            model.ContentItem         = field.ContentItem;
            model.AddressPart         = field;
            model.PartFieldDefinition = context.PartFieldDefinition;

            return(Task.CompletedTask);
        }
Ejemplo n.º 26
0
        public override IDisplayResult Edit(MediaField field, BuildFieldEditorContext context)
        {
            var itemPaths = field.Paths?.ToList().Select(p => new EditMediaFieldItemInfo {
                Path = p
            }) ?? new EditMediaFieldItemInfo[] { };

            return(Initialize <EditMediaFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Paths = JsonConvert.SerializeObject(itemPaths);
                model.TempUploadFolder = _attachedMediaFieldFileService.MediaFieldsTempSubFolder;
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
            }));
        }
Ejemplo n.º 27
0
        Task <IDisplayResult> IContentFieldDisplayDriver.BuildEditorAsync(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition, ContentTypePartDefinition typePartDefinition, BuildEditorContext context)
        {
            if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) &&
                !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name))
            {
                return(Task.FromResult(default(IDisplayResult)));
            }

            var field = contentPart.GetOrCreate <TField>(partFieldDefinition.Name);

            Prefix = typePartDefinition.Name + "." + partFieldDefinition.Name;
            var fieldEditorContext = new BuildFieldEditorContext(contentPart, typePartDefinition, partFieldDefinition, context);

            return(EditAsync(field, fieldEditorContext));
        }
Ejemplo n.º 28
0
        public override IDisplayResult Edit(DictionaryField field, BuildFieldEditorContext context)
        {
            var settings = GetSettings(context);

            return(Initialize <EditDictionaryFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;

                model.Data = JsonConvert.SerializeObject(field.Data == null ? GetDefaults(context) : field.Data);

                model.MaxEntries = settings?.MaxEntries;
                model.MinEntries = settings?.MinEntries;
            }));
        }
Ejemplo n.º 29
0
        public override IDisplayResult Edit(MediaField field, BuildFieldEditorContext context)
        {
            var itemPaths = field.Paths?.ToList().Select(p => new EditMediaFieldItemInfo {
                Path = p
            }).ToArray() ?? Array.Empty <EditMediaFieldItemInfo>();

            return(Initialize <EditMediaFieldViewModel>(GetEditorShapeType(context), model =>
            {
                var settings = context.PartFieldDefinition.GetSettings <MediaFieldSettings>();
                if (settings.AllowMediaText)
                {
                    if (field.MediaTexts != null)
                    {
                        for (var i = 0; i < itemPaths.Count(); i++)
                        {
                            if (i >= 0 && i < field.MediaTexts.Length)
                            {
                                itemPaths[i].MediaText = field.MediaTexts[i];
                            }
                        }
                    }
                }

                if (settings.AllowAnchors)
                {
                    var anchors = field.GetAnchors();
                    if (anchors != null)
                    {
                        for (var i = 0; i < itemPaths.Count(); i++)
                        {
                            if (i >= 0 && i < anchors.Length)
                            {
                                itemPaths[i].Anchor = anchors[i];
                            }
                        }
                    }
                }

                model.Paths = JsonConvert.SerializeObject(itemPaths, Settings);
                model.TempUploadFolder = _attachedMediaFieldFileService.MediaFieldsTempSubFolder;
                model.Field = field;
                model.Part = context.ContentPart;
                model.PartFieldDefinition = context.PartFieldDefinition;
                model.AllowMediaText = settings.AllowMediaText;
            }));
        }
Ejemplo n.º 30
0
 public override IDisplayResult Edit(MultiTextField field, BuildFieldEditorContext context)
 {
     return(Initialize <EditMultiTextFieldViewModel>(GetEditorShapeType(context), model =>
     {
         if (context.IsNew)
         {
             var settings = context.PartFieldDefinition.GetSettings <MultiTextFieldSettings>();
             model.Values = settings.Options.Where(o => o.Default).Select(o => o.Value).ToArray();
         }
         else
         {
             model.Values = field.Values;
         }
         model.Field = field;
         model.Part = context.ContentPart;
         model.PartFieldDefinition = context.PartFieldDefinition;
     }));
 }