Commit d538c6c5 authored by Roque's avatar Roque Committed by Roque

erp5_web_project_ui: link to project documents and working relative links in project page

parent bd2f51c9
...@@ -113,6 +113,8 @@ gadget_erp5_page_project_controller.html\n ...@@ -113,6 +113,8 @@ gadget_erp5_page_project_controller.html\n
gadget_erp5_page_project_controller.js\n gadget_erp5_page_project_controller.js\n
gadget_project_info.html\n gadget_project_info.html\n
gadget_project_info.js\n gadget_project_info.js\n
gadget_erp5_page_project_redirector.html\n
gadget_erp5_page_project_redirector.js\n
\n \n
favicon.ico\n favicon.ico\n
font-awesome/font-awesome-webfont.eot\n font-awesome/font-awesome-webfont.eot\n
...@@ -401,7 +403,7 @@ NETWORK:\n ...@@ -401,7 +403,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>979.42032.35189.30737</string> </value> <value> <string>979.47842.59522.17561</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -419,7 +421,7 @@ NETWORK:\n ...@@ -419,7 +421,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1573204450.6</float> <float>1573482418.03</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>979.43392.49527.61508</string> </value> <value> <string>979.43464.8150.52906</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>1573215416.11</float> <float>1573482096.66</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Project Redirector</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_page_project_redirector.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*global document, window, rJS */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 90 */
(function (document, window, rJS) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this, id,
types = '("Text", "File", "PDF", "Drawing", ' +
'"Presentation", "Spreadsheet")',
states = '("shared", "published", "released", ' +
'"shared_alive", "published_alive", "released_alive")',
query = 'portal_type:' + types +
'AND reference:"' + options.reference +
'" AND validation_state:' + states;
return gadget.jio_allDocs({
query: query,
limit: 1
})
.push(function (result_list) {
if (result_list.data.rows[0]) {
return gadget.redirect({
'command': 'display',
'options': {
'jio_key': result_list.data.rows[0].id,
'history': options.history
}
});
} else {
return gadget.redirect({command: 'history_previous', options: {}});
}
});
});
}(document, window, rJS));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list>
<string>listbox_thumbnail</string>
<string>listbox_download</string>
</list>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Project_viewDocumentList</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_viewDocumentList</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_list</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Documents</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_download</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_thumbnail</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>File_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/getIconURL</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>enabled</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_thumbnail</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_thumbnail</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>File_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>cell/absolute_url</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:cell.portal_type != \'File\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
<p> <p>
<a id="milestone_link" class="first-line-buttons ui-disabled" data-i18n="[value]Milestones" disabled >Milestones</a> <a id="milestone_link" class="first-line-buttons ui-disabled" data-i18n="[value]Milestones" disabled >Milestones</a>
<a id="support_request_link" class="first-line-buttons ui-disabled" data-i18n="[value]Support Requests" disabled >Support requests</a> <a id="support_request_link" class="first-line-buttons ui-disabled" data-i18n="[value]Support Requests" disabled >Support requests</a>
<a id="document_link" class="first-line-buttons ui-disabled" data-i18n="[value]Documents" disabled >Documents</a>
</p>
</div>
<div class="ui-field-contain project_links">
<p>
<a id="bug_link" class="first-line-buttons ui-disabled" data-i18n="[value]Bugs" disabled >Opened Bugs</a> <a id="bug_link" class="first-line-buttons ui-disabled" data-i18n="[value]Bugs" disabled >Opened Bugs</a>
<a id="closed_bug_link" class="first-line-buttons ui-disabled" data-i18n="[value]Closed Bugs" disabled >Closed Bugs</a> <a id="closed_bug_link" class="first-line-buttons ui-disabled" data-i18n="[value]Closed Bugs" disabled >Closed Bugs</a>
</p> </p>
......
...@@ -3,6 +3,20 @@ ...@@ -3,6 +3,20 @@
(function (window, rJS, RSVP, document, ensureArray) { (function (window, rJS, RSVP, document, ensureArray) {
"use strict"; "use strict";
function parseHTMLLinks(html, url) {
var content = document.createElement('html'),
regex = /href="(.*?)"/g,
link;
while ((link = regex.exec(html)) !== null) {
if (! link[1].startsWith("https") && ! link[1].startsWith("http") &&
! link[1].startsWith("ftp") && ! link[1].includes("/")
) {
html = html.replace(link[1], url + "&n.reference=" + link[1]);
}
}
return html;
}
function enableLink(link_element, url) { function enableLink(link_element, url) {
link_element.href = url; link_element.href = url;
link_element.disabled = false; link_element.disabled = false;
...@@ -41,18 +55,20 @@ ...@@ -41,18 +55,20 @@
function getWebPageInfo(gadget, project_reference) { function getWebPageInfo(gadget, project_reference) {
var query = 'portal_type:="Web Page" AND reference:"' + project_reference + var query = 'portal_type:="Web Page" AND reference:"' + project_reference +
'-Home.Page" AND validation_state:"published_alive"', '-Home.Page" AND validation_state:"published_alive"',
id, id, content, edit_view, redirector_ulr;
content, return gadget.getUrlFor({command: 'push_history', options: {page: "project_redirector"}})
edit_view; .push(function (url) {
return gadget.jio_allDocs({ redirector_ulr = url;
query: query, return gadget.jio_allDocs({
limit: 1, query: query,
select_list: ['text_content'] limit: 1,
}) select_list: ['text_content']
});
})
.push(function (result_list) { .push(function (result_list) {
if (result_list.data.rows[0]) { if (result_list.data.rows[0]) {
id = result_list.data.rows[0].id; id = result_list.data.rows[0].id;
content = result_list.data.rows[0].value.text_content; content = parseHTMLLinks(result_list.data.rows[0].value.text_content, redirector_ulr);
return gadget.jio_getAttachment(id, "links") return gadget.jio_getAttachment(id, "links")
.push(function (web_page_document) { .push(function (web_page_document) {
edit_view = getActionListByName( edit_view = getActionListByName(
...@@ -81,8 +97,10 @@ ...@@ -81,8 +97,10 @@
rJS(window) rJS(window)
.declareAcquiredMethod("getUrlForList", "getUrlForList") .declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("getSetting", "getSetting")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var state_dict = { var state_dict = {
...@@ -102,12 +120,16 @@ ...@@ -102,12 +120,16 @@
return RSVP.all([ return RSVP.all([
getWebPageInfo(gadget, modification_dict.project_reference), getWebPageInfo(gadget, modification_dict.project_reference),
gadget.jio_getAttachment(modification_dict.jio_key, "links"), gadget.jio_getAttachment(modification_dict.jio_key, "links"),
gadget.getDeclaredGadget("editor") gadget.getDeclaredGadget("editor"),
gadget.getSetting("hateoas_url")
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
var milestone_view = getActionListByName( var milestone_view = getActionListByName(
ensureArray(result_list[1]._links.view), "milestone"); ensureArray(result_list[1]._links.view), "milestone"),
document_view = result_list[3] +
'/ERP5Document_getHateoas?mode=traverse&relative_url=' +
modification_dict.jio_key + '&view=Project_viewDocumentList';
web_page_info = result_list[0]; web_page_info = result_list[0];
editor = result_list[2]; editor = result_list[2];
editor.render({"editor": "fck_editor", "editable": false, editor.render({"editor": "fck_editor", "editable": false,
...@@ -115,42 +137,44 @@ ...@@ -115,42 +137,44 @@
return gadget.getUrlForList([ return gadget.getUrlForList([
getUrlParameterDict('milestone_module', milestone_view, [["stop_date", "ascending"]]), getUrlParameterDict('milestone_module', milestone_view, [["stop_date", "ascending"]]),
getUrlParameterDict('task_module', "view", [["delivery.start_date", "descending"]], getUrlParameterDict('task_module', "view", [["delivery.start_date", "descending"]],
["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title", ["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title",
"source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"], "source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"],
('source_project_title: "' + modification_dict.project_title + ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_domain: "confirmed"')), '" AND selection_domain_state_task_domain: "confirmed"')),
getUrlParameterDict('support_request_module', "view", [["delivery.start_date", "descending"]], getUrlParameterDict('support_request_module', "view", [["delivery.start_date", "descending"]],
null, ('source_project_title: "' + modification_dict.project_title + null, ('source_project_title: "' + modification_dict.project_title +
'" AND destination_project_title: "' + modification_dict.project_title + '" AND destination_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_support_domain: "validated"')), '" AND selection_domain_state_support_domain: "validated"')),
getUrlParameterDict('bug_module', "view", [["delivery.start_date", "descending"]], getUrlParameterDict('bug_module', "view", [["delivery.start_date", "descending"]],
["title", "description", "delivery.start_date"], ["title", "description", "delivery.start_date"],
('source_project_title: "' + modification_dict.project_title + ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_bug_domain: "started"')), '" AND selection_domain_state_bug_domain: "started"')),
getUrlParameterDict('bug_module', "view", [["delivery.start_date", "descending"]], getUrlParameterDict('bug_module', "view", [["delivery.start_date", "descending"]],
["title", "description", "delivery.start_date"], ["title", "description", "delivery.start_date"],
('source_project_title: "' + modification_dict.project_title + ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_bug_domain: "closed"')), '" AND selection_domain_state_bug_domain: "closed"')),
getUrlParameterDict('task_report_module', 'view', [["delivery.start_date", "descending"]], getUrlParameterDict('task_report_module', 'view', [["delivery.start_date", "descending"]],
["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title", ["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title",
"source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"], "source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"],
('source_project_title: "' + modification_dict.project_title + ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_report_domain: "started"')), '" AND selection_domain_state_task_report_domain: "started"')),
getUrlParameterDict('task_report_module', 'view', [["delivery.start_date", "descending"]], getUrlParameterDict('task_report_module', 'view', [["delivery.start_date", "descending"]],
["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title", ["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title",
"source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"], "source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"],
('source_project_title: "' + modification_dict.project_title + ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_report_domain: "closed"')), '" AND selection_domain_state_task_report_domain: "closed"')),
getUrlParameterDict('test_result_module', 'view', [["delivery.start_date", "descending"]], getUrlParameterDict('test_result_module', 'view', [["delivery.start_date", "descending"]],
null, ('source_project_title: "' + modification_dict.project_title + '"')), null, ('source_project_title: "' + modification_dict.project_title + '"')),
getUrlParameterDict('test_suite_module', 'view', [["creation_date", "descending"]], getUrlParameterDict('test_suite_module', 'view', [["creation_date", "descending"]],
null, ('source_project_title: "' + modification_dict.project_title + '"')), null, ('source_project_title: "' + modification_dict.project_title + '"')),
getUrlParameterDict('task_module', "view", [["delivery.start_date", "descending"]], getUrlParameterDict('task_module', "view", [["delivery.start_date", "descending"]],
["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title", ["title", "delivery.start_date", "delivery.stop_date", "destination_decision_title",
"source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"], "source_title", "destination_title", "total_quantity", "task_line_quantity_unit_title"],
('source_project_title: "' + modification_dict.project_title + ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_domain: "not_confirmed"')), '" AND selection_domain_state_task_domain: "not_confirmed"')),
getUrlParameterDict(web_page_info.id, web_page_info.edit_view) getUrlParameterDict(web_page_info.id, web_page_info.edit_view),
getUrlParameterDict(modification_dict.jio_key, document_view, [["modification_date", "descending"]],
null, ('selection_domain_state_document_domain: "confirmed"'))
]); ]);
}) })
.push(function (url_list) { .push(function (url_list) {
...@@ -167,6 +191,7 @@ ...@@ -167,6 +191,7 @@
if (web_page_info.id) { if (web_page_info.id) {
enableLink(document.getElementById("web_page_link"), url_list[10]); enableLink(document.getElementById("web_page_link"), url_list[10]);
} }
enableLink(document.getElementById("document_link"), url_list[11]);
setLastTestResult(gadget, modification_dict.project_title, setLastTestResult(gadget, modification_dict.project_title,
document.getElementById("test_result_span")); document.getElementById("test_result_span"));
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment