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 = () => {
|
export const getStore = () => {
|
||||||
const initial = {
|
const initial = {
|
||||||
apps: [],
|
apps: [],
|
||||||
appname: "",
|
name: "",
|
||||||
|
description: "",
|
||||||
pages: DEFAULT_PAGES_OBJECT,
|
pages: DEFAULT_PAGES_OBJECT,
|
||||||
mainUi: {},
|
mainUi: {},
|
||||||
unauthenticatedUi: {},
|
unauthenticatedUi: {},
|
||||||
|
@ -101,7 +102,8 @@ const setPackage = (store, initial) => async pkg => {
|
||||||
|
|
||||||
initial.libraries = pkg.application.componentLibraries
|
initial.libraries = pkg.application.componentLibraries
|
||||||
initial.components = await fetchComponentLibDefinitions(pkg.application._id)
|
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.appId = pkg.application._id
|
||||||
initial.pages = pkg.pages
|
initial.pages = pkg.pages
|
||||||
initial.hasAppPackage = true
|
initial.hasAppPackage = true
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$: currentAppInfo = {
|
$: currentAppInfo = {
|
||||||
appname: $store.appname,
|
name: $store.name,
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUsers() {
|
async function fetchUsers() {
|
||||||
|
|
|
@ -1,15 +1,39 @@
|
||||||
<script>
|
<script>
|
||||||
import { Input, TextArea, Button } from "@budibase/bbui"
|
import { Input, TextArea, Button } from "@budibase/bbui"
|
||||||
|
import { store } from "builderStore"
|
||||||
|
import api from "builderStore/api"
|
||||||
import Title from "../TabTitle.svelte"
|
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>
|
</script>
|
||||||
|
|
||||||
<Title>General</Title>
|
<Title>General</Title>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="background">
|
<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>
|
||||||
<div class="background">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,22 @@ exports.create = async function(ctx) {
|
||||||
ctx.message = `Application ${ctx.request.body.name} created successfully`
|
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 createEmptyAppPackage = async (ctx, app) => {
|
||||||
const templateFolder = resolve(
|
const templateFolder = resolve(
|
||||||
__dirname,
|
__dirname,
|
||||||
|
|
|
@ -12,6 +12,7 @@ router
|
||||||
authorized(BUILDER),
|
authorized(BUILDER),
|
||||||
controller.fetchAppPackage
|
controller.fetchAppPackage
|
||||||
)
|
)
|
||||||
|
.put("/api/:applicationId", authorized(BUILDER), controller.update)
|
||||||
.post("/api/applications", authorized(BUILDER), controller.create)
|
.post("/api/applications", authorized(BUILDER), controller.create)
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
Loading…
Reference in New Issue