Skip to content

Commit

Permalink
Merge pull request #397 from hpatelserpentcs/13_web_widget_multi_image
Browse files Browse the repository at this point in the history
[ADD][IMP][13.0] Web Widget Multiple Image
  • Loading branch information
JayVora-SerpentCS authored Dec 7, 2019
2 parents 2b0663f + 3858426 commit 9812501
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions web_widget_multi_image/static/src/js/multi_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ odoo.define('web_widget_multi_image.MultiImage', function(require) {

var core = require('web.core');
var FieldOne2Many = require('web.relational_fields').FieldOne2Many;
var ControlPanelView = require('web.ControlPanelView');
var Pager = require('web.Pager');
var dataset = require('web.data');
var Dialog = require('web.Dialog');
var QWeb = core.qweb;
Expand Down Expand Up @@ -193,5 +195,54 @@ odoo.define('web_widget_multi_image.MultiImage', function(require) {
$(curr_id).closest('table.hoverbox').parent().remove();
},

_renderControlPanel: function () {
if (!this.view) {
return Promise.resolve();
}
var self = this;

var defs = [];
var controlPanelView = new ControlPanelView({
template: 'X2ManyControlPanel',
withSearchBar: false,
context: {'widget': self.attrs.widget}
});
var cpDef = controlPanelView.getController(this).then(function (controlPanel) {
self._controlPanel = controlPanel;
return self._controlPanel.prependTo(self.$el);
});
this.pager = new Pager(this, this.value.count, this.value.offset + 1, this.value.limit, {
single_page_hidden: true,
withAccessKey: false,
validate: function () {
var isList = self.view.arch.tag === 'tree';
// TODO: we should have some common method in the basic renderer...
return isList ? self.renderer.unselectRow() : Promise.resolve();
},
});
this.pager.on('pager_changed', this, function (new_state) {
self.trigger_up('load', {
id: self.value.id,
limit: new_state.limit,
offset: new_state.current_min - 1,
on_success: function (value) {
self.value = value;
self._render();
},
});
});
this._renderButtons();
defs.push(this.pager.appendTo($('<div>'))); // start the pager
defs.push(cpDef);
return Promise.all(defs).then(function () {
self._controlPanel.updateContents({
cp_content: {
$buttons: self.$buttons,
$pager: self.pager.$el,
}
});
});
},

});
});
2 changes: 1 addition & 1 deletion web_widget_multi_image/static/src/xml/image_multi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<t t-extend="X2ManyControlPanel">
<t t-jquery=".o_cp_buttons" t-operation="before">
<table>
<table t-if="widget.context.widget == 'image_multi'">
<tr style="background:white;">
<td style="padding: 10px 250px 15px 250px;">
<button class="fa fa-search oe-image-preview btn btn-sm oe_form_binary btn-primary" type="button" title="Preview">
Expand Down

0 comments on commit 9812501

Please sign in to comment.