diff options
| author | Géry Debongnie <ged@odoo.com> | 2015-06-15 16:31:27 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2015-06-15 16:31:27 +0200 |
| commit | 2c7367a8cc8d9e200b1fa2083ce0d80f8f4e4bd3 (patch) | |
| tree | af916cff4d94554b1e9667913e3feb331ec81a13 /addons/web/static/src/js | |
| parent | 5cb10d4fc9594f0c6825757c24d66d63664ce026 (diff) | |
| parent | 82186a93bb3f93c36667835df68fa31dcacf97a2 (diff) | |
[MERGE] new kanban view
This branch introduces the new kanban view. It is not completely
compatible with the previous version. Here are a few importants
points to be aware of:
* the kanban view template is rendered directly, not put inside a div.
It means that if a template has more than one root, chaos will ensue
* kanban view has been split into several files, and various js modules
have changed. For example, the KanbanRecord class is now exported by
the 'web_kanban.Record' module. So, require statements need to be
updated
* records do not have access to the view (i.e., record.view.is_action_enabled('edit'))
You can use the 'editable' and 'deletable' key instead
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/framework/core.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/form_widgets.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/widgets/pager.js | 111 |
3 files changed, 118 insertions, 1 deletions
diff --git a/addons/web/static/src/js/framework/core.js b/addons/web/static/src/js/framework/core.js index 7bd4800ec98..30138102663 100644 --- a/addons/web/static/src/js/framework/core.js +++ b/addons/web/static/src/js/framework/core.js @@ -186,6 +186,11 @@ return { list_widget_registry: new Registry(), search_widgets_registry: new Registry(), search_filters_registry: new Registry(), + + // necessary to make the kanban view compatible between + // community and enterprise edition + one2many_view_registry: new Registry(), + }; diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index ee04f8376b4..760ea703d35 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -285,7 +285,7 @@ var Priority = FieldChar.extend({ }, render_value: function() { this.priorities = this.prepare_priority(); - this.$el.html(QWeb.render("Priority", {'widget': this})); + this.$el.html(QWeb.render("FormPriority", {'widget': this})); if (!this.get('readonly')){ this.$el.find('li').on('click', this.set_priority.bind(this)); } @@ -1584,6 +1584,7 @@ var StatInfo = common.AbstractField.extend({ } } this.$el.html(QWeb.render("StatInfo", options)); + this.$el.addClass('o_stat_info'); }, }); diff --git a/addons/web/static/src/js/widgets/pager.js b/addons/web/static/src/js/widgets/pager.js new file mode 100644 index 00000000000..c195aaf530d --- /dev/null +++ b/addons/web/static/src/js/widgets/pager.js @@ -0,0 +1,111 @@ +odoo.define('web.Pager', function (require) { +"use strict"; + +var Widget = require('web.Widget'); + +var direction = { + previous: -1, + next: 1, +}; + +var Pager = Widget.extend({ + template: "Pager", + + events: { + 'click .o-pager-previous': 'previous', + 'click .o-pager-next': 'next', + }, + + // pager goes from 1 to size (included). + // current value is current_min (if limit === 1) + // or the interval [current_min, current_min + limit[ if limit > 1 + init: function (parent, size, current_min, limit, options) { + this.state = { + size: size, + current_min: current_min, + limit: limit, + }; + Object.defineProperty(this.state, 'current_max', { + get: function() { + return Math.min(this.current_min + this.limit - 1, this.size); + } + }); + this.options = options || {}; + this._super(parent); + }, + + start: function () { + this.$content = this.$('.o-pager-value'); + this._render(); + return this._super(); + }, + + set_state: function (options) { + _.extend(this.state, options); + this._render(); + }, + + previous: function(e) { + this._change_selection(direction.previous); + }, + + next: function() { + this._change_selection(direction.next); + }, + + disable: function() { + this.$('button').prop("disabled", true); + }, + + enable: function() { + this.$('button').prop("disabled", false); + }, + + _render: function () { + var state; + var size = this.state.size; + var current_min = this.state.current_min; + var current_max = this.state.current_max; + var single_page = 1 === current_min && current_max === size; + + if (size === 0 || (single_page && this.options.single_page_hidden)) { + this.$el.hide(); + } else { + this.$el.show(); + + if (single_page) { + this.disable(); + } else { + this.enable(); + } + + if (this.state.limit === 1) { + state = "" + current_min + " / " + size; + } else { + state = "" + current_min + "-" + current_max + " / " + size; + } + this.$content.html(state); + } + }, + + _change_selection: function (direction) { + var size = this.state.size; + var current_min = this.state.current_min; + var limit = this.state.limit; + current_min = (current_min + limit*direction); + if (current_min > size) { + current_min = 1; + } else if ((current_min < 1) && (limit === 1)) { + current_min = size; + } else if ((current_min < 1) && (limit > 1)) { + current_min = size - ((size % limit) || limit) + 1; + } + this.state.current_min = current_min; + this.trigger('pager_changed', _.clone(this.state)); + this._render(); + }, +}); + +return Pager; + +});
\ No newline at end of file |
