Commit 17ff606c authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_UI: site custom header

parent 3d3228e0
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.3732.6129.17322</string> </value> <value> <string>969.8998.9827.34850</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1509465615.33</float> <float>1532522343.05</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
possible_right_link_list = [ possible_right_link_list = [
['edit_url', 'Editable', 'pencil'], ['edit_url', 'Editable', 'pencil'],
['view_url', 'Viewable', 'eye'], ['view_url', 'Viewable', 'eye'],
['right_url', 'New', 'plus'] ['right_url', 'New', 'plus'],
['language_url', 'Language', 'flag']
], ],
possible_right_button_list = [ possible_right_button_list = [
['save_action', 'Save', 'check', 'submit'], ['save_action', 'Save', 'check', 'submit'],
...@@ -50,13 +51,16 @@ ...@@ -50,13 +51,16 @@
possible_sub_header_list = [ possible_sub_header_list = [
['tab_url', 'Views', 'eye'], ['tab_url', 'Views', 'eye'],
['jump_url', 'Jump', 'plane'], ['jump_url', 'Jump', 'plane'],
['delete_url', 'Delete', 'times'],
['export_url', 'Export', 'share-square-o'],
['actions_url', 'Actions', 'cogs'], ['actions_url', 'Actions', 'cogs'],
['cut_url', 'Cut', 'scissors'],
['add_url', 'Add', 'plus'], ['add_url', 'Add', 'plus'],
['export_url', 'Export', 'share-square-o'],
['delete_url', 'Delete', 'times'],
['cut_url', 'Cut', 'scissors'],
['fast_input_url', 'Fast Input', 'magic'],
['previous_url', 'Previous', 'carat-l'], ['previous_url', 'Previous', 'carat-l'],
['next_url', 'Next', 'carat-r'] ['next_url', 'Next', 'carat-r'],
['edit_content', 'Content', 'file-text'],
['edit_properties', 'Properties', 'info']
]; ];
gadget_klass gadget_klass
...@@ -73,7 +77,7 @@ ...@@ -73,7 +77,7 @@
// ready // ready
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Init local properties // Init local properties
.ready(function () { .ready(function ready() {
this.props = { this.props = {
element_list: [ element_list: [
this.element.querySelector("h1"), this.element.querySelector("h1"),
...@@ -90,50 +94,57 @@ ...@@ -90,50 +94,57 @@
.declareAcquiredMethod("translateHtml", "translateHtml") .declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("triggerSubmit", "triggerSubmit") .declareAcquiredMethod("triggerSubmit", "triggerSubmit")
.declareAcquiredMethod("triggerPanel", "triggerPanel") .declareAcquiredMethod("triggerPanel", "triggerPanel")
.declareAcquiredMethod("triggerMaximize", "triggerMaximize")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod('notifyLoaded', function () { .declareMethod('notifyLoaded', function notifyLoaded() {
return this.changeState({ return this.changeState({
loaded: true loaded: true
}); });
}) })
.declareMethod('notifyLoading', function () { .declareMethod('notifyLoading', function notifyLoading() {
return this.changeState({ return this.changeState({
loaded: false loaded: false
}); });
}) })
.declareMethod('notifySubmitted', function () { .declareMethod('notifySubmitted', function notifySubmitted() {
return this.changeState({ return this.changeState({
submitted: true, submitted: true,
// Change modify here, to allow user to redo some modification and being correctly notified // Change modify here, to allow user to redo some modification and being correctly notified
modified: false modified: false
}); });
}) })
.declareMethod('notifySubmitting', function () { .declareMethod('notifySubmitting', function notifySubmitting() {
return this.changeState({ return this.changeState({
submitted: false submitted: false
}); });
}) })
.declareMethod('notifyError', function () { .declareMethod('notifyError', function notifyError() {
return this.changeState({ return this.changeState({
loaded: true, loaded: true,
submitted: true, submitted: true,
error: true error: true
}); });
}) })
.declareMethod('notifyChange', function () { .declareMethod('notifyChange', function notifyChange() {
return this.changeState({ return this.changeState({
modified: true modified: true
}); });
}) })
/* .declareMethod('setButtonTitle', function setButtonTitle(options) {
return this.changeState({
title_button_icon: options.icon,
title_button_name: options.action
});
})
/*
.declareMethod('notifyUpdate', function () { .declareMethod('notifyUpdate', function () {
return this.render(this.stats.options); return this.render(this.stats.options);
}) })
*/ */
.declareMethod('render', function (options) { .declareMethod('render', function render(options) {
var state = { var state = {
error: false, error: false,
title_text: '', title_text: '',
...@@ -164,6 +175,10 @@ ...@@ -164,6 +175,10 @@
state.title_url = options[possible_main_link_list[i][0]]; state.title_url = options[possible_main_link_list[i][0]];
} }
} }
// Surcharge icon if the page want it
if (options.hasOwnProperty("page_icon")) {
state.title_icon = options.page_icon;
}
// Left button // Left button
for (i = 0; i < possible_left_button_list.length; i += 1) { for (i = 0; i < possible_left_button_list.length; i += 1) {
...@@ -177,9 +192,14 @@ ...@@ -177,9 +192,14 @@
// Handle right link // Handle right link
for (i = 0; i < possible_right_link_list.length; i += 1) { for (i = 0; i < possible_right_link_list.length; i += 1) {
if (options.hasOwnProperty(possible_right_link_list[i][0])) { if (options.hasOwnProperty(possible_right_link_list[i][0])) {
if (options.extra_class &&
options.extra_class.hasOwnProperty(possible_right_link_list[i][0])) {
klass = options.extra_class[possible_right_link_list[i][0]];
} else {
klass = ""; klass = "";
}
if (!options[possible_right_link_list[i][0]]) { if (!options[possible_right_link_list[i][0]]) {
klass = "ui-disabled"; klass += " ui-disabled";
} }
state.right_link_title = possible_right_link_list[i][1]; state.right_link_title = possible_right_link_list[i][1];
state.right_link_icon = possible_right_link_list[i][2]; state.right_link_icon = possible_right_link_list[i][2];
...@@ -211,29 +231,52 @@ ...@@ -211,29 +231,52 @@
} }
} }
state.sub_header_list = sub_header_list; state.sub_header_list = sub_header_list;
return this.changeState(state); return this.changeState(state);
}) })
.onStateChange(function (modification_dict) { .onStateChange(function onStateChange(modification_dict) {
var gadget = this, var gadget = this,
right_link, right_link,
right_button, right_button,
default_title_icon = "",
default_right_icon = "", default_right_icon = "",
title_link, title_link,
title_button,
promise_list = []; promise_list = [];
// Main title // Main title
if (modification_dict.hasOwnProperty('title_text') || if (modification_dict.hasOwnProperty('error') ||
modification_dict.hasOwnProperty('loaded') ||
modification_dict.hasOwnProperty('submitted') ||
modification_dict.hasOwnProperty('title_text') ||
modification_dict.hasOwnProperty('title_icon') || modification_dict.hasOwnProperty('title_icon') ||
modification_dict.hasOwnProperty('title_url')) { modification_dict.hasOwnProperty('title_url') ||
modification_dict.hasOwnProperty('title_button_name')) {
if (gadget.state.error) {
default_title_icon = "exclamation";
} else if (!gadget.state.loaded) {
default_title_icon = "spinner";
} else if (!gadget.state.submitted) {
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
if (modification_dict.hasOwnProperty('title_text')) {
// Be careful, this is CPU costly
document.title = gadget.state.title_text; document.title = gadget.state.title_text;
}
title_link = { title_link = {
title: gadget.state.title_text, title: gadget.state.title_text,
icon: gadget.state.title_icon, icon: default_title_icon || gadget.state.title_icon,
url: gadget.state.title_url url: gadget.state.title_url
}; };
if (title_link.url === undefined) { if (gadget.state.title_button_name) {
title_button = {
title: gadget.state.title_text,
icon: default_title_icon || gadget.state.title_button_icon,
name: gadget.state.title_button_name
};
promise_list.push(gadget.translateHtml(header_button_template(title_button)));
} else if (title_link.url === undefined) {
promise_list.push(gadget.translateHtml(header_title_template(title_link))); promise_list.push(gadget.translateHtml(header_title_template(title_link)));
} else { } else {
promise_list.push(gadget.translateHtml(header_title_link_template(title_link))); promise_list.push(gadget.translateHtml(header_title_link_template(title_link)));
...@@ -260,38 +303,22 @@ ...@@ -260,38 +303,22 @@
} }
// Handle right link // Handle right link
if (modification_dict.hasOwnProperty('error') || if (modification_dict.hasOwnProperty('loaded') ||
modification_dict.hasOwnProperty('loaded') || modification_dict.hasOwnProperty('submitted') ||
modification_dict.hasOwnProperty('modified') || modification_dict.hasOwnProperty('modified') ||
modification_dict.hasOwnProperty('right_link_title') || modification_dict.hasOwnProperty('right_link_title') ||
modification_dict.hasOwnProperty('right_link_icon') || modification_dict.hasOwnProperty('right_link_icon') ||
modification_dict.hasOwnProperty('right_link_url') || modification_dict.hasOwnProperty('right_link_url') ||
modification_dict.hasOwnProperty('right_link_class') || modification_dict.hasOwnProperty('right_link_class') ||
modification_dict.hasOwnProperty('right_button_title') || modification_dict.hasOwnProperty('right_button_title') ||
modification_dict.hasOwnProperty('right_button_icon') || modification_dict.hasOwnProperty('right_button_icon')) {
modification_dict.hasOwnProperty('submitted')) { if (gadget.state.modified) {
if (gadget.state.error) {
default_right_icon = "exclamation";
} else if (!gadget.state.loaded) {
default_right_icon = "spinner";
// Show default loading information
right_link = {
title: "Loading",
icon: default_right_icon,
url: "",
class: "ui-disabled ui-icon-spin"
};
} else if (!gadget.state.submitted) {
default_right_icon = "spinner";
} else if (gadget.state.modified) {
default_right_icon = "warning"; default_right_icon = "warning";
} }
if (gadget.state.right_link_title !== undefined) { if (gadget.state.right_link_title !== undefined) {
right_link = { right_link = {
title: gadget.state.right_link_title, title: gadget.state.right_link_title,
icon: default_right_icon || gadget.state.right_link_icon, icon: gadget.state.right_link_icon,
url: gadget.state.right_link_url, url: gadget.state.right_link_url,
class: gadget.state.right_link_class class: gadget.state.right_link_class
}; };
...@@ -302,20 +329,14 @@ ...@@ -302,20 +329,14 @@
icon: default_right_icon || gadget.state.right_button_icon, icon: default_right_icon || gadget.state.right_button_icon,
name: gadget.state.right_button_name name: gadget.state.right_button_name
}; };
if (gadget.state.error) { if (gadget.state.error || !gadget.state.loaded || !gadget.state.submitted) {
right_button.class = "ui-disabled"; right_button.class = "ui-disabled";
} }
} }
if (right_button !== undefined) { if (right_button !== undefined) {
if (right_button.icon === 'spinner') {
right_button.class = "ui-disabled ui-icon-spin";
}
promise_list.push(gadget.translateHtml(header_button_template(right_button))); promise_list.push(gadget.translateHtml(header_button_template(right_button)));
} else if (right_link !== undefined) { } else if (right_link !== undefined) {
if (right_link.icon === 'spinner') {
right_link.class = "ui-disabled ui-icon-spin";
}
promise_list.push(gadget.translateHtml(header_link_template(right_link))); promise_list.push(gadget.translateHtml(header_link_template(right_link)));
} else { } else {
promise_list.push(""); promise_list.push("");
...@@ -350,7 +371,7 @@ ...@@ -350,7 +371,7 @@
////////////////////////////////////////////// //////////////////////////////////////////////
// handle button submit // handle button submit
////////////////////////////////////////////// //////////////////////////////////////////////
.onEvent('submit', function (evt) { .onEvent('submit', function submit(evt) {
var name = evt.target[0].getAttribute("name"); var name = evt.target[0].getAttribute("name");
if (name === "panel") { if (name === "panel") {
return this.triggerPanel(); return this.triggerPanel();
...@@ -358,6 +379,9 @@ ...@@ -358,6 +379,9 @@
if (name === "submit") { if (name === "submit") {
return this.triggerSubmit(); return this.triggerSubmit();
} }
if (name === "maximize") {
return this.triggerMaximize();
}
throw new Error("Unsupported button " + name); throw new Error("Unsupported button " + name);
}); });
......
...@@ -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.58905.50664.31180</string> </value> <value> <string>969.9075.35285.62173</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>1509016469.74</float> <float>1532526555.8</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -343,9 +343,7 @@ ...@@ -343,9 +343,7 @@
</item> </item>
<item> <item>
<key> <string>configuration_header_gadget_url</string> </key> <key> <string>configuration_header_gadget_url</string> </key>
<value> <value> <string>fif_gadget_erp5_header.html</string> </value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>configuration_jio_gadget_url</string> </key> <key> <string>configuration_jio_gadget_url</string> </key>
...@@ -602,7 +600,7 @@ ...@@ -602,7 +600,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>959.44994.35078.29832</string> </value> <value> <string>969.9014.24555.34867</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -620,7 +618,7 @@ ...@@ -620,7 +618,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1508749049.28</float> <float>1532522442.79</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