Skip to content

Commit

Permalink
fix: script is not saved on every change
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Dec 16, 2024
1 parent 2d86dd4 commit 366110c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 5 additions & 7 deletions frontend/src2/query/components/ScriptQueryEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import { LoadingIndicator } from 'frappe-ui'
import { Bug, Play, RefreshCw } from 'lucide-vue-next'
import { computed, inject, ref } from 'vue'
import Code from '../../components/Code.vue'
import DataTable from '../../components/DataTable.vue'
import { Query } from '../query'
import ContentEditable from '../../components/ContentEditable.vue'
import { attachRealtimeListener } from '../../helpers'
import DataTable from '../../components/DataTable.vue'
import { attachRealtimeListener, wheneverChanges } from '../../helpers'
import session from '../../session'
import { Query } from '../query'
const query = inject<Query>('query')!
query.autoExecute = false
const operation = query.getCodeOperation()
const code = ref(operation ? operation.code : '')
function execute() {
query.setCode({ code: code.value })
}
wheneverChanges(code, () => query.setCode({ code: code.value }), { debounce: 500 })
const columns = computed(() => query.result.columns)
const rows = computed(() => query.result.formattedRows)
Expand Down Expand Up @@ -77,7 +75,7 @@ attachRealtimeListener('insights_script_log', (data: any) => {
</transition>
</div>
<div class="flex flex-shrink-0 gap-1 border-t p-1">
<Button @click="execute" label="Run">
<Button @click="query.execute" label="Run">
<template #prefix>
<Play class="h-3.5 w-3.5 text-gray-700" stroke-width="1.5" />
</template>
Expand Down
1 change: 0 additions & 1 deletion frontend/src2/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ export function makeQuery(workbookQuery: WorkbookQuery) {
if (args.code.trim().length) {
query.doc.operations.push(code(args))
query.activeOperationIdx = 0
query.execute()
} else {
query.activeOperationIdx = -1
}
Expand Down

0 comments on commit 366110c

Please sign in to comment.