@dvrd/dvr-controls 1.0.33 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ interface Props {
|
|
|
25
25
|
height?: number;
|
|
26
26
|
persistent?: PDFElementPersist;
|
|
27
27
|
mainFont: PdfFont;
|
|
28
|
+
tableHeaderLabels?: [string, string, string, string, string];
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
interface State {
|
|
@@ -147,14 +148,16 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
|
|
|
147
148
|
)
|
|
148
149
|
};
|
|
149
150
|
|
|
151
|
+
getTableHeaderLabels = (): [string, string, string, string, string] => {
|
|
152
|
+
const {tableHeaderLabels} = this.props;
|
|
153
|
+
if (tableHeaderLabels) return tableHeaderLabels;
|
|
154
|
+
return ['Omschrijving', 'Aantal', 'Bedrag', 'BTW', 'Subtotaal incl. BTW'];
|
|
155
|
+
}
|
|
156
|
+
|
|
150
157
|
render = () => {
|
|
151
|
-
const {dragging, settings} = this.state
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
width,
|
|
155
|
-
height,
|
|
156
|
-
onSaveHistory
|
|
157
|
-
} = this.props;
|
|
158
|
+
const {dragging, settings} = this.state;
|
|
159
|
+
const {draggable, defaultPosition, width, height, onSaveHistory} = this.props;
|
|
160
|
+
const headLabels = this.getTableHeaderLabels();
|
|
158
161
|
return (
|
|
159
162
|
<WithEvents events={this.event}>
|
|
160
163
|
<PDFDraggable dragging={dragging} draggable={draggable} onDragStart={this.onDragStart}
|
|
@@ -169,11 +172,11 @@ export default class PdfInvoiceTable extends PdfElement<Props, State> {
|
|
|
169
172
|
onResized={onSaveHistory} onDragged={onSaveHistory}>
|
|
170
173
|
<div className='pdf-invoice-table' onClick={this.onClick}>
|
|
171
174
|
<div className='invoice-line' style={this.getRowStyle(true)}>
|
|
172
|
-
<span>
|
|
173
|
-
<span>
|
|
174
|
-
<span>
|
|
175
|
-
<span>
|
|
176
|
-
<span className='end'>
|
|
175
|
+
<span>{headLabels[0]}</span>
|
|
176
|
+
<span>{headLabels[1]}</span>
|
|
177
|
+
<span>{headLabels[2]}</span>
|
|
178
|
+
<span>{headLabels[3]}</span>
|
|
179
|
+
<span className='end'>{headLabels[4]}</span>
|
|
177
180
|
</div>
|
|
178
181
|
{[1, 2].map(this.renderInvoiceLine)}
|
|
179
182
|
{this.renderTotals()}
|
|
@@ -49,6 +49,7 @@ interface Props {
|
|
|
49
49
|
options?: PDFOptions;
|
|
50
50
|
singleImage: boolean;
|
|
51
51
|
headerButtons?: Array<ReactElement>;
|
|
52
|
+
tableHeaderLabels?: [string, string, string, string, string];
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
interface State {
|
|
@@ -203,7 +204,7 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
203
204
|
};
|
|
204
205
|
const width = dimensions?.width;
|
|
205
206
|
const height = dimensions?.height;
|
|
206
|
-
const {values, mainFont} = this.props;
|
|
207
|
+
const {values, mainFont, tableHeaderLabels} = this.props;
|
|
207
208
|
const key: string = generateUUID();
|
|
208
209
|
const sharedProps = {
|
|
209
210
|
defaultPosition: position,
|
|
@@ -230,7 +231,8 @@ export default class PDFTemplateCreator extends PureComponent<Props, State> {
|
|
|
230
231
|
break;
|
|
231
232
|
case PDFElementType.INVOICE_TABLE:
|
|
232
233
|
element = <PdfInvoiceTable {...sharedProps} width={width} height={height} mainFont={mainFont}
|
|
233
|
-
persistent={PDFElementPersist.PERSISTENT}
|
|
234
|
+
persistent={PDFElementPersist.PERSISTENT}
|
|
235
|
+
tableHeaderLabels={tableHeaderLabels}/>;
|
|
234
236
|
break;
|
|
235
237
|
}
|
|
236
238
|
return {element, config};
|
package/src/js/util/miscUtil.ts
CHANGED
|
@@ -136,8 +136,13 @@ export const shuffleArray = (arr: any[]): any[] => {
|
|
|
136
136
|
return arr;
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
export const nullify = <T extends string | Array<any>>(value?: T | null): T | null => {
|
|
140
|
-
|
|
139
|
+
export const nullify = <T extends string | Array<any> | Set<any>>(value?: T | null): T | null => {
|
|
140
|
+
if (!value) return null;
|
|
141
|
+
else if (Array.isArray(value) || typeof value === 'string')
|
|
142
|
+
return value.length ? value : null;
|
|
143
|
+
else if (value instanceof Set)
|
|
144
|
+
return value.size ? value : null;
|
|
145
|
+
return null;
|
|
141
146
|
};
|
|
142
147
|
|
|
143
148
|
export const undefine = (value?: string | null): string | undefined => {
|