|
15 | 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | 16 | ********************************************************************************/ |
17 | 17 |
|
18 | | -// Commercial Licensing Information: |
19 | | -// For commercial use of this software without the copyleft provisions of the AGPLv3, |
20 | | -// you must obtain a commercial license from CoCreate LLC. |
21 | | -// For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app. |
| 18 | +/** |
| 19 | + * Commercial Licensing Information: |
| 20 | + * For commercial use of this software without the copyleft provisions of the AGPLv3, |
| 21 | + * you must obtain a commercial license from CoCreate LLC. |
| 22 | + * For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app. |
| 23 | + */ |
22 | 24 |
|
23 | 25 | import Observer from '@cocreate/observer'; |
24 | 26 | import Crud from '@cocreate/crud-client'; |
@@ -406,18 +408,16 @@ async function upload(element, data) { |
406 | 408 | } |
407 | 409 | } |
408 | 410 |
|
409 | | - let action = 'update' + Data.type.charAt(0).toUpperCase() + Data.type.slice(1) |
410 | | - if (Crud[action]) { |
411 | | - let response = await Crud[action](Data)({ |
412 | | - array, |
413 | | - object, |
414 | | - upsert: true |
415 | | - }); |
416 | | - |
417 | | - data.push(response) |
418 | | - if (response && (!object || object !== response.object)) { |
419 | | - Elements.setTypeValue(element, response); |
420 | | - } |
| 411 | + Data.method = 'update.' + Data.type |
| 412 | + let response = await Crud.send(Data)({ |
| 413 | + array, |
| 414 | + object, |
| 415 | + upsert: true |
| 416 | + }); |
| 417 | + |
| 418 | + data.push(response) |
| 419 | + if (response && (!object || object !== response.object)) { |
| 420 | + Elements.setTypeValue(element, response); |
421 | 421 | } |
422 | 422 | } |
423 | 423 | } |
@@ -482,10 +482,8 @@ async function Import(element, data) { |
482 | 482 |
|
483 | 483 | if (data.length) { |
484 | 484 | for (let i = 0; i < data.length; i++) { |
485 | | - let action = 'create' + data[i].type.charAt(0).toUpperCase() + data[i].type.slice(1) |
486 | | - if (Crud[action]) { |
487 | | - data[i] = await Crud[action](data[i]) |
488 | | - } |
| 485 | + data[i].method = 'create.' + data[i].type |
| 486 | + data[i] = await Crud.send(data[i]) |
489 | 487 | } |
490 | 488 | } |
491 | 489 |
|
@@ -527,11 +525,10 @@ async function Export(element, data) { |
527 | 525 |
|
528 | 526 | if (Data.type === 'key') |
529 | 527 | Data.type = 'object' |
530 | | - let action = 'read' + Data.type.charAt(0).toUpperCase() + Data.type.slice(1) |
531 | | - if (Crud[action]) { |
532 | | - Data = await Crud[action](Data) |
533 | | - data.push(...Data[Data.type]) |
534 | | - } |
| 528 | + Data.method = 'read.' + Data.type |
| 529 | + Data = await Crud.send(Data) |
| 530 | + data.push(...Data[Data.type]) |
| 531 | + |
535 | 532 | } |
536 | 533 |
|
537 | 534 | let queriedElements = queryElements({ element: element[i], prefix: 'export' }) |
|
0 commit comments