summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhumi Thakkar (Open ERP) <bth@tinyerp.com>2011-09-08 18:03:35 +0530
committerBhumi Thakkar (Open ERP) <bth@tinyerp.com>2011-09-08 18:03:35 +0530
commitee454617c7c27227d7c6fb02ecc622c5ec896dfa (patch)
treefe2f055f1162e2d4fe68a6b6c1caf1f0334881c8
parent5d561e0cf6e46029318312d8e110424b65dec722 (diff)
[IMP] Dynamically listview with theme.
bzr revid: bth@tinyerp.com-20110908123335-mdd0o4hbq9c97wwm
-rw-r--r--addons/web_mobile/static/src/js/chrome_mobile.js60
-rw-r--r--addons/web_mobile/static/src/js/list_mobile.js34
-rw-r--r--addons/web_mobile/static/src/xml/web_mobile.xml10
3 files changed, 56 insertions, 48 deletions
diff --git a/addons/web_mobile/static/src/js/chrome_mobile.js b/addons/web_mobile/static/src/js/chrome_mobile.js
index caf4da7e9e6..2b9d8600fef 100644
--- a/addons/web_mobile/static/src/js/chrome_mobile.js
+++ b/addons/web_mobile/static/src/js/chrome_mobile.js
@@ -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");
diff --git a/addons/web_mobile/static/src/js/list_mobile.js b/addons/web_mobile/static/src/js/list_mobile.js
index 328f29e1214..1d4e0d72ca2 100644
--- a/addons/web_mobile/static/src/js/list_mobile.js
+++ b/addons/web_mobile/static/src/js/list_mobile.js
@@ -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);
});
},
diff --git a/addons/web_mobile/static/src/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml
index ec5c03bca0a..75d30af55b1 100644
--- a/addons/web_mobile/static/src/xml/web_mobile.xml
+++ b/addons/web_mobile/static/src/xml/web_mobile.xml
@@ -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="#">