[IMP] Improved indentation.

bzr revid: jra@tinyerp.com-20110928062519-9pqd1to80a0bwoye
This commit is contained in:
Jiten (OpenERP) 2011-09-28 11:55:19 +05:30
parent 7c9a8945f4
commit 5f59f67e83
4 changed files with 225 additions and 258 deletions

View File

@ -33,20 +33,16 @@ openerp.web_mobile.MobileWebClient = openerp.web.Widget.extend({
openerp.web_mobile.Login = openerp.web.Widget.extend({ openerp.web_mobile.Login = openerp.web.Widget.extend({
start: function() { start: function() {
this.has_local_storage = typeof(localStorage) != 'undefined'; this.has_local_storage = typeof(localStorage) != 'undefined';
this.remember_creditentials = true; this.remember_creditentials = true;
this.selected_login = null; this.selected_login = null;
this.selected_password = null; this.selected_password = null;
if (this.has_local_storage && this.remember_creditentials) { if (this.has_local_storage && this.remember_creditentials) {
this.selected_login = localStorage.getItem('last_login_login_success'); this.selected_login = localStorage.getItem('last_login_login_success');
this.selected_password = localStorage.getItem('last_password_login_success'); this.selected_password = localStorage.getItem('last_password_login_success');
} }
var self = this; var self = this;
jQuery("#oe_header").children().remove(); jQuery("#oe_header").children().remove();
this.rpc("/web/database/get_list", {}, function(result) { this.rpc("/web/database/get_list", {}, function(result) {
self.db_list = result.db_list; self.db_list = result.db_list;
self.$element.html(QWeb.render("Login", self)); self.$element.html(QWeb.render("Login", self));
@ -66,7 +62,6 @@ openerp.web_mobile.Login = openerp.web.Widget.extend({
var db = $e.find("div select[name=database]").val(); var db = $e.find("div select[name=database]").val();
var login = $e.find("div input[name=login]").val(); var login = $e.find("div input[name=login]").val();
var password = $e.find("div input[name=password]").val(); var password = $e.find("div input[name=password]").val();
//$e.hide(); //$e.hide();
// Should hide then call callback // Should hide then call callback
this.session.session_login(db, login, password, function() { this.session.session_login(db, login, password, function() {
@ -116,6 +111,7 @@ openerp.web_mobile.Login = openerp.web.Widget.extend({
}); });
} }
}); });
openerp.web_mobile.Header = openerp.web.Widget.extend({ openerp.web_mobile.Header = openerp.web.Widget.extend({
init: function(session, element_id) { init: function(session, element_id) {
this._super(session, element_id); this._super(session, element_id);
@ -142,7 +138,6 @@ openerp.web_mobile.Shortcuts = openerp.web.Widget.extend({
var self = this; var self = this;
this.rpc('/web/session/sc_list',{} ,function(res){ this.rpc('/web/session/sc_list',{} ,function(res){
self.$element.html(QWeb.render("Shortcuts", {'sc' : res})) self.$element.html(QWeb.render("Shortcuts", {'sc' : res}))
self.$element.find("[data-role=header]").find('h1').html('Favourite'); self.$element.find("[data-role=header]").find('h1').html('Favourite');
self.$element.find("[data-role=header]").find('#home').click(function(){ self.$element.find("[data-role=header]").find('#home').click(function(){
$.mobile.changePage("#oe_menu", "slide", false, true); $.mobile.changePage("#oe_menu", "slide", false, true);
@ -167,7 +162,6 @@ openerp.web_mobile.Shortcuts = openerp.web.Widget.extend({
$shortcut = $(ev.currentTarget); $shortcut = $(ev.currentTarget);
id = $shortcut.data('menu'); id = $shortcut.data('menu');
res_id = $shortcut.data('res'); res_id = $shortcut.data('res');
if(!$('[id^="oe_list_'+res_id+'"]').html()){ 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'); $('<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 openerp.web_mobile.ListView(self, "oe_list_"+res_id, res_id);
@ -198,7 +192,6 @@ openerp.web_mobile.Menu = openerp.web.Widget.extend({
this.header.start(); this.header.start();
this.footer = new openerp.web_mobile.Footer(this, "oe_footer"); this.footer = new openerp.web_mobile.Footer(this, "oe_footer");
this.footer.start(); this.footer.start();
this.$element.html(QWeb.render("Menu", this.data)); this.$element.html(QWeb.render("Menu", this.data));
this.$element.find("[data-role=header]").find('h1').html('Application'); this.$element.find("[data-role=header]").find('h1').html('Application');
this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){
@ -235,7 +228,6 @@ openerp.web_mobile.Menu = openerp.web.Widget.extend({
this.$element this.$element
.removeClass("login_valid") .removeClass("login_valid")
.addClass("secondary_menu"); .addClass("secondary_menu");
if(!$('[id^="oe_sec_menu_'+id+'"]').html()){ if(!$('[id^="oe_sec_menu_'+id+'"]').html()){
$('<div id="oe_sec_menu_'+id+'" data-role="page" data-url="oe_sec_menu_'+id+'"> </div>').appendTo('#moe'); $('<div id="oe_sec_menu_'+id+'" data-role="page" data-url="oe_sec_menu_'+id+'"> </div>').appendTo('#moe');
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu_"+id, this.children); this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu_"+id, this.children);
@ -245,6 +237,7 @@ openerp.web_mobile.Menu = openerp.web.Widget.extend({
} }
} }
}); });
openerp.web_mobile.Secondary = openerp.web.Widget.extend({ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
init: function(session, element_id, secondary_menu_id) { init: function(session, element_id, secondary_menu_id) {
this._super(session, element_id); this._super(session, element_id);
@ -287,23 +280,23 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
ev.stopPropagation(); ev.stopPropagation();
var child_len = 0; var child_len = 0;
for (var i = 0; i < this.data.children.length; i++) { for (var i = 0; i < this.data.children.length; i++) {
for (var j=0; j < this.data.children[i].children.length; j++) { for (var j=0; j < this.data.children[i].children.length; j++) {
if (this.data.children[i].children[j].id == id) { if (this.data.children[i].children[j].id == id) {
this.children = this.data.children[i].children[j]; this.children = this.data.children[i].children[j];
child_len = this.children.children.length; child_len = this.children.children.length;
} }
} }
} }
if (child_len > 0) { if (child_len > 0) {
this.$element this.$element
.addClass("secondary_menu"); .addClass("secondary_menu");
if(!$('[id^="oe_sec_menu_'+id+'"]').html()){ if(!$('[id^="oe_sec_menu_'+id+'"]').html()){
$('<div id="oe_sec_menu_'+id+'" data-role="page" data-url="oe_sec_menu_'+id+'"> </div>').appendTo('#moe'); $('<div id="oe_sec_menu_'+id+'" data-role="page" data-url="oe_sec_menu_'+id+'"> </div>').appendTo('#moe');
this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu_"+id, this.children); this.secondary = new openerp.web_mobile.Secondary(this, "oe_sec_menu_"+id, this.children);
this.secondary.start(); this.secondary.start();
}else{ }else{
$.mobile.changePage('#oe_sec_menu_'+id, "slide", false, true); $.mobile.changePage('#oe_sec_menu_'+id, "slide", false, true);
} }
} }
else { else {
if(!$('[id^="oe_list_'+id+'"]').html()){ if(!$('[id^="oe_list_'+id+'"]').html()){
@ -314,13 +307,6 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
$.mobile.changePage('#oe_list_'+id, "slide", false, true); $.mobile.changePage('#oe_list_'+id, "slide", false, true);
} }
} }
/* 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.start();
}else{
$.mobile.changePage('#oe_list_'+id, "slide", false, true);
}*/
jQuery("#oe_header").find("h1").html($menu.data('name')); jQuery("#oe_header").find("h1").html($menu.data('name'));
} }
}); });
@ -328,7 +314,6 @@ openerp.web_mobile.Secondary = openerp.web.Widget.extend({
openerp.web_mobile.Options = openerp.web.Widget.extend({ openerp.web_mobile.Options = openerp.web.Widget.extend({
start: function() { start: function() {
var self = this; var self = this;
this.$element.html(QWeb.render("Options", this)); this.$element.html(QWeb.render("Options", this));
this.$element.find("[data-role=header]").find('h1').html('Preference'); this.$element.find("[data-role=header]").find('h1').html('Preference');
this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ this.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){

View File

@ -12,23 +12,19 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
this.head_title = head_title; this.head_title = head_title;
this.resmodel = resmodel; this.resmodel = resmodel;
this.viewid = viewid; this.viewid = viewid;
}, },
start: function() { start: function() {
var self = this; var self = this;
var id = this.list_id; var id = this.list_id;
var model = this.action.res_model || this.resmodel; var model = this.action.res_model || this.resmodel;
if(this.action){ if(this.action){
var view_id = this.action.views[1][0]; var view_id = this.action.views[1][0];
}else{ }else{
var view_id = this.viewid; var view_id = this.viewid;
} }
this.dataset = new openerp.web.DataSetSearch(this, model, null, null); this.dataset = new openerp.web.DataSetSearch(this, model, null, null);
var context = new openerp.web.CompoundContext(this.dataset.get_context()); var context = new openerp.web.CompoundContext(this.dataset.get_context());
this.dataset.read_slice([],{}, function (result) { this.dataset.read_slice([],{}, function (result) {
for (var i = 0; i < result.length; i++) { for (var i = 0; i < result.length; i++) {
if (result[i].id == id) { if (result[i].id == id) {
var data = result[i]; var data = result[i];
@ -44,216 +40,211 @@ 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.html(QWeb.render("FormView", {'get_fields': get_fields, 'notebooks': notebooks || false, 'fields' : fields, 'values' : data ,'temp_flag':'1'}));
for(var i=0;i<get_fields.length;i++) for(var i=0;i<get_fields.length;i++) {
{ if (get_fields[i].attrs.widget=="progressbar") {
if(get_fields[i].attrs.widget=="progressbar") $("#progress").progressbar({value:data[get_fields[i].attrs.name]})
{ }
$("#progress").progressbar({value:data[get_fields[i].attrs.name]}) }
} self.$element.find("[data-role=header]").find('h1').html(self.head_title);
} self.$element.find("[data-role=header]").find('#home').click(function(){
self.$element.find("[data-role=header]").find('h1').html(self.head_title); $.mobile.changePage("#oe_menu", "slide", false, true);
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){
self.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
if(!$('#oe_shortcuts').html().length){ this.shortcuts.start();
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('#formbutton').click(function(){
var head = $(this).prev().find('select').find("option:selected").text();
var selected_id = $(this).prev().find('select').val();
var select_model = $(this).prev().find('select').attr('for');
if(selected_id!="false"){
if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){
$('<div id="oe_form_'+selected_id+select_model+'" data-role="page" data-url="oe_form_'+selected_id+select_model+'"> </div>').appendTo('#moe');
this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false);
this.formview.start();
}else{
$.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true);
} }
else{ }
$.mobile.changePage("#oe_shortcuts", "slide", false, true); });
self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').each(function(i){
for (var k = 0; k < notebooks.children.length; k++) {
if (notebooks.children[k].attrs.string == $(this).attr('id')) {
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;
}
}
}
} }
}); if(notebook){
self.$element.find("[data-role=footer]").find('#preference').click(function(){ $(this).find('p').html(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data,'til': notebook.attrs.string }));
if(!$('#oe_options').html().length){ }else{
this.options = new openerp.web_mobile.Options(self, "oe_options"); $(this).find('p').html(QWeb.render("FormView", {'get_fields': get_fields,'fields' : result.fields, 'values' : data }));
this.options.start();
} }
else{ $(this).find('p').find('#formbutton').click(function(){
$.mobile.changePage("#oe_options", "slide", false, true); var head = $(this).prev().find('select').find("option:selected").text();
} var selected_id = $(this).prev().find('select').val();
}); var select_model = $(this).prev().find('select').attr('for');
self.$element.find('#formbutton').click(function(){ if(selected_id!="false"){
var head = $(this).prev().find('select').find("option:selected").text(); if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){
var selected_id = $(this).prev().find('select').val(); $('<div id="oe_form_'+selected_id+select_model+'" data-role="page" data-url="oe_form_'+selected_id+select_model+'"> </div>').appendTo('#moe');
var select_model = $(this).prev().find('select').attr('for');
if(selected_id!="false"){
if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){
$('<div id="oe_form_'+selected_id+select_model+'" data-role="page" data-url="oe_form_'+selected_id+select_model+'"> </div>').appendTo('#moe');
this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false); this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false);
this.formview.start(); this.formview.start();
}else{ }else{
$.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true); $.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true);
}
}
});
self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').each(function(i){
for (var k = 0; k < notebooks.children.length; k++) {
if (notebooks.children[k].attrs.string == $(this).attr('id')) {
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;
}
}
} }
} }
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 }));
}
$(this).find('p').find('#formbutton').click(function(){
var head = $(this).prev().find('select').find("option:selected").text();
var selected_id = $(this).prev().find('select').val();
var select_model = $(this).prev().find('select').attr('for');
if(selected_id!="false"){
if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){
$('<div id="oe_form_'+selected_id+select_model+'" data-role="page" data-url="oe_form_'+selected_id+select_model+'"> </div>').appendTo('#moe');
this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false);
this.formview.start();
}else{
$.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true);
}
}
});
}
});
self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').find('p').find('[data-role=content]').find('ul').find('li').click(function(ev){
ev.preventDefault();
ev.stopPropagation();
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()); self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').find('p').find('[data-role=content]').find('ul').find('li').click(function(ev){
var dataset = new openerp.web.DataSetStatic(self, result.fields[relational].relation, result.fields[relational].context); ev.preventDefault();
dataset.domain=[['id', 'in', data[relational]]]; ev.stopPropagation();
dataset.name_search('', dataset.domain, 'in',false ,function(res){ var latid,lastid;
for(var i=0;i<res.length;i++){ $(this).parents().each(function(){
var splited_data = res[i][1].split(','); latid = $(this).attr('id');
res[i][1] = splited_data[0]; self.$element.find('[data-role=collapsible-set]').find('[data-role=collapsible]').each(function(){
} if(latid==$(this).attr('id')){
if(!$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html()){ lastid = $(this).attr('id');
$('<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(QWeb.render("ListView", {'records' : res})); });
$('[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(){ var relational = $(this).attr('for');
$.mobile.changePage("#oe_menu", "slide", false, true); if(result.fields[relational]){
}); var head = $.trim($(this).text());
$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=footer]").find('#shrotcuts').click(function(){ var dataset = new openerp.web.DataSetStatic(self, result.fields[relational].relation, result.fields[relational].context);
if(!$('#oe_shortcuts').html().length){ dataset.domain=[['id', 'in', data[relational]]];
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); dataset.name_search('', dataset.domain, 'in',false ,function(res){
this.shortcuts.start(); for(var i=0;i<res.length;i++){
} var splited_data = res[i][1].split(',');
else{ res[i][1] = splited_data[0];
$.mobile.changePage("#oe_shortcuts", "slide", false, true); }
} 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+'"]').find("[data-role=footer]").find('#preference').click(function(){ $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').html(QWeb.render("ListView", {'records' : res}));
if(!$('#oe_options').html().length){ $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('h1').html(head);
this.options = new openerp.web_mobile.Options(self, "oe_options"); $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=header]").find('#home').click(function(){
this.options.start(); $.mobile.changePage("#oe_menu", "slide", false, true);
} });
else{ $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=footer]").find('#shrotcuts').click(function(){
$.mobile.changePage("#oe_options", "slide", false, true); if(!$('#oe_shortcuts').html().length){
} this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
}); this.shortcuts.start();
$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("a#list-id").click(function(ev){ }
ev.preventDefault(); else{
ev.stopPropagation(); $.mobile.changePage("#oe_shortcuts", "slide", false, true);
var head_title = $(this).text(); }
var listid = $(ev.currentTarget).data('id'); });
dataset = new openerp.web.DataSetSearch(self, dataset.model, null, null); $('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("[data-role=footer]").find('#preference').click(function(){
dataset.read_slice([],{}, function (result_relational) { if(!$('#oe_options').html().length){
for (var i = 0; i < result_relational.length; i++) { this.options = new openerp.web_mobile.Options(self, "oe_options");
if (result_relational[i].id == listid) { this.options.start();
var data_relational = result_relational[i]; }
} else{
$.mobile.changePage("#oe_options", "slide", false, true);
}
});
$('[id^="oe_list_'+relational+'_'+self.element_id+'"]').find("a#list-id").click(function(ev){
ev.preventDefault();
ev.stopPropagation();
var head_title = $(this).text();
var listid = $(ev.currentTarget).data('id');
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 == listid) {
var data_relational = result_relational[i];
} }
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'); if(!$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').html()){
for (var k = 0; k < notebooks.children.length; k++) { $('<div id="oe_form_'+listid+result.fields[relational].relation+'" data-role="page" data-url="oe_form_'+listid+result.fields[relational].relation+'"> </div>').appendTo('#moe');
if (notebooks.children[k].attrs.string == lastid) { for (var k = 0; k < notebooks.children.length; k++) {
get_fields = self.get_fields(notebooks.children[k].children); if (notebooks.children[k].attrs.string == lastid) {
for (var i = 0; i < get_fields.length; i++) { get_fields = self.get_fields(notebooks.children[k].children);
if (fields[get_fields[i].attrs.name].type == 'one2many'){ for (var i = 0; i < get_fields.length; i++) {
self.relational_fields = get_fields[i].attrs.name; if (fields[get_fields[i].attrs.name].type == 'one2many'){
if(fields[get_fields[i].attrs.name].views.form){ self.relational_fields = get_fields[i].attrs.name;
var get_fields_test = self.get_fields(fields[get_fields[i].attrs.name].views.form.arch.children); if(fields[get_fields[i].attrs.name].views.form){
var fields_test = fields[get_fields[i].attrs.name]['views'].form.fields; var get_fields_test = self.get_fields(fields[get_fields[i].attrs.name].views.form.arch.children);
var notebook=fields[get_fields[i].attrs.name].views.form.arch; var fields_test = fields[get_fields[i].attrs.name]['views'].form.fields;
} var notebook=fields[get_fields[i].attrs.name].views.form.arch;
} }
} }
} }
} }
$('[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+'"]').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);
});
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').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);
}
});
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').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);
}
});
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find('#formbutton').click(function(){
var head = $(this).prev().find('select').find("option:selected").text();
var selected_id = $(this).prev().find('select').val();
var select_model = $(this).prev().find('select').attr('for');
if(selected_id!="false"){
if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){
$('<div id="oe_form_'+selected_id+select_model+'" data-role="page" data-url="oe_form_'+selected_id+select_model+'"> </div>').appendTo('#moe');
this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false);
this.formview.start();
}else{
$.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true);
}
}
});
$.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", false, true);
}else{
$.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", false, true);
} }
}); $('[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+'"]').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);
});
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').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);
}
});
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').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);
}
});
$('[id^="oe_form_'+listid+result.fields[relational].relation+'"]').find('#formbutton').click(function(){
var head = $(this).prev().find('select').find("option:selected").text();
var selected_id = $(this).prev().find('select').val();
var select_model = $(this).prev().find('select').attr('for');
if(selected_id!="false"){
if(!$('[id^="oe_form_'+selected_id+select_model+'"]').html()){
$('<div id="oe_form_'+selected_id+select_model+'" data-role="page" data-url="oe_form_'+selected_id+select_model+'"> </div>').appendTo('#moe');
this.formview = new openerp.web_mobile.FormView(self, "oe_form_"+selected_id+select_model, selected_id, '', head, select_model, false);
this.formview.start();
}else{
$.mobile.changePage('#oe_form_'+selected_id+select_model, "slide", false, true);
}
}
});
$.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", false, true);
}else{
$.mobile.changePage('#oe_form_'+listid+result.fields[relational].relation, "slide", false, true);
}
}); });
$.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true); });
}else{ $.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true);
$.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true); }else{
} $.mobile.changePage("#oe_list_"+relational+"_"+self.element_id, "slide", false, true);
}); }
} });
}); }
$.mobile.changePage("#"+self.element_id, "slide", false, true);
}); });
$.mobile.changePage("#"+self.element_id, "slide", false, true);
});
}); });
}, },
get_fields: function(view_fields, fields) { get_fields: function(view_fields, fields) {
@ -269,4 +260,5 @@ openerp.web_mobile.FormView = openerp.web.Widget.extend({
return this.fields; return this.fields;
} }
}); });
}; };

