adds functionality to update name and description of app
This commit is contained in:
parent
2da62df873
commit
f39f913b4b
|
@ -1,15 +1,39 @@
|
|||
<script>
|
||||
import { Input, TextArea, Button } from "@budibase/bbui"
|
||||
import { store } from "builderStore"
|
||||
import api from "builderStore/api"
|
||||
import Title from "../TabTitle.svelte"
|
||||
|
||||
async function updateApplication(data) {
|
||||
const response = await api.put(`/api/${$store.appId}/appPackage`, data)
|
||||
const app = await response.json()
|
||||
store.update(state => {
|
||||
state = {
|
||||
...state,
|
||||
...data,
|
||||
}
|
||||
return state
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<Title>General</Title>
|
||||
<div class="container">
|
||||
<div class="background">
|
||||
<Input thin edit placeholder="Enter your name" label="Name" />
|
||||
<Input
|
||||
on:save={e => updateApplication({ name: e.detail })}
|
||||
thin
|
||||
edit
|
||||
value={$store.name}
|
||||
label="Name" />
|
||||
</div>
|
||||
<div class="background">
|
||||
<TextArea thin edit placeholder="Enter your name" label="Name" />
|
||||
<TextArea
|
||||
on:save={e => updateApplication({ description: e.detail })}
|
||||
thin
|
||||
edit
|
||||
value={$store.description}
|
||||
label="Name" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ exports.fetch = async function(ctx) {
|
|||
key: ["app"],
|
||||
})
|
||||
|
||||
console.log("Apps: ", body)
|
||||
|
||||
ctx.body = body.rows.map(row => row.doc)
|
||||
}
|
||||
|
||||
|
@ -90,6 +92,22 @@ exports.create = async function(ctx) {
|
|||
ctx.message = `Application ${ctx.request.body.name} created successfully`
|
||||
}
|
||||
|
||||
exports.update = async function(ctx) {
|
||||
const clientId = await lookupClientId(ctx.params.applicationId)
|
||||
const db = new CouchDB(ClientDb.name(clientId))
|
||||
const application = await db.get(ctx.params.applicationId)
|
||||
|
||||
const data = ctx.request.body
|
||||
const newData = { ...application, ...data }
|
||||
|
||||
const response = await db.put(newData)
|
||||
data._rev = response.rev
|
||||
|
||||
ctx.status = 200
|
||||
ctx.message = `Application ${application.name} updated successfully.`
|
||||
ctx.body = response
|
||||
}
|
||||
|
||||
const createEmptyAppPackage = async (ctx, app) => {
|
||||
const templateFolder = resolve(
|
||||
__dirname,
|
||||
|
|
|
@ -12,6 +12,7 @@ router
|
|||
authorized(BUILDER),
|
||||
controller.fetchAppPackage
|
||||
)
|
||||
.put("/api/:applicationId/appPackage", authorized(BUILDER), controller.update)
|
||||
.post("/api/applications", authorized(BUILDER), controller.create)
|
||||
|
||||
module.exports = router
|
||||
|
|
Loading…
Reference in New Issue