Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexander Emmerich
erp5
Commits
7b537266
Commit
7b537266
authored
Jun 25, 2018
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_json_form: add filter property in `schema_mode` for property selector
parent
764720ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
10 deletions
+143
-10
bt5/erp5_json_form/SkinTemplateItem/portal_skins/erp5_json_form/jsonform/gadget_json_generated_form_child.js.js
...json_form/jsonform/gadget_json_generated_form_child.js.js
+143
-10
No files found.
bt5/erp5_json_form/SkinTemplateItem/portal_skins/erp5_json_form/jsonform/gadget_json_generated_form_child.js.js
View file @
7b537266
...
@@ -834,10 +834,118 @@
...
@@ -834,10 +834,118 @@
});
});
}
}
function
checkSchemaIsMetaSchema
(
schema
)
{
if
(
schema
instanceof
Array
)
{
var
i
,
sch
;
for
(
i
=
0
;
i
<
schema
.
length
;
i
+=
1
)
{
sch
=
schema
[
i
].
schema
;
if
(
sch
.
hasOwnProperty
(
"
properties
"
)
&&
sch
.
properties
.
hasOwnProperty
(
"
$schema
"
))
{
return
true
;
}
}
return
false
;
}
return
schema
.
hasOwnProperty
(
"
properties
"
)
&&
schema
.
properties
.
hasOwnProperty
(
"
$schema
"
);
}
function
checkSchemaType
(
type
,
check
)
{
if
(
type
instanceof
Array
)
{
return
type
.
indexOf
(
check
)
>=
0
;
}
return
type
===
check
;
}
// filter property for schema editor mode
function
filterPropery
(
property_name
,
current_document
)
{
if
(
current_document
.
hasOwnProperty
(
"
type
"
))
{
switch
(
property_name
)
{
case
"
allOf
"
:
case
"
anyOf
"
:
case
"
oneOf
"
:
return
false
;
case
"
additionalItems
"
:
case
"
items
"
:
case
"
maxItems
"
:
case
"
minItems
"
:
case
"
uniqueItems
"
:
if
(
!
checkSchemaType
(
current_document
.
type
,
"
array
"
))
{
return
false
;
}
break
;
case
"
required
"
:
case
"
maxProperties
"
:
case
"
minProperties
"
:
case
"
additionalProperties
"
:
case
"
properties
"
:
case
"
patternProperties
"
:
case
"
propertyNames
"
:
if
(
!
checkSchemaType
(
current_document
.
type
,
"
object
"
))
{
return
false
;
}
break
;
case
"
maxLength
"
:
case
"
minLength
"
:
case
"
pattern
"
:
if
(
!
checkSchemaType
(
current_document
.
type
,
"
string
"
))
{
return
false
;
}
break
;
case
"
multipleOf
"
:
case
"
maximum
"
:
case
"
exclusiveMaximum
"
:
case
"
minimum
"
:
case
"
exclusiveMinimum
"
:
if
(
!
(
checkSchemaType
(
current_document
.
type
,
"
number
"
)
||
checkSchemaType
(
current_document
.
type
,
"
integer
"
)))
{
return
false
;
}
break
;
}
}
else
{
if
(
current_document
.
hasOwnProperty
(
"
allOf
"
)
||
current_document
.
hasOwnProperty
(
"
anyOf
"
)
||
current_document
.
hasOwnProperty
(
"
oneOf
"
))
{
switch
(
property_name
)
{
case
"
type
"
:
case
"
allOf
"
:
case
"
anyOf
"
:
case
"
oneOf
"
:
return
false
;
}
}
switch
(
property_name
)
{
case
"
additionalItems
"
:
case
"
items
"
:
case
"
maxItems
"
:
case
"
minItems
"
:
case
"
uniqueItems
"
:
case
"
required
"
:
case
"
maxProperties
"
:
case
"
minProperties
"
:
case
"
additionalProperties
"
:
case
"
properties
"
:
case
"
patternProperties
"
:
case
"
propertyNames
"
:
case
"
maxLength
"
:
case
"
minLength
"
:
case
"
pattern
"
:
case
"
multipleOf
"
:
case
"
maximum
"
:
case
"
exclusiveMaximum
"
:
case
"
minimum
"
:
case
"
exclusiveMinimum
"
:
return
false
;
}
}
return
true
;
}
render_object
=
function
(
g
,
json_field
,
default_dict
,
root
,
path
,
schema_path
)
{
render_object
=
function
(
g
,
json_field
,
default_dict
,
root
,
path
,
schema_path
)
{
var
required
=
json_field
.
required
||
[],
var
required
=
json_field
.
required
||
[],
schema_editor
=
json_field
.
hasOwnProperty
(
"
properties
"
)
&&
schema_editor
=
checkSchemaIsMetaSchema
(
json_field
),
json_field
.
properties
.
hasOwnProperty
(
"
$schema
"
),
used_properties
=
{},
used_properties
=
{},
properties
,
properties
,
selector
=
{};
selector
=
{};
...
@@ -930,11 +1038,14 @@
...
@@ -930,11 +1038,14 @@
function
(
gadget_s
,
schema_alternatives
)
{
function
(
gadget_s
,
schema_alternatives
)
{
var
x
,
var
x
,
item_list
=
[[
"
add property
"
,
"
add property
"
]],
item_list
=
[[
"
add property
"
,
"
add property
"
]],
item
;
item
,
current_document
=
g
.
props
.
current_document
;
if
(
schema_alternatives
)
{
if
(
schema_alternatives
)
{
for
(
x
=
0
;
x
<
schema_alternatives
.
length
;
x
+=
1
)
{
for
(
x
=
0
;
x
<
schema_alternatives
.
length
;
x
+=
1
)
{
item
=
schema_alternatives
[
x
];
item
=
schema_alternatives
[
x
];
if
(
!
used_properties
.
hasOwnProperty
(
item
.
value
.
property_name
))
{
if
(
!
used_properties
.
hasOwnProperty
(
item
.
value
.
property_name
)
&&
!
(
schema_editor
&&
current_document
&&
!
filterPropery
(
item
.
value
.
property_name
,
current_document
)))
{
item_list
.
push
([
item
.
title
,
x
]);
item_list
.
push
([
item
.
title
,
x
]);
}
}
}
}
...
@@ -1369,6 +1480,10 @@
...
@@ -1369,6 +1480,10 @@
while
(
root
.
firstChild
)
{
while
(
root
.
firstChild
)
{
root
.
removeChild
(
root
.
firstChild
);
root
.
removeChild
(
root
.
firstChild
);
}
}
if
(
checkSchemaIsMetaSchema
(
schema
))
{
g
.
props
.
updatePropertySelectors
=
true
;
g
.
props
.
current_document
=
options
.
document
;
}
return
render_field
(
g
,
property_name
,
""
,
schema
,
return
render_field
(
g
,
property_name
,
""
,
schema
,
options
.
document
,
root
,
options
.
schema_path
,
options
.
document
,
root
,
options
.
schema_path
,
{
{
...
@@ -1378,7 +1493,6 @@
...
@@ -1378,7 +1493,6 @@
top
:
options
.
top
top
:
options
.
top
})
})
.
push
(
function
()
{
.
push
(
function
()
{
g
.
listenEvents
();
return
g
.
element
;
return
g
.
element
;
});
});
})
})
...
@@ -1411,20 +1525,39 @@
...
@@ -1411,20 +1525,39 @@
var
field_list
=
this
.
props
.
inputs
,
var
field_list
=
this
.
props
.
inputs
,
i
;
i
;
// on form data field
for
(
i
=
0
;
i
<
field_list
.
length
;
i
=
i
+
1
)
{
for
(
i
=
0
;
i
<
field_list
.
length
;
i
=
i
+
1
)
{
if
(
evt
.
target
===
field_list
[
i
])
{
if
(
evt
.
target
===
field_list
[
i
])
{
return
checkValidityAndNotifyChange
(
this
);
return
checkValidityAndNotifyChange
(
this
);
}
}
}
}
})
})
.
declareJob
(
'
listenEvents
'
,
function
()
{
// XXX Disable
return
;
})
.
declareMethod
(
'
getContent
'
,
function
()
{
.
declareMethod
(
'
getContent
'
,
function
()
{
var
g
=
this
;
var
g
=
this
;
return
getFormValuesAsJSONDict
(
g
);
return
getFormValuesAsJSONDict
(
g
)
.
push
(
function
(
data
)
{
if
(
g
.
props
.
updatePropertySelectors
)
{
g
.
props
.
current_document
=
data
;
var
key
,
tasks
=
[];
for
(
key
in
g
.
props
.
add_custom_data
)
{
if
(
g
.
props
.
add_custom_data
.
hasOwnProperty
(
key
))
{
tasks
.
push
(
g
.
props
.
add_custom_data
[
key
].
rerender
());
}
}
if
(
tasks
.
length
>
0
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
tasks
);
})
.
push
(
function
()
{
return
data
;
});
}
}
return
data
;
});
});
});
}(
window
,
document
,
location
,
rJS
,
RSVP
,
jIO
,
tv4
));
}(
window
,
document
,
location
,
rJS
,
RSVP
,
jIO
,
tv4
));
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment