fix dataform
This commit is contained in:
parent
f3866a5e0d
commit
2f6e0f14ae
|
@ -28,7 +28,7 @@
|
|||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<Input onChange={onChange} value={parameter.value} />
|
||||
<Input {onChange} value={parameter.value} />
|
||||
<button on:click={() => (isOpen = !isOpen)}>
|
||||
<div class="icon" style={`transform: rotate(${isOpen ? 0 : 90}deg);`}>
|
||||
<ArrowDownIcon size={36} />
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="uk-margin block-field">
|
||||
<div class="uk-form-controls">
|
||||
<select class="budibase__input" on:change {value}>
|
||||
<option value=""></option>
|
||||
<option value="" />
|
||||
{#each $backendUiStore.models as model}
|
||||
<option value={model._id}>{model.name}</option>
|
||||
{/each}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="uk-margin block-field">
|
||||
<div class="uk-form-controls">
|
||||
<select class="budibase__input" bind:value>
|
||||
<option value=""></option>
|
||||
<option value="" />
|
||||
{#each $backendUiStore.models as model}
|
||||
<option value={model}>{model.name}</option>
|
||||
{/each}
|
||||
|
|
|
@ -10,6 +10,12 @@ exports.fetch = async function(ctx) {
|
|||
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) {
|
||||
const db = new CouchDB(ctx.params.instanceId)
|
||||
const newModel = {
|
||||
|
|
|
@ -13,7 +13,6 @@ exports.serveBuilder = async function(ctx) {
|
|||
}
|
||||
|
||||
exports.serveApp = async function(ctx) {
|
||||
// TODO: update homedir stuff to wherever budi is run
|
||||
// default to homedir
|
||||
const appPath = resolve(
|
||||
budibaseAppsDir(),
|
||||
|
@ -26,7 +25,6 @@ exports.serveApp = async function(ctx) {
|
|||
}
|
||||
|
||||
exports.serveComponentLibrary = async function(ctx) {
|
||||
// TODO: update homedir stuff to wherever budi is run
|
||||
// default to homedir
|
||||
let componentLibraryPath = resolve(
|
||||
budibaseAppsDir(),
|
||||
|
|
|
@ -43,6 +43,7 @@ router
|
|||
|
||||
router
|
||||
.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)
|
||||
// .patch("/api/:instanceId/models", controller.update)
|
||||
.delete(
|
||||
|
|
|
@ -8,19 +8,32 @@
|
|||
let username
|
||||
let password
|
||||
let newModel = {
|
||||
modelId: model._id,
|
||||
modelId: model,
|
||||
}
|
||||
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() {
|
||||
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 json = await response.json()
|
||||
|
||||
store.update(state => {
|
||||
state[model._id] = [...state[model._id], json]
|
||||
state[model._id] = [...state[model], json]
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
@ -46,14 +59,14 @@
|
|||
</script>
|
||||
|
||||
<form class="uk-form" on:submit|preventDefault>
|
||||
<h4>{model.name}</h4>
|
||||
<h4>{modelDef.name}</h4>
|
||||
<div>
|
||||
{#each fields as field}
|
||||
<div class="uk-margin">
|
||||
<label class="form-label" for="form-stacked-text">{field}</label>
|
||||
<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)} />
|
||||
</div>
|
||||
{/each}
|
||||
|
|
Loading…
Reference in New Issue