@mixd-id/web-scaffold 0.1.240411104 → 0.1.240411106

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.240411104",
4
+ "version": "0.1.240411106",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -372,7 +372,7 @@ export default{
372
372
  },
373
373
 
374
374
  load(){
375
- if(this.computedSrc){
375
+ if(this.computedSrc && this.preset){
376
376
  if(!this.preset.columns){
377
377
  this.preset.columns = JSON.parse(JSON.stringify(this.cConfig.columns))
378
378
  }
@@ -399,7 +399,7 @@ export default{
399
399
  },
400
400
 
401
401
  loadNext(){
402
- if(this.computedSrc && this.readyState !== 4 &&
402
+ if(this.computedSrc && this.preset && this.readyState !== 4 &&
403
403
  ((this.data ?? {}).hasNext !== false) &&
404
404
  !(this.preset.pivot ?? {}).enabled &&
405
405
  this.dataItems) {
@@ -472,7 +472,7 @@ export default{
472
472
  },
473
473
 
474
474
  async loadEnums(items){
475
- if(!items) return
475
+ if(!items || !this.preset) return
476
476
 
477
477
  return Promise.all((this.preset.columns ?? []).map(async column => {
478
478
 
@@ -523,7 +523,7 @@ export default{
523
523
  },
524
524
 
525
525
  loadExt(){
526
- if(!this.extBar.open) return
526
+ if(!this.extBar.open || !this.preset) return
527
527
 
528
528
  this.readyState = 3
529
529
  return this.useSocket().send(this.computedSrc, {
@@ -543,7 +543,7 @@ export default{
543
543
  },
544
544
 
545
545
  loadExtNext(){
546
- if(!this.preset.filters) return
546
+ if(!this.preset?.filters) return
547
547
 
548
548
  return this.useSocket().send(this.computedSrc, {
549
549
  ...this.preset,
@@ -626,7 +626,7 @@ export default{
626
626
  return sortsFn(a, b, this.sorts, 0)
627
627
  })
628
628
  }
629
- else if((this.preset.sorts ?? []).length > 0){
629
+ else if((this.preset?.sorts ?? []).length > 0){
630
630
  return (items ?? []).sort((a, b) => {
631
631
  return sortsFn(a, b, this.preset.sorts, 0)
632
632
  })
@@ -636,6 +636,8 @@ export default{
636
636
  },
637
637
 
638
638
  loadQueued(items){
639
+ if(!this.preset) return
640
+
639
641
  const key = items[0] && items[0].uid ? 'uid' : 'id'
640
642
 
641
643
  this.useSocket().send(this.computedSrc, {
@@ -698,7 +700,7 @@ export default{
698
700
  const key = pivotRow.key
699
701
  const presetColumn = this.preset.columns.find(_ => _.key === key)
700
702
  let value = item[pivotRow.key]
701
- switch(presetColumn.type){
703
+ switch(presetColumn?.type){
702
704
 
703
705
  case 'bool':
704
706
  case 'boolean':
@@ -380,7 +380,7 @@ export default{
380
380
  .modal{
381
381
  @apply fixed;
382
382
  @apply bg-base-400 dark:bg-base-300;
383
- @apply border-[1px] border-text-50 flex max-h-[90vh] max-w-full;
383
+ @apply border-[1px] border-text-50 flex md:max-w-[95vw] max-h-[90vh] max-w-full;
384
384
  @apply rounded-xl overflow-hidden transition-all;
385
385
  z-index: 101;
386
386
  }
@@ -32,6 +32,10 @@ const getCellText = (cell, image) => {
32
32
 
33
33
  const cellKey = (row, col) => row + ',' + col
34
34
 
35
+ // Header labels often carry stray padding in the source file ("TEKS PROGRAM "),
36
+ // normalise them so the column mapping does not depend on it
37
+ const columnName = (value) => `${value ?? ''}`.trim()
38
+
35
39
  // Maps the cell an image is anchored on to its media entry ({ buffer, extension, name }).
36
40
  // Only the top left anchor counts, an image spilling over its neighbours stays on one cell.
37
41
  const getWorksheetImages = (workbook, worksheet) => {
@@ -118,10 +122,10 @@ const analyseRequest = async(req) => {
118
122
  header.eachCell((cell) => {
119
123
  if(cell.isMerged){
120
124
  const sub = worksheet.getCell(cell.address.replace(/\d/g, '') + '2').value
121
- columns.push(cell.value + '>' + sub)
125
+ columns.push(columnName(cell.value) + '>' + columnName(sub))
122
126
  }
123
127
  else{
124
- columns.push(cell.value)
128
+ columns.push(columnName(cell.value))
125
129
  }
126
130
  })
127
131
 
@@ -190,11 +194,11 @@ const importRequest = async(req) => {
190
194
  header.eachCell((cell, index) => {
191
195
  if(cell.isMerged){
192
196
  const sub = worksheet.getCell(cell.address.replace(/\d/g, '') + '2').value
193
- columnAddress[cell.value + '>' + sub] = index
197
+ columnAddress[columnName(cell.value) + '>' + columnName(sub)] = index
194
198
  rowStart = 3
195
199
  }
196
200
  else{
197
- columnAddress[cell.value] = index
201
+ columnAddress[columnName(cell.value)] = index
198
202
  }
199
203
  })
200
204
 
@@ -227,8 +231,9 @@ const importRequest = async(req) => {
227
231
  let isItalic = false
228
232
  for(let idx in keys){
229
233
  const key = keys[idx]
230
- if(key.value && columnAddress[key.value]){
231
- const cell = row.getCell(columnAddress[key.value])
234
+ const address = columnAddress[columnName(key.value)]
235
+ if(key.value && address){
236
+ const cell = row.getCell(address)
232
237
  if(cell.font && cell.font.italic){
233
238
  isItalic = true
234
239
  break
@@ -243,9 +248,10 @@ const importRequest = async(req) => {
243
248
  if(keys){
244
249
  for(let idx in keys){
245
250
  const key = keys[idx]
246
- if(key.value && columnAddress[key.value]){
247
- const cell = row.getCell(columnAddress[key.value])
248
- obj[key.key] = getCellText(cell, cellImages.get(cellKey(index, columnAddress[key.value])))
251
+ const address = columnAddress[columnName(key.value)]
252
+ if(key.value && address){
253
+ const cell = row.getCell(address)
254
+ obj[key.key] = getCellText(cell, cellImages.get(cellKey(index, address)))
249
255
  }
250
256
  }
251
257
  }