Commit cd0cdd2a authored by Tomáš Peterka's avatar Tomáš Peterka

[renderjs_ui] Header.render expects complete state thus resets all buttons every time

parent ff7e889b
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
]; ];
gadget_klass gadget_klass
/* Init state is important because `render` is not necesarily called first*/
.setState({ .setState({
loaded: false, loaded: false,
modified: false, modified: false,
...@@ -75,6 +76,7 @@ ...@@ -75,6 +76,7 @@
right_button: {}, right_button: {},
right_link: {} right_link: {}
}) })
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// ready // ready
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -135,19 +137,25 @@ ...@@ -135,19 +137,25 @@
}); });
}) })
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var gadget = this, var sub_header_list = [],
state = { state = {
"error": options.error || false // render does not touch "loaded", "modified" or "submitted"
"error": options.error || false,
// set empty templates for all buttons to force-reset them because
// render expects complete state (complete definition of all buttons)
"main_link": {},
"right_link": {},
"right_button": {},
"left_button": {}
}, },
klass, klass,
sub_header_list = [],
i; i;
// Main title // Main title
if (options.hasOwnProperty("page_title") || options.hasOwnProperty("page_icon")) { if (options.hasOwnProperty("page_title") || options.hasOwnProperty("page_icon")) {
state.main_link = { state.main_link = {
"title": options.page_title || gadget.state.main_link.title, "title": options.page_title,
"icon": options.page_icon || gadget.state.main_link.icon, "icon": options.page_icon,
"url": '' "url": ''
}; };
for (i = 0; i < possible_main_link_list.length; i += 1) { for (i = 0; i < possible_main_link_list.length; i += 1) {
...@@ -156,11 +164,6 @@ ...@@ -156,11 +164,6 @@
state.main_link.url = options[possible_main_link_list[i][0]]; state.main_link.url = options[possible_main_link_list[i][0]];
} }
} }
// if a new page title|icon is specified then we clear all menu buttons
// because the view changed completely
state.right_link = {};
state.right_button = {};
state.left_button = {};
} }
// Left button // Left button
...@@ -240,7 +243,7 @@ ...@@ -240,7 +243,7 @@
default_title_icon = "spinner"; default_title_icon = "spinner";
} }
// Updating globally the page title. Does not follow RenderJS philosophy, but, it is enough for now // Updating globally the page title. Does not follow RenderJS philosophy, but, it is enough for now
document.title = gadget.state.main_link.title; document.title = gadget.state.main_link.title || "";
// Update icon in case an action in process (keep the original in state.title_icon) // Update icon in case an action in process (keep the original in state.title_icon)
main_link = { main_link = {
"title": gadget.state.main_link.title, "title": gadget.state.main_link.title,
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.1014.20681.8021</string> </value> <value> <string>962.15685.40055.49408</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>1505297561.5</float> <float>1506002370.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