~openerp-usertesting/openerp-web/trunk-muilti_address-rmu

« back to all changes in this revision

Viewing changes to addons/web_kanban/static/src/js/kanban.js

  • Committer: Thibault Delavallée
  • Date: 2013-04-05 15:21:31 UTC
  • mfrom: (3704.2.10 trunk-visibility-chm)
  • Revision ID: tde@openerp.com-20130405152131-4auticfaj24wbpqx
[MERGE] Alias Visibility and Salesteams View. Improve the display of alias in form views and in empty list help messages. Improve the use, visibility and display of salesteams.

Add support for 'no result' help message in kanban views.
Add css for empty list in kanban views + generic display of mail aliases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
225
225
    },
226
226
    do_search: function(domain, context, group_by) {
227
227
        var self = this;
228
 
        this.$el.find('.oe_view_nocontent').remove();
229
228
        this.search_domain = domain;
230
229
        this.search_context = context;
231
230
        this.search_group_by = group_by;
238
237
            var grouping_fields = self.group_by ? [self.group_by].concat(_.keys(self.aggregates)) : undefined;
239
238
            var grouping = new instance.web.Model(self.dataset.model, context, domain).query().group_by(grouping_fields);
240
239
            return self.alive($.when(grouping)).done(function(groups) {
 
240
                self.remove_no_result();
241
241
                if (groups) {
242
242
                    self.do_process_groups(groups);
243
243
                } else {
248
248
    },
249
249
    do_process_groups: function(groups) {
250
250
        var self = this;
 
251
        this.$el.find('table:first').show();
251
252
        this.$el.removeClass('oe_kanban_ungrouped').addClass('oe_kanban_grouped');
252
253
        this.add_group_mutex.exec(function() {
253
254
            self.do_clear_groups();
256
257
                self.no_result();
257
258
                return false;
258
259
            }
 
260
            self.nb_records = 0;
259
261
            var remaining = groups.length - 1,
260
262
                groups_array = [];
261
263
            return $.when.apply(null, _.map(groups, function (group, index) {
262
264
                var dataset = new instance.web.DataSetSearch(self, self.dataset.model,
263
265
                    new instance.web.CompoundContext(self.dataset.get_context(), group.model.context()), group.model.domain());
264
266
                return dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit })
265
 
                    .then(function(records) {
 
267
                    .then(function (records) {
 
268
                        self.nb_records += records.length;
266
269
                        self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
267
270
                        groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
268
271
                        if (!remaining--) {
270
273
                            return self.do_add_groups(groups_array);
271
274
                        }
272
275
                });
273
 
            }));
 
276
            })).then(function () {
 
277
                if(!self.nb_records) {
 
278
                    self.no_result();
 
279
                }
 
280
            });
274
281
        });
275
282
    },
276
283
    do_process_dataset: function() {
277
284
        var self = this;
 
285
        this.$el.find('table:first').show();
278
286
        this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
279
287
        this.add_group_mutex.exec(function() {
280
288
            var def = $.Deferred();
313
321
        var $last_td = self.$el.find('.oe_kanban_groups_headers td:last');
314
322
        var groups_started = _.map(this.groups, function(group) {
315
323
            if (!group.is_started) {
 
324
                group.on("add_record", self, function () {
 
325
                    self.remove_no_result();
 
326
                });
316
327
                return group.insertBefore($last_td);
317
328
            }
318
329
        });
445
456
        }
446
457
    },
447
458
    no_result: function() {
 
459
        var self = this;
448
460
        if (this.groups.group_by
449
461
            || !this.options.action
450
 
            || !this.options.action.help) {
 
462
            || (!this.options.action.help && !this.options.action.get_empty_list_help)) {
451
463
            return;
452
464
        }
453
 
        this.$el.find('.oe_view_nocontent').remove();
454
 
        this.$el.prepend(
455
 
            $('<div class="oe_view_nocontent">').html(this.options.action.help)
456
 
        );
457
 
        var create_nocontent = this.$buttons;
 
465
        this.$el.find('table:first').css("position", "absolute");
 
466
        $(QWeb.render('KanbanView.nocontent', { content : this.options.action.get_empty_list_help || this.options.action.help})).insertAfter(this.$('table:first'));
458
467
        this.$el.find('.oe_view_nocontent').click(function() {
459
 
            create_nocontent.openerpBounce();
 
468
            self.$buttons.openerpBounce();
460
469
        });
461
470
    },
 
471
    remove_no_result: function() {
 
472
        this.$el.find('table:first').css("position", false);
 
473
        this.$el.find('.oe_view_nocontent').remove();
 
474
    },
462
475
 
463
476
    /*
464
477
    *  postprocessing of fields type many2many
573
586
        });
574
587
 
575
588
        this.$el.find('.oe_kanban_add').click(function () {
 
589
            if (self.view.quick) {
 
590
                self.view.quick.trigger('close');
 
591
            }
576
592
            if (self.quick) {
577
 
                return self.quick.trigger('close');
 
593
                return false;
578
594
            }
 
595
            self.view.$el.find('.oe_view_nocontent').hide();
579
596
            var ctx = {};
580
597
            ctx['default_' + self.view.group_by] = self.value;
581
598
            self.quick = new (get_class(self.view.quick_create_class))(this, self.dataset, ctx, true)
582
599
                .on('added', self, self.proxy('quick_created'))
583
600
                .on('close', self, function() {
 
601
                    self.view.$el.find('.oe_view_nocontent').show();
584
602
                    this.quick.destroy();
 
603
                    delete self.view.quick;
585
604
                    delete this.quick;
586
605
                });
587
606
            self.quick.appendTo($(".oe_kanban_group_list_header", self.$records));
588
607
            self.quick.focus();
 
608
            self.view.quick = self.quick;
589
609
        });
590
610
        // Add bounce effect on image '+' of kanban header when click on empty space of kanban grouped column.
591
611
        this.$records.on('click', '.oe_kanban_show_more', this.do_show_more);
722
742
     */
723
743
    quick_created: function (record) {
724
744
        var id = record, self = this;
 
745
        self.view.remove_no_result();
 
746
        self.trigger("add_record");
725
747
        this.dataset.read_ids([id], this.view.fields_keys)
726
748
            .done(function (records) {
727
749
                self.view.dataset.ids.push(id);