allow editing row from modal

This commit is contained in:
Martin McKeaveney 2020-10-23 23:55:51 +01:00
parent 9ad336d984
commit 19f1f01d1a
7 changed files with 33 additions and 83 deletions

View File

@ -66,7 +66,7 @@
"@budibase/bbui": "^1.44.1", "@budibase/bbui": "^1.44.1",
"@budibase/client": "^0.2.6", "@budibase/client": "^0.2.6",
"@budibase/colorpicker": "^1.0.1", "@budibase/colorpicker": "^1.0.1",
"@budibase/svelte-ag-grid": "^0.0.14", "@budibase/svelte-ag-grid": "^0.0.15",
"@fortawesome/fontawesome-free": "^5.14.0", "@fortawesome/fontawesome-free": "^5.14.0",
"@sentry/browser": "5.19.1", "@sentry/browser": "5.19.1",
"@svelteschool/svelte-forms": "^0.7.0", "@svelteschool/svelte-forms": "^0.7.0",

View File

@ -1,14 +1,7 @@
<script> <script>
import { goto, params } from "@sveltech/routify"
import { onMount } from "svelte"
import { fade } from "svelte/transition" import { fade } from "svelte/transition"
import { store, backendUiStore } from "builderStore"
import api from "builderStore/api"
import { Button, Icon } from "@budibase/bbui"
import Spinner from "components/common/Spinner.svelte" import Spinner from "components/common/Spinner.svelte"
import AgGrid from "@budibase/svelte-ag-grid"
// New
import AgGrid from "./AgGrid.svelte"
import { getRenderer, editRowRenderer } from "./cells/cellRenderers"; import { getRenderer, editRowRenderer } from "./cells/cellRenderers";
import TableHeader from "./TableHeader" import TableHeader from "./TableHeader"
@ -25,10 +18,9 @@
let options = { let options = {
defaultColDef: { defaultColDef: {
flex: 1, flex: 1,
minWidth: 150,
filter: true, filter: true,
}, },
rowSelection: "multiple", rowSelection: true,
rowMultiSelectWithClick: true, rowMultiSelectWithClick: true,
suppressRowClickSelection: false, suppressRowClickSelection: false,
paginationAutoPageSize: true, paginationAutoPageSize: true,
@ -37,24 +29,23 @@
popupParent: document.body, popupParent: document.body,
} }
$: console.log(options)
// TODO: refactor // TODO: refactor
$: { $: {
let result = [] let result = []
if (allowEditing) { if (allowEditing) {
result.push({ result.push({
pinned: "left",
headerName: "Edit", headerName: "Edit",
sortable: false, sortable: false,
resizable: false, resizable: false,
suppressMovable: true, suppressMovable: true,
suppressMenu: true, suppressMenu: true,
minWidth: 0, minWidth: 75,
width: 10, width: 75,
cellRenderer: editRowRenderer cellRenderer: editRowRenderer
}) })
} }
columnDefs = [...result, ...Object.keys(schema).map(key => ({ columnDefs = [...result, ...Object.keys(schema || {}).map(key => ({
// headerCheckboxSelection: i === 0 && canEdit, // headerCheckboxSelection: i === 0 && canEdit,
// checkboxSelection: i === 0 && canEdit, // checkboxSelection: i === 0 && canEdit,
// valueSetter: setters.get(schema[key].type), // valueSetter: setters.get(schema[key].type),
@ -70,9 +61,9 @@
cellRenderer: getRenderer(schema[key], true), cellRenderer: getRenderer(schema[key], true),
autoHeight: true, autoHeight: true,
resizable: true, resizable: true,
minWidth: 200,
}))] }))]
} }
$: tableId = data?.length ? data[0].tableId : null
// function selectRelationship(row, fieldName) { // function selectRelationship(row, fieldName) {
// if (!row?.[fieldName]?.length) { // if (!row?.[fieldName]?.length) {

View File

