stemey / dojo-generate-form Goto Github PK
View Code? Open in Web Editor NEWgform - a dojo library to build administrative front-ends declaratively.
License: Other
gform - a dojo library to build administrative front-ends declaratively.
License: Other
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);
There seems to be a few changes in "openref" and "topic/vidadmin" compared to master
Do you recommend either of these branches over master or is master the safest bet to use?
visit method should visit the whole model or should be replaced by getModelHandle(path)
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()
Add description tooltip.
Add styles for header and add margin/padding to table cells.
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!
If a current value is invalid (tested with NumberTextBox) then discarding the changes in _CrudMixin will not remove the error indicator.
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}
.
By default the embedded attribute is preselected, but its properties are not displayed.
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,
},
getPlainValue uses meta data in the modelHandle. The meta data can be removed when getPlainValue used the schema and editorFactory like updateModelHandle .
{
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.
Enter invalid data in doc/utorial/validateAndSave.html. Hitting reset will only remove "required" errors after hitting three times.
The moved element has no options afterwards.
The file http://toobop.net/gform/app/example/kitchensink/kitchensink_schema.json is not a well-formed JSON.
label: "text",
description: "Text can be entered in different ways.",
editor: "listpane",
If you close a member in multi-array, add a new member and then reopen the first one, the tabs are gone.
If there is only one selectable ref in filteringSelect, it seems to be preselected but the model is null.
Kitchensink table-list tab:
Set the type to ExampleThing and set a message. drag and drop the element. The message will vanish. Does not happen with the other type "ExampleThing1".
texareas don't support validation and messages. Remove from getSchema().
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.
Groups in validTypes are not working.
ModelHandle will implement setPlainValue and getPlainValue itself - functions getPlainValue and updateModelHandle will be removed.
also:
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!
If you set language to "select" then the oter two values do not switch to null or empty
In the table list and the primitive list the indicators are not styled properly.
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.
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)
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.
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.
uses minLength message even though invalid message is set
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?
A StoreModel is straight forward.
Seekitvhensink. When setting fractional to a value with more than 3 fractional digits and blurring the field, then the value is cleared.
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.
Remove the errorIcon.
Whole value is cleared when too many fractional digits.
Hi, there are some pages are not found on the http://www.toobop.net/gform/app/#examples,
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"
}
}
Do you have any examples of gform working with Dojo mobile components? Any plans for factory bindings for these widgets?
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
*/
adding parent to meta data in modelHandle allows the Resolver to access any item in the tree. Also we can create the current absolute path.
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
*/
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 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
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
The checkbox does not receive any click events after the first one when it is placed in a columns group container.
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.
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.
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
}
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.