Skip to content

Commit

Permalink
Add pathways checkbox events for data tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
akhuoa committed May 6, 2024
1 parent f118467 commit 33afa37
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/FlatmapVuer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
identifierKey="key"
:selections="centreLines"
@changed="centreLinesSelected"
@selections-data-changed="onSelectionsDataChanged"
ref="centrelinesSelection"
key="centrelinesSelection"
/>
Expand All @@ -287,6 +288,7 @@
identifierKey="key"
:selections="sckanDisplay"
@changed="sckanSelected"
@selections-data-changed="onSelectionsDataChanged"
@checkAll="checkAllSCKAN"
ref="skcanSelection"
key="skcanSelection"
Expand All @@ -298,6 +300,7 @@
identifierKey="id"
:selections="layers"
@changed="layersSelected"
@selections-data-changed="onSelectionsDataChanged"
@checkAll="checkAllLayers"
ref="layersSelection"
key="layersSelection"
Expand All @@ -310,6 +313,7 @@
identifierKey="taxon"
:selections="taxonConnectivity"
@changed="taxonsSelected"
@selections-data-changed="onSelectionsDataChanged"
@checkAll="checkAllTaxons"
ref="taxonSelection"
key="taxonSelection"
Expand All @@ -322,6 +326,7 @@
colourStyle="line"
:selections="pathways"
@changed="pathwaysSelected"
@selections-data-changed="onSelectionsDataChanged"
@checkAll="checkAllPathways"
ref="pathwaysSelection"
key="pathwaysSelection"
Expand Down Expand Up @@ -801,6 +806,9 @@ export default {
this.mapImp.enableCentrelines(payload.value)
}
},
onSelectionsDataChanged: function (data) {
this.$emit('pathway-selection-changed', data);
},
/**
* // Currently not in use
* Function to show or hide paths valid in SCKAN
Expand Down
4 changes: 4 additions & 0 deletions src/components/MultiFlatmapVuer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* @arg $event
*/
$emit('open-map', $event)"
@pathway-selection-changed="onSelectionsDataChanged"
:minZoom="minZoom"
:helpMode="helpMode"
:renderAtMounted="renderAtMounted"
Expand Down Expand Up @@ -244,6 +245,9 @@ export default {
*/
this.$emit('pan-zoom-callback', payload)
},
onSelectionsDataChanged: function (data) {
this.$emit('pathway-selection-changed', data);
},
/**
* @vuese
* Function to show popup on map.
Expand Down
57 changes: 57 additions & 0 deletions src/components/SelectionsGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:indeterminate="isIndeterminate"
v-model="checkAll"
@change="handleCheckAllChange"
@click="onAllCheckboxNativeChange"
>Display all</el-checkbox
>
</el-col>
Expand All @@ -32,6 +33,7 @@
class="my-checkbox"
:label="item[identifierKey]"
@change="visibilityToggle(item[identifierKey], $event)"
@click="onCheckboxNativeChange"
:checked="!('enabled' in item) || item.enabled === true"
>
<el-row class="checkbox-row">
Expand Down Expand Up @@ -85,8 +87,52 @@ export default {
}
})
},
setCheckboxActionData: function (containerEl, option) {
// option = 'individual' or 'all'
if (containerEl) {
const checkboxEl = containerEl.querySelector('input[type="checkbox"]');
const checkboxLabelEl = containerEl.querySelector('.el-checkbox__label');
const selectionsContainerEl = containerEl.closest('.selections-container');
const selectionsTitleEl = selectionsContainerEl.querySelector('.checkall-display-text');
// change true/false to checked/unchecked for readability
let checkedLabel = '';
if (checkboxEl) {
checkedLabel = checkboxEl.checked ? 'checked' : 'unchecked';
}
this.checkboxActionData = {
selectionsTitle: selectionsTitleEl ? selectionsTitleEl.innerText : '',
property: (checkboxEl && option !== 'all') ? checkboxEl.value : '',
label: checkboxLabelEl ? checkboxLabelEl.innerText : '',
checked: checkedLabel
};
} else {
// reset if no checkbox container found
this.checkboxActionData = {
selectionsTitle: '',
property: '',
label: '',
checked: '',
};
}
},
onCheckboxNativeChange: function (event) {
const checkboxContainerEl = event.target.closest('.checkbox-container');
this.setCheckboxActionData(checkboxContainerEl, 'individual');
},
onAllCheckboxNativeChange: function (event) {
const checkboxContainerEl = event.target.closest('.all-checkbox');
this.setCheckboxActionData(checkboxContainerEl, 'all');
},
visibilityToggle: function (key, value) {
this.$emit('changed', { key, value })
// emit event with checkbox data for tracking
if (key === this.checkboxActionData.property) {
// change true/false to checked/unchecked for readability
this.checkboxActionData.checked = value ? 'checked' : 'unchecked';
}
this.$emit('selections-data-changed', this.checkboxActionData);
},
handleCheckedItemsChange: function (value) {
let checkedCount = value.length
Expand All @@ -100,6 +146,11 @@ export default {
keys: this.selections.map((a) => a[this.identifierKey]),
value: val,
})
// emit event with checkbox data for tracking
this.checkboxActionData.property = this.identifierKey;
// change true/false to checked/unchecked for readability
this.checkboxActionData.checked = val ? 'checked' : 'unchecked';
this.$emit('selections-data-changed', this.checkboxActionData);
},
getBackgroundStyles: function (item) {
if ('colour' in item && this.colourStyle === 'background') {
Expand Down Expand Up @@ -159,6 +210,12 @@ export default {
return {
checkedItems: [],
checkAll: true,
checkboxActionData: {
selectionsTitle: '',
property: '',
label: '',
checked: '',
},
}
},
mounted: function () {
Expand Down

0 comments on commit 33afa37

Please sign in to comment.