Commit 58295978 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Remove increase/decreaseLoadingCounter

Stop displaying the loader everytime jIO is called.
This clarify the loader meaning: the page is rendering.

Stop displaying the header loader during the first rendering.
parent 030c7116
...@@ -64,14 +64,13 @@ ...@@ -64,14 +64,13 @@
} }
function updateHeader(gadget) { function updateHeader(gadget) {
var header_gadget; return route(gadget, "header", 'notifySubmitted')
return gadget.getDeclaredGadget("header") .push(function () {
.push(function (result) { return route(gadget, 'header', 'notifyLoaded');
header_gadget = result;
return header_gadget.notifySubmitted();
}) })
.push(function () { .push(function () {
return header_gadget.render(gadget.props.header_argument_list); return route(gadget, "header", 'render',
[gadget.props.header_argument_list]);
}); });
} }
...@@ -79,49 +78,8 @@ ...@@ -79,49 +78,8 @@
return route(gadget, 'panel', 'render', [gadget.props.panel_argument_list]); return route(gadget, 'panel', 'render', [gadget.props.panel_argument_list]);
} }
function increaseLoadingCounter(gadget) {
gadget.props.loading_counter += 1;
if (gadget.props.loading_counter === 1) {
return route(gadget, 'header', 'notifyLoading');
}
return new RSVP.Queue();
}
function decreaseLoadingCounter(gadget) {
gadget.props.loading_counter -= 1;
if (gadget.props.loading_counter < 0) {
gadget.props.loading_counter = 0;
// throw new Error("Unexpected negative loading counter");
}
if (gadget.props.loading_counter === 0) {
return route(gadget, 'header', 'notifyLoaded');
}
return new RSVP.Queue();
}
function callJioGadget(gadget, method, param_list) { function callJioGadget(gadget, method, param_list) {
var called = true; return route(gadget, 'jio_gadget', method, param_list);
return increaseLoadingCounter(gadget)
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget[method].apply(jio_gadget, param_list);
})
.push(function (result) {
return decreaseLoadingCounter(gadget)
.push(function () {
return result;
});
}, function (error) {
if (called) {
return decreaseLoadingCounter(gadget)
.push(function () {
throw error;
});
}
throw error;
});
} }
function displayErrorContent(gadget, error) { function displayErrorContent(gadget, error) {
...@@ -220,7 +178,6 @@ ...@@ -220,7 +178,6 @@
setting_gadget, setting_gadget,
setting; setting;
this.props = { this.props = {
loading_counter: 0,
content_element: this.element.querySelector('.gadget-content') content_element: this.element.querySelector('.gadget-content')
}; };
// Configure setting storage // Configure setting storage
...@@ -575,6 +532,15 @@ ...@@ -575,6 +532,15 @@
promise_list = []; promise_list = [];
// Update the main gadget // Update the main gadget
if (modification_dict.hasOwnProperty('render_timestamp')) {
// By default, init the header options to be empty
// (ERP5 title by default + sidebar)
initHeaderOptions(gadget);
initPanelOptions(gadget);
if (!modification_dict.hasOwnProperty('first_bootstrap')) {
promise_list.push(route(gadget, 'header', 'notifyLoading'));
}
}
if (modification_dict.hasOwnProperty('url')) { if (modification_dict.hasOwnProperty('url')) {
promise_list.push(renderMainGadget( promise_list.push(renderMainGadget(
gadget, gadget,
...@@ -657,33 +623,19 @@ ...@@ -657,33 +623,19 @@
// Render the page // Render the page
.declareMethod('render', function render(route_result, keep_message) { .declareMethod('render', function render(route_result, keep_message) {
var gadget = this; var gadget = this;
return gadget.changeState({
// Reinitialize the loading counter first_bootstrap: true,
gadget.props.loading_counter = 0; url: route_result.url,
// By default, init the header options to be empty options: route_result.options,
// (ERP5 title by default + sidebar) panel_visible: false,
initHeaderOptions(gadget); editor_panel_url: undefined,
initPanelOptions(gadget); notification_options: (keep_message === true) ?
return increaseLoadingCounter(gadget) gadget.state.notification_options : undefined,
.push(function () { // Force calling main gadget render
return gadget.changeState({ render_timestamp: new Date().getTime()
url: route_result.url, })
options: route_result.options, .push(undefined, function (error) {
panel_visible: false, return displayError(gadget, error);
editor_panel_url: undefined,
notification_options: (keep_message === true) ?
gadget.state.notification_options : undefined,
// Force calling main gadget render
render_timestamp: new Date().getTime()
});
})
.push(function () {
return decreaseLoadingCounter(gadget);
}, function (error) {
return decreaseLoadingCounter(gadget)
.push(function () {
return displayError(gadget, error);
});
}); });
}) })
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.13462.14418.45004</string> </value> <value> <string>971.17819.63775.64836</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>1540805328.09</float> <float>1540990953.44</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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