Valentin Lab has proposed merging
lp:~vaab/openerp-web/mobile-client-extendability-patch into
lp:~openerp-dev/openerp-web/mobile-client.
Requested reviews:
OpenERP R&D Team (openerp-dev)
For more details, see:
https://code.launchpad.net/~vaab/openerp-web/mobile-client-extendability-patch/+merge/76583
These are modification that I had to conduct in mobile-client to be able to
extend/customize the mobile-client with my add-on.
Maybe this could be of some interest. Please have a look.
--
https://code.launchpad.net/~vaab/openerp-web/mobile-client-extendability-patch/+merge/76583
Your team OpenERP R&D Team is requested to review the proposed merge of
lp:~vaab/openerp-web/mobile-client-extendability-patch into
lp:~openerp-dev/openerp-web/mobile-client.
=== modified file 'addons/web_mobile/static/src/js/chrome_mobile.js'
--- addons/web_mobile/static/src/js/chrome_mobile.js 2011-09-22 12:34:40 +0000
+++ addons/web_mobile/static/src/js/chrome_mobile.js 2011-09-22 13:38:25 +0000
@@ -109,13 +109,21 @@
});
openerp.web_mobile.Shortcuts = openerp.web.Widget.extend({
+
+ qweb_template_name: "Shortcuts",
+
+ /**
+ * class instanciated for displaying list view
+ */
+ ListViewClass: openerp.web_mobile.ListView,
+
init: function(session, element_id) {
this._super(session, element_id);
},
start: function() {
var self = this;
this.rpc('/web/session/sc_list',{} ,function(res){
- self.$element.html(QWeb.render("Shortcuts", {'sc' : res}))
+ self.$element.html(QWeb.render(self.qweb_template_name, {'sc' : res}))
self.$element.find("[data-role=header]").find('h1').html('Favourite');
self.$element.find("[data-role=header]").find('#home').click(function(){
@@ -144,7 +152,7 @@
if(!$('[id^="oe_list_'+res_id+'"]').html()){
$('<div id="oe_list_'+res_id+'" data-role="page" data-url="oe_list_'+res_id+'"> </div>').appendTo('#moe');
- this.listview = new openerp.web_mobile.ListView(self, "oe_list_"+res_id, res_id);
+ this.listview = new this.ListViewClass(self, "oe_list_"+res_id, res_id);
this.listview.start();
}else{
$.mobile.changePage('#oe_list_'+res_id, "slide", false, true);
@@ -156,6 +164,9 @@
});
openerp.web_mobile.Menu = openerp.web.Widget.extend({
+
+ qweb_template_name: "Menu",
+
init: function(session, element_id, secondary_menu_id) {
this._super(session, element_id);
this.secondary_menu_id = secondary_menu_id;
@@ -173,7 +184,7 @@
this.footer = new openerp.web_mobile.Footer(this, "oe_footer");
this.footer.start();
- this.$element.html(QWeb.render("Menu", this.data));
+ this.$element.html(QWeb.render(this.qweb_template_name, this.data));
this.$element.find("[data-role=header]").find('h1').html('Application');
this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){
if(!$('#oe_shortcuts').html().length){
@@ -219,7 +230,17 @@
}
}
});
+
openerp.web_mobile.Secondary = openerp.web.Widget.extend({
+
+ qweb_template_name: "Menu.secondary",
+
+ /**
+ * class instanciated for displaying list view
+ */
+ ListViewClass: openerp.web_mobile.ListView,
+
+
init: function(session, element_id, secondary_menu_id) {
this._super(session, element_id);
this.data = secondary_menu_id;
@@ -228,7 +249,7 @@
var self = this;
var v = { menu : this.data };
- this.$element.html(QWeb.render("Menu.secondary", v));
+ this.$element.html(QWeb.render(this.qweb_template_name, v));
this.$element.find("[data-role=header]").find("h1").html(this.data.name);
this.$element.add(this.$secondary_menu).find('#content').find("a").click(this.on_menu_click);
@@ -264,7 +285,7 @@
if(!$('[id^="oe_list_'+id+'"]').html()){
$('<div id="oe_list_'+id+'" data-role="page" data-url="oe_list_'+id+'"> </div>').appendTo('#moe');
- this.listview = new openerp.web_mobile.ListView(this, "oe_list_"+id, id);
+ this.listview = new this.ListViewClass(this, "oe_list_"+id, id);
this.listview.start();
}else{
$.mobile.changePage('#oe_list_'+id, "slide", false, true);
=== modified file 'addons/web_mobile/static/src/js/form_mobile.js'
--- addons/web_mobile/static/src/js/form_mobile.js 2011-09-22 12:34:40 +0000
+++ addons/web_mobile/static/src/js/form_mobile.js 2011-09-22 13:38:25 +0000
@@ -5,6 +5,9 @@
openerp.web_mobile.form_mobile = function (openerp) {
openerp.web_mobile.FormView = openerp.web.Widget.extend({
+
+ qweb_template_name: 'FormView',
+
init: function(session, element_id, list_id, action, head_title, resmodel, viewid) {
this._super(session, element_id);
this.list_id = list_id;
@@ -45,7 +48,7 @@
var notebooks = view_fields[j];
}
}
- self.$element.html(QWeb.render("FormView", {'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : data ,'temp_flag':'1'}));
+ self.$element.html(QWeb.render(self.qweb_template_name, {'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : data ,'temp_flag':'1'}));
self.$element.find("[data-role=header]").find('h1').html(self.head_title);
self.$element.find("[data-role=header]").find('#home').click(function(){
@@ -101,9 +104,9 @@
}
if(notebook){
- $(this).find('p').html(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data,'til': notebook.attrs.string }));
+ $(this).find('p').html(QWeb.render(self.qweb_template_name, {'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 }));
+ $(this).find('p').html(QWeb.render(self.qweb_template_name, {'get_fields': get_fields,'fields' : result.fields, 'values' : data }));
}
$(this).find('p').find('#formbutton').click(function(){
var head = $(this).prev().find('select').find("option:selected").text();
@@ -199,7 +202,7 @@
}
}
}
- $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(QWeb.render("FormView", {'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, 'values' : data_relational, 'temp_flag':'1' }));
+ $('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html(QWeb.render(self.qweb_template_name, {'get_fields': get_fields_test, 'notebooks': false, 'fields' : fields_test, '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(){
=== modified file 'addons/web_mobile/static/src/js/list_mobile.js'
--- addons/web_mobile/static/src/js/list_mobile.js 2011-09-22 12:34:40 +0000
+++ addons/web_mobile/static/src/js/list_mobile.js 2011-09-22 13:38:25 +0000
@@ -5,6 +5,14 @@
openerp.web_mobile.list_mobile = function (openerp) {
openerp.web_mobile.ListView = openerp.web.Widget.extend({
+
+ list_view_template: 'ListView',
+
+ /**
+ * class instanciated for displaying form view
+ */
+ FormViewClass: openerp.web_mobile.FormView,
+
init: function(session, element_id, list_id) {
this._super(session, element_id);
this.list_id = list_id;
@@ -24,7 +32,7 @@
var self = this;
var dataset = new openerp.web.DataSetStatic(this, this.action.res_model, this.action.context);
dataset.name_search('', [], 'ilike',false ,function(result){
- self.$element.html(QWeb.render("ListView", {'records' : result}));
+ self.$element.html(QWeb.render(self.list_view_template, {'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);
@@ -61,7 +69,7 @@
if(!$('[id^="oe_form_'+id+this.action.res_model+'"]').html()){
$('<div id="oe_form_'+id+this.action.res_model+'" data-role="page" data-url="oe_form_'+id+this.action.res_model+'"> </div>').appendTo('#moe');
- this.formview = new openerp.web_mobile.FormView(this, "oe_form_"+id+this.action.res_model, id, this.action, head_title, '' ,'');
+ this.formview = new this.FormViewClass(this, "oe_form_"+id+this.action.res_model, id, this.action, head_title, '' ,'');
this.formview.start();
}else{
$.mobile.changePage('#oe_form_'+id+this.action.res_model, "slide", false, true);
=== modified file 'addons/web_mobile/static/src/js/web_mobile.js'
--- addons/web_mobile/static/src/js/web_mobile.js 2011-08-18 13:24:18 +0000
+++ addons/web_mobile/static/src/js/web_mobile.js 2011-09-22 13:38:25 +0000
@@ -3,7 +3,7 @@
*---------------------------------------------------------*/
openerp.web_mobile = function(instance) {
+ openerp.web_mobile.form_mobile(instance);
+ openerp.web_mobile.list_mobile(instance);
openerp.web_mobile.chrome_mobile(instance);
- openerp.web_mobile.list_mobile(instance);
- openerp.web_mobile.form_mobile(instance);
};
=== modified file 'addons/web_mobile/static/src/xml/web_mobile.xml'
--- addons/web_mobile/static/src/xml/web_mobile.xml 2011-09-22 07:33:03 +0000
+++ addons/web_mobile/static/src/xml/web_mobile.xml 2011-09-22 13:38:25 +0000
@@ -16,6 +16,13 @@
<div data-role="header" data-theme="b" data-position="fixed">
<h1>OpenERP</h1>
</div>
+ <t t-call="LoginContent"/>
+ <div data-role="footer" data-theme="b" data-position="fixed">
+ <h1>Powered by openerp.com</h1>
+ </div>
+</t>
+
+<t t-name="LoginContent">
<div data-role="content">
<fieldset>
<div data-role="fieldcontain">
@@ -38,10 +45,6 @@
</div>
</fieldset>
</div>
- <div data-role="footer" data-theme="b" data-position="fixed">
- <h1>Powered by openerp.com</h1>
- </div>
-
</t>
<t t-name="Header">
@@ -123,22 +126,35 @@
<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>
- </div>
+ <t t-call="ViewContent"/>
<t t-call="Footer" />
</t>
+
+<t t-name="ViewContent">
+ <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>
+ </div>
+</t>
+
<t t-name="FormView">
<t t-if="temp_flag">
<t t-call="Header" />
</t>
+ <t t-call="FormContent"/>
+
+ <t t-if="temp_flag">
+ <t t-call="Footer" />
+ </t>
+</t>
+
+<t t-name="FormContent">
<div data-role="content">
<form>
<t t-foreach="get_fields" t-as="field">
@@ -283,8 +299,7 @@
</t>
</form>
</div>
- <t t-if="temp_flag">
- <t t-call="Footer" />
- </t>
</t>
+
+
</templates>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp