[merge] improvements to mobile client

bzr revid: nicolas.vanhoren@openerp.com-20111110143556-b7ktaezdji2b40mn
This commit is contained in:
niv-openerp
2011-11-10 15:35:56 +01:00
4 changed files with 131 additions and 59 deletions
@@ -20,13 +20,10 @@ openerp.web_mobile.MobileWebClient = openerp.web.Widget.extend({
openerp.web.qweb.add_template("xml/web_mobile.xml");
var params = {};
this.$element.html(this.render());
this.session = new openerp.web.Session("oe_errors");
this.crashmanager = new openerp.web.CrashManager(this);
this.login = new openerp.web_mobile.Login(this, "oe_login");
// this.session.on_session_invalid.add(this.login.do_ask_login);
},
start: function() {
this.session.start();
this.login.start();
}
});
+50 -13
View File
@@ -96,10 +96,6 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}
}
}
}
if(notebook){
$(this).find('div#page_content').html(self.render({'get_fields': get_fields,'fields' : result.fields, 'values' : self.datarecord,'til': notebook.attrs.string }));
}else{
$(this).find('div#page_content').html(self.render({'get_fields': get_fields,'fields' : result.fields, 'values' : self.datarecord}));
}
self.formatdata(get_fields, fields, result, self.datarecord,'page_content','element');
@@ -135,16 +131,19 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
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);
var dataset = new openerp.web.DataSetSearch(self, result.fields[relational].relation, result.fields[relational].context);
dataset.domain=[['id', 'in', self.datarecord[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];
dataset.read_slice([], {}, function(result1,ids){
_.extend(self.action.context,{"html_name_get" : true});
var dataset1 = new openerp.web.DataSet(self, result.fields[relational].relation,result.fields[relational].context);
dataset1.name_get(dataset.ids,function(res){
var additional = "";
if(res['html_name_get']){
additional = res['display'];
}
if(!$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html()){
$('<div id="oe_list_'+relational+'_'+self.element_id+'" data-role="page" data-url="oe_list_'+relational+'_'+self.element_id+'"> </div>').appendTo('#moe');
$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html(openerp.web.qweb.render("ListView", {'records' : res}));
$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html(openerp.web.qweb.render("ListView", {'records' : res,'data': additional}));
$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('h1').html(head);
$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('#home').click(function(){
$.mobile.changePage("#oe_menu", "slide", false, true);
@@ -179,6 +178,7 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}
if(!$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html()){
$('<div id="oe_form_'+listid+result.fields[relational].relation+'" data-role="page" data-url="oe_form_'+listid+result.fields[relational].relation+'"> </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);
@@ -194,7 +194,11 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}
}
}
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(self.render({'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational, 'temp_flag':'1' }));
if(notebook){
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(self.render({'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational, 'temp_flag':'1' }));
}else{
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(self.render({'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields, 'values' : data_relational, 'temp_flag':'1' }));
}
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find("[data-role=header]").find('h1').html(head_title);
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find("[data-role=header]").find('#home').click(function(){
$.mobile.changePage("#oe_menu", "slide", false, true);
@@ -229,7 +233,11 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}
}
});
self.formatdata(get_fields_test, fields_test, result, data_relational,'oe_form_'+listid+result.fields[relational].relation,'element');
if(notebook){
self.formatdata(get_fields_test, fields_test, result, data_relational,'oe_form_'+listid+result.fields[relational].relation,'element');
}else{
self.formatdata(get_fields_test, fields, result, data_relational,'oe_form_'+listid+result.fields[relational].relation,'element');
}
$.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", false, true);
self.formatdata('', '', '', '','oe_form_'+listid+result.fields[relational].relation,'slider');
}else{
@@ -241,7 +249,8 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
}else{
$.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true);
}
});
});
});
}
});
$.mobile.changePage("#"+self.element_id, "slide", false, true);
@@ -256,6 +265,12 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
if (view_fields[i].tag == 'group') {
this.get_fields(view_fields[i].children, this.fields);
}
if (view_fields[i].tag == 'level') {
this.get_fields(view_fields[i].children, this.fields);
}
if (view_fields[i].tag == 'page') {
this.get_fields(view_fields[i].children, this.fields);
}
}
return this.fields;
},
@@ -280,6 +295,18 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
$(this).val(dateresult);
}
}
$('[id^="'+id+'"]').find('#website').each(function(){
$(this).css('display','inline-block');
$(this).css('width','60%');
});
$('[id^="'+id+'"]').find('#email').each(function(){
$(this).css('display','inline-block');
$(this).css('width','60%');
});
$('[id^="'+id+'"]').find('#email_from').each(function(){
$(this).css('display','inline-block');
$(this).css('width','60%');
});
});
// Temp: Selection set as disabled
$('[id^="'+id+'"]').find('select').each(function() {
@@ -297,6 +324,16 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
$(this).css('left', '-9999px');
});
});
// image displayed with m2o field
$('[id^="'+id+'"]').find('div[class=ui-select]').each(function(){
$(this).next().each(function(){
if($(this).attr('id')=="formbutton"){
$(this).prev().css('display','inline-table');
$(this).prev().find('a').find('.ui-btn-inner').removeClass('ui-btn-inner');
$(this).prev().find('a').find('span:first').css('padding-right','150px');
}
});
});
}
}
});
+40 -24
View File
@@ -19,36 +19,52 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
var self = this;
if (data.action.length) {
this.action = data.action[0][2];
this.on_search_data();
return this.rpc('/web/listview/load', {
model: this.action.res_model,
view_id: this.action.views[0][0],
view_type: "tree",
context: this.action.context,
toolbar: false
}, this.on_search_data);
}
},
on_search_data: function(ev){
var self = this;
var dataset = new openerp.web.DataSetStatic(this, this.action.res_model, this.action.context);
dataset.name_search('', this.action.domain, 'ilike', false, function(result){
self.$element.html(self.render({'records' : result}));
self.$element.find("[data-role=header]").find('h1').html(self.action.name);
self.$element.find("[data-role=header]").find('#home').click(function(){
$.mobile.changePage("#oe_menu", "slide", false, true);
});
self.$element.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", false, true);
var dataset = new openerp.web.DataSetSearch(this, this.action.res_model,this.action.context);
dataset.domain = self.action.domain;
dataset.read_slice([], {}, function(result,ids){
_.extend(self.action.context,{"html_name_get" : true});
var dataset1 = new openerp.web.DataSet(self, self.action.res_model,self.action.context);
dataset1.name_get(dataset.ids,function(res){
var additional = "";
if(res['html_name_get']){
additional = res['display'];
}
self.$element.html(self.render({'records': res, 'data': additional }));
self.$element.find("[data-role=header]").find('h1').html(self.action.name);
self.$element.find("[data-role=header]").find('#home').click(function(){
$.mobile.changePage("#oe_menu", "slide", false, true);
});
self.$element.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", false, true);
}
});
self.$element.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", false, true);
}
});
self.$element.find("a#list-id").click(self.on_list_click);
$.mobile.changePage("#"+self.element_id, "slide", false, true);
});
self.$element.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", false, true);
}
});
self.$element.find("a#list-id").click(self.on_list_click);
$.mobile.changePage("#"+self.element_id, "slide", false, true);
});
},
on_list_click: function(ev) {
+41 -19
View File
@@ -132,13 +132,32 @@
<t t-name="ListView">
<t t-call="Header" />
<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="#">
<t t-esc="record[1]"/>
</a>
</li>
</ul>
<t t-if="!(records.length>0)">
No one record is created
</t>
<t t-if="records.length>0">
<ul data-role="listview" data-inset="true" data-theme="d" data-filter="true">
<li data-theme="c" t-foreach="records" t-as="record">
<t t-foreach="record[1].split(',')" t-as="data1">
<t t-if="record[1].split(',')[0]==data1">
<a id="list-id" t-att-data-id="record[0]" href="#">
<t t-esc="data1" />
</a>
</t>
</t>
<p>
<t t-foreach="record[1].split(',')" t-as="data1">
<t t-if="record[1].split(',')[0]!=data1">
<t t-esc="data1" />
</t>
</t>
</p>
<t t-foreach="data" t-as="data1">
<t t-esc="data1[0]" />
</t>
</li>
</ul>
</t>
</div>
<t t-call="Footer" />
</t>
@@ -148,12 +167,11 @@
<t t-call="Header" />
</t>
<div data-role="content">
<form>
<t t-foreach="get_fields" t-as="field">
<t t-foreach="get_fields" t-as="field">
<div data-role="fieldcontain">
<t t-if="fields[field.attrs.name].type == 'char'">
<label for="">
<label t-att-for="field.attrs.name">
<t t-if="!(field.attrs.string)" t-esc="fields[field.attrs.name].string"></t>
<t t-if="field.attrs.string" t-esc="field.attrs.string"></t>:
</label>
@@ -178,7 +196,7 @@
<textarea name="" id="" readonly="true"></textarea>
</t>
<t t-if="fields[field.attrs.name].type == 'integer'">
<label for="">
<label t-att-for="field.attrs.name">
<t t-if="!(field.attrs.string)" t-esc="fields[field.attrs.name].string"></t>
<t t-if="field.attrs.string" t-esc="field.attrs.string"></t>:
</label>
@@ -190,7 +208,7 @@
</t>
</t>
<t t-if="fields[field.attrs.name].type == 'float_time'">
<label for="">
<label t-att-for="field.attrs.name">
<t t-if="!(field.attrs.string)" t-esc="fields[field.attrs.name].string"></t>
<t t-if="field.attrs.string" t-esc="field.attrs.string"></t>:
</label>
@@ -202,7 +220,7 @@
</t>
</t>
<t t-if="fields[field.attrs.name].type == 'float'">
<label for="">
<label t-att-for="field.attrs.name">
<t t-if="!(field.attrs.string)" t-esc="fields[field.attrs.name].string"></t>
<t t-if="field.attrs.string" t-esc="field.attrs.string"></t>:
</label>
@@ -277,14 +295,18 @@
<select id="" data-native-menu="false" t-att-for="fields[field.attrs.name].relation">
<t t-if="fields[field.attrs.name].selection">
<t t-foreach="fields[field.attrs.name].selection" t-as="opt">
<t t-if="values[field.attrs.name]==opt[0]">
<t t-if="values[field.attrs.name] and values[field.attrs.name]==opt[0]">
<option t-att-value="opt[0]" selected="true" ><t t-esc="opt[1]"/></option>
</t>
<t t-if="values[field.attrs.name]!=opt[0]">
<t t-if="values[field.attrs.name] and values[field.attrs.name]!=opt[0]">
<option t-att-value="opt[0]" ><t t-esc="opt[1]"/></option>
</t>
</t>
</t>
<t t-if="values[field.attrs.name] and !fields[field.attrs.name].selection">
<option t-att-value="values[field.attrs.name][0]" ><t t-esc="values[field.attrs.name][1]"/></option>
</t>
</select>
<t t-if="fields[field.attrs.name].selection">
<a id="formbutton" href="#" title="Form View"><img src="/web/static/src/img/icons/gtk-index.png" /></a>
@@ -292,11 +314,11 @@
</t>
<t t-if="fields[field.attrs.name].type == 'one2many'">
<ul data-role="listview" data-inset="true" data-theme="d">
<li data-theme="c" t-att-for="field.attrs.name">
<li data-theme="c" t-att-for="field.attrs.name" >
<a href="">
<t t-esc="til"/>
<t t-esc="fields[field.attrs.name].string"/>
</a>
</li>
</li>
</ul>
</t>
</div>
@@ -325,4 +347,4 @@
<t t-call="Footer" />
</t>
</t>
</templates>
</templates>