@things-factory/import-ui 4.3.767 → 4.3.790

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.
@@ -14,7 +14,9 @@ class ImportPopUp extends localize(i18next)(LitElement) {
14
14
  config: Object,
15
15
  _config: Object,
16
16
  records: Array,
17
- enableDirectInbound: Boolean
17
+ enableDirectInbound: Boolean,
18
+ enableRowErrors: Boolean,
19
+ _importing: Boolean
18
20
  }
19
21
  }
20
22
 
@@ -62,6 +64,26 @@ class ImportPopUp extends localize(i18next)(LitElement) {
62
64
  return this.shadowRoot.querySelector('data-grist')
63
65
  }
64
66
 
67
+ _blockClose() {
68
+ if (this._originalHistoryBack) return
69
+ this._originalHistoryBack = history.back.bind(history)
70
+ history.back = () => {
71
+ // Blocked — import in progress
72
+ }
73
+ }
74
+
75
+ _unblockClose() {
76
+ if (this._originalHistoryBack) {
77
+ history.back = this._originalHistoryBack
78
+ this._originalHistoryBack = null
79
+ }
80
+ }
81
+
82
+ disconnectedCallback() {
83
+ super.disconnectedCallback()
84
+ this._unblockClose()
85
+ }
86
+
65
87
  render() {
66
88
  return html`
67
89
  <div class="grist">
@@ -70,7 +92,10 @@ class ImportPopUp extends localize(i18next)(LitElement) {
70
92
 
71
93
  <div class="button-container">
72
94
  <mwc-button
95
+ ?disabled=${this._importing}
73
96
  @click=${async () => {
97
+ if (this._importing) return
98
+
74
99
  const patches = this.getCurrentRecord()
75
100
  if (patches.length) {
76
101
  const answer = await CustomAlert({
@@ -82,7 +107,26 @@ class ImportPopUp extends localize(i18next)(LitElement) {
82
107
 
83
108
  if (!answer.value) return
84
109
 
85
- this.importHandler(patches)
110
+ this._importing = true
111
+ this._blockClose()
112
+ this.dataGrist.showSpinner()
113
+ try {
114
+ const result = await this.importHandler(patches)
115
+ this._unblockClose()
116
+ if (Array.isArray(result)) {
117
+ this.records = result
118
+ this.dataGrist.data = { records: result, total: result.length }
119
+ } else {
120
+ // Success — handler returned undefined/null, close popup
121
+ history.back()
122
+ }
123
+ } catch (e) {
124
+ this._unblockClose()
125
+ // Handler threw — it already showed a toast
126
+ } finally {
127
+ this._importing = false
128
+ this.dataGrist.hideSpinner()
129
+ }
86
130
  } else {
87
131
  CustomAlert({
88
132
  title: i18next.t('text.nothing_selected'),
@@ -92,7 +136,7 @@ class ImportPopUp extends localize(i18next)(LitElement) {
92
136
  }}
93
137
  >${i18next.t('button.import')}</mwc-button
94
138
  >
95
- <mwc-button @click=${e => history.back()}>${i18next.t('button.cancel')}</mwc-button>
139
+ <mwc-button ?disabled=${this._importing} @click=${e => { if (!this._importing) history.back() }}>${i18next.t('button.cancel')}</mwc-button>
96
140
  </div>
97
141
  `
98
142
  }
@@ -106,7 +150,7 @@ class ImportPopUp extends localize(i18next)(LitElement) {
106
150
  pagination: { infinite: true },
107
151
  columns: [{ type: 'gutter', gutterName: 'row-selector', multiple: true }, ...columns]
108
152
  }
109
- if(this.enableDirectInbound){
153
+ if(this.enableDirectInbound || this.enableRowErrors){
110
154
  this._config.rows = {
111
155
  appendable: false,
112
156
  classifier: (record, rowIndex) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/import-ui",
3
- "version": "4.3.767",
3
+ "version": "4.3.790",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,10 +24,10 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@things-factory/context-base": "^4.3.767",
27
- "@things-factory/grist-ui": "^4.3.767",
27
+ "@things-factory/grist-ui": "^4.3.770",
28
28
  "@things-factory/i18n-base": "^4.3.767",
29
29
  "@things-factory/import-base": "^4.3.767",
30
30
  "@things-factory/layout-base": "^4.3.767"
31
31
  },
32
- "gitHead": "065b02059d800f6a759a98c240fed8608b48a52c"
32
+ "gitHead": "aac8be0c440911f309204b31d37d0b9fabd0c451"
33
33
  }