0
1
Fork 0

Download disabled for unavailable invoice PDFs

This commit is contained in:
Juan 2018-07-02 14:54:37 +02:00
parent 81a31a8674
commit 1395532b6c
13 changed files with 100 additions and 70 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.406.12) stable; urgency=low
hedera-web (1.406.13) stable; urgency=low
* Initial Release.

View File

@ -1,21 +1,30 @@
Hedera.Invoices = new Class
({
Extends: Hedera.Form
Hedera.Invoices = new Class({
Extends: Hedera.Form,
,onDownloadClick: function (column, invoiceId)
{
if (!invoiceId)
return;
var params = {
'srv': 'rest:dms/invoice'
,'invoice': invoiceId
,'token': this.conn.token
};
var url = '?'+ Vn.Url.makeUri (params);
window.open (url, '_blank');
donwloadRenderer: function(column, invoice) {
var invoiceId = invoice.get('id');
if (invoice.get('pdf') && invoiceId) {
var params = {
srv: 'rest:dms/invoice',
invoice: invoiceId,
token: this.conn.token
};
Object.assign(column, {
tip: _('Download PDF'),
disabled: false,
icon: 'download',
href: '?'+ Vn.Url.makeUri (params)
});
} else
Object.assign(column, {
tip: _('Request the invoice to your salesperson'),
disabled: true,
icon: 'warning',
href: null
});
}
});

View File

@ -3,3 +3,4 @@ Serial: Sèrie
Date: Data
Import: Import
Donwload PDF: Descarregar PDF
Request the invoice to your salesperson: Sol·licita la factura al teu comercial

View File

@ -3,3 +3,4 @@ Serial: Serial
Date: Date
Import: Import
Download PDF: Download PDF
Request the invoice to your salesperson: Request the invoice to your salesperson

View File

@ -3,3 +3,4 @@ Serial: Serie
Date: Fecha
Import: Importe
Download PDF: Descargar PDF
Request the invoice to your salesperson: Solicita la factura a tu comercial

View File

@ -3,3 +3,4 @@ Serial: Série
Date: Date
Import: Montant
Donwload PDF: Télécharger le PDF
Request the invoice to your salesperson: Demander la facture à votre commercial

View File

@ -3,3 +3,4 @@ Serial: Serie
Date: Data
Import: Importe
Download PDF: Baixar PDF
Request the invoice to your salesperson: Solicite a fatura ao seu comercial

View File

@ -7,7 +7,7 @@
<div>
<htk-grid show-header="false">
<db-model property="model" id="tickets">
SELECT id, ref, issued, amount
SELECT id, ref, issued, amount, pdf
FROM myInvoice
ORDER BY issued DESC
LIMIT 100
@ -16,10 +16,8 @@
<htk-column-date title="_Date" column="issued" format="_%e %b %Y"/>
<htk-column-spin title="_Import" column="amount" unit="€" digits="2"/>
<htk-column-button
column="id"
icon="download"
tip="_Download PDF"
on-clicked="onDownloadClick"/>
renderer="donwloadRenderer"
target="_blank"/>
</htk-grid>
</div>
</div>

View File

@ -85,10 +85,9 @@ module.exports = new Class
/**
* Draws the cell and returns its associated td.
*
* @param {HTMLTableRow} tr the table row
* @return {HTMLTableData} the rendered cell
**/
,render: function (tr)
,render: function ()
{
var td = this.td.cloneNode (true);

View File

@ -1,65 +1,78 @@
module.exports = new Class
({
Extends: Htk.Column
,Tag: 'htk-column-button'
,Properties:
{
image:
{
module.exports = new Class({
Extends: Htk.Column,
Tag: 'htk-column-button',
Properties: {
image: {
type: String
,value: null
},
icon:
{
icon: {
type: String
,set: function (x)
,set: function(x)
{
this._icon = x;
this.image = 'image/icon/light/'+ x + '.svg';
this.image = 'image/icon/light/'+ x +'.svg';
}
,get: function ()
,get: function()
{
return this._icon;
}
},
tip:
{
type: String
,value: null
tip: {
type: String,
value: null
},
disabled: {
type: Boolean,
value: false
},
href: {
type: String,
value: null
},
target: {
type: String,
value: ''
}
}
},
,initialize: function (props)
{
initialize: function(props) {
this._cssClass = 'cell-button';
this.parent (props);
}
this.parent(props);
},
,render: function (tr)
{
var td = this.parent (tr);
render: function(tr) {
var td = this.parent(tr);
var button = this.createElement ('button');
button.addEventListener ('click',
this.buttonClicked.bind (this, this.value, tr, button));
td.appendChild (button);
var button;
if (this.href == null) {
button = this.createElement('button');
button.addEventListener('click',
this.buttonClicked.bind(this, this.value, tr, button));
} else {
button = this.createElement('a');
button.href = this.href;
button.target = this.target;
}
var img = this.createElement ('img');
button.disabled = this.disabled;
td.appendChild(button);
var img = this.createElement('img');
img.src = this.image;
button.appendChild (img);
button.appendChild(img);
if (this.tip)
{
if (this.tip) {
button.title = _(this.tip);
img.title = _(this.tip);
}
return td;
}
},
,buttonClicked: function (value, tr, button)
{
this.signalEmit ('clicked', value, tr.rowIndex - 1, button);
buttonClicked: function(value, tr, button) {
this.signalEmit('clicked', value, tr.rowIndex - 1, button);
}
});

View File

@ -108,7 +108,7 @@ module.exports = new Class
this.showNoRecordsFound ();
}
,onRowInsert: function (model, row)
,onRowInsert: function (model)
{
this.buildRow (1);
}
@ -225,7 +225,7 @@ module.exports = new Class
this._node.appendChild (this.tbody);
}
,showNoRecordsFound: function (count)
,showNoRecordsFound: function ()
{
if (this._model.numRows == 0)
this.showMessage (_('EmptyList'), 'clean');

View File

@ -99,26 +99,32 @@ th.cell-radio
}
td.cell-button
{
max-width: 2em;
max-width: 1em;
text-align: center;
}
td.cell-button > button
td.cell-button > button,
td.cell-button > a
{
margin: 0;
padding: 0.5em;
display: inline-block;
margin: 0 auto;
padding: .5em;
border: none;
background-color: transparent;
border-radius: 0.1em;
border-radius: .1em;
box-sizing: border-box;
}
td.cell-button > button:hover
td.cell-button > button:hover,
td.cell-button > a:hover
{
background-color: rgba(1, 1, 1, 0.1);
}
td.cell-button img
{
height: 1.5em;
width: 1.5em;
display: block;
margin: auto;
padding: 0;
}
td.cell-image
{

View File

@ -1,6 +1,6 @@
{
"name": "hedera-web",
"version": "1.406.12",
"version": "1.406.13",
"description": "Verdnatura web page",
"license": "GPL-3.0",
"repository": {