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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
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
Hide 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,6 +51,92 @@
return
field_url
;
}
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
sandbox
=
"
public
"
,
field_element
=
document
.
createElement
(
"
div
"
),
renderered_field
=
rendered_form
[
field
[
0
]],
// suboptions = options[renderered_field.key] || suboption_dict;
suboptions
=
{};
// XXX Hardcoded for searchfield - remove later!
if
(
form_definition
.
extended_search
)
{
suboptions
.
extended_search
=
form_definition
.
extended_search
;
}
// XXX Hardcoded for listbox's hide functionality
suboptions
.
hide_enabled
=
form_definition
.
hide_enabled
;
suboptions
.
field_url
=
getFieldTypeGadgetUrl
(
renderered_field
.
type
);
suboptions
.
label
=
false
;
suboptions
.
field_json
=
renderered_field
;
suboptions
.
field_json
.
view
=
form_gadget
.
state
.
view
;
if
(
group
[
0
]
!==
"
bottom
"
)
{
suboptions
.
label
=
true
;
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
return
form_gadget
.
declareGadget
(
'
gadget_erp5_label_field.html
'
,
{
scope
:
renderered_field
.
key
,
element
:
field_element
,
sandbox
:
sandbox
});
}
return
form_gadget
.
getDeclaredGadget
(
renderered_field
.
key
);
})
.
push
(
function
(
label_gadget
)
{
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
// 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
"
)
{
form_gadget
.
props
.
listbox_gadget
=
label_gadget
;
}
form_gadget
.
props
.
gadget_list
.
push
(
label_gadget
);
}
return
label_gadget
.
render
(
suboptions
);
})
.
push
(
function
()
{
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
)
{
promise_field_list
.
push
(
addField
(
group
[
1
][
j
],
rendered_form
,
form_definition
,
form_gadget
,
group
,
modification_dict
));
}
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
=
{};
...
...
@@ -94,105 +181,35 @@
})
.
onStateChange
(
function
(
modification_dict
)
{
var
i
,
erp5_document
=
this
.
state
.
erp5_document
,
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
,
queue
=
new
RSVP
.
Queue
(),
form_gadget
=
this
,
parent_element
=
document
.
createElement
(
"
div
"
);
form_gadget
=
this
;
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
()
{
if
(
rendered_form
.
hasOwnProperty
(
field
[
0
]))
{
// Field is enabled in this context
var
field_queue
=
new
RSVP
.
Queue
(),
sandbox
=
"
public
"
,
field_element
=
document
.
createElement
(
"
div
"
),
renderered_field
=
rendered_form
[
field
[
0
]],
// suboptions = options[renderered_field.key] || suboption_dict;
suboptions
=
{};
// XXX Hardcoded for searchfield - remove later!
if
(
form_definition
.
extended_search
)
{
suboptions
.
extended_search
=
form_definition
.
extended_search
;
}
// XXX Hardcoded for listbox's hide functionality
suboptions
.
hide_enabled
=
form_definition
.
hide_enabled
;
suboptions
.
field_url
=
getFieldTypeGadgetUrl
(
renderered_field
.
type
);
suboptions
.
label
=
false
;
suboptions
.
field_json
=
renderered_field
;
suboptions
.
field_json
.
view
=
form_gadget
.
state
.
view
;
if
(
group
[
0
]
!==
"
bottom
"
)
{
suboptions
.
label
=
true
;
}
return
field_queue
.
push
(
function
()
{
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
return
form_gadget
.
declareGadget
(
'
gadget_erp5_label_field.html
'
,
{
scope
:
renderered_field
.
key
,
element
:
field_element
,
sandbox
:
sandbox
});
}
return
form_gadget
.
getDeclaredGadget
(
renderered_field
.
key
);
})
.
push
(
function
(
label_gadget
)
{
if
(
modification_dict
.
hasOwnProperty
(
'
hash
'
))
{
//XXXXX 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
"
)
{
form_gadget
.
props
.
listbox_gadget
=
label_gadget
;
}
form_gadget
.
props
.
gadget_list
.
push
(
label_gadget
);
}
return
label_gadget
.
render
(
suboptions
);
})
.
push
(
function
()
{
fieldset_element
.
appendChild
(
field_element
);
});
}
});
}
fieldset_element
.
setAttribute
(
"
class
"
,
group
[
0
]);
for
(
j
=
0
;
j
<
group
[
1
].
length
;
j
+=
1
)
{
addField
(
group
[
1
][
j
]);
}
return
group_queue
.
push
(
function
()
{
parent_element
.
appendChild
(
fieldset_element
);
});
});
}
for
(
i
=
0
;
i
<
group_list
.
length
;
i
+=
1
)
{
addGroup
(
group_list
[
i
]);
}
return
queue
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