@things-factory/sales-ui 4.2.2 → 4.2.6
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@things-factory/form-ui'
|
|
2
2
|
import '@things-factory/grist-ui'
|
|
3
|
-
|
|
3
|
+
import { GhostPrint } from '@operato/ghost-print'
|
|
4
4
|
import gql from 'graphql-tag'
|
|
5
5
|
import { css, html } from 'lit-element'
|
|
6
6
|
|
|
@@ -10,6 +10,10 @@ import { client, navigate, PageView } from '@things-factory/shell'
|
|
|
10
10
|
import { CommonButtonStyles, ScrollbarStyles } from '@things-factory/styles'
|
|
11
11
|
import { isMobileDevice } from '@things-factory/utils'
|
|
12
12
|
|
|
13
|
+
const HEADER_JSON = {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
Accept: 'application/json'
|
|
16
|
+
}
|
|
13
17
|
class PurchaseOrderList extends localize(i18next)(PageView) {
|
|
14
18
|
static get styles() {
|
|
15
19
|
return [
|
|
@@ -57,6 +61,11 @@ class PurchaseOrderList extends localize(i18next)(PageView) {
|
|
|
57
61
|
return {
|
|
58
62
|
title: i18next.t('title.purchase_orders'),
|
|
59
63
|
actions: [
|
|
64
|
+
{
|
|
65
|
+
title: i18next.t('button.print_purchase_order'),
|
|
66
|
+
action: this._printPurchaseOrders.bind(this),
|
|
67
|
+
...CommonButtonStyles.label
|
|
68
|
+
},
|
|
60
69
|
{
|
|
61
70
|
title: i18next.t('button.create_purchase_order'),
|
|
62
71
|
action: this._navigateToCreate.bind(this),
|
|
@@ -142,6 +151,7 @@ class PurchaseOrderList extends localize(i18next)(PageView) {
|
|
|
142
151
|
columns: [
|
|
143
152
|
{ type: 'gutter', gutterName: 'dirty' },
|
|
144
153
|
{ type: 'gutter', gutterName: 'sequence' },
|
|
154
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
145
155
|
{
|
|
146
156
|
type: 'gutter',
|
|
147
157
|
gutterName: 'button',
|
|
@@ -316,6 +326,58 @@ class PurchaseOrderList extends localize(i18next)(PageView) {
|
|
|
316
326
|
navigate(`purchase_order_detail/new`)
|
|
317
327
|
}
|
|
318
328
|
|
|
329
|
+
_showToast({ type, message }) {
|
|
330
|
+
document.dispatchEvent(
|
|
331
|
+
new CustomEvent('notify', {
|
|
332
|
+
detail: {
|
|
333
|
+
type,
|
|
334
|
+
message
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async _printPurchaseOrders() {
|
|
341
|
+
try {
|
|
342
|
+
if (this.dataGrist.selected && this.dataGrist.selected.length > 0) {
|
|
343
|
+
var timezoneOffSet = new Date().getTimezoneOffset().toString()
|
|
344
|
+
let url = new URL(window.location)
|
|
345
|
+
|
|
346
|
+
let data = await Promise.all(
|
|
347
|
+
this.dataGrist.selected.map(async x => {
|
|
348
|
+
return x.id
|
|
349
|
+
})
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
let response = await fetch(`/view_purchase_orders/${timezoneOffSet}`, {
|
|
353
|
+
method: 'POST',
|
|
354
|
+
credentials: 'include',
|
|
355
|
+
headers: HEADER_JSON,
|
|
356
|
+
body: JSON.stringify({ poIds: data })
|
|
357
|
+
}).then(function (response) {
|
|
358
|
+
return response.text()
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
this._callPrintDialog(response)
|
|
362
|
+
|
|
363
|
+
// navigate(`print_invoices/${data}`)
|
|
364
|
+
} else {
|
|
365
|
+
throw new Error(`Please select a record.`)
|
|
366
|
+
}
|
|
367
|
+
} catch (e) {
|
|
368
|
+
this._showToast(e)
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
async _callPrintDialog(contentSource) {
|
|
373
|
+
GhostPrint.print({
|
|
374
|
+
srcdoc: contentSource,
|
|
375
|
+
onfinish: () => {
|
|
376
|
+
this._showToast({ message: i18next.t('text.document_has_been_generated') })
|
|
377
|
+
}
|
|
378
|
+
})
|
|
379
|
+
}
|
|
380
|
+
|
|
319
381
|
async _fetchContactPoints() {
|
|
320
382
|
const response = await client.query({
|
|
321
383
|
query: gql`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/sales-ui",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.6",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@things-factory/grist-ui": "^4.1.40",
|
|
30
30
|
"@things-factory/i18n-base": "^4.1.40",
|
|
31
31
|
"@things-factory/import-ui": "^4.1.40",
|
|
32
|
-
"@things-factory/sales-base": "^4.2.
|
|
32
|
+
"@things-factory/sales-base": "^4.2.6",
|
|
33
33
|
"@things-factory/setting-ui": "^4.1.40",
|
|
34
34
|
"@things-factory/shell": "^4.1.40",
|
|
35
|
-
"@things-factory/warehouse-ui": "^4.2.
|
|
35
|
+
"@things-factory/warehouse-ui": "^4.2.6"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "a6ae8ce83ac935693632447e58012bd2d5aee512"
|
|
38
38
|
}
|