Commit b78bbd5a authored by Roque's avatar Roque

erp5_web_project_ui: refactor in home page query

parent 70e92517
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: {"project_title":here.getTitle(), "jio_key": here.getRelativeUrl(), "project_reference": here.getReference()}</string> </value> <value> <string>python: {"project_title":here.getTitle(), "jio_key": here.getRelativeUrl(), "project_reference": here.getReference(), "home_page_preference": "project_home_page"}</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -110,14 +110,14 @@ ...@@ -110,14 +110,14 @@
})); }));
} }
function getWebPageInfo(gadget, project_reference) { //TODO fully remove project_reference (render options, TALES exp, etc)
function getWebPageInfo(gadget, project_reference, home_page_preference) {
var id, var id,
content, content,
edit_view, edit_view,
redirector_ulr, redirector_ulr,
query, query,
query_list = [], query_list = [];
valid_state_list = ["shared_alive", "released_alive", "published_alive"];
query_list.push(new SimpleQuery({ query_list.push(new SimpleQuery({
key: "portal_type", key: "portal_type",
operator: "=", operator: "=",
...@@ -125,10 +125,16 @@ ...@@ -125,10 +125,16 @@
value: "Web Page" value: "Web Page"
})); }));
query_list.push(new SimpleQuery({ query_list.push(new SimpleQuery({
key: "reference", key: "validation_state",
operator: "=", operator: "=",
type: "simple", type: "simple",
value: project_reference + '-Home.Page' value: ("shared_alive", "released_alive", "published_alive")
}));
query_list.push(new SimpleQuery({
key: "publication_section",
operator: "=",
type: "simple",
value: ('project_home_page')
})); }));
query = new ComplexQuery({ query = new ComplexQuery({
operator: "AND", operator: "AND",
...@@ -140,15 +146,15 @@ ...@@ -140,15 +146,15 @@
redirector_ulr = url; redirector_ulr = url;
return gadget.jio_allDocs({ return gadget.jio_allDocs({
query: Query.objectToSearchText(query), query: Query.objectToSearchText(query),
select_list: ['validation_state', 'text_content'] select_list: ['validation_state', 'text_content', 'publication_section']
}); });
}) })
.push(function (result_list) { .push(function (result_list) {
if (result_list.data.rows[0]) { if (result_list.data.rows[0]) {
var i, state, web_page; var i, web_page, publication_section;
for (i = 0; i < result_list.data.rows.length; i = i + 1) { for (i = 0; i < result_list.data.rows.length; i = i + 1) {
state = result_list.data.rows[i].value.validation_state; publication_section = result_list.data.rows[i].value.publication_section;
if (valid_state_list.includes(state)) { if (publication_section === home_page_preference) {
web_page = result_list.data.rows[i]; web_page = result_list.data.rows[i];
break; break;
} }
...@@ -196,7 +202,8 @@ ...@@ -196,7 +202,8 @@
var state_dict = { var state_dict = {
jio_key: options.jio_key || "", jio_key: options.jio_key || "",
project_title: options.project_title, project_title: options.project_title,
project_reference: options.project_reference project_reference: options.project_reference,
home_page_preference: options.home_page_preference
}; };
return this.changeState(state_dict); return this.changeState(state_dict);
}) })
...@@ -208,7 +215,7 @@ ...@@ -208,7 +215,7 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
getWebPageInfo(gadget, modification_dict.project_reference), getWebPageInfo(gadget, modification_dict.project_reference, modification_dict.home_page_preference),
gadget.getDeclaredGadget("editor"), gadget.getDeclaredGadget("editor"),
gadget.getSetting("hateoas_url") gadget.getSetting("hateoas_url")
]); ]);
......
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