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
Labels
Merge Requests
147
Merge Requests
147
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
1d888b21
Commit
1d888b21
authored
Mar 18, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: got rid of editable view form and using gadget_erp5_form directly
parent
5c535db2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
57 deletions
+63
-57
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
...e_module/gadget_officejs_controller_page_controller_js.js
+61
-55
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
..._module/gadget_officejs_controller_page_controller_js.xml
+2
-2
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
View file @
1d888b21
/*global document, window, rJS, RSVP
, jIO
*/
/*global document, window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
document
,
window
,
rJS
,
RSVP
,
jIO
)
{
(
function
(
document
,
window
,
rJS
,
RSVP
)
{
"
use strict
"
;
function
renderField
(
field_id
,
field_definition
,
document
)
{
...
...
@@ -79,6 +79,7 @@
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_put
"
,
"
jio_put
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
...
...
@@ -108,7 +109,7 @@
return
renderForm
(
form_definition
,
document
);
})
.
allowPublicAcquisition
(
'
submitContent
'
,
function
(
options
)
{
.
declareMethod
(
'
submitContent
'
,
function
(
options
)
{
var
gadget
=
this
,
jio_key
=
options
[
0
],
//target_url = options[1],
...
...
@@ -134,40 +135,8 @@
.
allowPublicAcquisition
(
'
notifySubmit
'
,
function
()
{
return
this
.
triggerSubmit
();
})
.
declareMethod
(
'
triggerSubmit
'
,
function
()
{
return
this
.
getDeclaredGadget
(
'
fg
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
triggerSubmit
();
});
})
// kept until submit is done in controller
.
declareMethod
(
"
renderEditableView
"
,
function
(
gadget
,
subgadget
,
form_json
)
{
return
subgadget
.
render
({
jio_key
:
gadget
.
state
.
jio_key
,
doc
:
gadget
.
state
.
doc
,
erp5_document
:
form_json
.
erp5_document
,
form_definition
:
form_json
.
form_definition
,
editable
:
gadget
.
state
.
editable
,
view
:
gadget
.
state
.
view
,
form_json
:
form_json
})
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getUrlFor
({
command
:
'
history_previous
'
}),
gadget
.
getUrlFor
({
command
:
'
selection_previous
'
}),
gadget
.
getUrlFor
({
command
:
'
selection_next
'
})
]);
})
.
push
(
function
(
url_list
)
{
return
subgadget
.
updateHeader
({
page_title
:
gadget
.
state
.
doc
.
title
,
save_action
:
true
,
selection_url
:
url_list
[
0
],
previous_url
:
url_list
[
1
],
next_url
:
url_list
[
2
]
});
});
.
declareMethod
(
'
triggerSubmit
'
,
function
triggerSubmit
()
{
this
.
element
.
querySelector
(
'
button
'
).
click
();
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
...
...
@@ -179,8 +148,8 @@
/*child_gadget_url = 'gadget_officejs_jio_' +
result.portal_type.replace(/ /g, '_').toLowerCase() +
'_view.html';*/
// [HARDCODED] force to use form view
editable
child_gadget_url
=
'
gadget_erp5_pt_form_view_editable.html
'
;
// [HARDCODED] force to use form view
child_gadget_url
=
"
gadget_erp5_form.html
"
;
}
else
{
throw
new
Error
(
'
Can not display document:
'
+
options
.
jio_key
);
}
...
...
@@ -207,8 +176,8 @@
editable
:
gadget
.
state
.
editable
,
view
:
gadget
.
state
.
view
,
form_json
:
form_json
,
new_content_action
:
false
,
delete_action
:
false
,
//
new_content_action: false,
//
delete_action: false,
save_action
:
false
};
if
(
form_json
.
erp5_document
.
_embedded
.
_view
.
_actions
!==
undefined
)
{
...
...
@@ -234,7 +203,7 @@
}
return
RSVP
.
all
([
//calculatePageTitle(gadget, gadget.state.erp5_document),
gadget
.
getUrlParameter
(
'
selection_index
'
),
gadget
.
getUrlParameter
(
'
selection_index
'
),
// check if needed
gadget
.
getUrlForList
(
url_for_parameter_list
),
gadget
.
isDesktopMedia
()
]);
...
...
@@ -246,8 +215,8 @@
//actions_url: url_list[1],
//add_url: url_list[6] || '',
selection_url
:
url_list
[
2
],
previous_url
:
result_list
[
0
]
?
url_list
[
3
]
:
''
,
next_url
:
result_list
[
0
]
?
url_list
[
4
]
:
''
,
previous_url
:
url_list
[
3
]
,
next_url
:
url_list
[
4
]
,
page_title
:
gadget
.
state
.
doc
.
title
//or calculatePageTitle in RSVP.all ?
};
if
(
render_options
.
save_action
===
true
)
{
...
...
@@ -266,27 +235,64 @@
.
onStateChange
(
function
(
modification_dict
)
{
var
fragment
=
document
.
createElement
(
'
div
'
),
gadget
=
this
;
gadget
=
this
,
submit_button
=
gadget
.
element
.
querySelector
(
'
button
'
),
form
=
document
.
createElement
(
'
form
'
);
return
gadget
.
renderForm
(
gadget
.
state
.
form_definition
,
gadget
.
state
.
doc
)
.
push
(
function
(
form_json
)
{
/*
if (!modification_dict.hasOwnProperty('child_gadget_url')) {
return gadget.getDeclaredGadget('
fg
')
if
(
!
modification_dict
.
hasOwnProperty
(
'
child_gadget_url
'
))
{
return
gadget
.
getDeclaredGadget
(
'
sub_form
'
)
.
push
(
function
(
child_gadget
)
{
return
gadget
.
renderSubGadget
(
gadget
,
child_gadget
,
form_json
);
});
}
*/
}
// Clear first to DOM, append after to reduce flickering/manip
while
(
gadget
.
element
.
firstChild
)
{
gadget
.
element
.
removeChild
(
gadget
.
element
.
firstChild
);
}
gadget
.
element
.
appendChild
(
fragment
);
return
gadget
.
declareGadget
(
gadget
.
state
.
child_gadget_url
,
{
element
:
fragment
,
scope
:
'
fg
'
})
//return gadget.declareGadget("gadget_erp5_form.html", {element: fragment, scope: 'fg'})
form
.
appendChild
(
fragment
);
form
.
appendChild
(
submit_button
);
gadget
.
element
.
appendChild
(
form
);
return
gadget
.
declareGadget
(
gadget
.
state
.
child_gadget_url
,
{
element
:
fragment
,
scope
:
'
sub_form
'
})
.
push
(
function
(
form_gadget
)
{
//return gadget.renderSubGadget(gadget, form_gadget, form_json);
return
gadget
.
renderEditableView
(
gadget
,
form_gadget
,
form_json
);
return
gadget
.
renderSubGadget
(
gadget
,
form_gadget
,
form_json
);
});
});
});
})
.
onEvent
(
'
submit
'
,
function
submit
()
{
var
gadget
=
this
;
return
gadget
.
getDeclaredGadget
(
"
sub_form
"
)
.
push
(
function
(
form_gadget
)
{
if
(
form_gadget
.
state
.
erp5_document
.
_embedded
.
_view
.
_actions
===
undefined
||
form_gadget
.
state
.
erp5_document
.
_embedded
.
_view
.
_actions
.
put
===
undefined
)
{
return
;
}
var
action
=
form_gadget
.
state
.
erp5_document
.
_embedded
.
_view
.
_actions
.
put
;
return
form_gadget
.
checkValidity
()
.
push
(
function
(
is_valid
)
{
if
(
!
is_valid
)
{
return
null
;
}
return
form_gadget
.
getContent
();
})
.
push
(
function
(
content_dict
)
{
if
(
content_dict
===
null
)
{
return
;
}
return
gadget
.
submitContent
([
gadget
.
state
.
jio_key
,
action
.
href
,
content_dict
]);
})
.
push
(
function
(
jio_key
)
{
if
(
jio_key
)
{
// success redirect callback receives jio_key
return
gadget
.
redirect
({
command
:
'
reload
'
});
}
});
});
},
false
,
true
);
}(
document
,
window
,
rJS
,
RSVP
,
jIO
));
\ No newline at end of file
}(
document
,
window
,
rJS
,
RSVP
));
\ No newline at end of file
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
View file @
1d888b21
...
...
@@ -225,7 +225,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.2
4392.10238.46182
</string>
</value>
<value>
<string>
974.2
8432.14589.45499
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>
1552
673782.74
</float>
<float>
1552
916259.36
</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