fixes editable cell bug
This commit is contained in:
parent
66bb4bdebf
commit
6c173ac6b3
|
@ -0,0 +1,41 @@
|
||||||
|
<script>
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
import { DropdownMenu, TextButton as Button, Icon } from "@budibase/bbui"
|
||||||
|
import AttachmentList from "../../attachments/AttachmentList.svelte"
|
||||||
|
// import Modal from "./Modal.svelte"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
let anchor
|
||||||
|
let dropdown
|
||||||
|
|
||||||
|
export let files
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div bind:this={anchor}>
|
||||||
|
<Button text small on:click={dropdown.show}>
|
||||||
|
<Icon name="edit" />
|
||||||
|
</Button>
|
||||||
|
<AttachmentList {files} />
|
||||||
|
</div>
|
||||||
|
<DropdownMenu bind:this={dropdown} {anchor} align="left">
|
||||||
|
<h5>Edit Attachment(s)</h5>
|
||||||
|
<!-- <Modal
|
||||||
|
{_bb}
|
||||||
|
{model}
|
||||||
|
onClosed={dropdown.hide}
|
||||||
|
on:newRecord={() => dispatch('newRecord')} /> -->
|
||||||
|
</DropdownMenu>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto auto;
|
||||||
|
place-items: start center;
|
||||||
|
}
|
||||||
|
h5 {
|
||||||
|
padding: var(--spacing-xl) 0 0 var(--spacing-xl);
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -31,6 +31,7 @@
|
||||||
const jsonModel = await _bb.api.get(`/api/models/${datasource.modelId}`)
|
const jsonModel = await _bb.api.get(`/api/models/${datasource.modelId}`)
|
||||||
model = await jsonModel.json()
|
model = await jsonModel.json()
|
||||||
const { schema } = model
|
const { schema } = model
|
||||||
|
console.log(schema)
|
||||||
if (!isEmpty(datasource)) {
|
if (!isEmpty(datasource)) {
|
||||||
data = await fetchData(datasource)
|
data = await fetchData(datasource)
|
||||||
columnDefs = Object.keys(schema).map((key, i) => {
|
columnDefs = Object.keys(schema).map((key, i) => {
|
||||||
|
@ -43,7 +44,7 @@
|
||||||
hide: shouldHideField(key),
|
hide: shouldHideField(key),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
editable:
|
editable:
|
||||||
schema[key].type !== "boolean" || schema[key].type !== "attachment",
|
schema[key].type !== "boolean" && schema[key].type !== "attachment",
|
||||||
cellRenderer: renderers.get(schema[key].type),
|
cellRenderer: renderers.get(schema[key].type),
|
||||||
autoHeight: schema[key].type === "attachment",
|
autoHeight: schema[key].type === "attachment",
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Custom renderers to handle special types
|
// Custom renderers to handle special types
|
||||||
// https://www.ag-grid.com/javascript-grid-cell-rendering-components/
|
// https://www.ag-grid.com/javascript-grid-cell-rendering-components/
|
||||||
|
|
||||||
import AttachmentList from '../attachments/AttachmentList.svelte'
|
import AttachmentCell from './AttachmentCell/Button.svelte'
|
||||||
|
|
||||||
export const booleanRenderer = (params) => {
|
export const booleanRenderer = (params) => {
|
||||||
const toggle = (e) => {
|
const toggle = (e) => {
|
||||||
|
@ -18,11 +18,9 @@ export const booleanRenderer = (params) => {
|
||||||
export const attachmentRenderer = (params) => {
|
export const attachmentRenderer = (params) => {
|
||||||
let container = document.createElement("div")
|
let container = document.createElement("div")
|
||||||
|
|
||||||
const app = new AttachmentList({
|
const attachment = new AttachmentCell({
|
||||||
target: container,
|
target: container,
|
||||||
props: {
|
props: {
|
||||||
// assuming App.svelte contains something like
|
|
||||||
// `export let answer`:
|
|
||||||
files: params.value || [],
|
files: params.value || [],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import { cssVars } from "../cssVars.js"
|
|
||||||
import { FILE_TYPES } from "./fileTypes"
|
import { FILE_TYPES } from "./fileTypes"
|
||||||
|
|
||||||
export let files
|
export let files
|
||||||
export let height = 70
|
export let height
|
||||||
export let width = 70
|
export let width
|
||||||
|
|
||||||
$: cssVariables = {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="file-list" use:cssVars={cssVariables}>
|
<div class="file-list">
|
||||||
{#each files as file}
|
{#each files as file}
|
||||||
<a href={file.url} target="_blank">
|
<a href={file.url} target="_blank">
|
||||||
<div class="file">
|
<div class="file">
|
||||||
|
@ -63,7 +57,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
width: 75px;
|
width: 200px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue