Skip to content

Commit

Permalink
Merge pull request #880 from arjunrajlaboratory/channel-checkbox-list
Browse files Browse the repository at this point in the history
Added channel checkbox group to worker interface
  • Loading branch information
arjunrajlab authored Jan 31, 2025
2 parents 7f316ba + 08cb153 commit f2607f2
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
60 changes: 60 additions & 0 deletions src/components/ChannelCheckboxGroup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<v-container class="pa-0">
<v-subheader v-if="label" class="px-0">{{ label }}</v-subheader>
<template v-if="channelItems && channelItems.length">
<v-row v-for="item in channelItems" :key="item.value" class="ma-0">
<v-col cols="12" class="pa-1">
<v-checkbox
v-model="selectedChannels[item.value]"
:label="item.text"
dense
hide-details
v-bind="$attrs"
></v-checkbox>
</v-col>
</v-row>
</template>
</v-container>
</template>

<script lang="ts">
import { Vue, Component, Prop, VModel } from "vue-property-decorator";
import store from "@/store";
@Component({})
export default class ChannelCheckboxGroup extends Vue {
readonly store = store;
@Prop({ default: "" })
readonly label!: string;
@VModel({ type: Object, default: () => ({}) })
selectedChannels!: { [key: number]: boolean };
get channelItems() {
if (!this.store.dataset) return [];
return this.store.dataset.channels.map((channel: number) => ({
text:
this.store.dataset?.channelNames?.get(channel) || `Channel ${channel}`,
value: channel,
}));
}
created() {
// Initialize selectedChannels with an empty object if undefined
this.selectedChannels = this.selectedChannels || {};
// Then add any missing channels
if (this.store.dataset?.channels) {
const updatedChannels = { ...this.selectedChannels };
for (const channel of this.store.dataset.channels) {
if (!(channel in updatedChannels)) {
updatedChannels[channel] = false;
}
}
this.selectedChannels = updatedChannels;
}
}
}
</script>
18 changes: 17 additions & 1 deletion src/components/WorkerInterfaceValues.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
v-bind="item.vueAttrs"
v-model="interfaceValues[id]"
></channel-select>
<channel-checkbox-group
v-if="item.type === 'channelCheckboxes'"
v-bind="item.vueAttrs"
v-model="interfaceValues[id]"
></channel-checkbox-group>
<v-checkbox
v-if="item.type === 'checkbox'"
v-bind="item.vueAttrs"
Expand All @@ -99,10 +104,18 @@ import {
} from "@/store/model";
import LayerSelect from "@/components/LayerSelect.vue";
import ChannelSelect from "@/components/ChannelSelect.vue";
import ChannelCheckboxGroup from "@/components/ChannelCheckboxGroup.vue";
import TagPicker from "@/components/TagPicker.vue";
import { getTourStepId } from "@/utils/strings";
// Popup for new tool configuration
@Component({ components: { LayerSelect, ChannelSelect, TagPicker } })
@Component({
components: {
LayerSelect,
ChannelSelect,
ChannelCheckboxGroup,
TagPicker,
},
})
export default class WorkerInterfaceValues extends Vue {
@Prop()
readonly workerInterface!: IWorkerInterface;
Expand Down Expand Up @@ -139,6 +152,9 @@ export default class WorkerInterfaceValues extends Vue {
case "channel":
return 0;
case "channelCheckboxes":
return {};
case "checkbox":
return false;
}
Expand Down
8 changes: 8 additions & 0 deletions src/store/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,13 @@ export interface IChannelWorkerInterfaceElement
required?: boolean;
}

export interface IChannelCheckboxesWorkerInterfaceElement
extends ICommonWorkerInterfaceElement {
type: "channelCheckboxes";
default?: { [channel: number]: boolean };
required?: boolean;
}

export interface ICheckboxWorkerInterfaceElement
extends ICommonWorkerInterfaceElement {
type: "checkbox";
Expand All @@ -1107,6 +1114,7 @@ export type TWorkerInterfaceElement =
| ILayerWorkerInterfaceElement
| ISelectWorkerInterfaceElement
| IChannelWorkerInterfaceElement
| IChannelCheckboxesWorkerInterfaceElement
| ICheckboxWorkerInterfaceElement;

export type TWorkerInterfaceType = TWorkerInterfaceElement["type"];
Expand Down

0 comments on commit f2607f2

Please sign in to comment.