save button

This commit is contained in:
Martin McKeaveney 2020-06-18 17:44:42 +01:00
parent 7428dd40fc
commit f8c9cc4331
4 changed files with 86 additions and 61 deletions

View File

@ -198,4 +198,14 @@
.no-data { .no-data {
padding: 20px; padding: 20px;
} }
.button-inner {
display: flex;
align-items: center;
}
.button-inner i {
margin-right: 5px;
font-size: 20px;
}
</style> </style>

View File

@ -39,7 +39,7 @@
</div> </div>
<div class="info"> <div class="info">
<div class="required-field"> <div class="field">
<label>Required</label> <label>Required</label>
<input type="checkbox" /> <input type="checkbox" />
</div> </div>
@ -66,12 +66,15 @@
label="Max Value" label="Max Value"
bind:value={field.constraints.numericality.lessThanOrEqualTo} /> bind:value={field.constraints.numericality.lessThanOrEqualTo} />
{:else if field.type === 'link'} {:else if field.type === 'link'}
<select class="budibase__input" bind:value={field.modelId}> <div class="field">
<option value={''} /> <label>Link</label>
{#each $backendUiStore.models as model} <select class="budibase__input" bind:value={field.modelId}>
<option value={model._id}>{model.name}</option> <option value={''} />
{/each} {#each $backendUiStore.models as model}
</select> <option value={model._id}>{model.name}</option>
{/each}
</select>
</div>
{/if} {/if}
</div> </div>
@ -87,10 +90,11 @@
font-size: 12px; font-size: 12px;
} }
.required-field { .field {
display: grid; display: grid;
align-items: center; align-items: center;
grid-template-columns: 40% 1fr; grid-template-columns: 40% 1fr;
margin-top: 8px;
} }
.field-box header { .field-box header {
@ -98,4 +102,8 @@
font-weight: 500; font-weight: 500;
margin-bottom: 16px; margin-bottom: 16px;
} }
.field-box span {
font-weight: bold;
}
</style> </style>

View File

@ -19,9 +19,13 @@
}, },
] ]
let edited = false
$: selectedTab = $backendUiStore.tabs.SETUP_PANEL $: selectedTab = $backendUiStore.tabs.SETUP_PANEL
$: edited = $: edited =
$backendUiStore.selectedField ||
$backendUiStore.draftModel &&
$backendUiStore.draftModel.name !== $backendUiStore.selectedModel.name $backendUiStore.draftModel.name !== $backendUiStore.selectedModel.name
async function deleteModel() { async function deleteModel() {
@ -31,18 +35,16 @@
if (field) { if (field) {
delete model.schema[field] delete model.schema[field]
backendUiStore.actions.models.save({ model, instanceId }); backendUiStore.actions.models.save({ model, instanceId })
notifier.danger(`Field ${field} deleted.`); notifier.danger(`Field ${field} deleted.`)
return; return
} }
const DELETE_MODEL_URL = `/api/${instanceId}/models/${model._id}/${model._rev}` const DELETE_MODEL_URL = `/api/${instanceId}/models/${model._id}/${model._rev}`
const response = await api.delete(DELETE_MODEL_URL) const response = await api.delete(DELETE_MODEL_URL)
backendUiStore.update(state => { backendUiStore.update(state => {
state.selectedView = null state.selectedView = null
state.models = state.models.filter( state.models = state.models.filter(({ _id }) => _id !== model._id)
({ _id }) => _id !== model._id
)
notifier.danger(`${model.name} deleted successfully.`) notifier.danger(`${model.name} deleted successfully.`)
return state return state
}) })
@ -78,7 +80,9 @@
</div> </div>
{/if} {/if}
<footer> <footer>
<Button attention wide on:click={saveModel}>Save</Button> <Button disabled={!edited} attention={edited} wide on:click={saveModel}>
Save
</Button>
</footer> </footer>
{:else if selectedTab === 'DELETE'} {:else if selectedTab === 'DELETE'}
<div class="titled-input"> <div class="titled-input">
@ -96,6 +100,8 @@
footer { footer {
width: 100%; width: 100%;
position: fixed;
bottom: 20px;
} }
.items-root { .items-root {
@ -110,6 +116,7 @@
.titled-input { .titled-input {
padding: 12px; padding: 12px;
background: var(--light-grey); background: var(--light-grey);
margin-bottom: 5px;
} }
.titled-input header { .titled-input header {

View File

@ -30,52 +30,52 @@ export const FIELDS = {
presence: false, presence: false,
}, },
}, },
OPTIONS: { // OPTIONS: {
name: "Options", // name: "Options",
icon: "ri-list-check-2", // icon: "ri-list-check-2",
type: "options", // type: "options",
constraints: { // constraints: {
type: "string", // type: "string",
presence: false, // presence: false,
}, // },
}, // },
DATETIME: { // DATETIME: {
name: "Date/Time", // name: "Date/Time",
icon: "ri-calendar-event-fill", // icon: "ri-calendar-event-fill",
type: "datetime", // type: "datetime",
constraints: { // constraints: {
type: "date", // type: "date",
datetime: {}, // datetime: {},
presence: false, // presence: false,
}, // },
}, // },
IMAGE: { // IMAGE: {
name: "File", // name: "File",
icon: "ri-image-line", // icon: "ri-image-line",
type: "file", // type: "file",
constraints: { // constraints: {
type: "string", // type: "string",
presence: false, // presence: false,
}, // },
}, // },
FILE: { // FILE: {
name: "Image", // name: "Image",
icon: "ri-file-line", // icon: "ri-file-line",
type: "file", // type: "file",
constraints: { // constraints: {
type: "string", // type: "string",
presence: false, // presence: false,
}, // },
}, // },
DATA_LINK: { // DATA_LINK: {
name: "Data Links", // name: "Data Links",
icon: "ri-link", // icon: "ri-link",
type: "link", // type: "link",
modelId: null, // modelId: null,
constraints: { // constraints: {
type: "array", // type: "array",
} // }
}, // },
} }
export const BLOCKS = { export const BLOCKS = {