Code Monkey home page Code Monkey logo

dojo-generate-form's People

Contributors

milltree avatar muzuiget avatar stemey avatar websemantics avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dojo-generate-form's Issues

TypeError: html is null in RichText

In dojo 1.10.1, I get a console error complain TypeError: html.

To workaround this I edit primitive/RichtextAttributeFactory.js, make props.value to an empty string.

props.value = "";
var widget = new Editor(props);

Refactor Editor

visit method should visit the whole model or should be replaced by getModelHandle(path)

Unable to use registerStandardEditorFactory

Hello,
I'm trying to setup and play with gform. Getting an error "ReferenceError: define is not defined
dojo._loadUriAndCheck()".
This is while loading the editorFactory module at dojo.require("gform/registerStandardEditorFactory");

The firedebug console has following:
failed loading ../../../../dojo/dojo/../gform/registerStandardEditorFactory.js with error: ReferenceError: define is not defined
dojo._loadUriAndCheck()dojo.js (line 14)
dojo._loadPath(_21="../gform/registerStandardEditorFactory.js", _22="gform/registerStandardEditorFactory", cb=undefined)dojo.js (line 14)
dojo.require(_2d="gform/registerStandardEditorFactory", _2e=undefined)dojo.js (line 14)
FullGenDialog.html()

"this.options" is null when mapped primitives nested in groups during set data

Hi, I ran into this problem when processing this schema:

{
    "attributes": [
        {
            "label": "test",
            "code": "value",
            "type": "object",
            "typeProperty": "type",
            "groups": [
                {
                    "code": "test2",
                    "label": "test2",
                    "attributes": [
                        {
                            "type": "string",
                            "label": "language",
                            "values": [
                                "english",
                                "german"
                            ],
                            "code": "language"
                        },
                        {
                            "type": "string",
                            "label": "salutation",
                            "mapped_attribute": "language",
                            "mapped_values": {
                                "english": [
                                    "Mr.",
                                    "Mrs."
                                ],
                                "german": [
                                    "Herr",
                                    "Frau"
                                ]
                            },
                            "code": "salutation"
                        }
                    ]
                }
            ]
        }
    ]
}

it is ok to create an editor with this schema, but when I want to set PlainValue:
var data = {"value":{"language":"german", "salutation":"Frau", "type":"test2"}};
editor.setMetaAndPlainValue(schema,data);

I got an error:
TypeError: Cannot read property 'length' of null {stack: (...), message: "Cannot read property 'length' of null"}message: "Cannot read property 'length' of null"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }proto: Error "TypeError: Cannot read property 'length' of null

I don't know why this happened, wish to be fixed quickly, thanks!

[feature request] Support nullValue?

nullValue is different from defaultValue, the latter is the default value for input widget.

And I nullValue is if the field is not required, then the user didn't fill the field, then use the nullValue (instead of the JavaScript null value), for example

{
    code: "count"
    type: "number",
    required: false
}

We get {count: null}.

If we support nullValue

{
    code: "count"
    type: "number",
    required: false,
    nullValue: -1
}

We get {count: -1}.

type boolean widget can not set to disabled

I can use disabled: true in type string

{
    code: 'id',
    label: 'ID',
    type: 'string',
    required: false,
    disabled: true,
},

but not in type boolean

{
    code: 'active',
    label: 'Active',
    type: 'boolean',
    required: false,
    disabled: true,
},

Check list is [object Object] if the value is 0

{
    code: 'day_of_week',
    type: 'array',
    label: 'Day of Week',
    required: false,
    element: {
        type: 'number',
        values: [
            {label: 'Monday', value: 0},
            {label: 'Tuesday', value: 1},
            {label: 'Wednesday', value: 2},
            {label: 'Thursday', value: 3},
            {label: 'Friday', value: 4},
            {label: 'Saturday', value: 5},
            {label: 'Sunday', value: 6},
        ],
    },
},

Then Monday label will become [object Object], but use string '0' is fine.

Reset does not work as expected

Enter invalid data in doc/utorial/validateAndSave.html. Hitting reset will only remove "required" errors after hitting three times.

tabs vanish in multi-array

If you close a member in multi-array, add a new member and then reopen the first one, the tabs are gone.

model validation

