Skip to content

Commit

Permalink
feat: switch to edit mode if chart is drop on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Dec 9, 2024
1 parent 507359e commit 5433871
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions frontend/src2/dashboard/DashboardBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { Edit3, RefreshCcw, Share2 } from 'lucide-vue-next'
import { computed, provide, ref } from 'vue'
import ContentEditable from '../components/ContentEditable.vue'
import { safeJSONParse } from '../helpers'
import { createToast } from '../helpers/toasts'
import { WorkbookChart, WorkbookDashboard, WorkbookQuery } from '../types/workbook.types'
import ChartSelectorDialog from './ChartSelectorDialog.vue'
import useDashboard from './dashboard'
import DashboardFilterSelector from './DashboardFilterSelector.vue'
import DashboardItem from './DashboardItem.vue'
import DashboardItemActions from './DashboardItemActions.vue'
import VueGridLayout from './VueGridLayout.vue'
import DashboardShareDialog from './DashboardShareDialog.vue'
import VueGridLayout from './VueGridLayout.vue'
const props = defineProps<{
dashboard: WorkbookDashboard
Expand All @@ -38,20 +36,13 @@ function onDragOver(event: DragEvent) {
function onDrop(event: DragEvent) {
if (!event.dataTransfer) return
event.preventDefault()
if (!dashboard.editing && dashboard.doc.items.length > 0) {
return createToast({
title: 'Info',
message: 'You can only add charts to the dashboard in edit mode',
variant: 'info',
})
}
if (!dashboard.editing) {
dashboard.editing = true
}
const data = safeJSONParse(event.dataTransfer.getData('text/plain'))
const chartName = data.item.name
const chart = props.charts.find((c) => c.name === chartName)
if (!chart) return
if (!dashboard.editing) {
dashboard.editing = true
}
dashboard.addChart([chart])
}
Expand Down

0 comments on commit 5433871

Please sign in to comment.