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
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amer
erp5
Commits
133113b3
Commit
133113b3
authored
Apr 08, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: portal type actions are handle in handle action gadget instead of controller
parent
c4c3a11f
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
863 additions
and
107 deletions
+863
-107
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
...e_module/gadget_officejs_controller_page_controller_js.js
+5
-58
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
..._module/gadget_officejs_controller_page_controller_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_discussion_tool_appcache.xml
..._page_module/gadget_officejs_discussion_tool_appcache.xml
+10
-9
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.js
...web_page_module/gadget_officejs_erp5_page_post_list_js.js
+1
-1
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.xml
...eb_page_module/gadget_officejs_erp5_page_post_list_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_offline_js.js
...web_page_module/gadget_officejs_page_action_offline_js.js
+20
-33
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_offline_js.xml
...eb_page_module/gadget_officejs_page_action_offline_js.xml
+2
-2
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_html.html
..._page_module/gadget_officejs_page_handle_action_html.html
+19
-0
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_html.xml
...b_page_module/gadget_officejs_page_handle_action_html.xml
+363
-0
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.js
.../web_page_module/gadget_officejs_page_handle_action_js.js
+80
-0
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.xml
...web_page_module/gadget_officejs_page_handle_action_js.xml
+359
-0
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.js
View file @
133113b3
...
...
@@ -43,23 +43,6 @@
return
result
;
}
function
getActionReference
(
view_url_parameters
)
{
//TODO: check how to properly add a parameter to gadget render option
// and not within the view url-parameter
var
parser
=
document
.
createElement
(
'
a
'
),
urlParams
,
action_reference
;
if
(
view_url_parameters
.
indexOf
(
"
#!change?
"
)
!==
-
1
)
{
parser
.
href
=
window
.
location
.
origin
+
"
/
"
+
view_url_parameters
.
replace
(
/#!change
?
/g
,
'
change?
'
);
urlParams
=
new
URLSearchParams
(
parser
.
search
);
action_reference
=
urlParams
.
get
(
"
n.action
"
);
}
else
{
action_reference
=
view_url_parameters
;
}
if
(
action_reference
===
undefined
||
action_reference
===
null
||
action_reference
===
"
view
"
)
{
action_reference
=
default_view
;
}
return
action_reference
;
}
rJS
(
window
)
/////////////////////////////////////////////////////////////////
...
...
@@ -82,36 +65,6 @@
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
handleAction
"
,
function
(
key
,
document
,
view_parameters
)
{
var
gadget
=
this
,
jio_key
=
key
,
jio_document
=
document
,
action_reference
=
getActionReference
(
view_parameters
);
// This is the custom code to handle this specific reply action
// it should be somewhere else to keep the controller generic
if
(
action_reference
==
"
reply
"
)
{
var
doc
,
title
=
document
.
title
;
if
(
!
title
.
startsWith
(
"
Re:
"
))
{
title
=
"
Re:
"
+
document
.
title
;
}
doc
=
{
title
:
title
,
//thread parent: same as base post
source_reference
:
document
.
source_reference
,
portal_type
:
document
.
portal_type
,
parent_relative_url
:
document
.
parent_relative_url
};
return
gadget
.
jio_post
(
doc
)
.
push
(
function
(
id
)
{
jio_key
=
id
;
return
gadget
.
jio_get
(
jio_key
);
})
.
push
(
function
(
created_doc
)
{
jio_document
=
created_doc
;
return
[
jio_key
,
jio_document
,
action_reference
];
});
}
return
[
jio_key
,
jio_document
,
action_reference
];
})
.
declareMethod
(
"
getFormDefinition
"
,
function
(
portal_type
,
action_reference
)
{
var
gadget
=
this
,
parent
=
"
portal_types/
"
+
portal_type
,
...
...
@@ -209,24 +162,18 @@
if
(
document
.
portal_type
===
undefined
)
{
throw
new
Error
(
'
Can not display document:
'
+
options
.
jio_key
);
}
return
gadget
.
getUrlParameter
(
"
view
"
);
})
.
push
(
function
(
view_parameters
)
{
return
gadget
.
handleAction
(
options
.
jio_key
,
document
,
view_parameters
);
})
.
push
(
function
(
result_list
)
{
return
gadget
.
getFormDefinition
(
document
.
portal_type
,
result_list
[
2
])
return
gadget
.
getFormDefinition
(
document
.
portal_type
,
options
.
view
)
.
push
(
function
(
form_definition
)
{
return
gadget
.
changeState
({
jio_key
:
result_list
[
0
]
,
doc
:
result_list
[
1
]
,
jio_key
:
options
.
jio_key
,
doc
:
document
,
child_gadget_url
:
child_gadget_url
,
form_definition
:
form_definition
,
editable
:
options
.
editable
,
view
:
result_list
[
2
]
,
view
:
options
.
view
,
//HARDCODED: following fields should be indicated by the configuration
has_more_views
:
false
,
has_more_actions
:
result_list
[
2
]
==
default_view
,
has_more_actions
:
options
.
view
==
"
view
"
,
is_form_list
:
false
});
});
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_controller_page_controller_js.xml
View file @
133113b3
...
...
@@ -225,7 +225,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.5
3016.56105.24149
</string>
</value>
<value>
<string>
974.5
9024.11735.30037
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>
1554
391859.64
</float>
<float>
1554
751815.26
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_discussion_tool_appcache.xml
View file @
133113b3
...
...
@@ -225,7 +225,15 @@ gadget_erp5_pt_form_view_editable.html\n
gadget_erp5_pt_form_view_editable.js\n
gadget_erp5_page_action_offline.html\n
gadget_erp5_page_action_offline.js\n
gadget_erp5_page_handle_action.html\n
gadget_erp5_page_handle_action.js\n
gadget_officejs_discussion_tool_router.html\n
gadget_erp5_page_ojs_controller.html\n
gadget_erp5_page_ojs_controller.js\n
gadget_erp5_page_ojs_post_list.html\n
gadget_erp5_page_ojs_post_list.js\n
gadget_erp5_page_ojs_add_post.html\n
gadget_erp5_page_ojs_add_post.js\n
\n
#needed for appcachestorage sync\n
/\n
...
...
@@ -247,13 +255,6 @@ hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%2
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F2&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F3&view=view&appcache=1\n
\n
gadget_erp5_page_ojs_controller.html\n
gadget_erp5_page_ojs_controller.js\n
gadget_erp5_page_ojs_post_list.html\n
gadget_erp5_page_ojs_post_list.js\n
gadget_erp5_page_ojs_add_post.html\n
gadget_erp5_page_ojs_add_post.js\n
\n
gadget_erp5_field_listbox.html\n
gadget_erp5_field_listbox.js\n
\n
...
...
@@ -739,7 +740,7 @@ NETWORK:\n
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.5
1832.12674.167
08
</string>
</value>
<value>
<string>
974.5
9021.18848.281
08
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -757,7 +758,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>
1554
402100.2
</float>
<float>
1554
751524.94
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.js
View file @
133113b3
...
...
@@ -153,7 +153,7 @@
header_dict
.
save_action
=
true
;
}
}
if
(
tru
e
)
{
//TODO: configuration must indicate if there are more actions
if
(
fals
e
)
{
//TODO: configuration must indicate if there are more actions
header_dict
.
actions_url
=
url_list
[
1
];
}
if
(
url_list
[
7
])
{
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_erp5_page_post_list_js.xml
View file @
133113b3
...
...
@@ -269,7 +269,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.
49976.5658.2780
1
</string>
</value>
<value>
<string>
974.
59028.6381.4217
1
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>
1554
208935.58
</float>
<float>
1554
752043.96
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_offline_js.js
View file @
133113b3
...
...
@@ -19,38 +19,21 @@
* @param {Array} command_list - array of links obtained from ERP5 HATEOAS
*/
function
renderLinkList
(
gadget
,
title
,
icon
,
erp5_link_list
)
{
return
gadget
.
getUrlParameter
(
"
extended_search
"
)
.
push
(
function
(
query
)
{
// obtain RJS links from ERP5 links
return
RSVP
.
all
(
erp5_link_list
.
map
(
function
(
erp5_link
)
{
return
gadget
.
getUrlFor
({
"
command
"
:
'
change
'
,
"
options
"
:
{
"
view
"
:
UriTemplate
.
parse
(
erp5_link
.
href
).
expand
({
query
:
query
}),
"
page
"
:
undefined
}
});
})
);
// prepare links for template (replace @href for RJS link)
return
gadget
.
translateHtml
(
table_template
({
"
definition_i18n
"
:
title
,
"
definition_title
"
:
title
,
"
definition_icon
"
:
icon
,
"
document_list
"
:
erp5_link_list
.
map
(
function
(
erp5_link
,
index
)
{
return
{
"
title
"
:
erp5_link
.
title
,
"
i18n
"
:
erp5_link
.
title
,
"
link
"
:
erp5_link_list
[
index
].
href
};
})
})
.
push
(
function
(
url_list
)
{
// prepare links for template (replace @href for RJS link)
return
gadget
.
translateHtml
(
table_template
({
"
definition_i18n
"
:
title
,
"
definition_title
"
:
title
,
"
definition_icon
"
:
icon
,
"
document_list
"
:
erp5_link_list
.
map
(
function
(
erp5_link
,
index
)
{
return
{
"
title
"
:
erp5_link
.
title
,
"
i18n
"
:
erp5_link
.
title
,
"
link
"
:
url_list
[
index
]
};
})
})
);
});
);
}
...
...
@@ -92,10 +75,14 @@
})
.
push
(
function
(
action_document_list
)
{
var
url_for_parameter_list
=
[],
i
=
0
,
action_key
,
action_doc
;
page
,
action_key
,
action_doc
;
for
(
action_key
in
action_document_list
)
{
page
=
"
handle_action
"
;
action_doc
=
action_document_list
[
action_key
];
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
{
page
:
"
ojs_controller
"
,
action
:
action_doc
.
reference
}});
if
(
action_doc
.
reference
==
"
view
"
||
action_doc
.
reference
==
"
jio_view
"
)
{
page
=
"
ojs_controller
"
;
}
url_for_parameter_list
.
push
({
command
:
'
change
'
,
options
:
{
page
:
page
,
action
:
action_doc
.
reference
}});
action_info_list
[
i
]
=
{
reference
:
action_doc
.
reference
,
title
:
action_doc
.
title
};
i
+=
1
;
}
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_action_offline_js.xml
View file @
133113b3
...
...
@@ -228,7 +228,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
974.5
2897.57392.44646
</string>
</value>
<value>
<string>
974.5
8836.59077.24849
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>
1554
384682.86
</float>
<float>
1554
740463.74
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_html.html
0 → 100644
View file @
133113b3
<!doctype html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>
OfficeJS Handle Action
</title>
<script
src=
"rsvp.js"
></script>
<script
src=
"renderjs.js"
></script>
<script
src=
"gadget_erp5_page_handle_action.js"
></script>
</head>
<body>
HANDLE ACTION
</body>
</html>
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_html.xml
0 → 100644
View file @
133113b3
This diff is collapsed.
Click to expand it.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.js
0 → 100644
View file @
133113b3
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
Blob
)
{
"
use strict
"
;
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.
declareAcquiredMethod
(
"
updateHeader
"
,
"
updateHeader
"
)
.
declareAcquiredMethod
(
"
getSetting
"
,
"
getSetting
"
)
.
declareAcquiredMethod
(
"
jio_putAttachment
"
,
"
jio_putAttachment
"
)
.
declareAcquiredMethod
(
"
redirect
"
,
"
redirect
"
)
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
jio_post
"
,
"
jio_post
"
)
.
declareAcquiredMethod
(
"
getUrlParameter
"
,
"
getUrlParameter
"
)
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.
declareMethod
(
"
handleAction
"
,
function
(
jio_key
,
portal_type
)
{
var
gadget
=
this
,
jio_document
,
action_reference
;
return
gadget
.
getUrlParameter
(
"
action
"
)
.
push
(
function
(
action_parameter
)
{
action_reference
=
action_parameter
;
return
gadget
.
jio_get
(
jio_key
);
})
.
push
(
function
(
document
)
{
// This is the custom code to handle this specific reply action
if
(
action_reference
==
"
reply
"
)
{
var
doc
,
title
=
document
.
title
;
if
(
!
title
.
startsWith
(
"
Re:
"
))
{
title
=
"
Re:
"
+
document
.
title
;
}
doc
=
{
title
:
title
,
//thread parent: same as base post
source_reference
:
document
.
source_reference
,
portal_type
:
document
.
portal_type
,
parent_relative_url
:
document
.
parent_relative_url
};
return
gadget
.
jio_post
(
doc
)
.
push
(
function
(
id
)
{
jio_key
=
id
;
return
gadget
.
jio_get
(
jio_key
);
})
.
push
(
function
(
created_doc
)
{
jio_document
=
created_doc
;
return
[
jio_key
,
jio_document
,
action_reference
];
});
}
return
[
jio_key
,
jio_document
,
action_reference
];
});
})
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
doc_id
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
getSetting
(
'
portal_type
'
),
gadget
.
getSetting
(
'
parent_relative_url
'
)
]);
})
.
push
(
function
(
result
)
{
return
gadget
.
handleAction
(
options
.
jio_key
,
result
[
0
]);
})
.
push
(
function
(
action_result
)
{
return
gadget
.
redirect
({
command
:
'
change
'
,
options
:
{
page
:
undefined
,
jio_key
:
action_result
[
0
],
view
:
action_result
[
2
]
}
});
});
});
}(
window
,
rJS
,
RSVP
,
Blob
));
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_page_handle_action_js.xml
0 → 100644
View file @
133113b3
This diff is collapsed.
Click to expand it.
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