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
Papa Tamsir Kane
erp5
Commits
5007a1d5
Commit
5007a1d5
authored
Aug 08, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[renderjs_ui] Allow passing `editable` into (embedded) form and let it change fields state
parent
95dea8f5
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
91 additions
and
47 deletions
+91
-47
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+2
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_field_formbox_js.js
...eItem/web_page_module/rjs_gadget_erp5_field_formbox_js.js
+21
-12
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
+14
-4
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
...plateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
+13
-6
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml
...lateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
...Item/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
+1
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
...tem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.js
...teItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.js
+1
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.xml
...eItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_editable_js.js
...b_page_module/rjs_gadget_erp5_pt_form_view_editable_js.js
+2
-1
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_editable_js.xml
..._page_module/rjs_gadget_erp5_pt_form_view_editable_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_embedded.js.js
...b_page_module/rjs_gadget_erp5_pt_form_view_embedded.js.js
+1
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_embedded.js.xml
..._page_module/rjs_gadget_erp5_pt_form_view_embedded.js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_js.js
...teItem/web_page_module/rjs_gadget_erp5_pt_form_view_js.js
+17
-7
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_js.xml
...eItem/web_page_module/rjs_gadget_erp5_pt_form_view_js.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_report_view_js.js
...Item/web_page_module/rjs_gadget_erp5_pt_report_view_js.js
+5
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_report_view_js.xml
...tem/web_page_module/rjs_gadget_erp5_pt_report_view_js.xml
+2
-2
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
5007a1d5
...
...
@@ -473,6 +473,8 @@ def renderField(traversed_document, field, form_relative_url, value=None, meta_t
}
# renderForm mutates `result` therefor no return/assignment
renderForm
(
formbox_context
,
embeded_form
,
result
[
'_embedded'
][
'_view'
],
key_prefix
=
key
)
# fix editability which is hard-coded to 0 in `renderForm` implementation
result
[
'_embedded'
][
'_view'
][
'form_id'
][
'editable'
]
=
field
.
get_value
(
"editable"
)
else
:
# All other fields are not implemented and we'll return only basic info about them
result
=
{
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_field_formbox_js.js
View file @
5007a1d5
/*global window, rJS,
RSVP,
URI */
/*global window, rJS, URI */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
URI
)
{
/**
* FormBox displays embedded form in itself.
*
* There are two common CSS classes bound to the FormBox Field
* - "horizontal_align_form_box" renders fields without labels in horizontal manner (useful for phone etc.)
* - "invisible" despite its name should only hide label
*
*/
(
function
(
window
,
rJS
,
URI
)
{
"
use strict
"
;
rJS
(
window
)
.
setState
({
subgadget_template
:
null
subgadget_template
:
undefined
,
editable
:
undefined
})
.
declareAcquiredMethod
(
"
jio_getAttachment
"
,
"
jio_getAttachment
"
)
...
...
@@ -27,7 +36,12 @@
erp5_form
:
field_json
.
_embedded
};
if
(
gadget
.
state
.
subgadget_template
===
null
||
options
.
reset
===
true
)
{
// prefer editability from the global context (form)
if
(
options
.
editable
!==
undefined
)
{
new_state
.
editable
=
options
.
editable
;
}
if
(
gadget
.
state
.
subgadget_template
===
undefined
||
options
.
reset
===
true
)
{
// render subgadget only when there is none OR render is explicitely requested
return
this
.
declareGadget
(
'
gadget_erp5_page_form.html
'
,
{
scope
:
'
sub
'
})
.
push
(
function
(
form_gadget
)
{
...
...
@@ -54,15 +68,10 @@
},
key
:
gadget
.
state
.
name
,
view
:
gadget
.
state
.
view
,
jio_key
:
erp5_document_uri
.
segment
(
2
)
jio_key
:
erp5_document_uri
.
segment
(
2
),
editable
:
gadget
.
state
.
editable
};
// XXX: can be uncommented - dunno if it is needed
// if `editable` changes - force reloading of the gadget
// if (modification_dict.hasOwnProperty('editable')) {
// return gadget.render({reset: true});
// }
// do not preserve objects in the state
delete
gadget
.
state
.
erp5_form
;
...
...
@@ -92,4 +101,4 @@
return
true
;
});
}(
window
,
rJS
,
RSVP
,
URI
));
\ No newline at end of file
}(
window
,
rJS
,
URI
));
\ No newline at end of file
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.js
View file @
5007a1d5
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, document, rJS, RSVP*/
(
function
(
window
,
document
,
rJS
,
RSVP
)
{
"
use strict
"
;
/** Form is one of a complicated gadget!
*
* Editability - the form overrides editability of its fields. Editability is
* hard-coded changed either in Page Templates or soft-coded
* changed in FormBox gadget which renders form as a subgadget
**/
function
getFieldTypeGadgetUrl
(
type
)
{
var
field_url
=
'
gadget_erp5_field_readonly.html
'
;
...
...
@@ -75,8 +82,9 @@
suboptions
.
field_json
=
rendered_field
;
suboptions
.
field_json
.
view
=
form_gadget
.
state
.
view
;
if
(
group
[
0
]
!==
"
bottom
"
)
{
suboptions
.
label
=
true
;
// if the whole form is non-editable than every field has to be non-editable
if
(
form_gadget
.
state
.
editable
===
0
)
{
suboptions
.
field_json
.
editable
=
0
;
}
return
new
RSVP
.
Queue
()
...
...
@@ -179,7 +187,9 @@
form_definition
:
options
.
form_definition
,
jio_key
:
options
.
jio_key
,
hash
:
hash
,
view
:
options
.
view
view
:
options
.
view
,
editable
:
options
.
editable
,
title
:
options
.
title
});
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
View file @
5007a1d5
...
...
@@ -81,7 +81,7 @@
if
(
options
.
hasOwnProperty
(
'
erp5_document
'
))
{
// if we get erp5 document during rendering then no need to fetch it
new_state
.
erp5_document
=
options
.
erp5_document
;
//
thank you options
//
remove reference to erp5_document from options (and new_state.options)
delete
options
.
erp5_document
;
}
else
{
promise_queue
...
...
@@ -103,6 +103,13 @@
});
}
// options.editable differs when it comes from the erp5_launcher of FormBox - try to unify it here
if
(
options
.
editable
===
"
true
"
||
options
.
editable
===
true
||
options
.
editable
===
"
1
"
||
options
.
editable
===
1
)
{
options
.
editable
=
1
;
}
else
{
options
.
editable
=
0
;
}
return
promise_queue
.
push
(
function
()
{
var
uri
=
new
URI
(
new_state
.
erp5_document
.
_embedded
.
_view
.
_links
.
form_definition
.
href
);
...
...
@@ -111,7 +118,7 @@
.
push
(
function
(
erp5_form
)
{
var
url
=
"
gadget_erp5_pt_
"
+
erp5_form
.
pt
;
// XXX Hardcoded specific behaviour for form_view
if
((
options
.
editable
!==
undefined
)
&&
(
erp5_form
.
pt
===
"
form_view
"
))
{
if
((
options
.
editable
===
1
)
&&
(
erp5_form
.
pt
===
"
form_view
"
))
{
url
+=
"
_editable
"
;
}
url
+=
"
.html
"
;
...
...
@@ -151,8 +158,8 @@
sub_options
.
form_definition
=
erp5_form
;
sub_options
.
view
=
options
.
view
;
sub_options
.
action_view
=
options
.
action_view
;
sub_options
.
jio_key
=
options
.
jio_key
;
sub_options
.
editable
=
options
.
editable
;
sub_options
.
jio_key
=
options
.
jio_key
;
// jIO identifier of currently rendered ERP5 document
sub_options
.
editable
=
options
.
editable
;
// form decides on editability of its fields
return
page_template_gadget
.
render
(
sub_options
);
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml
View file @
5007a1d5
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.1
1846.36682.48964
</string>
</value>
<value>
<string>
961.1
6455.47614.10018
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
150
1840583.61
</float>
<float>
150
2198575.84
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.js
View file @
5007a1d5
...
...
@@ -173,6 +173,7 @@
form_options
.
form_definition
=
form_gadget
.
state
.
form_definition
;
form_options
.
view
=
form_gadget
.
state
.
view
;
form_options
.
jio_key
=
form_gadget
.
state
.
jio_key
;
form_options
.
editable
=
form_gadget
.
state
.
editable
;
return
erp5_form
.
render
(
form_options
);
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_dialog_js.xml
View file @
5007a1d5
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.1
1852.40121.13414
</string>
</value>
<value>
<string>
961.1
6461.13159.33399
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
150
1840477.03
</float>
<float>
150
2116641.07
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.js
View file @
5007a1d5
...
...
@@ -60,6 +60,7 @@
form_options
.
form_definition
=
form_gadget
.
state
.
form_definition
;
form_options
.
view
=
form_gadget
.
state
.
view
;
form_options
.
jio_key
=
form_gadget
.
state
.
jio_key
;
form_options
.
editable
=
form_gadget
.
state
.
editable
;
// XXX Hardcoded for listbox's hide functionality
form_options
.
form_definition
.
hide_enabled
=
true
;
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_list_js.xml
View file @
5007a1d5
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.1
1851.43795.41164
</string>
</value>
<value>
<string>
961.1
6133.2066.40123
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
150
1840485.34
</float>
<float>
150
2114387.31
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_editable_js.js
View file @
5007a1d5
...
...
@@ -70,7 +70,8 @@
form_options
.
erp5_document
=
form_gadget
.
state
.
erp5_document
;
form_options
.
form_definition
=
form_gadget
.
state
.
form_definition
;
form_options
.
view
=
form_gadget
.
state
.
view
;
form_options
.
jio_key
=
form_gadget
.
state
.
jio_key
form_options
.
jio_key
=
form_gadget
.
state
.
jio_key
;
form_options
.
editable
=
1
;
return
erp5_form
.
render
(
form_options
);
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_editable_js.xml
View file @
5007a1d5
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.1
1851.10359.5666
</string>
</value>
<value>
<string>
961.1
6418.20259.26675
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
150
1840494.81
</float>
<float>
150
2116591.57
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_embedded.js.js
View file @
5007a1d5
...
...
@@ -51,6 +51,7 @@
form_options
.
form_definition
=
form_gadget
.
state
.
form_definition
;
form_options
.
view
=
form_gadget
.
state
.
view
;
form_options
.
name
=
form_gadget
.
state
.
name
;
form_options
.
editable
=
form_gadget
.
state
.
editable
;
return
erp5_form
.
render
(
form_options
);
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_embedded.js.xml
View file @
5007a1d5
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.1
1856.9454.43844
</string>
</value>
<value>
<string>
961.1
6458.28534.25173
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
150
1840453.3
6
</float>
<float>
150
2116475.5
6
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_js.js
View file @
5007a1d5
...
...
@@ -3,6 +3,20 @@
(
function
(
window
,
rJS
,
RSVP
,
calculatePageTitle
)
{
"
use strict
"
;
function
isGoodNonEditableField
(
field
)
{
// ListBox and FormBox should always get a chance to render
if
(
field
.
type
===
"
ListBox
"
)
{
return
true
;
}
if
(
field
.
type
===
"
FormBox
"
)
{
return
true
;
}
// hidden fields should not be obviously rendered
if
(
field
.
hidden
===
1
)
{
return
false
;
}
// field without default
if
(
!
field
.
default
)
{
return
false
;
}
if
(
field
.
default
.
length
===
0
)
{
return
false
;
}
if
(
field
.
default
.
length
===
1
&&
(
!
field
.
default
[
0
]))
{
return
false
;
}
return
true
;
}
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// Acquired methods
...
...
@@ -48,18 +62,13 @@
.
push
(
function
(
erp5_form
)
{
var
form_options
=
gadget
.
state
.
erp5_form
,
rendered_form
=
gadget
.
state
.
erp5_document
.
_embedded
.
_view
,
rendered_field
,
key
;
// Remove all empty
fields, and mark all others as non editable
// Remove all empty
or otherwise bad non-editable fields
for
(
key
in
rendered_form
)
{
if
(
rendered_form
.
hasOwnProperty
(
key
)
&&
(
key
[
0
]
!==
"
_
"
))
{
rendered_field
=
rendered_form
[
key
];
if
((
rendered_field
.
type
!==
"
ListBox
"
)
&&
((
!
rendered_field
.
default
)
||
(
rendered_field
.
hidden
===
1
)
||
(
rendered_field
.
default
.
length
===
0
)
||
(
rendered_field
.
default
.
length
===
1
&&
(
!
rendered_field
.
default
[
0
]))))
{
if
(
!
isGoodNonEditableField
(
rendered_form
[
key
]))
{
delete
rendered_form
[
key
];
}
else
{
rendered_field
.
editable
=
0
;
}
}
}
...
...
@@ -68,6 +77,7 @@
form_options
.
form_definition
=
gadget
.
state
.
form_definition
;
form_options
.
view
=
gadget
.
state
.
view
;
form_options
.
jio_key
=
gadget
.
state
.
jio_key
;
form_options
.
editable
=
0
;
return
erp5_form
.
render
(
form_options
);
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_form_view_js.xml
View file @
5007a1d5
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.1
1849.54154.45550
</string>
</value>
<value>
<string>
961.1
6419.13605.17578
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
150
1840503.4
4
</float>
<float>
150
2116554.6
4
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_report_view_js.js
View file @
5007a1d5
...
...
@@ -32,7 +32,8 @@
}
};
return
form_gadget
.
render
({
erp5_document
:
erp5_document
,
form_definition
:
form_definition
});
form_definition
:
form_definition
,
editable
:
0
});
});
}
...
...
@@ -66,7 +67,7 @@
return
this
.
changeState
({
erp5_document
:
options
.
erp5_document
,
form_definition
:
options
.
form_definition
,
form_gadget_url
:
form_gadget_url
form_gadget_url
:
form_gadget_url
,
});
})
.
onStateChange
(
function
(
modification_dict
)
{
...
...
@@ -90,7 +91,8 @@
form_gadget
=
result
;
return
form_gadget
.
render
({
erp5_document
:
gadget
.
state
.
erp5_document
,
form_definition
:
gadget
.
state
.
form_definition
form_definition
:
gadget
.
state
.
form_definition
,
editable
:
0
});
})
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_report_view_js.xml
View file @
5007a1d5
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
54.25919.63902.23893
</string>
</value>
<value>
<string>
9
61.16421.12334.2201
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
1
476194238.38
</float>
<float>
1
502116518.17
</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