[IMP] Dynamically listview with theme.

bzr revid: bth@tinyerp.com-20110908123335-mdd0o4hbq9c97wwm
This commit is contained in:
Bhumi Thakkar (Open ERP)
2011-09-08 18:03:35 +05:30
parent 5d561e0cf6
commit ee454617c7
3 changed files with 56 additions and 48 deletions
@@ -114,15 +114,6 @@ openerp.web_mobile.Shortcuts = openerp.web.Widget.extend({
this.rpc('/web/session/sc_list',{} ,function(res){
self.$element.html(QWeb.render("Shortcuts", {'sc' : res}))
self.$element.find('#content').find("a").click(self.on_clicked);
self.$element.find("#header").find('#application').click(function(){
if(!$('#oe_menu').html().length){
this.menu = new openerp.web_mobile.Menu(self, "oe_menu");
this.menu.start();
}
else{
self.$element.find("#header").find('#application').attr('href','#oe_menu');
}
});
self.$element.find("#footer").find('#preference').click(function(){
if(!$('#oe_options').html().length){
this.options = new openerp.web_mobile.Options(self, "oe_options");
@@ -195,10 +186,20 @@ openerp.web_mobile.Menu = openerp.web.Widget.extend({
.removeClass("login_valid")
.addClass("secondary_menu");
//.hide();
// this.header = new openerp.web_mobile.Header(this, "oe_header");
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
// this.header.start();
this.secondary.start();
if(!$('#oe_sec_menu').html().length){
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
this.secondary.start();
}else{
this.$element.find("#content").find('a').attr('href','#oe_sec_menu');
}
/*if(!$('#oe_sec_menu').html().length){
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu", this.children);
this.secondary.start();
}else{
// self.$element.find("#content").find('a').attr('href','#oe_sec_menu');
this.$element.add(this.$secondary_menu).find("#content").find('a').attr('href','#oe_sec_menu');
}*/
}
});
openerp.web_mobile.Secondary = openerp.web.Widget.extend({
@@ -208,19 +209,25 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
},
start: function(ev, id) {
var self = this;
// console.log(this.data,this.$element.html().length);
/* if(this.$element.html().length){
self.$element.find('[data-role="listview"]').remove();
_.each(self.data.children,function(i){
var newul = '<ul data-dividertheme="b" class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-theme="c" data-inset="true" data-role="listview"><li data-role="list-divider">'+
i.name+'</li></ul>'; // Create New List Item
self.$element.find('#content').append(newul);
//console.log('in for loop',i.children);
});
console.log('saaasasaaa',self.$element.find('#content'),self.data);
//self.$element.find('[data-role="listview"]').listview('refresh');
}else{*/
var v = { menu : this.data };
this.$element.html(QWeb.render("Menu.secondary", v));
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("#header").find('#application').click(function(){
if(!$('#oe_menu').html().length){
this.menu = new openerp.web_mobile.Menu(self, "oe_menu");
this.menu.start();
}
else{
self.$element.find("#header").find('#application').attr('href','#oe_menu');
}
});
this.$element.find("#footer").find('#shrotcuts').click(function(){
if(!$('#oe_shortcuts').html().length){
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
@@ -256,15 +263,6 @@ openerp.web_mobile.Options = openerp.web.Widget.extend({
start: function() {
var self = this;
this.$element.html(QWeb.render("Options", this));
this.$element.find("#header").find('#application').click(function(){
if(!$('#oe_menu').html().length){
this.menu = new openerp.web_mobile.Menu(self, "oe_menu");
this.menu.start();
}
else{
self.$element.find("#header").find('#application').attr('href','#oe_menu');
}
});
this.$element.find("#footer").find('#shrotcuts').click(function(){
if(!$('#oe_shortcuts').html().length){
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
+22 -12
View File
@@ -24,26 +24,36 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
var self = this;
var dataset = new openerp.web.DataSetStatic(this, this.action.res_model, this.action.context);
dataset.name_search('', [], 'ilike',false ,function(result){
if(self.$element.html().length){
self.$element.find('[data-role="listview"]').find('li').remove();
for(var i=0;i<result.length;i++){
var newli = '<li><a id="list-id" data-id='+ result[i][0] +' href="#">' + result[i][1] + '</a></li>'; // Create New List Item
self.$element.find('[data-role="listview"]').append(newli);
}
self.$element.find('[data-role="listview"]').listview('refresh');
}else{
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("#header").find('#application').click(function(){
if(!$('#oe_menu').html().length){
this.menu = new openerp.web_mobile.Menu(self, "oe_menu");
this.menu.start();
self.$element.find("#footer").find('#shortcuts').click(function(){
if(!$('#oe_shortcuts').html().length){
this.shortcut = new openerp.web_mobile.Options(self, "oe_shortcuts");
this.options.start();
}
else{
self.$element.find("#header").find('#application').attr('href','#oe_menu');
self.$element.find("#footer").find('#shrotcuts').attr('href','#oe_shortcuts');
}
});
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();
if(!$('#oe_options').html().length){
this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start();
}
else{
self.$element.find("#footer").find('#preference').attr('href','#oe_options');
}
});
}
self.$element.find("a#list-id").click(self.on_list_click);
$.mobile.changePage($("#oe_list"), "slide", true, true);
});
},
@@ -58,7 +58,7 @@
<t t-name="Shortcuts">
<div id="header" data-role="header" data-theme="b" data-position="fixed">
<h1>Favourite</h1>
<a id="application" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#" title="Home" data-theme="b"></a>
<a id="application" 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">
@@ -96,7 +96,7 @@
<t t-name="Menu.secondary">
<div id="header" data-role="header" data-theme="b" data-position="fixed">
<h1></h1>
<a id="application" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#" title="Home" data-theme="b"></a>
<a id="application" 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">
<t t-foreach="menu.children" t-as="menu1" >
@@ -122,7 +122,7 @@
<t t-name="Options">
<div id="header" data-role="header" data-theme="b" data-position="fixed">
<h1>Options</h1>
<a id="application" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#" title="Home" data-theme="b"></a>
<a id="application" 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-dividertheme="b" data-theme="c" data-inset="true" data-role="listview">
@@ -140,9 +140,9 @@
<t t-name="ListView">
<div id="header" data-role="header" data-theme="b" data-position="fixed">
<h1></h1>
<a id="application" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#" title="Home" data-theme="b"></a>
<a id="application" class="ui-btn-right" data-iconpos="notext" data-icon="home" href="#oe_menu" title="Home" data-theme="b"></a>
</div>
<div data-role="content">
<div id="content" data-role="content">
<ul data-role="listview" data-inset="true" data-theme="d" data-filter="true">
<li data-theme="c" t-foreach="records" t-as="record">
<a id="list-id" t-att-data-id="record[0]" href="#">