[IMP] Implement footer functionality,on click of menu displayed all sub menus & Relational Fields.

bzr revid: bth@tinyerp.com-20110906113111-47qh4pwms82ktfnl
This commit is contained in:
Bhumi Thakkar (Open ERP)
2011-09-06 17:01:11 +05:30
parent 5f930a857e
commit 7d8809d3a8
4 changed files with 177 additions and 119 deletions
@@ -74,8 +74,9 @@ openerp.web_mobile.Login = openerp.base.Widget.extend({
.removeClass("login_invalid")
.addClass("login_valid");
//.hide();
this.homepage = new openerp.web_mobile.HomePage(this, "oe_home");
this.homepage.start();
this.menu = new openerp.web_mobile.Menu(this, "oe_menu", "oe_secondary_menu");
this.menu.start();
},
do_ask_login: function(continuation) {
this.on_login_invalid();
@@ -87,27 +88,6 @@ openerp.web_mobile.Login = openerp.base.Widget.extend({
}
});
openerp.web_mobile.HomePage = openerp.base.Widget.extend({
init: function(session, element_id) {
this._super(session, element_id);
},
start: function() {
this.$element.html(QWeb.render("HomePage", {}));
// this.header = new openerp.web_mobile.Header(this, "oe_header");
this.shortcuts = new openerp.web_mobile.Shortcuts(this, "oe_shortcuts");
this.menu = new openerp.web_mobile.Menu(this, "oe_menu", "oe_secondary_menu");
this.options = new openerp.web_mobile.Options(this, "oe_options");
// this.footer = new openerp.web_mobile.Footer(this, "oe_footer");
// this.header.start();
this.shortcuts.start();
this.menu.start();
this.options.start();
// this.footer.start();
this.$element.find("a").click(this.on_clicked);
$.mobile.changePage($("#oe_home"), "slide", true, true);
}
});
openerp.web_mobile.Header = openerp.base.Widget.extend({
init: function(session, element_id) {
this._super(session, element_id);
@@ -136,8 +116,13 @@ openerp.web_mobile.Shortcuts = openerp.base.Widget.extend({
var self = this;
this.rpc('/base/session/sc_list',{} ,function(res){
self.$element.html(QWeb.render("Shortcuts", {'sc' : res}))
self.$element.find("a").click(self.on_clicked);
})
self.$element.find('#content').find("a").click(self.on_clicked);
self.$element.find("#footer").find('#preference').click(function(){
this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start();
});
$.mobile.changePage($("#oe_shortcuts"), "slide", true, true);
});
},
on_clicked: function(ev) {
$shortcut = $(ev.currentTarget);
@@ -162,9 +147,20 @@ openerp.web_mobile.Menu = openerp.base.Widget.extend({
this.rpc("/base/menu/load", {}, this.on_loaded);
},
on_loaded: function(data) {
var self = this;
this.data = data;
this.$element.html(QWeb.render("Menu", this.data));
this.$element.add(this.$secondary_menu).find("a").click(this.on_menu_click);
this.$element.find("#footer").find('#shrotcuts').click(function(){
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
this.shortcuts.start();
});
this.$element.find("#footer").find('#preference').click(function(){
this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start();
});
this.$element.add(this.$secondary_menu).find("#content").find('a').click(this.on_menu_click);
$.mobile.changePage($("#oe_menu"), "slide", true, true);
},
on_menu_click: function(ev, id) {
$menu = $(ev.currentTarget);
@@ -182,46 +178,35 @@ openerp.web_mobile.Menu = openerp.base.Widget.extend({
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
// this.header.start();
this.secondary.start();
jQuery("#oe_header").find("h1").html($menu.data('name'));
}
});
openerp.web_mobile.Secondary = openerp.base.Widget.extend({
init: function(session, element_id, secondary_menu_id) {
this._super(session, element_id);
this.data = secondary_menu_id;
},
start: function(ev, id) {
var self = this;
var v = { menu : this.data };
this.$element.html(QWeb.render("Menu.secondary", v));
this.$element.add(this.$secondary_menu).find("a").click(this.on_menu_click);
this.$element.find("#header").find("h1").html(this.data.name);
this.$element.add(this.$secondary_menu).find('#content').find("a").click(this.on_menu_click);
this.$element.find("#footer").find('#shrotcuts').click(function(){
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
this.shortcuts.start();
});
this.$element.find("#footer").find('#preference').click(function(){
this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start();
});
$.mobile.changePage($("#oe_sec_menu"), "slide", true, true);
},
on_menu_click: function(ev, id) {
$menu = $(ev.currentTarget);
id = $menu.data('menu');
for (var i = 0; i < this.data.children.length; i++) {
if (this.data.children[i].id == id) {
this.children = this.data.children[i];
}
}
var child_len = this.children.children.length;
if (child_len > 0) {
this.$element
.removeClass("secondary_menu")
.addClass("content_menu");
//.hide();
// this.header = new openerp.web_mobile.Header(this, "oe_header");
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu_new", this.children);
// this.header.start();
this.secondary.start();
$.mobile.changePage($("#oe_sec_menu_new"), "slide", true, true);
}
else {
if (id) {
this.listview = new openerp.web_mobile.ListView(this, "oe_list", id);
this.listview.start();
}
if (id) {
this.listview = new openerp.web_mobile.ListView(this, "oe_list", id);
this.listview.start();
}
jQuery("#oe_header").find("h1").html($menu.data('name'));
}
@@ -234,6 +219,11 @@ openerp.web_mobile.Options = openerp.base.Widget.extend({
start: function() {
var self = this;
this.$element.html(QWeb.render("Options", this));
this.$element.find("#footer").find('#shrotcuts').click(function(){
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
this.shortcuts.start();
});
$.mobile.changePage($("#oe_options"), "slide", true, true);
}
});
+37 -16
View File
@@ -39,6 +39,8 @@ openerp.web_mobile.FormView = openerp.base.Widget.extend({
}
}
self.$element.html(QWeb.render("FormView", {'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : data }));
self.$element.find("#header").find('h1').html(self.action.name);
self.$element.find('select').change(function(ev){
selection.on_select_option(ev);
});
@@ -68,9 +70,12 @@ openerp.web_mobile.FormView = openerp.base.Widget.extend({
if (!next.find('.detail').html().length) {
for (var i = 0; i < get_fields.length; i++) {
if (fields[get_fields[i].attrs.name].type == 'one2many'){
var get_fields_test = self.get_fields(fields[get_fields[i].attrs.name].views.form.arch.children);
var fields_test = fields[get_fields[i].attrs.name]['views'].form.fields;
var notebook=fields[get_fields[i].attrs.name].views.form.arch;
if(fields[get_fields[i].attrs.name].views.form){
var get_fields_test = self.get_fields(fields[get_fields[i].attrs.name].views.form.arch.children);
var fields_test = fields[get_fields[i].attrs.name]['views'].form.fields;
var notebook=fields[get_fields[i].attrs.name].views.form.arch;
}
var relational = get_fields[i].attrs.name;
}
}
if(notebook){
@@ -79,18 +84,34 @@ openerp.web_mobile.FormView = openerp.base.Widget.extend({
next.find('.detail').append(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields_view.fields, 'values' : data }));
}
}
next.find('.detail').find('a').click(function(){
if(next.find('.detail').find('a').next().find('.detail').html().length){
if (next.find('.detail').find('a').next().hasClass(self.content_collapsed_class)) {
self.collapsed(next.find('.detail').find('a').next(),next.find('.detail').find('a').find('span .ui-icon'));
}
else if (next.find('.detail').find('a').next().hasClass(self.content_expanded_class)) {
self.expanded(next.find('.detail').find('a').next(),next.find('.detail').find('a').find('span .ui-icon'));
}
}
if(!next.find('.detail').find('a').next().find('.detail').html().length){
next.find('.detail').find('a').next().find('.detail').append(QWeb.render("FormView", {'get_fields': get_fields_test,'fields' : fields_test, 'values' : data }));
self.collapsed(next.find('.detail').find('a').next(),next.find('.detail').find('a').find('span .ui-icon'));
//$.mobile.changePage($("#oe_form"), "slide", true, true);
next.find('.detail').find('li').click(function(){
if(data[relational]){
var dataset = new openerp.base.DataSetStatic(self, result.fields_view.fields[relational].relation, result.fields_view.fields[relational].context);
dataset.domain=[['id', 'in', data[relational]]];
dataset.name_search('', dataset.domain, 'in',false ,function(res){
for(var i=0;i<res.length;i++){
var splited_data = res[i][1].split(',');
res[i][1] = splited_data[0];
}
self.$element.html(QWeb.render("ListView", {'records' : res}));
self.$element.find("#searchid").focus();
self.$element.find("a#list-id").click(function(ev){
dataset = new openerp.base.DataSetSearch(self, dataset.model, null, null);
dataset.read_slice([],{}, function (result_relational) {
for (var i = 0; i < result_relational.length; i++) {
if (result_relational[i].id == $(ev.currentTarget).data('id')) {
var data_relational = result_relational[i];
}
}
self.$element.html(QWeb.render("FormView", {'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational }));
self.$element.find('select').change(function(ev){
selection.on_select_option(ev);
});
});
});
});
}
});
}
@@ -101,7 +122,7 @@ openerp.web_mobile.FormView = openerp.base.Widget.extend({
});
});
$.mobile.changePage($("#oe_form"), "slide", true, true);
$("#oe_header").find("h1").html(result.fields_view.arch.attrs.string);
//$("#oe_header").find("h1").html(result.fields_view.arch.attrs.string);
});
},
get_fields: function(view_fields, fields) {
@@ -22,10 +22,21 @@ openerp.web_mobile.ListView = openerp.base.Widget.extend({
},
on_search_data: function(ev){
var self = this;
var dataset = new openerp.base.DataSetStatic(this, this.action.res_model, this.action.context);
dataset.name_search('', [], 'ilike',false ,function(result){
self.$element.html(QWeb.render("ListView", {'records' : result}));
self.$element.find("#header").find('h1').html(self.action.name);
self.$element.find("a#list-id").click(self.on_list_click);
self.$element.find("#footer").find('#shrotcuts').click(function(){
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
this.shortcuts.start();
});
self.$element.find("#footer").find('#preference').click(function(){
this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start();
});
$.mobile.changePage($("#oe_list"), "slide", true, true);
});
},
+88 -52
View File
@@ -10,6 +10,9 @@
<div data-role="page" id="oe_sec_menu_new"></div>
<div data-role="page" id="oe_list"></div>
<div data-role="page" id="oe_form"></div>
<div data-role="page" id="oe_shortcuts"></div>
<div data-role="page" id="oe_menu"></div>
<div data-role="page" id="oe_options"></div>
</t>
<t t-name="Login">
@@ -41,17 +44,16 @@
</t>
<t t-name="HomePage">
<div data-role="header" data-theme="b" data-position="fixed">
<div id="header" data-role="header" data-theme="b" data-position="fixed">
<h1>OpenERP</h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#oe_home" title="Home" data-theme="b"></a>
</div>
<div data-role="content">
<div id="oe_shortcuts"></div>
<div id="oe_menu"></div>
<div id="oe_options"></div>
</div>
<div data-role="footer" data-theme="b" data-position="fixed">
<h1>Footer</h1>
<div id="footer" data-role="footer" data-theme="b" data-position="fixed">
<a id="shortcuts" class="ui-btn-right" data-iconpos="notext" title="Favourite" data-theme="b"></a>
<a id="application" class="ui-btn-right" data-iconpos="notext" href="#oe_home" title="Application" data-theme="b"></a>
</div>
</t>
@@ -69,61 +71,86 @@
</t>
<t t-name="Shortcuts">
<ul data-dividertheme="b" data-theme="c" data-inset="true" data-role="listview" class="ui-listview ui-listview-inset ui-corner-all ui-shadow">
<li data-role="list-divider" role="heading" class="ui-li ui-li-divider ui-btn ui-bar-b ui-corner-top ui-btn-up-undefined">
<div data-role="header" data-theme="b">
<h1>OpenERP</h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#oe_menu" title="Home" data-theme="b"></a>
</div>
<div id="content" data-role="content">
<ul data-role="listview" data-inset="true">
<li data-role="list-divider" role="heading">
Shortcuts
</li>
<li data-theme="c" class="ui-btn ui-btn-icon-right ui-li ui-btn-up-c" t-foreach="sc" t-as="opt">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" class="ui-link-inherit" t-att-data-menu="opt.id" t-att-data-name="opt.name" t-att-data-res="opt.res_id">
<span><t t-esc="opt.name"/></span>
</a>
</div>
<span class="ui-icon ui-icon-arrow-r"></span>
</div>
<li data-theme="c" t-foreach="sc" t-as="opt">
<a href="#" t-att-data-menu="opt.id" t-att-data-name="opt.name" t-att-data-res="opt.res_id">
<span><t t-esc="opt.name"/></span>
</a>
</li>
</ul>
</div>
<div id="footer" data-role="footer" data-theme="b" data-position="fixed">
<a data-role="button" id="shrotcuts" href="">Favourite</a>
<a data-role="button" id="application" href="#oe_menu">Application</a>
<a data-role="button" id="preference" href="">Preference</a>
</div>
</t>
<t t-name="Menu">
<ul data-dividertheme="b" data-theme="c" data-inset="true" data-role="listview" class="ui-listview ui-listview-inset ui-corner-all ui-shadow">
<li data-role="list-divider" role="heading" class="ui-li ui-li-divider ui-btn ui-bar-b ui-corner-top ui-btn-up-undefined">
<div data-role="header" data-theme="b" data-position="fixed">
<h1>OpenERP</h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#oe_menu" title="Home" data-theme="b"></a>
</div>
<div id="content" data-role="content">
<ul data-role="listview" data-inset="true">
<li data-role="list-divider" role="heading">
Menu
</li>
<li data-theme="c" class="ui-btn ui-btn-icon-right ui-li ui-btn-up-c" t-foreach="data.children" t-as="menu">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" class="ui-link-inherit" t-att-data-menu="menu.id" t-att-data-name="menu.name">
<li data-theme="c" t-foreach="data.children" t-as="menu">
<a href="#" t-att-data-menu="menu.id" t-att-data-name="menu.name">
<span><t t-esc="menu.name"/></span>
</a>
</div>
<span class="ui-icon ui-icon-arrow-r"></span>
</div>
</li>
</ul>
</div>
<div id="footer" data-role="footer" data-theme="b" data-position="fixed">
<a data-role="button" id="shrotcuts">Favourite</a>
<a data-role="button" id="application" href="#oe_menu">Application</a>
<a data-role="button" id="preference">Preference</a>
</div>
</t>
<t t-name="Menu.secondary">
<div data-role="header" data-theme="b" data-position="fixed">
<h1>OpenERP</h1>
<div id="header" data-role="header" data-theme="b" data-position="fixed">
<h1></h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#" title="Home" data-theme="b"></a>
</div>
<div id="content" data-role="content">
<ul data-dividertheme="b" data-theme="c" data-inset="true" data-role="listview">
<t t-foreach="menu.children" t-as="menu1" >
<li data-role="list-divider">
<t t-esc="menu1.name"/>
</li>
<t t-if="menu1.children.length">
<li data-theme="c" t-foreach="menu1.children" t-as="childmenu" >
<a href="#" t-attf-id="menu_#{childmenu.id}" t-att-data-menu="childmenu.id" t-att-data-name="childmenu.name">
<t t-esc="childmenu.name" />
</a>
</li>
</t>
</t>
</ul>
</div>
<div id="footer" data-role="footer" data-theme="b" data-position="fixed">
<a data-role="button" id="shrotcuts">Favourite</a>
<a data-role="button" id="application" href="#oe_menu">Application</a>
<a data-role="button" id="preference" href="">Preference</a>
</div>
</t>
<t t-name="Options">
<div id="header" data-role="header" data-theme="b" data-position="fixed">
<h1>Openerp</h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#" title="Home" data-theme="b"></a>
</div>
<div data-role="content">
<ul data-role="listview">
<li data-theme="c" t-foreach="menu.children" t-as="menu">
<a href="#" t-attf-id="menu_#{menu.id}" t-att-data-menu="menu.id" t-att-data-name="menu.name">
<t t-esc="menu.name"/>
</a>
</li>
</ul>
</div>
<div data-role="footer" data-theme="b" data-position="fixed">
<h1>Footer</h1>
</div>
</t>
<t t-name="Options">
<ul data-dividertheme="b" data-theme="c" data-inset="true" data-role="listview">
<li data-role="list-divider">
Options
@@ -131,16 +158,19 @@
<li data-theme="c">
<a id="logout" href="#oe_login">Logout</a>
</li>
<li data-theme="c">
<a id="pref" href="#">Preferences</a>
</li>
</ul>
</div>
<div id="footer" data-role="footer" data-theme="b" data-position="fixed">
<a data-role="button" id="shrotcuts" >Favourite</a>
<a data-role="button" id="application" href="#oe_menu">Application</a>
<a data-role="button" id="preference">Preference</a>
</div>
</t>
<t t-name="ListView">
<div data-role="header" data-theme="b">
<h1>OpenERP</h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#oe_home" title="Home" data-theme="b"></a>
<div id="header" data-role="header" data-theme="b">
<h1></h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#oe_menu" title="Home" data-theme="b"></a>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="d" data-filter="true">
@@ -151,13 +181,19 @@
</li>
</ul>
</div>
<div data-role="footer" data-theme="b" data-position="fixed">
<h1>Footer</h1>
<div id="footer" data-role="footer" data-theme="b" data-position="fixed">
<a data-role="button" id="shrotcuts" href="#oe_shortcuts">Favourite</a>
<a data-role="button" id="application" href="#oe_menu">Application</a>
<a data-role="button" id="preference" href="#oe_options">Preference</a>
</div>
</t>
<t t-name="FormView">
<div role="main" class="ui-content" data-role="content">
<div id="header" data-role="header" data-theme="b">
<h1></h1>
<a id="home" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#oe_menu" title="Home" data-theme="b"></a>
</div>
<div role="main" data-role="content">
<form>
<t t-foreach="get_fields" t-as="field">
<div data-role="fieldcontain">