~therp-nl/openerp-web/7.0-lp1013636-x2m_honour_required_attribute

« back to all changes in this revision

Viewing changes to addons/web_dashboard/static/src/js/dashboard.js

[MERGE] from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
        this.$element.delegate('.oe-dashboard-column .oe-dashboard-fold', 'click', this.on_fold_action);
32
32
        this.$element.delegate('.oe-dashboard-column .ui-icon-closethick', 'click', this.on_close_action);
33
33
 
34
 
        this.actions_attrs = {};
35
34
        // Init actions
36
35
        _.each(this.node.children, function(column, column_index) {
37
36
            _.each(column.children, function(action, action_index) {
38
37
                delete(action.attrs.width);
39
38
                delete(action.attrs.height);
40
39
                delete(action.attrs.colspan);
41
 
                self.actions_attrs[action.attrs.name] = action.attrs;
42
40
                self.rpc('/web/action/load', {
43
41
                    action_id: parseInt(action.attrs.name, 10)
44
42
                }, function(result) {
45
 
                    self.on_load_action(result, column_index + '_' + action_index);
 
43
                    self.on_load_action(result, column_index + '_' + action_index, action.attrs);
46
44
                });
47
45
            });
48
46
        });
97
95
            $action = $e.parents('.oe-dashboard-action:first'),
98
96
            id = parseInt($action.attr('data-id'), 10);
99
97
        if ($e.is('.ui-icon-minusthick')) {
100
 
            this.actions_attrs[id].fold = '1';
 
98
            $action.data('action_attrs').fold = '1';
101
99
        } else {
102
 
            delete(this.actions_attrs[id].fold);
 
100
            delete($action.data('action_attrs').fold);
103
101
        }
104
102
        $e.toggleClass('ui-icon-minusthick ui-icon-plusthick');
105
103
        $action.find('.oe-dashboard-action-content').toggle();
122
120
            var actions = [];
123
121
            $(this).find('.oe-dashboard-action').each(function() {
124
122
                var action_id = $(this).attr('data-id'),
125
 
                    new_attrs = _.clone(self.actions_attrs[action_id]);
 
123
                    new_attrs = _.clone($(this).data('action_attrs'));
126
124
                if (new_attrs.domain) {
127
125
                    new_attrs.domain = new_attrs.domain_string;
128
126
                    delete(new_attrs.domain_string);
143
141
            self.$element.find('.oe-dashboard-link-reset').show();
144
142
        });
145
143
    },
146
 
    on_load_action: function(result, index) {
 
144
    on_load_action: function(result, index, action_attrs) {
147
145
        var self = this,
148
146
            action = result.result,
149
 
            action_attrs = this.actions_attrs[action.id],
150
147
            view_mode = action_attrs.view_mode;
151
148
 
152
 
        if (action_attrs.context) {
153
 
            action.context = _.extend((action.context || {}), action_attrs.context);
154
 
        }
155
 
        if (action_attrs.domain) {
156
 
            action.domain = action.domain || [];
157
 
            action.domain.unshift.apply(action.domain, action_attrs.domain);
158
 
        }
 
149
        if (action_attrs.context && action_attrs.context['dashboard_merge_domains_contexts'] === false) {
 
150
            // TODO: replace this 6.1 workaround by attribute on <action/>
 
151
            action.context = action_attrs.context || {};
 
152
            action.domain = action_attrs.domain || [];
 
153
        } else {
 
154
            if (action_attrs.context) {
 
155
                action.context = _.extend((action.context || {}), action_attrs.context);
 
156
            }
 
157
            if (action_attrs.domain) {
 
158
                action.domain = action.domain || [];
 
159
                action.domain.unshift.apply(action.domain, action_attrs.domain);
 
160
            }
 
161
        }
 
162
 
159
163
        var action_orig = _.extend({ flags : {} }, action);
160
164
 
161
165
        if (view_mode && view_mode != action.view_mode) {
187
191
        var am = new openerp.web.ActionManager(this),
188
192
            // FIXME: ideally the dashboard view shall be refactored like kanban.
189
193
            $action = $('#' + this.view.element_id + '_action_' + index);
 
194
        $action.parent().data('action_attrs', action_attrs);
190
195
        this.action_managers.push(am);
191
196
        am.appendTo($action);
192
197
        am.do_action(action);