Skip to content

Commit

Permalink
fix: set all checkboxes of processor filter to selected on page load
Browse files Browse the repository at this point in the history
  • Loading branch information
amtul.noor committed Apr 17, 2024
1 parent f4b6adb commit 3387ceb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/components/workflows/WorkflowsTimeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ const selectedWorkflow = ref<DropdownOption | null>(null)
const workflowStepOptions = ref<DropdownOption[]>([])
const selectedWorkflowSteps = ref<DropdownOption[]>([])
const workflowStepDropdownChanged = ref(false)
const workflowStepDropdownLabel = computed(() => {
if (!workflowStepDropdownChanged.value && workflowStepOptions.value.length === selectedWorkflowSteps.value.length) {
return t('Filter by processor')
}
return null
})
const gtList = computed<GroundTruth[]>(() => {
return workflowsStore.gt.filter(({ id, metadata }) => {
let flag = filtersStore.gt.findIndex(({ value }) => value === id) > -1
Expand Down Expand Up @@ -75,6 +83,7 @@ watch(
selectedWorkflowSteps.value = []
if (!selected) {
workflowStepOptions.value = deduplicateStepIds(workflowsStore.workflows).map(id => ({ value: id, label: t(id) }))
selectedWorkflowSteps.value = workflowStepOptions.value
return
}
const workflow = workflowsStore.workflows.find((item) => item.id === selected.value)
Expand All @@ -83,6 +92,7 @@ watch(
return
}
workflowStepOptions.value = workflow.steps.map(({ id }) => ({ value: id, label: t(id) }))
selectedWorkflowSteps.value = workflowStepOptions.value
},
{ immediate: true }
)
Expand Down Expand Up @@ -129,6 +139,8 @@ watch(
:options="workflowStepOptions"
optionLabel="label"
:placeholder="t('Filter by processor')"
:selected-items-label="workflowStepDropdownLabel"
@change="workflowStepDropdownChanged = true"
class="ml-4 md:w-14rem"
/>
</div>
Expand Down
16 changes: 6 additions & 10 deletions src/components/workflows/timeline/TimelineItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ const workflows = computed(() => {
if (props.selectedWorkflowId) {
return workflowsStore.workflows.filter((item) => item.id === props.selectedWorkflowId)
} else {
if (props.selectedWorkflowStepIds.length > 0) {
return workflowsStore.workflows.filter(({ steps }) => {
return props.selectedWorkflowStepIds.findIndex((id) => {
return steps.findIndex((step) => step.id === id) > -1
}) > -1
})
} else {
return workflowsStore.workflows
}
return workflowsStore.workflows.filter(({ steps }) => {
return props.selectedWorkflowStepIds.findIndex((id) => {
return steps.findIndex((step) => step.id === id) > -1
}) > -1
})
}
})
Expand All @@ -47,7 +43,7 @@ function showWorkflowStep(stepId: string) {
if (props.selectedWorkflowStepIds.length > 0) {
return props.selectedWorkflowStepIds.findIndex(id => id === stepId) > -1
} else {
return true
return false
}
}
Expand Down

0 comments on commit 3387ceb

Please sign in to comment.