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
Łukasz Nowak
erp5
Commits
fb85639e
Commit
fb85639e
authored
Sep 19, 2017
by
Tomáš Peterka
Committed by
Tomáš Peterka
Sep 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[renderjs_ui] Refactor of action and export page
parent
1728550c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
138 additions
and
144 deletions
+138
-144
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_html.html
...m/web_page_module/rjs_gadget_erp5_pt_actionpage_html.html
+3
-1
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_html.xml
...em/web_page_module/rjs_gadget_erp5_pt_actionpage_html.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_js.js
...eItem/web_page_module/rjs_gadget_erp5_pt_actionpage_js.js
+63
-80
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_js.xml
...Item/web_page_module/rjs_gadget_erp5_pt_actionpage_js.xml
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_html.html
...m/web_page_module/rjs_gadget_erp5_pt_exportpage_html.html
+3
-1
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_html.xml
...em/web_page_module/rjs_gadget_erp5_pt_exportpage_html.xml
+2
-2
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_js.js
...eItem/web_page_module/rjs_gadget_erp5_pt_exportpage_js.js
+60
-53
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_js.xml
...Item/web_page_module/rjs_gadget_erp5_pt_exportpage_js.xml
+2
-2
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_html.html
View file @
fb85639e
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
<script
src=
"gadget_erp5_page_action.js"
type=
"text/javascript"
></script>
<script
src=
"gadget_erp5_page_action.js"
type=
"text/javascript"
></script>
<script
id=
"table-template"
type=
"text/x-handlebars-template"
>
<script
id=
"table-template"
type=
"text/x-handlebars-template"
>
{{
#
if
document_list
}}
<
section
class
=
"
ui-content-header-plain
"
>
<
section
class
=
"
ui-content-header-plain
"
>
<
h3
class
=
"
ui-content-title ui-body-c
"
data
-
i18n
=
"
[last]{{definition_i18n}}
"
>
<
h3
class
=
"
ui-content-title ui-body-c
"
data
-
i18n
=
"
[last]{{definition_i18n}}
"
>
<
span
class
=
"
ui-icon ui-icon-custom ui-icon-{{definition_icon}}
"
>&
nbsp
;
<
/span
>
<
span
class
=
"
ui-icon ui-icon-custom ui-icon-{{definition_icon}}
"
>&
nbsp
;
<
/span
>
...
@@ -28,10 +29,11 @@
...
@@ -28,10 +29,11 @@
<
/h3
>
<
/h3
>
<
/section
>
<
/section
>
<
ul
data
-
role
=
"
listview
"
data
-
theme
=
"
c
"
data
-
inset
=
"
true
"
class
=
"
document-listview
"
>
<
ul
data
-
role
=
"
listview
"
data
-
theme
=
"
c
"
data
-
inset
=
"
true
"
class
=
"
document-listview
"
>
{{
#
each
documentlist
}}
{{
#
each
document
_
list
}}
<
li
><
a
data
-
i18n
=
"
{{title}}
"
class
=
"
ui-body-inherit
"
href
=
"
{{link}}
"
>
{{
title
}}
<
/a></
li
>
<
li
><
a
data
-
i18n
=
"
{{title}}
"
class
=
"
ui-body-inherit
"
href
=
"
{{link}}
"
>
{{
title
}}
<
/a></
li
>
{{
/
each
}}
{{
/
each
}}
<
/ul
>
<
/ul
>
{{
/
if
}}
</script>
</script>
</head>
</head>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_html.xml
View file @
fb85639e
...
@@ -234,7 +234,7 @@
...
@@ -234,7 +234,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
53.48219.30595.27340
</string>
</value>
<value>
<string>
9
62.2453.12386.29235
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -252,7 +252,7 @@
...
@@ -252,7 +252,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
474556323.96
</float>
<float>
1
505211775.45
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_js.js
View file @
fb85639e
...
@@ -12,6 +12,54 @@
...
@@ -12,6 +12,54 @@
.
getElementById
(
"
table-template
"
)
.
getElementById
(
"
table-template
"
)
.
innerHTML
);
.
innerHTML
);
/** Render translated HTML of title + links
*
* @param {string} title - H3 title of the section with the links
* @param {string} icon - alias used in font-awesome iconset
* @param {Array} command_list - array of links obtained from ERP5 HATEOAS
*/
function
renderLinkList
(
gadget
,
title
,
icon
,
erp5_link_list
,
editable
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
// obtain RJS links from ERP5 links
return
RSVP
.
all
(
erp5_link_list
.
map
(
function
(
erp5_link
)
{
return
gadget
.
getUrlFor
({
"
command
"
:
'
change
'
,
"
options
"
:
{
"
view
"
:
erp5_link
.
href
,
"
page
"
:
undefined
,
"
editable
"
:
editable
}
});
})
);
})
.
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
]
};
})
})
);
});
}
function
asArray
(
obj
)
{
if
(
!
obj
)
{
return
[];
}
if
(
Array
.
isArray
(
obj
))
{
return
obj
;
}
return
[
obj
];
}
gadget_klass
gadget_klass
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Acquired methods
// Acquired methods
...
@@ -27,97 +75,32 @@
...
@@ -27,97 +75,32 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
var
gadget
=
this
,
erp5_document
,
erp5_document
,
result_list
,
view_list
,
view_list
,
action_list
;
action_list
;
return
gadget
.
jio_getAttachment
(
options
.
jio_key
,
"
links
"
)
return
gadget
.
jio_getAttachment
(
options
.
jio_key
,
"
links
"
)
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
var
i
,
i_len
,
promise_list
=
[
gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
page
:
undefined
}})
];
erp5_document
=
result
;
erp5_document
=
result
;
view_list
=
erp5_document
.
_links
.
action_workflow
||
[];
view_list
=
asArray
(
erp5_document
.
_links
.
action_workflow
);
action_list
=
erp5_document
.
_links
.
action_object_action_jio
||
[];
action_list
=
asArray
(
erp5_document
.
_links
.
action_object_action_jio
)
if
(
view_list
.
constructor
!==
Array
)
{
.
concat
(
asArray
(
erp5_document
.
_links
.
action_object_clone_action
));
view_list
=
[
view_list
];
}
if
(
action_list
.
constructor
!==
Array
)
{
action_list
=
[
action_list
];
}
for
(
i
=
0
;
i
<
view_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
view
:
view_list
[
i
].
href
,
page
:
undefined
}
})
);
}
if
(
erp5_document
.
_links
.
action_object_clone_action
)
{
action_list
.
push
(
erp5_document
.
_links
.
action_object_clone_action
);
}
for
(
i
=
0
,
i_len
=
action_list
.
length
;
i
<
i_len
;
i
+=
1
)
{
promise_list
.
push
(
gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
view
:
action_list
[
i
].
href
,
page
:
undefined
,
editable
:
true
}
})
);
}
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
all_result
)
{
var
i
,
tab_list
=
[],
action_tab_list
=
[];
result_list
=
all_result
;
for
(
i
=
0
;
i
<
view_list
.
length
;
i
+=
1
)
{
tab_list
.
push
({
title
:
view_list
[
i
].
title
,
link
:
all_result
[
i
+
1
],
i18n
:
view_list
[
i
].
title
});
}
for
(
i
=
0
;
i
<
action_list
.
length
;
i
+=
1
)
{
action_tab_list
.
push
({
title
:
action_list
[
i
].
title
,
link
:
all_result
[
i
+
1
+
view_list
.
length
],
i18n
:
action_list
[
i
].
title
});
}
return
RSVP
.
all
([
return
RSVP
.
all
([
gadget
.
translateHtml
(
renderLinkList
(
gadget
,
"
Actions
"
,
"
gear
"
,
view_list
,
options
.
editable
),
table_template
({
renderLinkList
(
gadget
,
"
Workflow Transitions
"
,
"
random
"
,
action_list
,
true
)
definition_title
:
"
Workflow Transitions
"
,
]);
definition_icon
:
"
random
"
,
documentlist
:
tab_list
,
definition_i18n
:
"
Workflow-Transitions
"
})
+
table_template
({
definition_i18n
:
"
Actions
"
,
definition_title
:
"
Actions
"
,
definition_icon
:
"
gear
"
,
documentlist
:
action_tab_list
})
})
),
.
push
(
function
(
translated_html_link_list
)
{
calculatePageTitle
(
gadget
,
erp5_document
)
gadget
.
element
.
innerHTML
=
translated_html_link_list
.
join
(
"
\n
"
);
return
RSVP
.
all
([
calculatePageTitle
(
gadget
,
erp5_document
),
gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
page
:
undefined
}})
]);
]);
})
})
.
push
(
function
(
last_result_list
)
{
.
push
(
function
(
result_list
)
{
gadget
.
element
.
innerHTML
=
last_result_list
[
0
];
return
gadget
.
updateHeader
({
return
gadget
.
updateHeader
({
back_url
:
result_list
[
0
],
page_title
:
result_list
[
0
],
page_title
:
last_
result_list
[
1
]
back_url
:
result_list
[
1
]
});
});
});
});
});
});
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_actionpage_js.xml
View file @
fb85639e
...
@@ -216,7 +216,7 @@
...
@@ -216,7 +216,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
cedric.le.ninivin
</string>
</value>
<value>
<string>
zope
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
96
0.54321.50792.6877
</string>
</value>
<value>
<string>
96
2.4062.25838.43485
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
150
0456255.01
</float>
<float>
150
5824423.08
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_html.html
View file @
fb85639e
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
<script
src=
"gadget_erp5_page_export.js"
type=
"text/javascript"
></script>
<script
src=
"gadget_erp5_page_export.js"
type=
"text/javascript"
></script>
<script
id=
"table-template"
type=
"text/x-handlebars-template"
>
<script
id=
"table-template"
type=
"text/x-handlebars-template"
>
{{
#
if
document_list
}}
<
section
class
=
"
ui-content-header-plain
"
>
<
section
class
=
"
ui-content-header-plain
"
>
<
h3
class
=
"
ui-content-title ui-body-c
"
data
-
i18n
=
"
[last]{{definition_i18n}}
"
>
<
h3
class
=
"
ui-content-title ui-body-c
"
data
-
i18n
=
"
[last]{{definition_i18n}}
"
>
<
span
class
=
"
ui-icon ui-icon-custom ui-icon-{{definition_icon}}
"
>&
nbsp
;
<
/span
>
<
span
class
=
"
ui-icon ui-icon-custom ui-icon-{{definition_icon}}
"
>&
nbsp
;
<
/span
>
...
@@ -27,10 +28,11 @@
...
@@ -27,10 +28,11 @@
<
/h3
>
<
/h3
>
<
/section
>
<
/section
>
<
ul
data
-
role
=
"
listview
"
data
-
theme
=
"
c
"
data
-
inset
=
"
true
"
class
=
"
document-listview
"
>
<
ul
data
-
role
=
"
listview
"
data
-
theme
=
"
c
"
data
-
inset
=
"
true
"
class
=
"
document-listview
"
>
{{
#
each
documentlist
}}
{{
#
each
document
_
list
}}
<
li
><
a
data
-
i18n
=
"
{{title}}
"
class
=
"
ui-body-inherit
"
href
=
"
{{link}}
"
>
{{
title
}}
<
/a></
li
>
<
li
><
a
data
-
i18n
=
"
{{title}}
"
class
=
"
ui-body-inherit
"
href
=
"
{{link}}
"
>
{{
title
}}
<
/a></
li
>
{{
/
each
}}
{{
/
each
}}
<
/ul
>
<
/ul
>
{{
/
if
}}
</script>
</script>
</head>
</head>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_html.xml
View file @
fb85639e
...
@@ -234,7 +234,7 @@
...
@@ -234,7 +234,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
57.58323.64047.9540
</string>
</value>
<value>
<string>
9
60.5523.58984.43537
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -252,7 +252,7 @@
...
@@ -252,7 +252,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
489072645.22
</float>
<float>
1
505229776.11
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_js.js
View file @
fb85639e
...
@@ -12,6 +12,54 @@
...
@@ -12,6 +12,54 @@
.
getElementById
(
"
table-template
"
)
.
getElementById
(
"
table-template
"
)
.
innerHTML
);
.
innerHTML
);
/** Render translated HTML of title + links
*
* @param {string} title - H3 title of the section with the links
* @param {string} icon - alias used in font-awesome iconset
* @param {Array} command_list - array of links obtained from ERP5 HATEOAS
*/
function
renderLinkList
(
gadget
,
title
,
icon
,
erp5_link_list
,
editable
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
// obtain RJS links from ERP5 links
return
RSVP
.
all
(
erp5_link_list
.
map
(
function
(
erp5_link
)
{
return
gadget
.
getUrlFor
({
"
command
"
:
'
change
'
,
"
options
"
:
{
"
view
"
:
erp5_link
.
href
,
"
page
"
:
undefined
,
"
editable
"
:
editable
}
});
})
);
})
.
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
]
};
})
})
);
});
}
function
asArray
(
obj
)
{
if
(
!
obj
)
{
return
[];
}
if
(
Array
.
isArray
(
obj
))
{
return
obj
;
}
return
[
obj
];
}
gadget_klass
gadget_klass
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Acquired methods
// Acquired methods
...
@@ -27,69 +75,28 @@
...
@@ -27,69 +75,28 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
var
gadget
=
this
,
erp5_document
,
erp5_document
,
result_list
,
report_list
;
report_list
;
return
gadget
.
jio_getAttachment
(
options
.
jio_key
,
"
links
"
)
return
gadget
.
jio_getAttachment
(
options
.
jio_key
,
"
links
"
)
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
var
i
,
i_len
,
promise_list
=
[
gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
page
:
undefined
}})
];
erp5_document
=
result
;
erp5_document
=
result
;
report_list
=
erp5_document
.
_links
.
action_object_report_jio
||
[];
report_list
=
asArray
(
erp5_document
.
_links
.
action_object_report_jio
);
if
(
report_list
.
constructor
!==
Array
)
{
report_list
=
[
report_list
];
}
for
(
i
=
0
;
i
<
report_list
.
length
;
i
+=
1
)
{
promise_list
.
push
(
gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
view
:
report_list
[
i
].
href
,
page
:
undefined
,
editable
:
options
.
editable
}
})
);
}
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
all_result
)
{
var
i
,
tab_list
=
[],
report_tab_list
=
[],
html
=
""
;
result_list
=
all_result
;
for
(
i
=
0
;
i
<
report_list
.
length
;
i
+=
1
)
{
report_tab_list
.
push
({
title
:
report_list
[
i
].
title
,
link
:
all_result
[
i
+
1
],
i18n
:
report_list
[
i
].
title
});
}
if
(
i
)
{
html
+=
table_template
({
definition_i18n
:
"
Report
"
,
definition_title
:
"
Report
"
,
definition_icon
:
"
gear
"
,
documentlist
:
report_tab_list
});
}
return
RSVP
.
all
([
return
RSVP
.
all
([
gadget
.
translateHtml
(
html
),
renderLinkList
(
gadget
,
"
Reports
"
,
"
bar-chart-o
"
,
report_list
,
true
)
calculatePageTitle
(
gadget
,
erp5_document
)
]);
]);
})
})
.
push
(
function
(
last_result_list
)
{
.
push
(
function
(
translated_html_link_list
)
{
gadget
.
element
.
innerHTML
=
last_result_list
[
0
];
gadget
.
element
.
innerHTML
=
translated_html_link_list
.
join
(
"
\n
"
);
return
RSVP
.
all
([
calculatePageTitle
(
gadget
,
erp5_document
),
gadget
.
getUrlFor
({
command
:
'
change
'
,
options
:
{
page
:
undefined
}})
]);
})
.
push
(
function
(
result_list
)
{
return
gadget
.
updateHeader
({
return
gadget
.
updateHeader
({
back_url
:
result_list
[
0
],
page_title
:
result_list
[
0
],
page_title
:
last_
result_list
[
1
]
back_url
:
result_list
[
1
]
});
});
});
});
});
});
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_pt_exportpage_js.xml
View file @
fb85639e
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
58.23104.13268.55347
</string>
</value>
<value>
<string>
9
62.12722.31387.26146
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
490968345.34
</float>
<float>
1
505824496.49
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</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