Commit 89cc018b authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Panel: use onStateChange

parent c3d27c57
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
.innerHTML); .innerHTML);
gadget_klass gadget_klass
.setState({
visible: false
})
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
////////////////////////////////////////////// //////////////////////////////////////////////
...@@ -27,12 +30,14 @@ ...@@ -27,12 +30,14 @@
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod('toggle', function () { .declareMethod('toggle', function () {
this.element.classList.toggle('visible'); return this.changeState({
visible: !this.state.visible
});
}) })
.declareMethod('close', function () { .declareMethod('close', function () {
if (this.element.classList.contains('visible')) { return this.changeState({
this.element.classList.remove('visible'); visible: false
} });
}) })
.declareMethod('render', function () { .declareMethod('render', function () {
...@@ -56,7 +61,6 @@ ...@@ -56,7 +61,6 @@
"module_href": all_result[0], "module_href": all_result[0],
"history_href": all_result[1], "history_href": all_result[1],
"preference_href": all_result[2], "preference_href": all_result[2],
// "language_list": language_list,
"logout_href": all_result[3], "logout_href": all_result[3],
"search_href": all_result[4], "search_href": all_result[4],
"worklist_href": all_result[5] "worklist_href": all_result[5]
...@@ -68,6 +72,18 @@ ...@@ -68,6 +72,18 @@
}); });
}) })
.onStateChange(function () {
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');
}
}
})
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared services // declared services
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
......
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