View File

@ -10,8 +10,7 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
this.list_id = list_id; this.list_id = list_id;
}, },
start: function() { start: function() {
this.rpc('/web/menu/action', {'menu_id': this.list_id}, this.rpc('/web/menu/action', {'menu_id': this.list_id}, this.on_menu_action_loaded);
this.on_menu_action_loaded);
}, },
on_menu_action_loaded: function(data) { on_menu_action_loaded: function(data) {
var self = this; var self = this;
@ -30,11 +29,10 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
$.mobile.changePage("#oe_menu", "slide", false, true); $.mobile.changePage("#oe_menu", "slide", false, true);
}); });
self.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){ self.$element.find("[data-role=footer]").find('#shrotcuts').click(function(){
if(!$('#oe_shortcuts').html().length){ if (!$('#oe_shortcuts').html().length) {
this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts"); this.shortcuts = new openerp.web_mobile.Shortcuts(self, "oe_shortcuts");
this.shortcuts.start(); this.shortcuts.start();
} }else{
else{
$.mobile.changePage("#oe_shortcuts", "slide", false, true); $.mobile.changePage("#oe_shortcuts", "slide", false, true);
} }
}); });
@ -42,8 +40,7 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
if(!$('#oe_options').html().length){ if(!$('#oe_options').html().length){
this.options = new openerp.web_mobile.Options(self, "oe_options"); this.options = new openerp.web_mobile.Options(self, "oe_options");
this.options.start(); this.options.start();
} }else{
else{
$.mobile.changePage("#oe_options", "slide", false, true); $.mobile.changePage("#oe_options", "slide", false, true);
} }
}); });
@ -58,7 +55,6 @@ openerp.web_mobile.ListView = openerp.web.Widget.extend({
ev.stopPropagation(); ev.stopPropagation();
id = $record.data('id'); id = $record.data('id');
head_title = $.trim($record.text()); head_title = $.trim($record.text());
if(!$('[id^="oe_form_'+id+this.action.res_model+'"]').html()){ 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'); $('<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 openerp.web_mobile.FormView(this, "oe_form_"+id+this.action.res_model, id, this.action, head_title, '' ,'');

View File

@ -41,7 +41,6 @@
<div data-role="footer" data-theme="b" data-position="fixed"> <div data-role="footer" data-theme="b" data-position="fixed">
<h1>Powered by openerp.com</h1> <h1>Powered by openerp.com</h1>
</div> </div>
</t> </t>
<t t-name="Header"> <t t-name="Header">
@ -75,6 +74,7 @@
</div> </div>
<t t-call="Footer" /> <t t-call="Footer" />
</t> </t>
<t t-name="Menu"> <t t-name="Menu">
<t t-call="Header" /> <t t-call="Header" />
<div id="content" data-role="content"> <div id="content" data-role="content">
@ -95,19 +95,19 @@
<t t-foreach="menu.children" t-as="menu1" > <t t-foreach="menu.children" t-as="menu1" >
<ul data-dividertheme="b" data-theme="c" data-inset="true" data-role="listview"> <ul data-dividertheme="b" data-theme="c" data-inset="true" data-role="listview">
<li data-role="list-divider"> <li data-role="list-divider">
<t t-if="(menu1.children.length)"> <t t-if="(menu1.children.length)">
<t t-esc="menu1.name"/> <t t-esc="menu1.name"/>
</t> </t>
<t t-if="!(menu1.children.length)"> <t t-if="!(menu1.children.length)">
<a href="#" t-attf-id="menu_#{menu1.id}" t-att-data-menu="menu1.id" t-att-data-name="menu1.name"> <a href="#" t-attf-id="menu_#{menu1.id}" t-att-data-menu="menu1.id" t-att-data-name="menu1.name">
<t t-esc="menu1.name"/> <t t-esc="menu1.name"/>
</a> </a>
</t> </t>
</li> </li>
<t t-if="menu1.children.length"> <t t-if="menu1.children.length">
<li data-theme="c" t-foreach="menu1.children" t-as="childmenu" > <li data-theme="c" t-foreach="menu1.children" t-as="childmenu" >
<a href="#" t-attf-id="menu_#{childmenu.id}" t-att-data-menu="childmenu.id" t-att-data-name="childmenu.name"> <a href="#" t-attf-id="menu_#{childmenu.id}" t-att-data-menu="childmenu.id" t-att-data-name="childmenu.name">
<t t-esc="childmenu.name" /> <t t-esc="childmenu.name" />
</a> </a>
</li> </li>
</t> </t>
@ -116,6 +116,7 @@
</div> </div>
<t t-call="Footer" /> <t t-call="Footer" />
</t> </t>
<t t-name="Options"> <t t-name="Options">
<t t-call="Header" /> <t t-call="Header" />
<div data-role="content"> <div data-role="content">
@ -141,11 +142,11 @@
</div> </div>
<t t-call="Footer" /> <t t-call="Footer" />
</t> </t>
<t t-name="FormView"> <t t-name="FormView">
<t t-if="temp_flag"> <t t-if="temp_flag">
<t t-call="Header" /> <t t-call="Header" />
</t> </t>
<div data-role="content"> <div data-role="content">
<form> <form>
<t t-foreach="get_fields" t-as="field"> <t t-foreach="get_fields" t-as="field">
@ -181,19 +182,18 @@
<t t-if="field.attrs.string" t-esc="field.attrs.string"></t>: <t t-if="field.attrs.string" t-esc="field.attrs.string"></t>:
</label> </label>
<t t-if="values[field.attrs.name] and field.attrs.name=='progress_rate'"> <t t-if="values[field.attrs.name] and field.attrs.name=='progress_rate'">
<div id="progress" value="" title="Percent of tasks closed according to total of tasks to do..."></div> <div id="progress" value="" title="Percent of tasks closed according to total of tasks to do..."></div>
</t> </t>
<t t-if="!(values[field.attrs.name]) and field.attrs.name=='progress_rate'"> <t t-if="!(values[field.attrs.name]) and field.attrs.name=='progress_rate'">
<div id="progress" value="" title="Percent of tasks closed according to total of tasks to do..."></div> <div id="progress" value="" title="Percent of tasks closed according to total of tasks to do..."></div>
</t> </t>
<t t-if="values[field.attrs.name] and field.attrs.name!='progress_rate'"> <t t-if="values[field.attrs.name] and field.attrs.name!='progress_rate'">
<input id="" type="text" t-att-value="values[field.attrs.name]"/> <input id="" type="text" t-att-value="values[field.attrs.name]"/>
</t> </t>
<t t-if="!values[field.attrs.name] and field.attrs.name!='progress_rate'"> <t t-if="!values[field.attrs.name] and field.attrs.name!='progress_rate'">
<input id="" type="text" value=""/> <input id="" type="text" value=""/>
</t> </t>
</t> </t>
<t t-if="fields[field.attrs.name].type == 'date'"> <t t-if="fields[field.attrs.name].type == 'date'">
<label for=""> <label for="">
<t t-if="!(field.attrs.string)" t-esc="fields[field.attrs.name].string"></t> <t t-if="!(field.attrs.string)" t-esc="fields[field.attrs.name].string"></t>
@ -276,23 +276,17 @@
</t> </t>
</div> </div>
</t> </t>
<t t-if="notebooks"> <t t-if="notebooks">
<div data-role="collapsible-set"> <div data-role="collapsible-set">
<t t-foreach="notebooks.children" t-as="page"> <t t-foreach="notebooks.children" t-as="page">
<t t-if="page.attrs.invisible"> <t t-if="page.attrs.invisible">
<div style="display:none;" data-collapsed="true" data-role="collapsible" t-att-id="page.attrs.string"> <div style="display:none;" data-collapsed="true" data-role="collapsible" t-att-id="page.attrs.string">
<h3> <h3><t t-esc="page.attrs.string"></t></h3>
<t t-esc="page.attrs.string"></t>
</h3>
<p></p>
</div> </div>
</t> </t>
<t t-if="!page.attrs.invisible"> <t t-if="!page.attrs.invisible">
<div data-collapsed="true" data-role="collapsible" t-att-id="page.attrs.string"> <div data-collapsed="true" data-role="collapsible" t-att-id="page.attrs.string">
<h3> <h3><t t-esc="page.attrs.string"></t></h3>
<t t-esc="page.attrs.string"></t>
</h3>
<p></p>
</div> </div>
</t> </t>
</t> </t>