removing delete functionality - not necessary
This commit is contained in:
parent
28fd0e4831
commit
319fcabaa5
|
@ -1,28 +0,0 @@
|
||||||
/**
|
|
||||||
* buildStateOrigins
|
|
||||||
*
|
|
||||||
* Builds an object that details all the bound state in the application, and what updates it.
|
|
||||||
*
|
|
||||||
* @param screenDefinition - the screen definition metadata.
|
|
||||||
* @returns {Object} an object with the client state values and how they are managed.
|
|
||||||
*/
|
|
||||||
export const buildStateOrigins = screenDefinition => {
|
|
||||||
const origins = {}
|
|
||||||
|
|
||||||
function traverse(propValue) {
|
|
||||||
for (let key in propValue) {
|
|
||||||
if (!Array.isArray(propValue[key])) continue
|
|
||||||
|
|
||||||
if (key === "_children") propValue[key].forEach(traverse)
|
|
||||||
|
|
||||||
for (let element of propValue[key]) {
|
|
||||||
if (element["##eventHandlerType"] === "Set State")
|
|
||||||
origins[element.parameters.path] = element
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
traverse(screenDefinition.props)
|
|
||||||
|
|
||||||
return origins
|
|
||||||
}
|
|
|
@ -38,9 +38,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeFile() {
|
async function removeFile() {
|
||||||
const response = await api.delete(
|
|
||||||
`/api/attachments/${selectedImage.fileName}`
|
|
||||||
)
|
|
||||||
files.splice(selectedImageIdx, 1)
|
files.splice(selectedImageIdx, 1)
|
||||||
files = files
|
files = files
|
||||||
selectedImageIdx = 0
|
selectedImageIdx = 0
|
||||||
|
@ -82,7 +79,6 @@
|
||||||
on:dragenter={handleDragOver}
|
on:dragenter={handleDragOver}
|
||||||
on:drop={handleDrop}
|
on:drop={handleDrop}
|
||||||
class:fileDragged>
|
class:fileDragged>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{#if selectedImage}
|
{#if selectedImage}
|
||||||
<li>
|
<li>
|
||||||
|
@ -106,7 +102,7 @@
|
||||||
<i class="ri-arrow-left-line" />
|
<i class="ri-arrow-left-line" />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<img src={selectedImage.clientUrl} />
|
<img src={selectedImage.url} />
|
||||||
{#if selectedImageIdx !== files.length - 1}
|
{#if selectedImageIdx !== files.length - 1}
|
||||||
<div class="nav right" on:click={navigateRight}>
|
<div class="nav right" on:click={navigateRight}>
|
||||||
<i class="ri-arrow-right-line" />
|
<i class="ri-arrow-right-line" />
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<div class="file-list">
|
<div class="file-list">
|
||||||
{#each files as file}
|
{#each files as file}
|
||||||
<div class="file">
|
<div class="file">
|
||||||
{#if FILE_TYPES.IMAGE.includes(file.extension)}
|
{#if FILE_TYPES.IMAGE.includes(file.extension.toLowerCase())}
|
||||||
<img {width} {height} src={file.clientUrl} />
|
<img {width} {height} src={file.url} />
|
||||||
{:else}
|
{:else}
|
||||||
<i class="ri-file-line" />
|
<i class="ri-file-line" />
|
||||||
<span class="extension">.{file.extension}</span>
|
<span class="extension">.{file.extension}</span>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
export let meta
|
export let meta
|
||||||
export let value = meta.type === "boolean" ? false : ""
|
export let value = meta.type === "boolean" ? false : ""
|
||||||
export let saveRecord
|
export let originalValue
|
||||||
|
|
||||||
let isSelect =
|
let isSelect =
|
||||||
meta.type === "string" &&
|
meta.type === "string" &&
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<DatePicker bind:value />
|
<DatePicker bind:value />
|
||||||
{:else if type === 'file'}
|
{:else if type === 'file'}
|
||||||
<Label small forAttr={'dropzone-label'}>{meta.name}</Label>
|
<Label small forAttr={'dropzone-label'}>{meta.name}</Label>
|
||||||
<Dropzone bind:files={value} />
|
<Dropzone bind:files={value} savedFiles={originalValue} />
|
||||||
{:else}
|
{:else}
|
||||||
{#if type === 'checkbox'}
|
{#if type === 'checkbox'}
|
||||||
<label>{meta.name}</label>
|
<label>{meta.name}</label>
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
import { DropdownMenu, Button, Icon, Input, Select } from "@budibase/bbui"
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
Button,
|
||||||
|
Icon,
|
||||||
|
Input,
|
||||||
|
Select,
|
||||||
|
Heading,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import { FIELDS } from "constants/backend"
|
import { FIELDS } from "constants/backend"
|
||||||
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
import CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
||||||
import DeleteRecordModal from "../modals/DeleteRecord.svelte"
|
import DeleteRecordModal from "../modals/DeleteRecord.svelte"
|
||||||
|
@ -48,11 +55,11 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li data-cy="edit-row" on:click={showEditor}>
|
<li data-cy="edit-row" on:click={showEditor}>
|
||||||
<Icon name="edit" />
|
<Icon name="edit" />
|
||||||
Edit
|
<span>Edit</span>
|
||||||
</li>
|
</li>
|
||||||
<li data-cy="delete-row" on:click={deleteRow}>
|
<li data-cy="delete-row" on:click={deleteRow}>
|
||||||
<Icon name="delete" />
|
<Icon name="delete" />
|
||||||
Delete
|
<span>Delete</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -79,7 +86,6 @@
|
||||||
li {
|
li {
|
||||||
display: flex;
|
display: flex;
|
||||||
font-family: var(--font-sans);
|
font-family: var(--font-sans);
|
||||||
font-size: var(--font-size-xs);
|
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
padding: var(--spacing-s) var(--spacing-m);
|
padding: var(--spacing-s) var(--spacing-m);
|
||||||
margin: auto 0px;
|
margin: auto 0px;
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
import { buildStateOrigins } from "../src/builderStore/buildStateOrigins"
|
|
||||||
|
|
||||||
it("builds the correct stateOrigins object from a screen definition with handlers", () => {
|
|
||||||
expect(
|
|
||||||
buildStateOrigins({
|
|
||||||
name: "screen1",
|
|
||||||
description: "",
|
|
||||||
props: {
|
|
||||||
_component: "@budibase/standard-components/container",
|
|
||||||
className: "",
|
|
||||||
type: "div",
|
|
||||||
onClick: [
|
|
||||||
{
|
|
||||||
"##eventHandlerType": "Set State",
|
|
||||||
parameters: {
|
|
||||||
path: "testKey",
|
|
||||||
value: "value",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
).toEqual({
|
|
||||||
testKey: {
|
|
||||||
"##eventHandlerType": "Set State",
|
|
||||||
parameters: {
|
|
||||||
path: "testKey",
|
|
||||||
value: "value",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -22,22 +22,6 @@ exports.serveBuilder = async function(ctx) {
|
||||||
await send(ctx, ctx.file, { root: ctx.devPath || builderPath })
|
await send(ctx, ctx.file, { root: ctx.devPath || builderPath })
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.deleteLocalFileUpload = async function(ctx) {
|
|
||||||
try {
|
|
||||||
const db = new CouchDB(ctx.user.instanceId)
|
|
||||||
let fileUploads = await db.get("_local/fileuploads")
|
|
||||||
fileUploads.uploads = fileUploads.uploads.filter(
|
|
||||||
upload => upload.fileName !== ctx.params.fileName
|
|
||||||
)
|
|
||||||
await db.put(fileUploads)
|
|
||||||
ctx.body = {
|
|
||||||
message: `${ctx.fileName} deleted.`,
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
ctx.throw(500, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.processLocalFileUpload = async function(ctx) {
|
exports.processLocalFileUpload = async function(ctx) {
|
||||||
const { files } = ctx.request.body
|
const { files } = ctx.request.body
|
||||||
|
|
||||||
|
@ -61,7 +45,7 @@ exports.processLocalFileUpload = async function(ctx) {
|
||||||
fileName,
|
fileName,
|
||||||
extension: fileExtension,
|
extension: fileExtension,
|
||||||
outputPath: join(attachmentsPath, fileName),
|
outputPath: join(attachmentsPath, fileName),
|
||||||
clientUrl: join("/attachments", fileName),
|
url: join("/attachments", fileName),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,6 @@ router
|
||||||
authorized(BUILDER),
|
authorized(BUILDER),
|
||||||
controller.processLocalFileUpload
|
controller.processLocalFileUpload
|
||||||
)
|
)
|
||||||
.delete(
|
|
||||||
"/api/attachments/:fileName",
|
|
||||||
authorized(BUILDER),
|
|
||||||
controller.deleteLocalFileUpload
|
|
||||||
)
|
|
||||||
.get("/componentlibrary", controller.serveComponentLibrary)
|
.get("/componentlibrary", controller.serveComponentLibrary)
|
||||||
.get("/assets/:file*", controller.serveAppAsset)
|
.get("/assets/:file*", controller.serveAppAsset)
|
||||||
.get("/attachments/:file*", controller.serveAttachment)
|
.get("/attachments/:file*", controller.serveAttachment)
|
||||||
|
|
Loading…
Reference in New Issue