validation by widget works.

Now a dijit independent model validation should be added. This could be done in the converter.

converter validates the new value, adds errors to meta laye of modelHandle and throws an error to prevent model update.

create ModelHandle subtypes

ModelHandle will implement setPlainValue and getPlainValue itself - functions getPlainValue and updateModelHandle will be removed.

also:

  • visit
  • addErrors
    -...

Bug with mapped primitives used in groups

Below is my test schema which caused this bug:

var schema = {
        attributes:[
        {
            label: "BugRecur",
            code: "bug",
            type: "array",
            typeProperty: "testname",
            groups:[
            {
                code: "test",
                label: "test",
                attributes:[
                {
                    code: "name",
                    type: "string",
                    label: "name",
                    values:['a', "b"]
                },
                {
                    code:"mapvalue",
                    label:"mapvalue",
                    type:"array",
                    element:{
                        type:"string",
                        mapped_attribute: "name",
                        mapped_values:{
                            "a": ['1'],
                            "b":['2']
                        }
                    }

                }
                ]
            },
            {
                code: "test2",
                label: "test2",
                attributes:[
                {
                    code: "name2",
                    type: "string",
                    label: "name2"
                }
                ]
            }
            ]
        },
        ]
    };

There is an "Uncaught TypeError: Cannot read property 'type' of null" in gform/schema/meta.js(line 82), I am not good at javascript, so I can't find the original reason of this error, and I just fixed it by adding a isNull judge in gform/model/SingleObject.js->initDefault->forEach:

 Object.keys(this.get("attributes")).forEach(function (key) {
                var model = this.get("attributes")[key];
                if(model.schema == null){
                    return;
                }
                // don't init Default on complex attributes unless it is an array with defaults or it is required.
                if (metaHelper.isArray(model.schema) || !metaHelper.isComplex(model.schema) || model.isRequired()) {
                    model.initDefault();
                }

            }, this);

Wish this bug soon to be fixed, as our project is in heavy use of gform and really need this feature which use mapped primitives in groups.
Thanks for your work on gform which helps us more!

Upgrade indicators

In the table list and the primitive list the indicators are not styled properly.

type integer group element form need to switch twitce to show up

var schema = {
    attributes: [
        {
            code: 'triggerTypeGroup',
            type: 'object',
            typeProperty: 'triggerType',
            required: true,
            groups: [
                {
                    code: 'date1',
                    attributes: [
                        {
                            code: 'run_date',
                            type: 'string',
                            placeHolder: 'type is string',
                            required: true,
                        }
                    ],
                },
                {
                    code: 'date2',
                    attributes: [
                        {
                            code: 'run_date',
                            type: 'integer',
                            placeHolder: 'type is integer',
                            required: true,
                        }
                    ],
                },
            ]
        }
    ]
};

Similar to #52, when date2 group element has a integer type, need to switch twice to make the form show up, but use number type if fine.

can not watch editor.plainValue

the code below doesn't run

editor.watch('plainValue', someFunc)

looks like its a simple fix of below in Editor._setPlainValueAttr

this._set('plainValue', value)

Move *Factory.getSchema to its own file.

The json schemas for attributs and groups are used for validation, documentation and the formbuilder. The method should be moved to its own file to reduce the download size.

`meta is null` in groups when group element has array type

var schema = {
    attributes: [
        {
            code: 'triggerTypeGroup',
            type: 'object',
            typeProperty: 'triggerType',
            required: true,
            groups: [
                {
                    code: 'date',
                    attributes: [
                        {
                            code: 'run_date',
                            type: 'string',
                            required: true,
                        }
                    ],
                },
                {
                    code: 'cron',
                    attributes: [
                        {
                            code: 'day_of_week',
                            type: 'array',
                            label: 'Day of Week',
                            required: false,
                            element: {
                                type: 'number',
                                values: [
                                    {label: 'Monday', value: 0},
                                    {label: 'Tuesday', value: 1},
                                    {label: 'Wednesday', value: 2},
                                    {label: 'Thursday', value: 3},
                                    {label: 'Friday', value: 4},
                                    {label: 'Saturday', value: 5},
                                    {label: 'Sunday', value: 6},
                                ],
                            },
                        },
                    ],
                },
            ]
        }
    ]
};

