Commit 3a7ae796 by Roque

erp5_web_project_ui: code cleanup in project info gadget

parent 4aa18574
/*jslint nomen: true, indent: 2 */ /*jslint nomen: true, indent: 2 */
/*global window, rJS, RSVP, document, FileReader, Blob, jIO, ensureArray, /*global window, rJS, RSVP, document, ensureArray*/
lockGadgetInQueue, unlockGadgetInQueue*/ (function (window, rJS, RSVP, document, ensureArray) {
(function (window, rJS, RSVP, document, FileReader, Blob, jIO, ensureArray,
lockGadgetInQueue, unlockGadgetInQueue) {
"use strict"; "use strict";
function enableLink(link_element, url) { function enableLink(link_element, url) {
...@@ -24,42 +22,46 @@ lockGadgetInQueue, unlockGadgetInQueue*/ ...@@ -24,42 +22,46 @@ lockGadgetInQueue, unlockGadgetInQueue*/
sort_on: [['creation_date', 'descending']], sort_on: [['creation_date', 'descending']],
select_list: ['simulation_state'] select_list: ['simulation_state']
}) })
.push(function (result_list) { .push(function (result_list) {
var i, state; var i, state;
result_list = result_list.data.rows; result_list = result_list.data.rows;
for (i = 0; i < result_list.length; i = i + 1) { for (i = 0; i < result_list.length; i = i + 1) {
state = result_list[i].value.simulation_state; state = result_list[i].value.simulation_state;
if (state === "stopped" || state === "public_stopped") { if (state === "stopped" || state === "public_stopped") {
span_element.classList.add("pass"); span_element.classList.add("pass");
break; break;
} else if (state === "failed") { } else if (state === "failed") {
span_element.classList.add("fail"); span_element.classList.add("fail");
break; break;
}
} }
} });
});
} }
function getWebPageInfo(gadget, project_reference) { function getWebPageInfo(gadget, project_reference) {
var query = 'portal_type:="Web Page" AND reference:"' + project_reference + '-Home.Page" AND validation_state:"published_alive"', var query = 'portal_type:="Web Page" AND reference:"' + project_reference +
id, content, edit_view; '-Home.Page" AND validation_state:"published_alive"',
id,
content,
edit_view;
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: query, query: query,
limit: 1, limit: 1,
select_list: ['text_content'] 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 = result_list.data.rows[0].value.text_content;
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(ensureArray(web_page_document._links.view), "view_editor"); edit_view = getActionListByName(
return {"id": id, "content": content, "edit_view": edit_view}; ensureArray(web_page_document._links.view), "view_editor");
}); return {"id": id, "content": content, "edit_view": edit_view};
} });
return {"id": id, "content": content, "edit_view": edit_view}; }
}); return {"id": id, "content": content, "edit_view": edit_view};
});
} }
function getUrlParameters(jio_key, view, sort_list, column_list, extended_search) { function getUrlParameters(jio_key, view, sort_list, column_list, extended_search) {
...@@ -104,35 +106,41 @@ lockGadgetInQueue, unlockGadgetInQueue*/ ...@@ -104,35 +106,41 @@ lockGadgetInQueue, unlockGadgetInQueue*/
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
var milestone_view = getActionListByName(ensureArray(result_list[1]._links.view), "milestone"); var milestone_view = getActionListByName(
ensureArray(result_list[1]._links.view), "milestone");
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, "value": web_page_info.content}); editor.render({"editor": "fck_editor", "editable": false,
"value": web_page_info.content});
return gadget.getUrlForList([ return gadget.getUrlForList([
getUrlParameters('milestone_module', milestone_view, [["stop_date", "ascending"]]), getUrlParameters('milestone_module', milestone_view, [["stop_date", "ascending"]]),
getUrlParameters('task_module', "view", [["delivery.start_date", "descending"]], getUrlParameters('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 + '" AND selection_domain_state_task_domain: "confirmed"')), ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_domain: "confirmed"')),
getUrlParameters('support_request_module', "view", [["delivery.start_date", "descending"]], getUrlParameters('support_request_module', "view", [["delivery.start_date", "descending"]],
//null, ('source_project_title: "' + modification_dict.project_title + '" AND selection_domain_state_support_domain: "validated"')),
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"')),
getUrlParameters('bug_module', "view", [["delivery.start_date", "descending"]], getUrlParameters('bug_module', "view", [["delivery.start_date", "descending"]],
["title", "description", "delivery.start_date"], ["title", "description", "delivery.start_date"],
('source_project_title: "' + modification_dict.project_title + '" AND selection_domain_state_bug_domain: "started"')), ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_bug_domain: "started"')),
getUrlParameters('bug_module', "view", [["delivery.start_date", "descending"]], getUrlParameters('bug_module', "view", [["delivery.start_date", "descending"]],
["title", "description", "delivery.start_date"], ["title", "description", "delivery.start_date"],
('source_project_title: "' + modification_dict.project_title + '" AND selection_domain_state_bug_domain: "closed"')), ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_bug_domain: "closed"')),
getUrlParameters('task_report_module', 'view', [["delivery.start_date", "descending"]], getUrlParameters('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 + '" AND selection_domain_state_task_report_domain: "started"')), ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_report_domain: "started"')),
getUrlParameters('task_report_module', 'view', [["delivery.start_date", "descending"]], getUrlParameters('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 + '" AND selection_domain_state_task_report_domain: "closed"')), ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_report_domain: "closed"')),
getUrlParameters('test_result_module', 'view', [["delivery.start_date", "descending"]], getUrlParameters('test_result_module', 'view', [["delivery.start_date", "descending"]],
null, ('source_project_title: "' + modification_dict.project_title + '"')), null, ('source_project_title: "' + modification_dict.project_title + '"')),
getUrlParameters('test_suite_module', 'view', [["creation_date", "descending"]], getUrlParameters('test_suite_module', 'view', [["creation_date", "descending"]],
...@@ -140,7 +148,8 @@ lockGadgetInQueue, unlockGadgetInQueue*/ ...@@ -140,7 +148,8 @@ lockGadgetInQueue, unlockGadgetInQueue*/
getUrlParameters('task_module', "view", [["delivery.start_date", "descending"]], getUrlParameters('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 + '" AND selection_domain_state_task_domain: "not_confirmed"')), ('source_project_title: "' + modification_dict.project_title +
'" AND selection_domain_state_task_domain: "not_confirmed"')),
getUrlParameters(web_page_info.id, web_page_info.edit_view) getUrlParameters(web_page_info.id, web_page_info.edit_view)
]); ]);
}) })
...@@ -158,7 +167,8 @@ lockGadgetInQueue, unlockGadgetInQueue*/ ...@@ -158,7 +167,8 @@ lockGadgetInQueue, unlockGadgetInQueue*/
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]);
} }
setLastTestResult(gadget, modification_dict.project_title, document.getElementById("test_result_span")); setLastTestResult(gadget, modification_dict.project_title,
document.getElementById("test_result_span"));
}); });
}) })
...@@ -170,5 +180,4 @@ lockGadgetInQueue, unlockGadgetInQueue*/ ...@@ -170,5 +180,4 @@ lockGadgetInQueue, unlockGadgetInQueue*/
return true; return true;
}); });
}(window, rJS, RSVP, document, FileReader, Blob, jIO, ensureArray, }(window, rJS, RSVP, document, ensureArray));
lockGadgetInQueue, unlockGadgetInQueue)); \ No newline at end of file
\ No newline at end of file
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 sign in to comment