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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Iliya Manolov
erp5
Commits
990a3253
Commit
990a3253
authored
Dec 05, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Create form fields in parallel
parent
b1c79faf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
90 deletions
+107
-90
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.js
...thTemplateItem/web_page_module/rjs_gadget_erp5_form_js.js
+105
-88
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
...hTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.js
View file @
990a3253
...
...
@@ -3,6 +3,7 @@
(
function
(
window
,
document
,
rJS
,
RSVP
)
{
"
use strict
"
;
function
getFieldTypeGadgetUrl
(
type
)
{
var
field_url
=
'
gadget_erp5_field_readonly.html
'
;
if
(
type
===
'
ListField
'
)
{
...
...
@@ -50,78 +51,11 @@
return
field_url
;
}
rJS
(
window
)
.
ready
(
function
(
g
)
{
g
.
props
=
{};
})
.
allowPublicAcquisition
(
"
getFieldTypeGadgetUrl
"
,
function
(
param_list
)
{
return
getFieldTypeGadgetUrl
(
param_list
[
0
]);
})
.
allowPublicAcquisition
(
"
getFormContent
"
,
function
(
param_list
)
{
return
this
.
getContent
(
param_list
[
0
]);
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
group_list
=
options
.
form_definition
.
group_list
,
rendered_form
=
options
.
erp5_document
.
_embedded
.
_view
,
i
,
j
,
hash
=
""
;
// Check the list of field to render
// If the list is different, DOM content will be dropped
// and recreated
for
(
i
=
0
;
i
<
group_list
.
length
;
i
+=
1
)
{
hash
+=
group_list
[
i
][
0
];
for
(
j
=
0
;
j
<
group_list
[
i
][
1
].
length
;
j
+=
1
)
{
if
(
rendered_form
.
hasOwnProperty
(
group_list
[
i
][
1
][
j
][
0
]))
{
hash
+=
group_list
[
i
][
1
][
j
][
0
];
}
}
}
return
this
.
changeState
({
erp5_document
:
options
.
erp5_document
,
form_definition
:
options
.
form_definition
,
hash
:
hash
,
view
:
options
.
view
});
})
.
onStateChange
(
function
(
modification_dict
)
{
var
i
,
erp5_document
=
this
.
state
.
erp5_document
,
form_definition
=
this
.
state
.
form_definition
,
rendered_form
=
erp5_document
.
_embedded
.
_view
,
group_list
=
form_definition
.
group_list
,
queue
=
new
RSVP
.
Queue
(),
form_gadget
=
this
,
parent_element
=
document
.
createElement
(
"
div
"
);
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
form_gadget
.
props
.
gadget_list
=
[];
}
function
addGroup
(
group
)
{
queue
.
push
(
function
()
{
var
j
,
// XXX: > Romain: fieldset will be needed later for menus
fieldset_element
=
document
.
createElement
(
"
div
"
),
group_queue
=
new
RSVP
.
Queue
();
function
addField
(
field
)
{
group_queue
.
push
(
function
()
{
function
addField
(
field
,
rendered_form
,
form_definition
,
form_gadget
,
group
,
modification_dict
)
{
if
(
rendered_form
.
hasOwnProperty
(
field
[
0
]))
{
// Field is enabled in this context
var
field_queue
=
new
RSVP
.
Queue
(),
sandbox
=
"
public
"
,
var
sandbox
=
"
public
"
,
field_element
=
document
.
createElement
(
"
div
"
),
renderered_field
=
rendered_form
[
field
[
0
]],
// suboptions = options[renderered_field.key] || suboption_dict;
...
...
@@ -143,7 +77,7 @@
suboptions
.
label
=
true
;
}
return
field_queue
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
return
form_gadget
.
declareGadget
(
'
gadget_erp5_label_field.html
'
,
{
...
...
@@ -157,7 +91,7 @@
.
push
(
function
(
label_gadget
)
{
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
//XX
XXX Hardcoded to get one listbox gadget
//
XXX Hardcoded to get one listbox gadget
//pt form list gadget will get this listbox's info
//then pass to search field gadget
if
(
suboptions
.
field_url
===
"
gadget_erp5_field_listbox.html
"
)
{
...
...
@@ -168,31 +102,114 @@
return
label_gadget
.
render
(
suboptions
);
})
.
push
(
function
()
{
fieldset_element
.
appendChild
(
field_element
);
return
field_element
;
// return fieldset_element;
// fieldset_element.appendChild(field_element);
});
}
});
}
function
addGroup
(
group
,
rendered_form
,
form_definition
,
form_gadget
,
modification_dict
)
{
// XXX: > Romain: fieldset will be needed later for menus
var
fieldset_element
=
document
.
createElement
(
"
div
"
),
promise_field_list
=
[],
j
;
fieldset_element
.
setAttribute
(
"
class
"
,
group
[
0
]);
for
(
j
=
0
;
j
<
group
[
1
].
length
;
j
+=
1
)
{
addField
(
group
[
1
][
j
]
);
promise_field_list
.
push
(
addField
(
group
[
1
][
j
],
rendered_form
,
form_definition
,
form_gadget
,
group
,
modification_dict
)
);
}
return
group_queue
.
push
(
function
()
{
parent_element
.
appendChild
(
fieldset_element
);
});
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
promise_field_list
);
})
.
push
(
function
(
result_list
)
{
var
i
;
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
if
(
result_list
[
i
])
{
fieldset_element
.
appendChild
(
result_list
[
i
]);
}
}
return
fieldset_element
;
});
}
rJS
(
window
)
.
ready
(
function
(
g
)
{
g
.
props
=
{};
})
.
allowPublicAcquisition
(
"
getFieldTypeGadgetUrl
"
,
function
(
param_list
)
{
return
getFieldTypeGadgetUrl
(
param_list
[
0
]);
})
.
allowPublicAcquisition
(
"
getFormContent
"
,
function
(
param_list
)
{
return
this
.
getContent
(
param_list
[
0
]);
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
group_list
=
options
.
form_definition
.
group_list
,
rendered_form
=
options
.
erp5_document
.
_embedded
.
_view
,
i
,
j
,
hash
=
""
;
// Check the list of field to render
// If the list is different, DOM content will be dropped
// and recreated
for
(
i
=
0
;
i
<
group_list
.
length
;
i
+=
1
)
{
addGroup
(
group_list
[
i
]);
hash
+=
group_list
[
i
][
0
];
for
(
j
=
0
;
j
<
group_list
[
i
][
1
].
length
;
j
+=
1
)
{
if
(
rendered_form
.
hasOwnProperty
(
group_list
[
i
][
1
][
j
][
0
]))
{
hash
+=
group_list
[
i
][
1
][
j
][
0
];
}
}
}
return
queue
return
this
.
changeState
({
erp5_document
:
options
.
erp5_document
,
form_definition
:
options
.
form_definition
,
hash
:
hash
,
view
:
options
.
view
});
})
.
onStateChange
(
function
(
modification_dict
)
{
var
erp5_document
=
this
.
state
.
erp5_document
,
form_definition
=
this
.
state
.
form_definition
,
rendered_form
=
erp5_document
.
_embedded
.
_view
,
group_list
=
form_definition
.
group_list
,
form_gadget
=
this
;
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
form_gadget
.
props
.
gadget_list
=
[];
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
var
group_promise_list
=
[],
j
;
for
(
j
=
0
;
j
<
group_list
.
length
;
j
+=
1
)
{
group_promise_list
.
push
(
addGroup
(
group_list
[
j
],
rendered_form
,
form_definition
,
form_gadget
,
modification_dict
));
}
return
RSVP
.
all
(
group_promise_list
);
})
.
push
(
function
(
result_list
)
{
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
var
dom_element
=
form_gadget
.
element
.
querySelector
(
"
.field_container
"
);
.
querySelector
(
"
.field_container
"
),
j
,
parent_element
=
document
.
createDocumentFragment
();
// Add all fieldset into the fragment
for
(
j
=
0
;
j
<
result_list
.
length
;
j
+=
1
)
{
parent_element
.
appendChild
(
result_list
[
j
]);
}
while
(
dom_element
.
firstChild
)
{
dom_element
.
removeChild
(
dom_element
.
firstChild
);
}
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
View file @
990a3253
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
95
4.45675.44850.53452
</string>
</value>
<value>
<string>
95
5.49459.46929.49339
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
14
78189239.8
</float>
<float>
14
80936090.54
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
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