Commit c83cb5e6 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Load the editor panel gadget only if user click on a related button

parent c4d2fe8e
......@@ -8,39 +8,26 @@
// acquired method
//////////////////////////////////////////////
.allowPublicAcquisition('trigger', function trigger() {
return this.toggle();
return this.close();
})
.declareMethod('toggle', function toggle() {
if (this.state.visible) {
return this.close();
}
return this.changeState({
visible: !this.state.visible
url: undefined
});
})
.declareMethod('close', function close() {
return this.changeState({
visible: false,
url: undefined,
options: undefined
url: undefined
});
})
.declareMethod('render', function render(url, options) {
// XXX Hack to close the panel if the sort/filter button
// is clicked twice
if (url === this.state.url) {
return this.changeState({
visible: false,
url: undefined,
options: undefined
});
}
return this.changeState({
visible: true,
url: url,
// Hack to close the panel if the sort/filter button
// is clicked twice
url: (url === this.state.url) ? undefined : url,
options: options
});
})
......@@ -48,22 +35,19 @@
.onStateChange(function onStateChange(modification_dict) {
var queue,
gadget = this;
if (this.state.visible) {
if (!this.element.classList.contains('visible')) {
this.element.classList.toggle('visible');
}
} else {
if (this.element.classList.contains('visible')) {
this.element.classList.remove('visible');
}
}
if (modification_dict.hasOwnProperty('url')) {
if (this.state.url === undefined) {
if (this.element.classList.contains('visible')) {
this.element.classList.remove('visible');
}
while (this.element.firstChild) {
this.element.removeChild(this.element.firstChild);
}
} else {
if (!this.element.classList.contains('visible')) {
this.element.classList.toggle('visible');
}
queue = this.declareGadget(this.state.url,
{scope: "declared_gadget"});
}
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.11788.48702.26146</string> </value>
<value> <string>971.13319.43014.16520</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1526656627.08</float>
<float>1540559107.01</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -466,7 +466,12 @@
})
.allowPublicAcquisition('renderEditorPanel',
function renderEditorPanel(param_list) {
return route(this, "editor_panel", 'render', param_list);
return this.changeState({
// Force calling editor panel render
editor_panel_render_timestamp: new Date().getTime(),
editor_panel_url: param_list[0],
editor_panel_options: param_list[1]
});
})
.allowPublicAcquisition("jio_allDocs", function jio_allDocs(param_list) {
return callJioGadget(this, "allDocs", param_list);
......@@ -525,7 +530,8 @@
})
.onStateChange(function onStateChange(modification_dict) {
var gadget = this,
route_result = gadget.state;
route_result = gadget.state,
promise_list;
if (modification_dict.hasOwnProperty('error_text')) {
return gadget.dropGadget(MAIN_SCOPE)
......@@ -546,8 +552,11 @@
});
}
promise_list = [];
// Update the main gadget
if (modification_dict.hasOwnProperty('url')) {
return renderMainGadget(
promise_list.push(renderMainGadget(
gadget,
route_result.url,
route_result.options
......@@ -575,20 +584,32 @@
// XXX Drop notification
// return header_gadget.notifyLoaded();
}
});
}));
} else if (modification_dict.hasOwnProperty('render_timestamp')) {
// Same subgadget
promise_list.push(gadget.getDeclaredGadget(MAIN_SCOPE)
.push(function (page_gadget) {
return page_gadget.render(gadget.state.options);
})
.push(function () {
return RSVP.all([
updateHeader(gadget),
updatePanel(gadget)
]);
}));
}
// Same subgadget
return gadget.getDeclaredGadget(MAIN_SCOPE)
.push(function (page_gadget) {
return page_gadget.render(gadget.state.options);
})
.push(function () {
return RSVP.all([
updateHeader(gadget),
updatePanel(gadget)
]);
});
// Update the editor panel
if (modification_dict.hasOwnProperty('editor_panel_url') ||
modification_dict.hasOwnProperty('editor_panel_render_timestamp')) {
promise_list.push(
route(gadget, 'editor_panel', 'render',
[gadget.state.editor_panel_url,
gadget.state.editor_panel_options])
);
}
return RSVP.all(promise_list);
})
// Render the page
.declareMethod('render', function render(route_result, keep_message) {
......@@ -604,7 +625,6 @@
.push(function () {
var promise_list = [
route(gadget, 'panel', 'close'),
route(gadget, 'editor_panel', 'close'),
route(gadget, 'router', 'notify', [{modified : false}])
];
if (keep_message !== true) {
......@@ -613,8 +633,13 @@
return RSVP.all(promise_list);
})
.push(function () {
return gadget.changeState({url: route_result.url,
options: route_result.options});
return gadget.changeState({
url: route_result.url,
options: route_result.options,
editor_panel_url: undefined,
// Force calling main gadget render
render_timestamp: new Date().getTime()
});
})
.push(function () {
return decreaseLoadingCounter(gadget);
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.13016.8122.59972</string> </value>
<value> <string>971.13336.56125.62259</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1540541176.76</float>
<float>1540559619.45</float>
<string>UTC</string>
</tuple>
</state>
......
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