fix dataform
This commit is contained in:
parent
b8df2f15fb
commit
f939d9ef13
|
@ -28,7 +28,7 @@
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
{:else}
|
{:else}
|
||||||
<Input onChange={onChange} value={parameter.value} />
|
<Input {onChange} value={parameter.value} />
|
||||||
<button on:click={() => (isOpen = !isOpen)}>
|
<button on:click={() => (isOpen = !isOpen)}>
|
||||||
<div class="icon" style={`transform: rotate(${isOpen ? 0 : 90}deg);`}>
|
<div class="icon" style={`transform: rotate(${isOpen ? 0 : 90}deg);`}>
|
||||||
<ArrowDownIcon size={36} />
|
<ArrowDownIcon size={36} />
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="uk-margin block-field">
|
<div class="uk-margin block-field">
|
||||||
<div class="uk-form-controls">
|
<div class="uk-form-controls">
|
||||||
<select class="budibase__input" on:change {value}>
|
<select class="budibase__input" on:change {value}>
|
||||||
<option value=""></option>
|
<option value="" />
|
||||||
{#each $backendUiStore.models as model}
|
{#each $backendUiStore.models as model}
|
||||||
<option value={model._id}>{model.name}</option>
|
<option value={model._id}>{model.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="uk-margin block-field">
|
<div class="uk-margin block-field">
|
||||||
<div class="uk-form-controls">
|
<div class="uk-form-controls">
|
||||||
<select class="budibase__input" bind:value>
|
<select class="budibase__input" bind:value>
|
||||||
<option value=""></option>
|
<option value="" />
|
||||||
{#each $backendUiStore.models as model}
|
{#each $backendUiStore.models as model}
|
||||||
<option value={model}>{model.name}</option>
|
<option value={model}>{model.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
@ -10,6 +10,12 @@ exports.fetch = async function(ctx) {
|
||||||
ctx.body = body.rows.map(row => row.doc)
|
ctx.body = body.rows.map(row => row.doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.find = async function(ctx) {
|
||||||
|
const db = new CouchDB(ctx.params.instanceId)
|
||||||
|
const model = await db.get(ctx.params.id)
|
||||||
|
ctx.body = model
|
||||||
|
}
|
||||||
|
|
||||||
exports.create = async function(ctx) {
|
exports.create = async function(ctx) {
|
||||||
const db = new CouchDB(ctx.params.instanceId)
|
const db = new CouchDB(ctx.params.instanceId)
|
||||||
const newModel = {
|
const newModel = {
|
||||||
|
|
|
@ -13,7 +13,6 @@ exports.serveBuilder = async function(ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.serveApp = async function(ctx) {
|
exports.serveApp = async function(ctx) {
|
||||||
// TODO: update homedir stuff to wherever budi is run
|
|
||||||
// default to homedir
|
// default to homedir
|
||||||
const appPath = resolve(
|
const appPath = resolve(
|
||||||
budibaseAppsDir(),
|
budibaseAppsDir(),
|
||||||
|
@ -26,7 +25,6 @@ exports.serveApp = async function(ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.serveComponentLibrary = async function(ctx) {
|
exports.serveComponentLibrary = async function(ctx) {
|
||||||
// TODO: update homedir stuff to wherever budi is run
|
|
||||||
// default to homedir
|
// default to homedir
|
||||||
let componentLibraryPath = resolve(
|
let componentLibraryPath = resolve(
|
||||||
budibaseAppsDir(),
|
budibaseAppsDir(),
|
||||||
|
|
|
@ -43,6 +43,7 @@ router
|
||||||
|
|
||||||
router
|
router
|
||||||
.get("/api/:instanceId/models", authorized(BUILDER), modelController.fetch)
|
.get("/api/:instanceId/models", authorized(BUILDER), modelController.fetch)
|
||||||
|
.get("/api/:instanceId/models/:id", authorized(BUILDER), modelController.find)
|
||||||
.post("/api/:instanceId/models", authorized(BUILDER), modelController.create)
|
.post("/api/:instanceId/models", authorized(BUILDER), modelController.create)
|
||||||
// .patch("/api/:instanceId/models", controller.update)
|
// .patch("/api/:instanceId/models", controller.update)
|
||||||
.delete(
|
.delete(
|
||||||
|
|
|
@ -8,19 +8,32 @@
|
||||||
let username
|
let username
|
||||||
let password
|
let password
|
||||||
let newModel = {
|
let newModel = {
|
||||||
modelId: model._id,
|
modelId: model,
|
||||||
}
|
}
|
||||||
let store = _bb.store
|
let store = _bb.store
|
||||||
|
let schema = {}
|
||||||
|
let modelDef = {}
|
||||||
|
|
||||||
$: fields = Object.keys(model.schema)
|
$: if (model && model.length !== 0) {
|
||||||
|
fetchModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
$: fields = Object.keys(schema)
|
||||||
|
|
||||||
|
async function fetchModel() {
|
||||||
|
const FETCH_MODEL_URL = `/api/${_instanceId}/models/${model}`
|
||||||
|
const response = await _bb.api.get(FETCH_MODEL_URL)
|
||||||
|
modelDef = await response.json()
|
||||||
|
schema = modelDef.schema
|
||||||
|
}
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
const SAVE_RECORD_URL = `/api/${_instanceId}/records`
|
const SAVE_RECORD_URL = `/api/${_instanceId}/${model}/records`
|
||||||
const response = await _bb.api.post(SAVE_RECORD_URL, newModel)
|
const response = await _bb.api.post(SAVE_RECORD_URL, newModel)
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
|
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state[model._id] = [...state[model._id], json]
|
state[model._id] = [...state[model], json]
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -46,14 +59,14 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form class="uk-form" on:submit|preventDefault>
|
<form class="uk-form" on:submit|preventDefault>
|
||||||
<h4>{model.name}</h4>
|
<h4>{modelDef.name}</h4>
|
||||||
<div>
|
<div>
|
||||||
{#each fields as field}
|
{#each fields as field}
|
||||||
<div class="uk-margin">
|
<div class="uk-margin">
|
||||||
<label class="form-label" for="form-stacked-text">{field}</label>
|
<label class="form-label" for="form-stacked-text">{field}</label>
|
||||||
<input
|
<input
|
||||||
class="uk-input"
|
class="uk-input"
|
||||||
type={model.schema[field].type === 'string' ? 'text' : model.schema[field].type}
|
type={schema[field].type === 'string' ? 'text' : schema[field].type}
|
||||||
on:change={handleInput(field)} />
|
on:change={handleInput(field)} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
Loading…
Reference in New Issue