When switch to cron group, the group form doesn't show up, switch back to date then switch back again cron then the form will show up.

subclassing CrudController causes error in dojo parser

When subclassing the CrudController I get the following error raised by dojo parser

"calling chained constructor with inherited"

The error goes away if I comment out the call to this.inherited in CrudControllers constructor

Is there a way to subclass without commenting this out or can it be commented out without any negative impact?

Access a field's widget?

Is it possible to retrieve a field's widget problematically? In some cases I'd like to be able to enable/disable controls, add onclick handlers, etc.

Refactor EditorFactory

  • AtributeFactoryFinder should be integrated in EditorFatory

  • remove inheritance from Stateful

  • EditorFactory should be configured with json literal:

    {
    attributes: {
        string: { // all AttributeFactories have an editor id
            type: "gform/primitiveStringAttributeFactory", // type if the AttributeFactory
            default: { // default dijit props
                placeHolder: "please enter a value"
            }   
    },
    groups: {
        list: {
            type: "gform/group/GroupFactory", // type if the AttributeFactory
            dijitType: "    gform/group/AttributeListWidget",
            default: { // config for dijit
    
            }
        }
    },
    defaultGroup: "list",
    converters: { // define default converter for primitive types
        string: "gform/primitive/nullableStringConverter"
        ref: "gform/primitive/refConverter"
    }
    }
    

Dojo Mobile examples?

Do you have any examples of gform working with Dojo mobile components? Any plans for factory bindings for these widgets?

question ; multi property validation

I'm looking at ways to perform multi property validation, an example of the kind of thing i will be doing is when a I have 2 dates in a form and the start date can not be later than the end date.

Below is one way I have found to do multi property validation (using a very simple example). The example aspects editor rather than sub classing Editor as this is just a quick prototype.

Is there a better way to do this kind of validation?


// Generated by CoffeeScript 1.6.3
(function() {
  require(["dojo_toolbox/libs/lodash", "dojo/_base/lang", "dojo/_base/declare", "dojo/aspect", "gform/Editor", "gform/EditorFactory", "gform/createLayoutEditorFactory"], function(ld, lang, declare, aspect, Editor, EditorFactory, createLayoutEditorFactory) {
    var editor, editorFactory, meta;
    meta = {
      "editor": "listgroup",
      "groups": [
        {
          "editor": "list",
          "attributes": [
            {
              code: "validate_name_field",
              type: "boolean"
            }, {
              code: "name",
              type: "string"
            }
          ]
        }
      ]
    };
    editorFactory = createLayoutEditorFactory();
    editor = window.editor = new Editor({
      plainValue: {},
      meta: meta,
      editorFactory: editorFactory
    });
    editor.onFormValidation = function() {
      var data;
      data = this.getPlainValue();
      if (data.validate_name_field && !data.name) {
        return this.addError('name', 'name field is required when "validated name field" is checked');
      }
    };
    editor._runFormValidations = function() {
      this._inRunFormValidations = true;
      this.resetErrors();
      this.onFormValidation();
      this._inRunFormValidations = false;
      return this.modelHandle.get("errorCount");
    };
    editor._runFormValidationsDebounce = ld.debounce(lang.hitch(editor, '_runFormValidations'), 100);
    aspect.after(editor, 'onChange', function() {
      if (!this._inRunFormValidations) {
        return editor._runFormValidationsDebounce();
      }
    });
    aspect.after(editor, 'validate', lang.hitch(editor, '_runFormValidations'));
    editor.startup();
    return document.getElementById('form').appendChild(editor.domNode);
  });

}).call(this);

/*
//@ sourceMappingURL=main.map
*/


custom validation error messages on date widget are not displayed

Here's a example of adding a custom validation function to a date field which, when something is entered and the validation function is run the error message is not displayed on the field, but if the type of the field is changed from "date" to "string" then the error message is displayed


// Generated by CoffeeScript 1.6.3
(function() {
  require(["dojo/_base/lang", "dojo/_base/declare", "gform/Editor", "gform/EditorFactory", "gform/createLayoutEditorFactory"], function(lang, declare, Editor, EditorFactory, createLayoutFactory) {
    var editor, meta;
    meta = {
      "editor": "listgroup",
      "groups": [
        {
          "editor": "list",
          "attributes": [
            {
              code: "some_field",
              type: "date",
              myValidation: true
            }
          ]
        }
      ]
    };
    EditorFactory.prototype.arrayValidators.myValidation = function() {
      return function() {
        return [
          {
            path: '',
            message: 'some error '
          }
        ];
      };
    };
    editor = window.editor = new Editor({
      plainValue: {},
      meta: meta,
      editorFactory: createLayoutFactory()
    });
    editor.startup();
    return document.getElementById('form').appendChild(editor.domNode);
  });

}).call(this);

/*
//@ sourceMappingURL=main.map
*/

text dijit custom validation not run when user deletes all text in field

if a user enters any text into the text field created from the code below the custom validation function will run, but if the user then deletes all text in the text field and blurs the text field then the custom validation function is not run


// Generated by CoffeeScript 1.6.3
(function() {
  require(["dojo/_base/lang", "dojo/_base/declare", "gform/Editor", "gform/EditorFactory", "gform/createLayoutEditorFactory"], function(lang, declare, Editor, EditorFactory, createLayoutFactory) {
    var editor, meta;
    meta = {
      "editor": "listgroup",
      "groups": [
        {
          "editor": "list",
          "attributes": [
            {
              code: "some_field",
              type: "string",
              textCustomValidation: true
            }
          ]
        }
      ]
    };
    EditorFactory.prototype.arrayValidators.textCustomValidation = function() {
      return function(propertyModelHandle) {
        debugger;
        console.log("run custom validation when value was \"" + (propertyModelHandle.getPlainValue()) + "\"");
        return [];
      };
    };
    editor = window.editor = new Editor({
      plainValue: {},
      meta: meta,
      editorFactory: createLayoutFactory()
    });
    editor.startup();
    return document.getElementById('form').appendChild(editor.domNode);
  });

}).call(this);

/*
//@ sourceMappingURL=main.map
*/

is there anyway to get editor object to preserve entity data which isn't present in meta data?

Is there a way to preserve properties in the entity record which are not defined in the schema. The example below shows a entity where only the name property has been defined in the schema but I'd like the additional properties to be returned unchanged when calling editor.get('plainValue').

The reason this is useful is that

  • not all properties will be displayed in a form
  • the server api is likley to change over time and additional properties may be added which don't need to be edited or shown to the user but still need to be present in the entity
      var entity = {id: 1, name: 'some name', newProperty: 'things'};

      var schema = {

        "attributes": [
          {
            "type": "string",
            "label": "name",
            "code": "name",
            "array": false
          }
        ],
        "type_property": "ext_type"

      }

      editor.setMetaAndPlainValue(schema, entity);

      var newEntity = editor.get('plainValue');

      console.log(newEntity.id) // => undefined
      console.log(newEntity.name) // => 'some name'
      console.log(newEntity.newProperty) // => undefined

About optional object's chekbox

For the schema like

{
    code: 'optional',
    label: 'Optional',
    type: 'object',
    group: {
        attributes: [
            {
                code: 'foo',
                label: 'Foo',
                type: 'string',
            },
            {
                code: 'bar',
                label: 'Bar',
                type: 'string',
            },
        ],
    }
},

the form will be [x] Null.

But end-user(not programmer) don't know what is Null, especially for non-English speaker. And uncheck to expand inner form is a little contrary to the intuitive.

So suggest to become [ ] Setup, check to expand inner form, And make Setup can custom with label property.

update bower.json for v0.24.3

the version in bower.json not bumped, and the v0.24.3 compatible dojo v1.10.x? it seem to is the last verison dojo 1.x.

question ; is there a way to set a default value in meta data?

Is there a way to set the default value for a field if the user does not select a value, for example say i have a boolean field that i want to be set to true if the user does not select it is there something like

{
  code: "someBooleanField", 
  type: "boolean", 
  label: "my label", 
  defaultValue: true
}

editor.visit returns empty string

A few things have changed since I last used this so this maybe my misunderstand of the updates but when calling editor.visit('name') on a model with a name attribute with a value of "some string" an empty string is returned. It seems like the method model.getModelByPath maybe a suitable alternative. Is this correct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.