Commit f2c3d48c authored by Vincent Bechu's avatar Vincent Bechu

[erp5_web_renderjs_ui] add possibility to hide panel in desktop view

parent f19a3c76
...@@ -130,6 +130,11 @@ ...@@ -130,6 +130,11 @@
modified: true modified: true
}); });
}) })
.declareMethod('setDesktopMode', function (isDesktop) {
return this.changeState({
desktop: isDesktop
});
})
/* /*
.declareMethod('notifyUpdate', function () { .declareMethod('notifyUpdate', function () {
return this.render(this.stats.options); return this.render(this.stats.options);
...@@ -228,6 +233,17 @@ ...@@ -228,6 +233,17 @@
default_right_icon = "", default_right_icon = "",
title_link, title_link,
promise_list = []; promise_list = [];
if (modification_dict.hasOwnProperty('desktop')) {
if (this.state.desktop) {
if (this.element.classList.contains('tablet-mode')) {
this.element.classList.remove('tablet-mode');
}
} else {
if (!this.element.classList.contains('tablet-mode')) {
this.element.classList.toggle('tablet-mode');
}
}
}
// Main title // Main title
if (modification_dict.hasOwnProperty('error') || if (modification_dict.hasOwnProperty('error') ||
modification_dict.hasOwnProperty('loaded') || modification_dict.hasOwnProperty('loaded') ||
......
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>vincent</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.19028.47293.9045</string> </value> <value> <string>963.43879.9730.43520</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>1502270945.98</float> <float>1511881522.84</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -429,6 +429,19 @@ ...@@ -429,6 +429,19 @@
.allowPublicAcquisition('triggerPanel', function () { .allowPublicAcquisition('triggerPanel', function () {
return route(this, "panel", "toggle"); return route(this, "panel", "toggle");
}) })
.allowPublicAcquisition('setDesktopMode', function (param_list) {
this.props.desktop_mode = param_list[0];
if (param_list[0]) {
if (this.props.content_element.classList.contains('tablet-mode')) {
this.props.content_element.classList.remove('tablet-mode');
}
} else {
if (!this.props.content_element.classList.contains('tablet-mode')) {
this.props.content_element.classList.toggle('tablet-mode');
}
}
return route(this, "header", "setDesktopMode", [param_list[0]]);
})
.allowPublicAcquisition('renderEditorPanel', function (param_list) { .allowPublicAcquisition('renderEditorPanel', function (param_list) {
return route(this, "editor_panel", 'render', param_list); return route(this, "editor_panel", 'render', param_list);
}) })
...@@ -561,9 +574,11 @@ ...@@ -561,9 +574,11 @@
}) })
.push(function () { .push(function () {
var promise_list = [ var promise_list = [
route(gadget, 'panel', 'close'),
route(gadget, 'editor_panel', 'close') route(gadget, 'editor_panel', 'close')
]; ];
if (!gadget.props.desktop_mode) {
promise_list.push(route(gadget, 'panel', 'close'));
}
if (keep_message !== true) { if (keep_message !== true) {
promise_list.push(route(gadget, 'notification', 'close')); promise_list.push(route(gadget, 'notification', 'close'));
} }
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.7551.15104.28279</string> </value> <value> <string>963.49583.4046.44697</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>1509376504.09</float> <float>1511882028.25</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Precompile templates while loading the first gadget instance // Precompile templates while loading the first gadget instance
var gadget_klass = rJS(window), var gadget_klass = rJS(window),
matchMedia = window.matchMedia("(min-width: 85em)"),
template_element = gadget_klass.__template_element, template_element = gadget_klass.__template_element,
panel_template_header = Handlebars.compile(template_element panel_template_header = Handlebars.compile(template_element
.getElementById("panel-template-header") .getElementById("panel-template-header")
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
gadget_klass gadget_klass
.setState({ .setState({
visible: false, visible: false,
desktop: false desktop: matchMedia.matches
}) })
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("setDesktopMode", "setDesktopMode")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
...@@ -97,6 +99,14 @@ ...@@ -97,6 +99,14 @@
} }
} }
} }
if (modification_dict.hasOwnProperty('desktop') ||
modification_dict.hasOwnProperty("visible")) {
queue.push(function () {
return gadget.setDesktopMode(
gadget.state.visible && gadget.state.desktop
);
});
}
if (modification_dict.hasOwnProperty("global")) { if (modification_dict.hasOwnProperty("global")) {
queue queue
...@@ -280,13 +290,15 @@ ...@@ -280,13 +290,15 @@
event, event,
context = this; context = this;
function extractSizeAndDispatch() { function extractSizeAndDispatch() {
if (window.matchMedia("(min-width: 85em)").matches) { if (matchMedia.matches) {
return context.changeState({ return context.changeState({
desktop: true desktop: true,
visible: true
}); });
} }
return context.changeState({ return context.changeState({
desktop: false desktop: false,
visible: false
}); });
} }
result = loopEventListener(window, 'resize', false, result = loopEventListener(window, 'resize', false,
...@@ -359,4 +371,4 @@ ...@@ -359,4 +371,4 @@
}, /*useCapture=*/false, /*preventDefault=*/true); }, /*useCapture=*/false, /*preventDefault=*/true);
}(window, document, rJS, Handlebars, RSVP, Node, loopEventListener)); }(window, document, rJS, Handlebars, RSVP, Node, loopEventListener));
\ No newline at end of file
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>vincent</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.1708.1551.12032</string> </value> <value> <string>963.49579.37797.17544</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>1501231473.84</float> <float>1511882299.1</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