diff options
| author | Bhumi Thakkar (Open ERP) <bth@tinyerp.com> | 2011-09-16 16:19:38 +0530 |
|---|---|---|
| committer | Bhumi Thakkar (Open ERP) <bth@tinyerp.com> | 2011-09-16 16:19:38 +0530 |
| commit | 930babc88ec6f5fa24b955afb337f05b435378ec (patch) | |
| tree | 3418233a22e3ff1848efc49c40c06243baa75f7f /addons/web_mobile/static/src | |
| parent | e1268a91680435bb88b36e61d8f583c7f0db17ac (diff) | |
[IMP]Implement Relational Fields in listview and formview with theme.
bzr revid: bth@tinyerp.com-20110916104938-kskhg7c41iwyt465
Diffstat (limited to 'addons/web_mobile/static/src')
| -rw-r--r-- | addons/web_mobile/static/src/js/chrome_mobile.js | 13 | ||||
| -rw-r--r-- | addons/web_mobile/static/src/js/form_mobile.js | 116 | ||||
| -rw-r--r-- | addons/web_mobile/static/src/js/list_mobile.js | 6 | ||||
| -rw-r--r-- | addons/web_mobile/static/src/xml/web_mobile.xml | 139 |
4 files changed, 118 insertions, 156 deletions
diff --git a/addons/web_mobile/static/src/js/chrome_mobile.js b/addons/web_mobile/static/src/js/chrome_mobile.js index 1a71236e6f4..8cbe19a105c 100644 --- a/addons/web_mobile/static/src/js/chrome_mobile.js +++ b/addons/web_mobile/static/src/js/chrome_mobile.js @@ -84,19 +84,6 @@ openerp.web_mobile.Login = openerp.web.Widget.extend({ }); } }); -openerp.web_mobile.Notepage = openerp.web.Widget.extend({ - init: function(session, element_id) { - this._super(session, element_id); - this.get_fields = this.widget_parent.get_fields; - this.page_fields = this.widget_parent.page_fields; - this.values = this.widget_parent.values; - this.til = this.widget_parent.til; - }, - start: function() { - console.log(this.get_fields,this.page_fields,this.values,this.til,this.$element); - this.$element.html(QWeb.render("NotePage", {'get_fields1': this.get_fields,'fields1' : this.page_fields, 'values1' : this.values,'til1': this.til })); - } -}); openerp.web_mobile.Header = openerp.web.Widget.extend({ init: function(session, element_id) { this._super(session, element_id); diff --git a/addons/web_mobile/static/src/js/form_mobile.js b/addons/web_mobile/static/src/js/form_mobile.js index 1699824ce77..f31742d9760 100644 --- a/addons/web_mobile/static/src/js/form_mobile.js +++ b/addons/web_mobile/static/src/js/form_mobile.js @@ -5,10 +5,11 @@ openerp.web_mobile.form_mobile = function (openerp) { openerp.web_mobile.FormView = openerp.web.Widget.extend({ - init: function(session, element_id, list_id, action) { + init: function(session, element_id, list_id, action, head_title) { this._super(session, element_id); this.list_id = list_id; this.action = action; + this.head_title = head_title; this.content_expanded_class = "ui-collapsible-content ui-collapsible-content-expanded"; this.content_collapsed_class = "ui-collapsible-content ui-collapsible-content-collapsed"; this.expanded_class = "ui-collapsible-content-expanded"; @@ -41,7 +42,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ } self.$element.html(QWeb.render("FormView", {'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : data ,'temp_flag':'1'})); - self.$element.find("[data-role=header]").find('h1').html(self.action.name); + self.$element.find("[data-role=header]").find('h1').html(self.head_title); self.$element.find("[data-role=header]").find('#home').click(function(){ $.mobile.changePage($("#oe_menu"), "slide", true, true); }); @@ -74,6 +75,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ get_fields = self.get_fields(notebooks.children[k].children); for (var i = 0; i < get_fields.length; i++) { if (fields[get_fields[i].attrs.name].type == 'one2many'){ + self.relational_fields = get_fields[i].attrs.name; 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; @@ -82,16 +84,124 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({ } } } + if(notebook){ $(this).find('p').html(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data,'til': notebook.attrs.string })); }else{ $(this).find('p').html(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data })); } + } }); - self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').find('p').find('[data-role=content]').find('ul').find('li').click(function(){ + var latid,lastid; + $(this).parents().each(function(){ + latid = $(this).attr('id'); + self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').each(function(){ + if(latid==$(this).attr('id')){ + lastid = $(this).attr('id'); + } + }); + }); + var relational = $(this).attr('for'); + if(result.fields[relational]){ + var head = $.trim($(this).text()); + var dataset = new openerp.web.DataSetStatic(self, result.fields[relational].relation, result.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]; + } + + if($('#oe_list').html().length){ + $('#oe_list').remove(); + $('<div id="oe_list" data-role="page"> </div>').appendTo('#moe'); + $('#oe_list').html(QWeb.render("ListView", {'records' : res})); + $('#oe_list').find("[data-role=header]").find('h1').html(head); + $('#oe_list').find("[data-role=header]").find('#home').click(function(){ + $.mobile.changePage($("#oe_menu"), "slide", true, true); + }); + $('#oe_list').find("[data-role=footer]").find('#shrotcuts').click(function(){ + if(!$('#oe_shortcuts').html().length){ + this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); + this.shortcuts.start(); + } + else{ + $.mobile.changePage($("#oe_shortcuts"), "slide", true, true); + } + }); + $('#oe_list').find("[data-role=footer]").find('#preference').click(function(){ + if(!$('#oe_options').html().length){ + this.options = new openerp.web_mobile.Options(self, "oe_options"); + this.options.start(); + } + else{ + $.mobile.changePage($("#oe_options"), "slide", true, true); + } + }); + $('#oe_list').find("a#list-id").click(function(ev){ + var head_title = $(this).text(); + dataset = new openerp.web.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]; + } + } + if($('#oe_form').html().length){ + $('#oe_form').remove(); + $('<div id="oe_form" data-role="page"> </div>').appendTo('#moe'); + for (var k = 0; k < notebooks.children.length; k++) { + if (notebooks.children[k].attrs.string == lastid) { + get_fields = self.get_fields(notebooks.children[k].children); + for (var i = 0; i < get_fields.length; i++) { + if (fields[get_fields[i].attrs.name].type == 'one2many'){ + self.relational_fields = get_fields[i].attrs.name; + 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; + } + } + } + } + } + $('#oe_form').html(QWeb.render("FormView", {'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational, 'temp_flag':'1' })); + $('#oe_form').find('select').change(function(ev){ + selection.on_select_option(ev); + }); + $('#oe_form').find("[data-role=header]").find('h1').html(head_title); + $('#oe_form').find("[data-role=header]").find('#home').click(function(){ + $.mobile.changePage($("#oe_menu"), "slide", true, true); + }); + $('#oe_form').find("[data-role=footer]").find('#shrotcuts').click(function(){ + if(!$('#oe_shortcuts').html().length){ + this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); + this.shortcuts.start(); + } + else{ + $.mobile.changePage($("#oe_shortcuts"), "slide", true, true); + } + }); + $('#oe_form').find("[data-role=footer]").find('#preference').click(function(){ + if(!$('#oe_options').html().length){ + this.options = new openerp.web_mobile.Options(self, "oe_options"); + this.options.start(); + } + else{ + $.mobile.changePage($("#oe_options"), "slide", true, true); + } + }); + $.mobile.changePage($("#oe_form"), "slide", true, true); + } + }); + }); + $.mobile.changePage($("#oe_list"), "slide", true, true); + } + }); + } }); $.mobile.changePage($("#oe_form"), "slide", true, true); }); diff --git a/addons/web_mobile/static/src/js/list_mobile.js b/addons/web_mobile/static/src/js/list_mobile.js index 3c872496577..d7e7918afbe 100644 --- a/addons/web_mobile/static/src/js/list_mobile.js +++ b/addons/web_mobile/static/src/js/list_mobile.js @@ -55,13 +55,15 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({ var $record = $(ev.currentTarget); var self = this; id = $record.data('id'); + + head_title = $.trim($record.text()); if(!$('#oe_form').html().length){ - this.formview = new openerp.web_mobile.FormView(this, "oe_form", id, this.action); + this.formview = new openerp.web_mobile.FormView(this, "oe_form", id, this.action, head_title); this.formview.start(); }else{ $('#oe_form').remove(); $('<div id="oe_form" data-role="page"> </div>').appendTo('#moe'); - this.formview = new openerp.web_mobile.FormView(this, "oe_form", id, this.action); + this.formview = new openerp.web_mobile.FormView(this, "oe_form", id, this.action, head_title); this.formview.start(); } } diff --git a/addons/web_mobile/static/src/xml/web_mobile.xml b/addons/web_mobile/static/src/xml/web_mobile.xml index 208fba1dc77..a6242858069 100644 --- a/addons/web_mobile/static/src/xml/web_mobile.xml +++ b/addons/web_mobile/static/src/xml/web_mobile.xml @@ -7,7 +7,6 @@ <div data-role="page" id="oe_login"></div> <div id="oe_header" /> <div id="oe_footer" /> - <div id="oe_notepage" /> <div data-role="page" id="oe_sec_menu"></div> <div data-role="page" id="oe_sec_menu_new"></div> <div data-role="page" id="oe_list"></div> @@ -139,142 +138,6 @@ </div> <t t-call="Footer" /> </t> -<t t-name="NotePage"> - <div id="oe_note" data-role="content"> - <form> - <t t-foreach="get_fields1" t-as="field1"> - <t t-esc="field1.attrs.name" /> - <div data-role="fieldcontain"> - <t t-if="fields1[field1.attrs.name].type == 'char'"> - <label for=""> - <t t-if="!(field1.attrs.string)" t-esc="fields1[field1.attrs.name].string"></t> - <t t-if="field1.attrs.string" t-esc="field1.attrs.string"></t>: - </label> - <t t-if="values1[field1.attrs.name]"> - <input type="text" id="" t-att-value="values1[field1.attrs.name]"/> - </t> - <t t-if="!(values1[field1.attrs.name])"> - <input type="text" value="" id=""/> - </t> - </t> - <t t-if="fields1[field1.attrs.name].type == 'text'"> - <label for=""> - <t t-if="!(field1.attrs.string)" t-esc="fields1[field1.attrs.name].string"></t> - <t t-if="field1.attrs.string" t-esc="field1.attrs.string"></t>: - </label> - <textarea name="" id=""></textarea> - </t> - <t t-if="fields1[field1.attrs.name].type == 'float'"> - <label for=""> - <t t-if="!(field1.attrs.string)" t-esc="fields1[field1.attrs.name].string"></t> - <t t-if="field1.attrs.string" t-esc="field1.attrs.string"></t>: - </label> - <t t-if="values[field1.attrs.name]"> - <input id="" type="text" t-att-value="values1[field1.attrs.name]"/> - </t> - <t t-if="!(values1[field1.attrs.name])"> - <input id="" type="text" value=""/> - </t> - </t> - <t t-if="fields1[field1.attrs.name].type == 'date'"> - <label for=""> - <t t-if="!(field1.attrs.string)" t-esc="fields1[field1.attrs.name].string"></t> - <t t-if="field1.attrs.string" t-esc="field1.attrs.string"></t>: - </label> - <t t-if="values1[field1.attrs.name]"> - <input id="" type="text" t-att-value="values1[field1.attrs.name]"/> - </t> - <t t-if="!(values1[field1.attrs.name])"> - <input id="" type="text" value=""/> - </t> - </t> - <t t-if="fields1[field1.attrs.name].type == 'datetime'"> - <label for=""> - <t t-if="!(field1.attrs.string)" t-esc="fields1[field1.attrs.name].string"></t> - <t t-if="field1.attrs.string" t-esc="field1.attrs.string"></t>: - </label> - <t t-if="values1[field1.attrs.name]"> - <input id="" type="text" t-att-value="values1[field1.attrs.name]"/> - </t> - <t t-if="!(values1[field1.attrs.name])"> - <input id="" type="text" value=""/> - </t> - </t> - <t t-if="fields1[field1.attrs.name].type == 'boolean'"> - <fieldset data-role="controlgroup"> - <t t-if="values1[field1.attrs.name]"> - <input type="checkbox" name="checkbox-1" id="checkbox-1" checked="yes" class="custom"/> - </t> - <t t-if="!(values1[field1.attrs.name])"> - <input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" /> - </t> - <label for="checkbox-1"><t t-esc="fields1[field1.attrs.name].string" /></label> - </fieldset> - </t> - <t t-if="fields1[field1.attrs.name].type == 'selection'"> - <label for="" class="select"> - <t t-if="!(field1.attrs.string)" t-esc="fields1[field1.attrs.name].string"></t> - <t t-if="field1.attrs.string" t-esc="field1.attrs.string"></t>: - </label> - <select id="" data-native-menu="false"> - <t t-foreach="fields1[field1.attrs.name].selection" t-as="opt"> - <option t-att-value="opt[0]"><t t-esc="opt[1]"/></option> - </t> - </select> - </t> - <t t-if="fields1[field1.attrs.name].type == 'many2one'"> - <label for="" class="select"> - <t t-if="!(field1.attrs.string)" t-esc="fields1[field1.attrs.name].string"></t> - <t t-if="field1.attrs.string" t-esc="field1.attrs.string"></t>: - </label> - <select id="" data-native-menu="false"> - <t t-if="fields1[field1.attrs.name].selection"> - <t t-foreach="fields1[field1.attrs.name].selection" t-as="opt"> - <t t-if="values1[field1.attrs.name]==opt[0]"> - <option t-att-value="opt[0]" selected="true" ><t t-esc="opt[1]"/></option> - </t> - <t t-if="values1[field1.attrs.name]!=opt[0]"> - <option t-att-value="opt[0]" ><t t-esc="opt[1]"/></option> - </t> - </t> - </t> - </select> - </t> - <t t-if="fields1[field1.attrs.name].type == 'one2many'"> - <ul data-role="listview" data-inset="true" data-theme="d"> - <li data-theme="c"> - <a href="#"> - <t t-esc="til1"/> - </a> - </li> - </ul> - </t> - </div> - </t> - <!-- <t t-if="notebooks"> - <div data-role="collapsible-set"> - <t t-foreach="notebooks.children" t-as="page"> - <t t-if="page.attrs.invisible"> - <div style="display:none;" data-collapsed="true" data-role="collapsible"> - <h3> - <t t-esc="page.attrs.string"></t> - </h3> - <p></p> - </div> - </t> - <t t-if="!page.attrs.invisible"> - <div data-collapsed="true" data-role="collapsible"> - <h3> - <t t-esc="page.attrs.string"></t> - </h3> - </div> - </t> - </t> - </div> - </t>--> - </form> - </div> -</t> <t t-name="FormView"> <t t-if="temp_flag"> <t t-call="Header" /> @@ -381,7 +244,7 @@ </t> <t t-if="fields[field.attrs.name].type == 'one2many'"> <ul data-role="listview" data-inset="true" data-theme="d"> - <li data-theme="c"> + <li data-theme="c" t-att-for="field.attrs.name"> <a href=""> <t t-esc="til"/> </a> |
