310
310
this.expand_all = 0;
311
311
$('#expand_all').hide();
313
group_by: function(id, record, no_leaf, group) {
313
group_by: function(id, record, no_leaf, group, offset, remove) {
314
314
var $group_record = jQuery('[records="' + record + '"]');
315
315
var group_by_context = $group_record.attr('grp_context');
316
316
var domain = $group_record.attr('grp_domain');
329
330
var expand_all = this.expand_all;
331
if (group_by_context == '[]') {
332
jQuery('#' + record + '[parent_grp_id="' + id + '"]').toggle();
332
if (group_by_context == '[]' && this.sort_order) {
333
sort_order = this.sort_order;
334
sort_key = this.sort_key;
336
if (jQuery(group).hasClass('group-expand')) {
337
// get listview selectable value, so we know if we are in
338
// simple or multiple selection mode
339
var selectable = openobject.dom.get('_terp_selectable');
341
selectable = selectable.value
344
url: '/openerp/listgrid/multiple_groupby',
346
data: { 'model': this.model, 'name': this.name,
347
'grp_domain': domain, 'group_by': group_by_context,
348
'view_id': this.view_id,
349
'view_type': this.view_type,
350
'parent_group': record,
351
'group_level': jQuery(group).index() + 1,
352
'groups': total_groups,
354
'sort_order': sort_order,
355
'sort_key': sort_key,
356
'_terp_editable': openobject.dom.get('_terp_editable').value,
357
'_terp_selectable': selectable,
358
'_terp_context': openobject.dom.get('_terp_context').value,
359
'_terp_offset': offset,
360
//'_terp_offset': openobject.dom.get('_terp_offset').value, // we force offset to 0 for multiple_groupby calls
361
'_terp_limit': openobject.dom.get('_terp_limit').value,
364
success: function(xmlHttp) {
365
$group_record.after(xmlHttp);
334
if (jQuery(group).hasClass('group-expand')) {
336
url: '/openerp/listgrid/multiple_groupby',
338
data: { 'model': this.model, 'name': this.name,
339
'grp_domain': domain, 'group_by': group_by_context,
340
'view_id': this.view_id,
341
'view_type': this.view_type,
342
'parent_group': record,
343
'group_level': jQuery(group).index() + 1,
344
'groups': total_groups,
346
'sort_order': sort_order,
347
'sort_key': sort_key},
349
success: function(xmlHttp) {
350
$group_record.after(xmlHttp);
352
self.expand_all_group(record);
357
jQuery('[parent="' + record + '"]').each(function() {
358
var parent_id = jQuery('[parent="' + record + '"]').attr('records');
359
if (jQuery('[parent="' + parent_id + '"]').length > 0) {
360
jQuery('[parent="' + parent_id + '"]').remove();
362
jQuery(this).remove();
372
jQuery('[parent="' + record + '"]').each(function() {
373
var parent_id = jQuery('[parent="' + record + '"]').attr('records');
374
if (jQuery('[parent="' + parent_id + '"]').length > 0) {
375
jQuery('[parent="' + parent_id + '"]').remove();
377
jQuery(this).remove();
367
382
jQuery(group).toggleClass('group-collapse group-expand');
371
386
var _list_view = new ListView(view);
375
391
var drop_record = drop.attr('record');
376
392
var drag_record = drag.attr('record');
378
var dropGroup = drop.attr('id').split('grid-row ')[1];
379
domain = jQuery('tr.grid-row-group[records="'+dropGroup+'"]').attr('grp_domain');
394
domain = jQuery('tr.grid-row-group[records="'+drop.attr('parent')+'"]').attr('grp_domain');
395
level = jQuery('tr.grid-row-group[records="'+drop.attr('parent')+'"]').attr('grp_level');
382
397
domain = drop.attr('grp_domain');
398
level = drop.attr('grp_level');
385
401
var ch_records = drag.attr('ch_records');
387
children = ch_records;
403
children = drag.attr('grp_domain');
404
} else if (drag.attr('id') == drop.attr('id')) {
405
children = jQuery('tr.grid-row-group[records="'+drag.attr('parent')+'"]').attr('ch_records');
390
if(drag.attr('id') == drop.attr('id')) {
391
var dragGroup = drag.attr('id').split('grid-row ')[1];
392
children = jQuery('tr.grid-row-group[records="'+dragGroup+'"]').attr('ch_records');
395
children = drag_record;
408
children = "[('id','=',"+drag_record+")]";
399
if((drag_record && drop_record) && (drag.attr('id')) == drop.attr('id')) {
411
if ((drag_record && drop_record) && (drag.attr('id') == drop.attr('id'))) {
412
// drag'n'drop within the same group
413
// - get group ids and new position
415
jQuery('[parent='+drop.attr('parent')+']').each(function() {
416
drop_ids.push(jQuery(this).attr('record'));
418
// target position is always drop_position + 1,
419
// exception when dropping on the 1st line where we force exclusive position of 0
420
var drop_position = drop_ids.indexOf(drop_record) > 0 ? drop_ids.indexOf(drop_record) + 1 : 0;
401
422
drag.attr('record'),
402
drag.prevAll().length);
424
'['+drop_ids.join(',')+']');
406
428
url: '/openerp/listgrid/groupbyDrag',
408
data: {'model': _list_view.model, 'children': children, 'domain': domain},
430
data: {'model': _list_view.model, 'children': children, 'domain': domain, 'level': level},
409
431
dataType: 'json',
410
432
success: function () {
411
433
_list_view.reload();
417
dragRow: function(id, to_index) {
439
dragRow: function(id, to_index, to_ids) {
440
var ids = to_ids ? to_ids : this.ids;
419
442
url: '/openerp/listgrid/dragRow',
422
445
data: {'_terp_model': this.model,
423
'_terp_ids': this.ids,
425
448
'_terp_destination_index': to_index
1127
function next_p(el, name, no_leaf, limit, way) {
1128
pr = jQuery(el).parent().parent().parent().prev('.grid-row-group');
1129
offset = pr.attr('offset') || 0
1130
offset = parseInt(offset)
1131
offset = offset + way * limit
1132
pr.attr('offset', offset)
1133
grp_by = pr.attr('grp_by_id');
1134
pr.toggleClass('group-expand', true);
1135
records = pr.attr('records');
1136
to_remove = pr.siblings('[parent="'+records+'"]');
1137
new ListView(name).group_by(grp_by, records, no_leaf, pr, offset, to_remove);