-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ColumnHeaderMenu): add replace functionality #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DaxServer
merged 1 commit into
main
from
add-replace-functionality-to-column-header-menu
Sep 28, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
frontend/src/features/data-processing/components/ReplaceDialog.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| <script setup lang="ts"> | ||
| const props = defineProps<{ | ||
| visible: boolean | ||
| columnField: string | ||
| columnHeader: string | ||
| }>() | ||
|
|
||
| const emit = defineEmits<{ | ||
| 'update:visible': [value: boolean] | ||
| 'replace-completed': [affectedRows: number] | ||
| }>() | ||
|
|
||
| const api = useApi() | ||
| const { showError } = useErrorHandling() | ||
| const projectId = useRouteParams('id') as Ref<UUID> | ||
|
|
||
| const findText = ref('') | ||
| const replaceText = ref('') | ||
| const caseSensitive = ref(false) | ||
| const wholeWord = ref(false) | ||
| const isLoading = ref(false) | ||
|
|
||
| const handleReplace = async () => { | ||
| if (!findText.value) { | ||
| return | ||
| } | ||
|
|
||
| isLoading.value = true | ||
|
|
||
| try { | ||
| const { data, error } = await api.project({ projectId: projectId.value }).replace.post({ | ||
| column: props.columnField, | ||
| find: findText.value, | ||
| replace: replaceText.value, | ||
| caseSensitive: caseSensitive.value, | ||
| wholeWord: wholeWord.value, | ||
| }) | ||
|
|
||
| if (error) { | ||
| showError(error.value as ExtendedError[]) | ||
| return | ||
| } | ||
|
|
||
| if (!data?.affectedRows) { | ||
| showError([{ code: 'NOT_FOUND', message: 'Replace operation failed' }]) | ||
| return | ||
| } | ||
|
|
||
| if (data?.affectedRows !== undefined && data?.affectedRows !== null) { | ||
| emit('replace-completed', data.affectedRows) | ||
| } | ||
| } catch (error) { | ||
| console.error('Replace operation failed:', error) | ||
| } finally { | ||
| isLoading.value = false | ||
| closeDialog() | ||
| } | ||
| } | ||
|
|
||
| const closeDialog = () => { | ||
| emit('update:visible', false) | ||
| // Reset form | ||
| findText.value = '' | ||
| replaceText.value = '' | ||
| caseSensitive.value = false | ||
| wholeWord.value = false | ||
| } | ||
|
|
||
| const handleVisibleChange = (visible: boolean) => { | ||
| emit('update:visible', visible) | ||
| if (!visible) { | ||
| // Reset form when dialog is closed | ||
| findText.value = '' | ||
| replaceText.value = '' | ||
| caseSensitive.value = false | ||
| wholeWord.value = false | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <Dialog | ||
| :visible="visible" | ||
| modal | ||
| :header="`Replace in ${columnHeader}`" | ||
| :style="{ width: '30vw' }" | ||
| @update:visible="handleVisibleChange" | ||
| > | ||
| <div class="flex flex-col gap-4"> | ||
| <div class="flex flex-col gap-2"> | ||
| <label for="find-text" class="font-semibold">Find</label> | ||
| <InputText | ||
| id="find-text" | ||
| v-model="findText" | ||
| placeholder="Enter text to find" | ||
| :disabled="isLoading" | ||
| /> | ||
| </div> | ||
|
|
||
| <div class="flex flex-col gap-2"> | ||
| <label for="replace-text" class="font-semibold">Replace with</label> | ||
| <InputText | ||
| id="replace-text" | ||
| v-model="replaceText" | ||
| placeholder="Enter replacement text" | ||
| :disabled="isLoading" | ||
| /> | ||
| </div> | ||
|
|
||
| <div class="flex flex-col gap-3"> | ||
| <div class="flex items-center gap-2"> | ||
| <Checkbox | ||
| id="case-sensitive" | ||
| v-model="caseSensitive" | ||
| binary | ||
| :disabled="isLoading" | ||
| /> | ||
| <label for="case-sensitive" class="cursor-pointer">Case sensitive</label> | ||
| </div> | ||
|
|
||
| <div class="flex items-center gap-2"> | ||
| <Checkbox | ||
| id="whole-word" | ||
| v-model="wholeWord" | ||
| binary | ||
| :disabled="isLoading" | ||
| /> | ||
| <label for="whole-word" class="cursor-pointer">Whole word only</label> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <template #footer> | ||
| <Button | ||
| label="Cancel" | ||
| icon="pi pi-times" | ||
| text | ||
| severity="secondary" | ||
| :disabled="isLoading" | ||
| @click="closeDialog" | ||
| /> | ||
| <Button | ||
| label="Replace" | ||
| icon="pi pi-check" | ||
| :loading="isLoading" | ||
| :disabled="!findText" | ||
| @click="handleReplace" | ||
| /> | ||
| </template> | ||
| </Dialog> | ||
| </template> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle 0-row results without flagging failure.
Line 44 treats
data.affectedRows === 0as a failure, which is a valid outcome when nothing matched the search. That branch shows an error and returns before we emitreplace-completed, so callers never learn that the operation succeeded (with zero matches) and users see a spurious failure message. Please adjust the guard to only bail out whenaffectedRowsisnull/undefined, and continue to emit the event (and close the dialog) when it’s0.📝 Committable suggestion
🤖 Prompt for AI Agents