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
138
Merge Requests
138
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
3de2bb25
Commit
3de2bb25
authored
Apr 30, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: simplifying action gadget fields
parent
f2155f45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
21 deletions
+89
-21
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.js
.../web_page_module/gadget_officejs_page_handle_action_js.js
+87
-19
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.xml
...web_page_module/gadget_officejs_page_handle_action_js.xml
+2
-2
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.js
View file @
3de2bb25
...
...
@@ -10,6 +10,9 @@
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
"
getUrlParameter
"
,
"
getUrlParameter
"
)
.
declareAcquiredMethod
(
"
notifySubmitted
"
,
'
notifySubmitted
'
)
.
declareAcquiredMethod
(
"
notifySubmitting
"
,
"
notifySubmitting
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
/////////////////////////////////////////////////////////////////
// declared methods
...
...
@@ -32,7 +35,7 @@
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
action_reference
;
var
gadget
=
this
,
action_reference
,
valid_action
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
...
...
@@ -50,32 +53,97 @@
return
gadget
.
getActionFormDefinition
(
action_reference
);
})
.
push
(
function
(
form_definition
)
{
if
(
form_definition
.
action_type
===
"
object_jio_js_script
"
)
{
if
(
form_definition
.
fields_raw_properties
.
hasOwnProperty
(
"
gadget_field_action_js_script
"
))
{
var
fragment
=
document
.
createElement
(
'
div
'
),
action_gadget_url
=
form_definition
.
fields_raw_properties
.
gadget_field_action_js_script
.
values
.
gadget_url
;
gadget
.
element
.
appendChild
(
fragment
);
return
gadget
.
declareGadget
(
action_gadget_url
,
{
scope
:
"
action_field
"
,
element
:
fragment
/*,
sandbox: 'iframe'*/
})
.
push
(
function
(
action_gadget
)
{
return
action_gadget
.
render
(
options
,
action_reference
,
form_definition
);
valid_action
=
form_definition
.
action_type
===
"
object_jio_js_script
"
&&
form_definition
.
fields_raw_properties
.
hasOwnProperty
(
"
gadget_field_action_js_script
"
);
var
fragment
=
document
.
createElement
(
'
div
'
),
action_gadget_url
=
form_definition
.
fields_raw_properties
.
gadget_field_action_js_script
.
values
.
gadget_url
;
if
(
valid_action
)
{
gadget
.
element
.
appendChild
(
fragment
);
return
gadget
.
declareGadget
(
action_gadget_url
,
{
scope
:
"
action_field
"
,
element
:
fragment
})
.
push
(
function
(
action_gadget
)
{
return
action_gadget
.
preRenderDocument
(
options
);
})
.
push
(
function
(
doc
)
{
return
gadget
.
changeState
({
doc
:
doc
,
parent_options
:
options
,
child_gadget_url
:
'
gadget_erp5_pt_form_dialog.html
'
,
form_type
:
'
dialog
'
,
form_definition
:
form_definition
,
view
:
action_reference
,
valid_action
:
valid_action
});
}
});
}
else
{
return
gadget
.
changeState
({
doc
:
{},
parent_options
:
options
,
child_gadget_url
:
'
gadget_erp5_pt_form_dialog.html
'
,
form_type
:
'
dialog
'
,
form_definition
:
form_definition
,
view
:
action_reference
,
valid_action
:
valid_action
});
}
// avoid crash if form doesn't have gadget_field_action_js_script or object_jio_js_script action
// TODO: render form without submit (and warn/inform user?)
});
})
.
declareMethod
(
'
triggerSubmit
'
,
function
()
{
.
onStateChange
(
function
()
{
var
gadget
=
this
;
return
gadget
.
getDeclaredGadget
(
'
action_field
'
)
return
gadget
.
declareGadget
(
"
gadget_officejs_form_view.html
"
)
.
push
(
function
(
form_view_gadget
)
{
return
form_view_gadget
.
renderGadget
(
gadget
);
});
})
.
declareMethod
(
'
triggerSubmit
'
,
function
()
{
return
this
.
getDeclaredGadget
(
'
fg
'
)
.
push
(
function
(
gadget
)
{
return
gadget
.
triggerSubmit
();
});
})
.
allowPublicAcquisition
(
'
submitContent
'
,
function
(
options
)
{
var
gadget
=
this
,
//target_url = options[1],
content_dict
=
options
[
2
],
fragment
=
document
.
createElement
(
'
div
'
),
action_gadget_url
,
jio_key
;
if
(
gadget
.
state
.
valid_action
)
{
action_gadget_url
=
gadget
.
state
.
form_definition
.
fields_raw_properties
.
gadget_field_action_js_script
.
values
.
gadget_url
;
gadget
.
element
.
appendChild
(
fragment
);
return
gadget
.
declareGadget
(
action_gadget_url
,
{
scope
:
"
action_field
"
,
element
:
fragment
})
.
push
(
function
(
action_gadget
)
{
return
action_gadget
.
triggerSubmit
();
return
action_gadget
.
handleSubmit
(
content_dict
,
gadget
.
state
);
})
.
push
(
function
(
id
)
{
jio_key
=
id
;
return
gadget
.
notifySubmitting
();
})
.
push
(
function
()
{
return
gadget
.
notifySubmitted
({
message
:
'
Data Updated
'
,
status
:
'
success
'
});
})
.
push
(
function
()
{
return
gadget
.
redirect
({
command
:
'
display
'
,
options
:
{
jio_key
:
jio_key
,
editable
:
true
}
});
});
}
else
{
return
gadget
.
notifySubmitted
({
message
:
'
Could not perform this action: configuration error
'
,
status
:
'
fail
'
})
.
push
(
function
()
{
return
;
});
}
});
}(
window
,
document
,
rJS
,
RSVP
));
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.xml
View file @
3de2bb25
...
...
@@ -269,7 +269,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
975.2
3867.41521.38092
</string>
</value>
<value>
<string>
975.2
5263.50685.65109
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>
1556
575547.5
6
</float>
<float>
1556
658280.7
6
</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