[MERGE] notes

bzr revid: fp@tinyerp.com-20120919144607-ylnhfms86wvl2ap7
This commit is contained in:
Fabien Pinckaers 2012-09-19 16:46:07 +02:00
commit c439f18168
3 changed files with 52 additions and 35 deletions

View File

@ -536,6 +536,11 @@
.openerp .oe_tags.oe_inline {
min-width: 250px;
}
.openerp .oe_form header .oe_tags {
margin:5px 0 0 5px;
width:400px;
padding-bottom:0;
}
.openerp .oe_tags .text-wrap {
width: 100% !important;
}
@ -1919,7 +1924,7 @@
}
.openerp .oe_form_nosheet > header {
margin: -16px -16px 0 -16px;
padding: 8px;
padding: 0;
}
.openerp .oe_form_sheetbg {
padding: 8px 0;

View File

@ -475,6 +475,12 @@ $sheet-max-width: 860px
text-decoration: none
margin-bottom: 1px
// }}}
.oe_form
header
.oe_tags
margin:5px 0 0 5px
width:400px
padding-bottom:0
// Tooltips {{{
&.oe_tooltip
font-size: 12px
@ -1525,7 +1531,7 @@ $sheet-max-width: 860px
margin: 16px
> header
margin: -16px -16px 0 -16px
padding: 8px
padding: 0
.oe_form_sheetbg
padding: 8px 0
.oe_form_sheet_width

View File

@ -130,7 +130,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
case 'field':
if(this.fields_view.fields[ node.attrs['name'] ].type == 'many2many'){
node.tag = 'div';
node.attrs['class'] = 'oe_kanban_many2many_tags';
node.attrs['class'] = 'oe_form_field oe_tags';
node.attrs['model'] = this.fields_view.fields[node.attrs['name']].relation;
node.attrs['t-att-data'] = 'record.' + node.attrs['name'] + '.raw_value';
}else {
@ -176,37 +176,6 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
}
}
},
/* widget for list of tags/categories...
*/
transform_widget_many2many: function(){
var self=this,
arg={};
// select all widget
self.$el.find(".oe_kanban_many2many_tags").each(function(){
var model = $(this).attr("model");
var data = $(this).attr("data");
var list = data.split(",");
//select all id (per model)
if(!arg[model]) arg[model]=[];
for(var t=0;t<list.length;t++) if(list[t]!="") arg[model].push( list[t] );
});
// only one request by model
for(var model in arg){
if(arg[model].length>0){
var dataset = new instance.web.DataSetSearch(self, model, self.session.context);
dataset.name_get(_.uniq( arg[model] )).then(
function(result) {
for(var t=0;t<result.length;t++){
self.$el.find(".oe_kanban_many2many_tags[model='" + model + "']")
.filter(function(){ return this.getAttribute("data").match(new RegExp('(^|,)'+result[t][0]+'(,|$)')); })
.append('<span class="oe_tag" data-list_id="' + result[t][0] +'"">'+result[t][1]+'</span>');
}
}
);
}
}
},
do_add_record: function() {
this.dataset.index = null;
this.do_switch_view('form');
@ -394,7 +363,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
} else {
this.$el.find('.oe_kanban_draghandle').removeClass('oe_kanban_draghandle');
}
this.transform_widget_many2many();
instance.web_kanban.KanbanView.postprocessing_widget_many2many_tags(self);
},
on_record_moved : function(record, old_group, old_index, new_group, new_index) {
var self = this;
@ -479,6 +448,42 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
}
});
/*
* widget for list of tags/categories
* make the rpc request for all ids/model and insert value inside .oe_tags fields
*/
instance.web_kanban.KanbanView.postprocessing_widget_many2many_tags = function(self){
var model_list_id={};
// select all widget for the kanban view or the widget inside the record
self.$el.find(".oe_form_field.oe_tags").each(function(){
var model = $(this).attr("model");
if(model.length){
var data = $(this).attr("data");
var list = data.split(",");
//select all id (per model)
if(!model_list_id[model]) model_list_id[model]=[];
for(var t=0;t<list.length;t++) if(list[t]!="") model_list_id[model].push( list[t] );
}
});
// rpc and insert
for(var model in model_list_id){
if(model_list_id[model].length>0){
var block = self.$el.find(".oe_form_field.oe_tags[model='" + model + "']");
var dataset = new instance.web.DataSetSearch(self, model, self.session.context);
dataset.name_get(_.uniq( model_list_id[model] )).then(
function(result) {
for(var t=0;t<result.length;t++){
block.filter(function(){ return this.getAttribute("data").match(new RegExp('(^|,)'+result[t][0]+'(,|$)')); })
.append('<span class="oe_tag" data-list_id="' + result[t][0] +'"">'+result[t][1]+'</span>');
}
}
);
}
}
}
function get_class(name) {
return new instance.web.Registry({'tmp' : name}).get_object("tmp");
}
@ -913,6 +918,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
self.$el.data('widget', self);
self.bind_events();
self.group.compute_cards_auto_height();
instance.web_kanban.KanbanView.postprocessing_widget_many2many_tags(self);
} else {
self.destroy();
}