removing delete functionality - not necessary
This commit is contained in:
parent
a307e4d8b4
commit
e717d35f9e
|
@ -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() {
|
||||
const response = await api.delete(
|
||||
`/api/attachments/${selectedImage.fileName}`
|
||||
)
|
||||
files.splice(selectedImageIdx, 1)
|
||||
files = files
|
||||
selectedImageIdx = 0
|
||||
|
@ -82,7 +79,6 @@
|
|||
on:dragenter={handleDragOver}
|
||||
on:drop={handleDrop}
|
||||
class:fileDragged>
|
||||
|
||||
<ul>
|
||||
{#if selectedImage}
|
||||
<li>
|
||||
|
@ -106,7 +102,7 @@
|
|||
<i class="ri-arrow-left-line" />
|
||||
</div>
|
||||
{/if}
|
||||
<img src={selectedImage.clientUrl} />
|
||||
<img src={selectedImage.url} />
|
||||
{#if selectedImageIdx !== files.length - 1}
|
||||
<div class="nav right" on:click={navigateRight}>
|
||||
<i class="ri-arrow-right-line" />
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<div class="file-list">
|
||||
{#each files as file}
|
||||
<div class="file">
|
||||
{#if FILE_TYPES.IMAGE.includes(file.extension)}
|
||||
<img {width} {height} src={file.clientUrl} />
|
||||
{#if FILE_TYPES.IMAGE.includes(file.extension.toLowerCase())}
|
||||
<img {width} {height} src={file.url} />
|
||||
{:else}
|
||||
<i class="ri-file-line" />
|
||||
<span class="extension">.{file.extension}</span>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
export let meta
|
||||
export let value = meta.type === "boolean" ? false : ""
|
||||
export let saveRecord
|
||||
export let originalValue
|
||||
|
||||
let isSelect =
|
||||
meta.type === "string" &&
|
||||
|
@ -51,7 +51,7 @@
|
|||
<DatePicker bind:value />
|
||||
{:else if type === 'file'}
|
||||
<Label small forAttr={'dropzone-label'}>{meta.name}</Label>
|
||||
<Dropzone bind:files={value} />
|
||||
<Dropzone bind:files={value} savedFiles={originalValue} />
|
||||
{:else}
|
||||
{#if type === 'checkbox'}
|
||||
<label>{meta.name}</label>
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
<script>
|
||||
import { getContext } from "svelte"
|
||||
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 CreateEditRecord from "../modals/CreateEditRecord.svelte"
|
||||
import DeleteRecordModal from "../modals/DeleteRecord.svelte"
|
||||
|
@ -48,11 +55,11 @@
|
|||
<ul>
|
||||
<li data-cy="edit-row" on:click={showEditor}>
|
||||
<Icon name="edit" />
|
||||
Edit
|
||||
<span>Edit</span>
|
||||
</li>
|
||||
<li data-cy="delete-row" on:click={deleteRow}>
|
||||
<Icon name="delete" />
|
||||
Delete
|
||||
<span>Delete</span>
|
||||
</li>
|
||||
</ul>
|
||||
{/if}
|
||||
|
@ -79,7 +86,6 @@
|
|||
li {
|
||||
display: flex;
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--ink);
|
||||
padding: var(--spacing-s) var(--spacing-m);
|
||||
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 })
|
||||
}
|
||||
|
||||
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) {
|
||||
const { files } = ctx.request.body
|
||||
|
||||
|
@ -61,7 +45,7 @@ exports.processLocalFileUpload = async function(ctx) {
|
|||
fileName,
|
||||
extension: fileExtension,
|
||||
outputPath: join(attachmentsPath, fileName),
|
||||
clientUrl: join("/attachments", fileName),
|
||||
url: join("/attachments", fileName),
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -28,11 +28,6 @@ router
|
|||
authorized(BUILDER),
|
||||
controller.processLocalFileUpload
|
||||
)
|
||||
.delete(
|
||||
"/api/attachments/:fileName",
|
||||
authorized(BUILDER),
|
||||
controller.deleteLocalFileUpload
|
||||
)
|
||||
.get("/componentlibrary", controller.serveComponentLibrary)
|
||||
.get("/assets/:file*", controller.serveAppAsset)
|
||||
.get("/attachments/:file*", controller.serveAttachment)
|
||||
|
|
Loading…
Reference in New Issue