$menu.addClass('active');
$menu.parent('h4').addClass('active');
- return !$menu.is(".leaf");
+ if (this.$secondary_menu.has($menu).length) {
+ return !$menu.is(".leaf");
+ } else {
+ return false;
+ }
},
on_menu_action_loaded: function(data) {
var self = this;
// Do you autorize this ? will be replaced by notify() in controller
openerp.web.Widget.prototype.notification = new openerp.web.Notification(this, "oe_notification");
-
this.header = new openerp.web.Header(this);
this.login = new openerp.web.Login(this, "oe_login");
this.header.on_logout.add(this.login.on_logout);
this.menu = new openerp.web.Menu(this, "oe_menu", "oe_secondary_menu");
this.menu.on_action.add(this.on_menu_action);
+
+ this.url_internal_hashchange = false;
+ this.url_external_hashchange = false;
+ jQuery(window).bind('hashchange', this.on_url_hashchange);
+
},
start: function() {
this.header.appendTo($("#oe_header"));
this.action_manager.stop();
this.action_manager = new openerp.web.ActionManager(this);
this.action_manager.appendTo($("#oe_app"));
-
- // if using saved actions, load the action and give it to action manager
- var parameters = jQuery.deparam(jQuery.param.querystring());
- if (parameters["s_action"] != undefined) {
- var key = parseInt(parameters["s_action"], 10);
- var self = this;
- this.rpc("/web/session/get_session_action", {key:key}, function(action) {
- self.action_manager.do_action(action);
- });
- } else if (openerp._modules_loaded) { // TODO: find better option than this
- this.load_url_state()
- } else {
- this.session.on_modules_loaded.add({
- callback: $.proxy(this, 'load_url_state'),
- unique: true,
- position: 'last'
- })
- }
- },
- /**
- * Loads state from URL if any, or checks if there is a home action and
- * loads that, assuming we're at the index
- */
- load_url_state: function () {
- var self = this;
- // TODO: add actual loading if there is url state to unpack, test on window.location.hash
-
- // not logged in
- if (!this.session.uid) { return; }
- var ds = new openerp.web.DataSetSearch(this, 'res.users');
- ds.read_ids([this.session.uid], ['action_id'], function (users) {
- var home_action = users[0].action_id;
- if (!home_action) {
- self.default_home();
- return;
- }
- self.execute_home_action(home_action[0], ds);
- })
+ this.action_manager.do_url_set_hash.add_last(this.do_url_set_hash);
+
+ // // if using saved actions, load the action and give it to action manager
+ // var parameters = jQuery.deparam(jQuery.param.querystring());
+ // if (parameters["s_action"] != undefined) {
+ // var key = parseInt(parameters["s_action"], 10);
+ // var self = this;
+ // this.rpc("/web/session/get_session_action", {key:key}, function(action) {
+ // self.action_manager.do_action(action);
+ // });
+ // } else if (openerp._modules_loaded) { // TODO: find better option than this
+ // this.load_url_state()
+ // } else {
+ // this.session.on_modules_loaded.add({
+ // callback: $.proxy(this, 'load_url_state'),
+ // unique: true,
+ // position: 'last'
+ // })
+ // }
+
+ // /**
+ // * Loads state from URL if any, or checks if there is a home action and
+ // * loads that, assuming we're at the index
+ // */
+ // load_url_state: function () {
+ // var self = this;
+ // // TODO: add actual loading if there is url state to unpack, test on window.location.hash
+ // // not logged in
+ // if (!this.session.uid) { return; }
+ // var ds = new openerp.web.DataSetSearch(this, 'res.users');
+ // ds.read_ids([this.session.uid], ['action_id'], function (users) {
+ // var home_action = users[0].action_id;
+ // if (!home_action) {
+ // self.default_home();
+ // return;
+ // }
+ // self.execute_home_action(home_action[0], ds);
+ // })
+ // },
},
default_home: function () {
},
self.action_manager.do_action(action);
});
},
+ do_url_set_hash: function(url) {
+ if(!this.url_external_hashchange) {
+ console.log("url set #hash to",url);
+ this.url_internal_hashchange = true;
+ jQuery.bbq.pushState(url);
+ }
+ },
+ on_url_hashchange: function() {
+ if(this.url_internal_hashchange) {
+ this.url_internal_hashchange = false;
+ console.log("url jump to FLAG OFF");
+ } else {
+ var url = jQuery.deparam.fragment();
+ console.log("url jump to",url);
+ this.url_external_hashchange = true;
+ this.action_manager.on_url_hashchange(url);
+ this.url_external_hashchange = false;
+ }
+ },
on_menu_action: function(action) {
this.action_manager.do_action(action);
},
this.dialog = null;
this.dialog_viewmanager = null;
this.client_widget = null;
- this.url = {}
},
render: function() {
return "<div id='"+this.element_id+"'></div>";
}
},
url_update: function(action) {
+ var url = {};
+ if(action.id)
+ url.action_id = action.id;
// this.url = {
- // "model": action.model,
+ // "model": action.res_model,
// "domain": action.domain,
// };
// action.res_model
// action.res_id
// mode
// menu
+ this.do_url_set_hash(url);
},
- url_stringify: function(action) {
+ do_url_set_hash: function(url) {
},
- url_parse: function(action) {
- },
- on_url_update: function(url) {
- },
- do_url_action: function(url) {
+ on_url_hashchange: function(url) {
+ var self = this;
+ self.rpc("/web/action/load", { action_id: url.action_id }, function(result) {
+ self.do_action(result.result);
+ });
},
do_action: function(action, on_close) {
var type = action.type.replace(/\./g,'_');