commit
42a98d3f25
|
@ -10,7 +10,7 @@
|
|||
"eslint-plugin-svelte3": "^2.7.3",
|
||||
"lerna": "3.14.1",
|
||||
"prettier": "^1.19.1",
|
||||
"prettier-plugin-svelte": "^0.7.0",
|
||||
"prettier-plugin-svelte": "^1.1.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup-plugin-replace": "^2.2.0",
|
||||
"svelte": "^3.28.0"
|
||||
|
|
|
@ -53,6 +53,7 @@ export const getStore = () => {
|
|||
|
||||
store.saveScreen = saveScreen(store)
|
||||
store.setCurrentScreen = setCurrentScreen(store)
|
||||
store.deleteScreens = deleteScreens(store)
|
||||
store.setCurrentPage = setCurrentPage(store)
|
||||
store.createScreen = createScreen(store)
|
||||
store.addStylesheet = addStylesheet(store)
|
||||
|
@ -185,6 +186,26 @@ const setCurrentScreen = store => screenName => {
|
|||
})
|
||||
}
|
||||
|
||||
const deleteScreens = store => (screens, pageName = null) => {
|
||||
if (!(screens instanceof Array)) {
|
||||
screens = [screens]
|
||||
}
|
||||
store.update(state => {
|
||||
if (pageName == null) {
|
||||
pageName = state.pages.main.name
|
||||
}
|
||||
for (let screen of screens) {
|
||||
state.screens = state.screens.filter(c => c.name !== screen.name)
|
||||
// Remove screen from current page as well
|
||||
state.pages[pageName]._screens = state.pages[pageName]._screens.filter(
|
||||
scr => scr.name !== screen.name
|
||||
)
|
||||
api.delete(`/_builder/api/pages/${pageName}/screens/${screen.name}`)
|
||||
}
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
||||
const savePage = store => async page => {
|
||||
store.update(state => {
|
||||
if (state.currentFrontEndType !== "page" || !state.currentPageName) {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<script>
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { backendUiStore, store } from "builderStore"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import { DropdownMenu, Button, Icon, Input, Select } from "@budibase/bbui"
|
||||
import { FIELDS } from "constants/backend"
|
||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||
import screenTemplates from "builderStore/store/screenTemplates"
|
||||
import api from "builderStore/api"
|
||||
|
||||
export let table
|
||||
|
||||
|
@ -11,6 +13,8 @@
|
|||
let dropdown
|
||||
let editing
|
||||
let confirmDeleteDialog
|
||||
let templateScreens
|
||||
let willBeDeleted
|
||||
|
||||
$: fields = Object.keys(table.schema)
|
||||
|
||||
|
@ -24,12 +28,18 @@
|
|||
}
|
||||
|
||||
function showModal() {
|
||||
const screens = $store.allScreens
|
||||
templateScreens = screens.filter(screen => screen.props.table === table._id)
|
||||
willBeDeleted = ["All table data"].concat(
|
||||
templateScreens.map(screen => `Screen ${screen.props._instanceName}`)
|
||||
)
|
||||
hideEditor()
|
||||
confirmDeleteDialog.show()
|
||||
}
|
||||
|
||||
async function deleteTable() {
|
||||
await backendUiStore.actions.tables.delete(table)
|
||||
store.deleteScreens(templateScreens)
|
||||
notifier.success("Table deleted")
|
||||
hideEditor()
|
||||
}
|
||||
|
@ -79,10 +89,21 @@
|
|||
</DropdownMenu>
|
||||
<ConfirmDialog
|
||||
bind:this={confirmDeleteDialog}
|
||||
body={`Are you sure you wish to delete the table '${table.name}'? Your data will be deleted and this action cannot be undone.`}
|
||||
okText="Delete Table"
|
||||
onOk={deleteTable}
|
||||
title="Confirm Delete" />
|
||||
title="Confirm Delete">
|
||||
Are you sure you wish to delete the table
|
||||
<i>{table.name}?</i>
|
||||
The following will also be deleted:
|
||||
<b>
|
||||
<div class="delete-items">
|
||||
{#each willBeDeleted as item}
|
||||
<div>{item}</div>
|
||||
{/each}
|
||||
</div>
|
||||
</b>
|
||||
This action cannot be undone.
|
||||
</ConfirmDialog>
|
||||
|
||||
<style>
|
||||
div.icon {
|
||||
|
@ -96,6 +117,17 @@
|
|||
font-size: 16px;
|
||||
}
|
||||
|
||||
div.delete-items {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
div.delete-items div {
|
||||
margin-top: 4px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.actions {
|
||||
padding: var(--spacing-xl);
|
||||
display: grid;
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
|
||||
<Modal bind:this={modal} on:hide={onCancel}>
|
||||
<ModalContent onConfirm={onOk} {title} confirmText={okText} {cancelText} red>
|
||||
<div class="body">{body}</div>
|
||||
<div class="body">
|
||||
{body}
|
||||
<slot />
|
||||
</div>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
||||
|
|
|
@ -17,26 +17,13 @@
|
|||
}
|
||||
|
||||
const deleteScreen = () => {
|
||||
store.deleteScreens(screen, $store.currentPageName)
|
||||
// update the page if required
|
||||
store.update(state => {
|
||||
// Remove screen from screens
|
||||
const screens = state.screens.filter(c => c.name !== screen.name)
|
||||
state.screens = screens
|
||||
|
||||
// Remove screen from current page as well
|
||||
const pageScreens = state.pages[state.currentPageName]._screens.filter(
|
||||
scr => scr.name !== screen.name
|
||||
)
|
||||
state.pages[state.currentPageName]._screens = pageScreens
|
||||
|
||||
if (state.currentPreviewItem.name === screen.name) {
|
||||
store.setCurrentPage($store.currentPageName)
|
||||
$goto(`./:page/page-layout`)
|
||||
}
|
||||
|
||||
api.delete(
|
||||
`/_builder/api/pages/${state.currentPageName}/screens/${screen.name}`
|
||||
)
|
||||
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ const ClientDb = require("../../db/clientDb")
|
|||
const { getPackageForBuilder, buildPage } = require("../../utilities/builder")
|
||||
const env = require("../../environment")
|
||||
const instanceController = require("./instance")
|
||||
const { copy, exists, readFile, writeFile } = require("fs-extra")
|
||||
const { copy, existsSync, readFile, writeFile } = require("fs-extra")
|
||||
const { budibaseAppsDir } = require("../../utilities/budibaseDir")
|
||||
const sqrl = require("squirrelly")
|
||||
const setBuilderToken = require("../../utilities/builder/setBuilderToken")
|
||||
|
@ -116,6 +116,12 @@ exports.delete = async function(ctx) {
|
|||
const db = new CouchDB(ClientDb.name(getClientId(ctx)))
|
||||
const app = await db.get(ctx.params.applicationId)
|
||||
const result = await db.remove(app)
|
||||
for (let instance of app.instances) {
|
||||
const instanceDb = new CouchDB(instance._id)
|
||||
await instanceDb.destroy()
|
||||
}
|
||||
|
||||
// remove top level directory
|
||||
await fs.rmdir(join(budibaseAppsDir(), ctx.params.applicationId), {
|
||||
recursive: true,
|
||||
})
|
||||
|
@ -137,7 +143,7 @@ const createEmptyAppPackage = async (ctx, app) => {
|
|||
const appsFolder = budibaseAppsDir()
|
||||
const newAppFolder = resolve(appsFolder, app._id)
|
||||
|
||||
if (await exists(newAppFolder)) {
|
||||
if (existsSync(newAppFolder)) {
|
||||
ctx.throw(400, "App folder already exists for this application")
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* This controller is not currently fully implemented. Screens are
|
||||
* currently managed as part of the pages API, please look in api/routes/page.js
|
||||
* for routes and controllers.
|
||||
*/
|
||||
|
||||
exports.fetch = async ctx => {
|
||||
ctx.throw(501)
|
||||
}
|
||||
|
||||
exports.save = async ctx => {
|
||||
ctx.throw(501)
|
||||
}
|
||||
|
||||
exports.destroy = async ctx => {
|
||||
ctx.throw(501)
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
const { exists, readFile, writeFile, ensureDir } = require("fs-extra")
|
||||
const { existsSync, readFile, writeFile, ensureDir } = require("fs-extra")
|
||||
const { join, resolve } = require("./centralPath")
|
||||
const Sqrl = require("squirrelly")
|
||||
const uuid = require("uuid")
|
||||
|
@ -28,7 +28,7 @@ const setCouchDbUrl = async opts => {
|
|||
|
||||
const createDevEnvFile = async opts => {
|
||||
const destConfigFile = join(opts.dir, "./.env")
|
||||
let createConfig = !(await exists(destConfigFile)) || opts.quiet
|
||||
let createConfig = !existsSync(destConfigFile) || opts.quiet
|
||||
if (createConfig) {
|
||||
const template = await readFile(
|
||||
resolve(__dirname, "..", "..", ".env.template"),
|
||||
|
|
11
yarn.lock
11
yarn.lock
|
@ -3690,11 +3690,10 @@ prettier-linter-helpers@^1.0.0:
|
|||
dependencies:
|
||||
fast-diff "^1.1.2"
|
||||
|
||||
prettier-plugin-svelte@^0.7.0:
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-0.7.0.tgz#5ac0b9f194e0450c88ff1e167cbf3b32d2642df2"
|
||||
dependencies:
|
||||
tslib "^1.9.3"
|
||||
prettier-plugin-svelte@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-1.1.0.tgz#e6ec282d8457598b0c02164083b11ad8cb8ab304"
|
||||
integrity sha512-wmIggG/ryV0wcmE9D5p+k5TwKDpS2SGKJpF6IV1aYHK7dkBJD+di1w47Ci00DRsI4RrXZRC2Ef37DSyrTb6Zqg==
|
||||
|
||||
prettier@^1.19.1:
|
||||
version "1.19.1"
|
||||
|
@ -4529,7 +4528,7 @@ trim-off-newlines@^1.0.0:
|
|||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3"
|
||||
|
||||
tslib@^1.9.0, tslib@^1.9.3:
|
||||
tslib@^1.9.0:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
|
||||
|
||||
|
|
Loading…
Reference in New Issue