@ -1,9 +1,6 @@
<script> <script>
import { onMount } from "svelte" import { onMount } from "svelte"
import { store, backendUiStore } from "builderStore" import { Modal, ModalContent } from "@budibase/bbui"
import { notifier } from "builderStore/store/notifications"
import { Modal, ModalContent, Icon } from "@budibase/bbui"
import ColumnHeaderPopover from "../popovers/ColumnPopover.svelte"
import CreateEditColumnPopover from "../popovers/CreateEditColumnPopover.svelte" import CreateEditColumnPopover from "../popovers/CreateEditColumnPopover.svelte"
const SORT_ICON_MAP = { const SORT_ICON_MAP = {
@ -12,22 +9,18 @@
} }
export let field export let field
export let displayName
export let column export let column
export let gridApi
export let enableMenu = true
export let enableSorting = true export let enableSorting = true
export let showColumnMenu export let showColumnMenu
export let progressSort export let progressSort
export let gridApi
export let enableMenu = true
let menuButton let menuButton
let sortDirection = "" let sortDirection = ""
let modal let modal
let originalName = field.name
let primaryDisplay =
$backendUiStore.selectedTable.primaryDisplay == null ||
$backendUiStore.selectedTable.primaryDisplay === field.name
function toggleMenu() { function toggleMenu() {
showColumnMenu(menuButton) showColumnMenu(menuButton)
} }
@ -49,7 +42,7 @@
<header on:click={onSort}> <header on:click={onSort}>
<div> <div>
<span>{field.name}</span> <span>{displayName}</span>
{#if enableSorting && sortDirection} {#if enableSorting && sortDirection}
<i class={`${SORT_ICON_MAP[sortDirection]} sort-icon`} /> <i class={`${SORT_ICON_MAP[sortDirection]} sort-icon`} />
{/if} {/if}

View File

@ -80,33 +80,6 @@ function attachmentRenderer(options, constraints, editable) {
return container return container
} }
} }
/* eslint-disable no-unused-vars */
// function dateRenderer(options, constraints, editable) {
// return function(params) {
// const container = document.createElement("div")
// const toggle = e => {
// params.setValue(e.detail[0][0])
// }
// // Options need to be passed in with minTime and maxTime! Needs bbui update.
// new DatePicker({
// target: container,
// props: {
// value: params.value,
// },
// })
// return container
// }
// }
function optionsRenderer(options, constraints, editable) {
return params => {
const container = document.createElement("div")
// TODO: show a pill
return container
}
}
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
function linkedRowRenderer(options, constraints, editable) { function linkedRowRenderer(options, constraints, editable) {

View File

@ -1,27 +1,17 @@
<script> <script>
import { onMount } from "svelte"
import { import {
Input, Input,
TextArea,
Button, Button,
Select, Select,
Toggle, Toggle,
Label,
} from "@budibase/bbui" } from "@budibase/bbui"
import { cloneDeep, merge } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { store, backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
import { FIELDS } from "constants/backend" import { FIELDS } from "constants/backend"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import ButtonGroup from "components/common/ButtonGroup.svelte"
import NumberBox from "components/common/NumberBox.svelte"
import ValuesList from "components/common/ValuesList.svelte" import ValuesList from "components/common/ValuesList.svelte"
import ErrorsBox from "components/common/ErrorsBox.svelte"
import Checkbox from "components/common/Checkbox.svelte"
import ActionButton from "components/common/ActionButton.svelte"
import DatePicker from "components/common/DatePicker.svelte" import DatePicker from "components/common/DatePicker.svelte"
import LinkedRowSelector from "components/common/LinkedRowSelector.svelte"
import ConfirmDialog from "components/common/ConfirmDialog.svelte" import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import * as api from "../api"
let fieldDefinitions = cloneDeep(FIELDS) let fieldDefinitions = cloneDeep(FIELDS)
@ -63,11 +53,10 @@
} else { } else {
backendUiStore.actions.tables.deleteField(field) backendUiStore.actions.tables.deleteField(field)
notifier.success("Column deleted") notifier.success("Column deleted")
hideDeleteDialog()
} }
onClosed()
} }
function handleFieldConstraints(event) { function handleFieldConstraints(event) {
const { type, constraints } = fieldDefinitions[ const { type, constraints } = fieldDefinitions[
event.target.value.toUpperCase() event.target.value.toUpperCase()
@ -91,8 +80,12 @@
} }
function confirmDelete() { function confirmDelete() {
onClosed()
confirmDeleteDialog.show() confirmDeleteDialog.show()
onClosed()
}
function hideDeleteDialog() {
confirmDeleteDialog.hide()
} }
</script> </script>
@ -168,9 +161,9 @@
{/if} {/if}
<footer> <footer>
{#if originalName} {#if originalName}
<Button secondary on:click={onClosed}>Cancel</Button> <Button red on:click={confirmDelete}>Delete Column</Button>
{/if} {/if}
<Button red on:click={confirmDelete}>Delete Column</Button> <Button secondary on:click={onClosed}>Cancel</Button>
<Button primary on:click={saveColumn}>Save Column</Button> <Button primary on:click={saveColumn}>Save Column</Button>
</footer> </footer>
</div> </div>
@ -179,11 +172,11 @@
body={`Are you sure you wish to delete this column? Your data will be deleted and this action cannot be undone.`} body={`Are you sure you wish to delete this column? Your data will be deleted and this action cannot be undone.`}
okText="Delete Column" okText="Delete Column"
onOk={deleteColumn} onOk={deleteColumn}
onCancel={hideDeleteDialog}
title="Confirm Delete" /> title="Confirm Delete" />
<style> <style>
.actions { .actions {
/* padding: var(--spacing-xl); */
display: grid; display: grid;
grid-gap: var(--spacing-xl); grid-gap: var(--spacing-xl);
min-width: 400px; min-width: 400px;

View File

@ -14,12 +14,12 @@
let modal let modal
function showModal() { function showModal() {
dropdown.hide() // dropdown.hide()
modal.show() modal.show()
} }
function showDelete() { function showDelete() {
dropdown.hide() // dropdown.hide()
confirmDeleteDialog.show() confirmDeleteDialog.show()
} }
@ -30,10 +30,10 @@
} }
</script> </script>
<div bind:this={anchor} on:click={dropdown.show}> <div on:click={showModal}>
<i class="ri-more-line" /> <i class="ri-more-line" />
</div> </div>
<DropdownMenu bind:this={dropdown} {anchor} align="left"> <!-- <DropdownMenu bind:this={dropdown} {anchor} align="left">
<ul> <ul>
<li data-cy="edit-row" on:click={showModal}> <li data-cy="edit-row" on:click={showModal}>
<Icon name="edit" /> <Icon name="edit" />
@ -44,7 +44,7 @@
<span>Delete</span> <span>Delete</span>
</li> </li>
</ul> </ul>
</DropdownMenu> </DropdownMenu> -->
<ConfirmDialog <ConfirmDialog
bind:this={confirmDeleteDialog} bind:this={confirmDeleteDialog}
body={`Are you sure you wish to delete this row? Your data will be deleted and this action cannot be undone.`} body={`Are you sure you wish to delete this row? Your data will be deleted and this action cannot be undone.`}

View File

@ -731,10 +731,10 @@
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/@budibase/colorpicker/-/colorpicker-1.0.1.tgz#940c180e7ebba0cb0756c4c8ef13f5dfab58e810" resolved "https://registry.yarnpkg.com/@budibase/colorpicker/-/colorpicker-1.0.1.tgz#940c180e7ebba0cb0756c4c8ef13f5dfab58e810"
"@budibase/svelte-ag-grid@^0.0.14": "@budibase/svelte-ag-grid@^0.0.15":
version "0.0.14" version "0.0.15"
resolved "https://registry.yarnpkg.com/@budibase/svelte-ag-grid/-/svelte-ag-grid-0.0.14.tgz#387e0423f726d9eb6fa38c5cfd3e5d3c6fa9ca56" resolved "https://registry.yarnpkg.com/@budibase/svelte-ag-grid/-/svelte-ag-grid-0.0.15.tgz#d115243e54b2d00624794afa07fbea4f45c2824d"
integrity sha512-CYcPDdbEVGB6w3h0GQCBM4/Kg5sTxl9TFDpgFhMKmDmbbOU5+gVqsNQ4TtINP46nRPGQgTBRyfhkh0NJgOGafQ== integrity sha512-1DYrbv07urntexv8nTHsKcgseQOaw6rVNMU0kLQXoDqHJncyyBc9bSh5qCgitAYvKtJ2GhT/Lj/v84z8Kb2fdQ==
dependencies: dependencies:
ag-grid-community "^24.0.0" ag-grid-community "^24.0.0"