Skip to content
Snippets Groups Projects
Commit e7392285 authored by Khoi Nguyen's avatar Khoi Nguyen Committed by Simon Lejeune
Browse files

[IMP] mrp: Allow page-setting fields for pdf widget

This revision allows the page number of a pdf file to be set via an
integer field. If the pdf widget is attached to the 'field' field, then
the page can be changed via the 'field_page' field.
parent 0c7d4b64
Branches
Tags
No related merge requests found
......@@ -46,10 +46,11 @@ var FieldPdfViewer = FieldBinaryFile.extend({
field: this.name,
id: this.res_id,
};
var page = this.recordData[this.name + '_page'] || 1;
var queryString = $.param(queryObj);
var url = encodeURIComponent('/web/image?' + queryString);
var viewerURL = '/web/static/lib/pdfjs/web/viewer.html?file=';
return viewerURL + url;
return viewerURL + url + '#page=' + page;
},
/**
* @private
......
......@@ -80,7 +80,7 @@ QUnit.module('mrp', {
assert.notOk(form.$('.o_field_widget iframe.o_pdfview_iframe').hasClass('o_hidden'),
"there should be an visible iframe");
assert.strictEqual(form.$('.o_field_widget iframe.o_pdfview_iframe').attr('data-src'),
'/web/static/lib/pdfjs/web/viewer.html?file=%2Fweb%2Fimage%3Fmodel%3Dpartner%26field%3Ddocument%26id%3D1',
'/web/static/lib/pdfjs/web/viewer.html?file=%2Fweb%2Fimage%3Fmodel%3Dpartner%26field%3Ddocument%26id%3D1#page=1',
"the src attribute should be correctly set on the iframe");
form.destroy();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment