summaryrefslogtreecommitdiff
path: root/addons/web_mobile/static/src/js
diff options
context:
space:
mode:
authorBhumi Thakkar (Open ERP) <bth@tinyerp.com>2011-09-16 16:19:38 +0530
committerBhumi Thakkar (Open ERP) <bth@tinyerp.com>2011-09-16 16:19:38 +0530
commit930babc88ec6f5fa24b955afb337f05b435378ec (patch)
tree3418233a22e3ff1848efc49c40c06243baa75f7f /addons/web_mobile/static/src/js
parente1268a91680435bb88b36e61d8f583c7f0db17ac (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/js')
-rw-r--r--addons/web_mobile/static/src/js/chrome_mobile.js13
-rw-r--r--addons/web_mobile/static/src/js/form_mobile.js116
-rw-r--r--addons/web_mobile/static/src/js/list_mobile.js6
3 files changed, 117 insertions, 18 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();
}
}