From f8c9cc433101426c33f94eaddbdbdb64e0517372 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 18 Jun 2020 17:44:42 +0100 Subject: [PATCH] save button --- .../ModelDataTable/ModelDataTable.svelte | 10 ++ .../nav/ModelSetupNav/ModelFieldEditor.svelte | 24 +++-- .../nav/ModelSetupNav/ModelSetupNav.svelte | 21 +++-- .../builder/src/constants/backend/index.js | 92 +++++++++---------- 4 files changed, 86 insertions(+), 61 deletions(-) diff --git a/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte b/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte index 2f02db9a6d..008c4eeed0 100644 --- a/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte +++ b/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte @@ -198,4 +198,14 @@ .no-data { padding: 20px; } + + .button-inner { + display: flex; + align-items: center; + } + + .button-inner i { + margin-right: 5px; + font-size: 20px; + } diff --git a/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte b/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte index 6e72fdb2fa..d76e782ee7 100644 --- a/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte +++ b/packages/builder/src/components/nav/ModelSetupNav/ModelFieldEditor.svelte @@ -39,7 +39,7 @@
-
+
@@ -66,12 +66,15 @@ label="Max Value" bind:value={field.constraints.numericality.lessThanOrEqualTo} /> {:else if field.type === 'link'} - +
+ + +
{/if}
@@ -87,10 +90,11 @@ font-size: 12px; } - .required-field { + .field { display: grid; align-items: center; grid-template-columns: 40% 1fr; + margin-top: 8px; } .field-box header { @@ -98,4 +102,8 @@ font-weight: 500; margin-bottom: 16px; } + + .field-box span { + font-weight: bold; + } diff --git a/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte b/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte index d82389ec66..2407ee7f60 100644 --- a/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte +++ b/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte @@ -19,9 +19,13 @@ }, ] + let edited = false + $: selectedTab = $backendUiStore.tabs.SETUP_PANEL $: edited = + $backendUiStore.selectedField || + $backendUiStore.draftModel && $backendUiStore.draftModel.name !== $backendUiStore.selectedModel.name async function deleteModel() { @@ -31,18 +35,16 @@ if (field) { delete model.schema[field] - backendUiStore.actions.models.save({ model, instanceId }); - notifier.danger(`Field ${field} deleted.`); - return; + backendUiStore.actions.models.save({ model, instanceId }) + notifier.danger(`Field ${field} deleted.`) + return } const DELETE_MODEL_URL = `/api/${instanceId}/models/${model._id}/${model._rev}` const response = await api.delete(DELETE_MODEL_URL) backendUiStore.update(state => { state.selectedView = null - state.models = state.models.filter( - ({ _id }) => _id !== model._id - ) + state.models = state.models.filter(({ _id }) => _id !== model._id) notifier.danger(`${model.name} deleted successfully.`) return state }) @@ -78,7 +80,9 @@
{/if} {:else if selectedTab === 'DELETE'}
@@ -96,6 +100,8 @@ footer { width: 100%; + position: fixed; + bottom: 20px; } .items-root { @@ -110,6 +116,7 @@ .titled-input { padding: 12px; background: var(--light-grey); + margin-bottom: 5px; } .titled-input header { diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 3973b09238..7cd7aeae31 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -30,52 +30,52 @@ export const FIELDS = { presence: false, }, }, - OPTIONS: { - name: "Options", - icon: "ri-list-check-2", - type: "options", - constraints: { - type: "string", - presence: false, - }, - }, - DATETIME: { - name: "Date/Time", - icon: "ri-calendar-event-fill", - type: "datetime", - constraints: { - type: "date", - datetime: {}, - presence: false, - }, - }, - IMAGE: { - name: "File", - icon: "ri-image-line", - type: "file", - constraints: { - type: "string", - presence: false, - }, - }, - FILE: { - name: "Image", - icon: "ri-file-line", - type: "file", - constraints: { - type: "string", - presence: false, - }, - }, - DATA_LINK: { - name: "Data Links", - icon: "ri-link", - type: "link", - modelId: null, - constraints: { - type: "array", - } - }, + // OPTIONS: { + // name: "Options", + // icon: "ri-list-check-2", + // type: "options", + // constraints: { + // type: "string", + // presence: false, + // }, + // }, + // DATETIME: { + // name: "Date/Time", + // icon: "ri-calendar-event-fill", + // type: "datetime", + // constraints: { + // type: "date", + // datetime: {}, + // presence: false, + // }, + // }, + // IMAGE: { + // name: "File", + // icon: "ri-image-line", + // type: "file", + // constraints: { + // type: "string", + // presence: false, + // }, + // }, + // FILE: { + // name: "Image", + // icon: "ri-file-line", + // type: "file", + // constraints: { + // type: "string", + // presence: false, + // }, + // }, + // DATA_LINK: { + // name: "Data Links", + // icon: "ri-link", + // type: "link", + // modelId: null, + // constraints: { + // type: "array", + // } + // }, } export const BLOCKS = {