public GridConfigurationEditor(IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser)
        : base(ioHelper, editorConfigurationParser)
    {
        ConfigurationField items = Fields.First(x => x.Key == "items");

        items.Validators.Add(new GridValidator());
    }
Exemplo n.º 2
0
        public UmbracoEntityDataListSource(IEntityService entityService)
        {
            _entityService = entityService;

            Fields = new ConfigurationField[]
            {
                new NotesConfigurationField(@"<div class=""alert alert-warning"">
<p><strong>A note about supported Umbraco entity types.</strong></p>
<p>Umbraco's `EntityService` API has limited support for querying entity types by <abbr title=""Globally Unique Identifier"">GUID</abbr> or <abbr title=""Umbraco Data Identifier"">UDI</abbr>.</p>
<p>Supported entity types are available in the list below.</p>
</div>", true),
                new ConfigurationField
                {
                    Key         = "entityType",
                    Name        = "Entity type",
                    Description = "Select the Umbraco entity type to use.",
                    View        = IOHelper.ResolveUrl(DropdownListDataEditor.DataEditorViewPath),
                    Config      = new Dictionary <string, object>()
                    {
                        { AllowEmptyConfigurationField.AllowEmpty, Constants.Values.False },
                        { DropdownListConfigurationEditor.Items, SupportedEntityTypes.Keys.Select(x => new DataListItem {
                                Name = x.SplitPascalCasing(), Value = x
                            }) },
                    }
                }
            };
        }
Exemplo n.º 3
0
 // Umbraco.Code.MapAll -Value
 private static void Map(ConfigurationField source, DataTypeConfigurationFieldDisplay target, MapperContext context)
 {
     target.Config      = source.Config;
     target.Description = source.Description;
     target.HideLabel   = source.HideLabel;
     target.Key         = source.Key;
     target.Name        = source.Name;
     target.View        = source.View;
 }
    public DropDownFlexibleConfigurationEditor(ILocalizedTextService textService, IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser)
        : base(ioHelper, editorConfigurationParser)
    {
        ConfigurationField items = Fields.First(x => x.Key == "items");

        // customize the items field
        items.Name = textService.Localize("editdatatype", "addPrevalue");
        items.Validators.Add(new ValueListUniqueValueValidator());
    }
Exemplo n.º 5
0
    public ColorPickerConfigurationEditor(IIOHelper ioHelper, IJsonSerializer jsonSerializer,
                                          IEditorConfigurationParser editorConfigurationParser)
        : base(ioHelper, editorConfigurationParser)
    {
        _jsonSerializer = jsonSerializer;
        ConfigurationField items = Fields.First(x => x.Key == "items");

        // customize the items field
        items.View        = "views/propertyeditors/colorpicker/colorpicker.prevalues.html";
        items.Description = "Add, remove or sort colors";
        items.Name        = "Colors";
        items.Validators.Add(new ColorListValidator());
    }
Exemplo n.º 6
0
        public void CanParseManifest_PropertyEditors()
        {
            const string json = @"{'propertyEditors': [
    {
        alias: 'Test.Test1',
        name: 'Test 1',
        editor: {
            view: '~/App_Plugins/MyPackage/PropertyEditors/MyEditor.html',
            valueType: 'int',
            hideLabel: true,
            validation: {
                'required': true,
                'Regex': '\\d*'
            }
        },
        prevalues: {
                fields: [
                    {
                        label: 'Some config 1',
                        key: 'key1',
                        view: '~/App_Plugins/MyPackage/PropertyEditors/Views/pre-val1.html',
                        validation: {
                            required: true
                        }
                    },
                    {
                        label: 'Some config 2',
                        key: 'key2',
                        view: '~/App_Plugins/MyPackage/PropertyEditors/Views/pre-val2.html'
                    }
                ]
            }
    },
    {
        alias: 'Test.Test2',
        name: 'Test 2',
        isParameterEditor: true,
        defaultConfig: { key1: 'some default val' },
        editor: {
            view: '~/App_Plugins/MyPackage/PropertyEditors/MyEditor.html',
            valueType: 'int',
            validation: {
                required : true,
                regex : '\\d*'
            }
        }
    }
]}";

            PackageManifest manifest = _parser.ParseManifest(json);

            Assert.AreEqual(2, manifest.PropertyEditors.Length);

            IDataEditor editor = manifest.PropertyEditors[1];

            Assert.IsTrue((editor.Type & EditorType.MacroParameter) > 0);
            Assert.IsNotEmpty(editor.DefaultConfiguration);
            Assert.AreEqual("some default val", editor.DefaultConfiguration["key1"]);

            editor = manifest.PropertyEditors[0];
            Assert.AreEqual("Test.Test1", editor.Alias);
            Assert.AreEqual("Test 1", editor.Name);
            Assert.IsFalse((editor.Type & EditorType.MacroParameter) > 0);

            IDataValueEditor valueEditor = editor.GetValueEditor();

            Assert.AreEqual(_ioHelper.ResolveUrl("/App_Plugins/MyPackage/PropertyEditors/MyEditor.html"), valueEditor.View);
            Assert.AreEqual("int", valueEditor.ValueType);
            Assert.IsTrue(valueEditor.HideLabel);

            // these two don't make much sense here
            //// valueEditor.RegexValidator;
            //// valueEditor.RequiredValidator;

            List <IValueValidator> validators = valueEditor.Validators;

            Assert.AreEqual(2, validators.Count);
            IValueValidator validator = validators[0];
            var             v1        = validator as RequiredValidator;

            Assert.IsNotNull(v1);
            Assert.AreEqual("Required", v1.ValidationName);
            validator = validators[1];
            var v2 = validator as RegexValidator;

            Assert.IsNotNull(v2);
            Assert.AreEqual("Regex", v2.ValidationName);
            Assert.AreEqual("\\d*", v2.Configuration);

            // this is not part of the manifest
            IDictionary <string, object> preValues = editor.GetConfigurationEditor().DefaultConfiguration;

            Assert.IsEmpty(preValues);

            IConfigurationEditor preValueEditor = editor.GetConfigurationEditor();

            Assert.IsNotNull(preValueEditor);
            Assert.IsNotNull(preValueEditor.Fields);
            Assert.AreEqual(2, preValueEditor.Fields.Count);

            ConfigurationField f = preValueEditor.Fields[0];

            Assert.AreEqual("key1", f.Key);
            Assert.AreEqual("Some config 1", f.Name);
            Assert.AreEqual(_ioHelper.ResolveUrl("/App_Plugins/MyPackage/PropertyEditors/Views/pre-val1.html"), f.View);
            List <IValueValidator> fvalidators = f.Validators;

            Assert.IsNotNull(fvalidators);
            Assert.AreEqual(1, fvalidators.Count);
            var fv = fvalidators[0] as RequiredValidator;

            Assert.IsNotNull(fv);
            Assert.AreEqual("Required", fv.ValidationName);

            f = preValueEditor.Fields[1];
            Assert.AreEqual("key2", f.Key);
            Assert.AreEqual("Some config 2", f.Name);
            Assert.AreEqual(_ioHelper.ResolveUrl("/App_Plugins/MyPackage/PropertyEditors/Views/pre-val2.html"), f.View);
            fvalidators = f.Validators;
            Assert.IsNotNull(fvalidators);
            Assert.AreEqual(0, fvalidators.Count);
        }
 private static void GetField(List<int> listfield, ConfigurationField field)
 {
     if (field == null)
         return;
     listfield.Add(field.IdField);
     foreach (var child in field.ConfigurationField1)
     {
         GetField(listfield, child);
     }
 }