+ {#each stringList as value, index}
+
+ {
+ const newValues = stringList.map((v, i) => (i === index ? e.target['value'] : v));
+ setFieldValue(name, newValues);
+ }}
+ />
+
+ {
+ setFieldValue(name, [...stringList.slice(0, index), ...stringList.slice(index + 1)]);
+ }}
+ >
+
+
+
+ {/each}
+
+ {
+ setFieldValue(name, [...stringList, '']);
+ }}
+ />
+
+
+
\ No newline at end of file
diff --git a/packages/web/src/modals/NewCollectionModal.svelte b/packages/web/src/modals/NewCollectionModal.svelte
index 4f48026b..17c117d3 100644
--- a/packages/web/src/modals/NewCollectionModal.svelte
+++ b/packages/web/src/modals/NewCollectionModal.svelte
@@ -5,15 +5,39 @@
import FormProvider from '../forms/FormProvider.svelte';
import FormSubmit from '../forms/FormSubmit.svelte';
import FormTextField from '../forms/FormTextField.svelte';
+ import { apiCall } from '../utility/api';
+ import { showSnackbarSuccess } from '../utility/snackbar';
+ import ErrorMessageModal from './ErrorMessageModal.svelte';
import ModalBase from './ModalBase.svelte';
- import { closeCurrentModal } from './modalTools';
+ import { closeCurrentModal, showModal } from './modalTools';
- export let onConfirm;
export let driver;
+ export let dbid;
+
+ let isSaving = false;
const handleSubmit = async values => {
- closeCurrentModal();
- onConfirm(values);
+ isSaving = true;
+ try {
+ const resp = await apiCall('database-connections/run-operation', {
+ ...dbid,
+ operation: {
+ type: 'createCollection',
+ collection: values,
+ },
+ });
+
+ const { errorMessage } = resp || {};
+ if (errorMessage) {
+ showModal(ErrorMessageModal, { title: 'Error when executing operation', message: errorMessage });
+ } else {
+ showSnackbarSuccess('Saved to database');
+ apiCall('database-connections/sync-model', dbid);
+ closeCurrentModal();
+ }
+ } finally {
+ isSaving = false;
+ }
};
@@ -26,7 +50,7 @@