public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(
          ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var model = new FloatFieldSettings();
            if (updateModel.TryUpdateModel(
              model, "FloatFieldSettings", null, null))
            {
                builder.WithSetting("FloatFieldSettings.Decimals",
                                    model.Decimals.ToString());
            }

            yield return DefinitionTemplate(model);
        }
Exemplo n.º 2
0
 protected override DriverResult Display(
     ContentPart part, Fields.FloatField field,
     string displayType, dynamic shapeHelper)
 {
     return(ContentShape("Fields_Custom_Float", // key in Shape Table
                         field.Name,            // used to differentiate shapes in placement.info overrides, e.g. Fields_Common_Text-DIFFERENTIATOR
                                                // this is the actual Shape which will be resolved
                                                // (Fields/Custom.Float.cshtml)
                         s =>
                         s.Name(field.Name)
                         .Display(FloatFieldSettings.GetFloatDiplay(field, field.FloatValue))
                         .Value(field.FloatValue)
                         ));
 }
Exemplo n.º 3
0
        protected override DriverResult Editor(ContentPart part,
                                               Fields.FloatField field,
                                               dynamic shapeHelper)
        {
            var settings = field.PartFieldDefinition.Settings
                           .GetModel <FloatFieldSettings>();
            var value = field.FloatValue;

            var viewModel = new FloatFieldViewModel {
                Name     = field.Name,
                Display  = FloatFieldSettings.GetFloatDiplay(field, value),
                Decimals = settings.Decimals,
                Value    = value
            };

            return(ContentShape("Fields_Custom_Float_Edit",
                                () => shapeHelper.EditorTemplate(
                                    TemplateName: TemplateName,
                                    Model: viewModel,
                                    Prefix: GetPrefix(field, part))));
        }