Merge pull request #399 from Budibase/features/edit-application-info
Features/edit application info
This commit is contained in:
commit
b5ae3a280a
|
@ -29,7 +29,8 @@ import {
|
|||
export const getStore = () => {
|
||||
const initial = {
|
||||
apps: [],
|
||||
appname: "",
|
||||
name: "",
|
||||
description: "",
|
||||
pages: DEFAULT_PAGES_OBJECT,
|
||||
mainUi: {},
|
||||
unauthenticatedUi: {},
|
||||
|
@ -101,7 +102,8 @@ const setPackage = (store, initial) => async pkg => {
|
|||
|
||||
initial.libraries = pkg.application.componentLibraries
|
||||
initial.components = await fetchComponentLibDefinitions(pkg.application._id)
|
||||
initial.appname = pkg.application.name
|
||||
initial.name = pkg.application.name
|
||||
initial.description = pkg.application.description
|
||||
initial.appId = pkg.application._id
|
||||
initial.pages = pkg.pages
|
||||
initial.hasAppPackage = true
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
|
||||
$: currentAppInfo = {
|
||||
appname: $store.appname,
|
||||
name: $store.name,
|
||||
}
|
||||
|
||||
async function fetchUsers() {
|
||||
|
|
|
@ -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}`, 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>
|
||||
|
||||
|
|
|
@ -90,6 +90,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", authorized(BUILDER), controller.update)
|
||||
.post("/api/applications", authorized(BUILDER), controller.create)
|
||||
|
||||
module.exports = router
|
||||
|
|
Loading…
Reference in New Issue