|
91 | 91 | originalDataset = dataset; |
92 | 92 | datasetId = dataset.id; |
93 | 93 | datasetName = dataset.name; |
94 | | - if (datasetTypes.indexOf(dataset.type) !== -1) { |
| 94 | + if (!dataset.type || datasetTypes.indexOf(dataset.type) !== -1) { |
95 | 95 | datasetTypeOption = 'standard'; |
96 | | - datasetType = dataset.type; |
| 96 | + datasetType = dataset.type || ""; |
97 | 97 | customDatasetType = ''; |
98 | 98 | } else { |
99 | 99 | datasetTypeOption = 'custom'; |
100 | 100 | datasetType = ''; |
101 | | - customDatasetType = dataset.type; |
| 101 | + customDatasetType = dataset.type || ""; |
102 | 102 | } |
103 | 103 | readonly = dataset.readonly; |
104 | 104 | resources = dataset.resource_list.map((r) => { |
|
154 | 154 | headers, |
155 | 155 | body: JSON.stringify({ |
156 | 156 | name: datasetName, |
157 | | - type: datasetType, |
| 157 | + type: getDatasetType(), |
158 | 158 | read_only: readonly, |
159 | 159 | meta: {} |
160 | 160 | }) |
|
177 | 177 | headers, |
178 | 178 | body: JSON.stringify({ |
179 | 179 | name: datasetName, |
180 | | - type: datasetTypeOption === 'standard' ? datasetType : customDatasetType, |
| 180 | + type: getDatasetType(), |
181 | 181 | read_only: readonly, |
182 | 182 | meta: {} |
183 | 183 | }) |
|
365 | 365 | return false; |
366 | 366 | } |
367 | 367 | } |
368 | | - return datasetName && getDatasetType(); |
| 368 | + return datasetName; |
369 | 369 | } |
370 | 370 |
|
371 | 371 | function getDatasetType() { |
372 | 372 | if (datasetTypeOption === 'custom') { |
373 | | - return customDatasetType; |
| 373 | + return customDatasetType || undefined; |
374 | 374 | } |
375 | | - return datasetType; |
| 375 | + return datasetType || undefined; |
376 | 376 | } |
377 | 377 |
|
378 | 378 | function handleResourceKeyDown(/** @type {KeyboardEvent} */ event, /** @type {number} */ index) { |
|
442 | 442 | id="datasetType" |
443 | 443 | bind:value={datasetType} |
444 | 444 | class="form-control" |
445 | | - class:is-invalid={submitted && !datasetType} |
446 | 445 | > |
447 | 446 | <option value="">Select...</option> |
448 | 447 | {#each datasetTypes as allowedType} |
449 | 448 | <option>{allowedType}</option> |
450 | 449 | {/each} |
451 | 450 | </select> |
452 | | - {#if submitted && !datasetType} |
453 | | - <div class="invalid-feedback">Required field</div> |
454 | | - {/if} |
455 | 451 | {:else} |
456 | 452 | <input |
457 | 453 | id="customDatasetType" |
458 | 454 | type="text" |
459 | 455 | bind:value={customDatasetType} |
460 | 456 | class="form-control" |
461 | | - class:is-invalid={submitted && !customDatasetType} |
462 | 457 | placeholder="Your custom type" |
463 | 458 | /> |
464 | | - {#if submitted && !customDatasetType} |
465 | | - <div class="invalid-feedback">Required field</div> |
466 | | - {/if} |
467 | 459 | {/if} |
468 | 460 | </div> |
469 | 461 | </div> |
|
0 commit comments