Skip to content
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

Add pathways checkbox events for data tracking #163

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
:enableOpenMapUI="true"
:flatmapAPI="flatmapAPI"
:disableUI="disableUI"
@open-pubmed-url="onOpenPubmedUrl"
@pathway-selection-changed="onPathwaySelectionChanged"
/>
</div>
</template>
Expand Down Expand Up @@ -114,6 +116,12 @@ export default {
console.log('resource', resource)
}
},
onOpenPubmedUrl: function (url) {
console.log('open-pubmed-url', url);
},
onPathwaySelectionChanged: function (data) {
console.log('pathway-selection-changed', data);
},
FlatmapReady: function (component) {
console.log(component)
let taxon = component.mapImp.describes
Expand Down
2 changes: 2 additions & 0 deletions src/components/ExternalResourceCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '@element-plus/icons-vue'
/* eslint-disable no-alert, no-console */
import { ElButton as Button } from 'element-plus'
import EventBus from './EventBus'

export default {
name: 'ExternalResourceCard',
Expand All @@ -47,6 +48,7 @@ export default {
return string.charAt(0).toUpperCase() + string.slice(1)
},
openUrl: function (url) {
EventBus.emit('open-pubmed-url', url);
window.open(url, '_blank')
},
},
Expand Down
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
13 changes: 13 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 @@ -120,6 +121,15 @@ export default {
EventBus.on('onActionClick', (action) => {
this.resourceSelected(action)
})
EventBus.on('open-pubmed-url', (url) => {
/**
* This event is emitted when the user clicks
* on "Open publications in pubmed" button
* from provenance popup.
* @arg url
*/
this.$emit('open-pubmed-url', url);
});
},
methods: {
/**
Expand Down Expand Up @@ -244,6 +254,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
Loading