diff --git a/app/javascript/vue/tasks/otu/browse/components/NomenclatureHistory.vue b/app/javascript/vue/tasks/otu/browse/components/NomenclatureHistory.vue index 3dbe3225d3..ae21acfcdc 100644 --- a/app/javascript/vue/tasks/otu/browse/components/NomenclatureHistory.vue +++ b/app/javascript/vue/tasks/otu/browse/components/NomenclatureHistory.vue @@ -1,31 +1,21 @@ @@ -67,11 +84,13 @@ import SectionPanel from './shared/sectionPanel' import { GetNomenclatureHistory } from '../request/resources.js' import SwitchComponent from 'components/switch' +import ModalComponent from 'components/modal' export default { components: { SectionPanel, - SwitchComponent + SwitchComponent, + ModalComponent }, props: { otu: { @@ -80,29 +99,77 @@ export default { }, data() { return { - tabs: ['All', 'Nomenclature', 'Protonym', 'OTU (Biology)'], - nomenclature: '', - filterSelected: [], - hideInfo: [{ - label: 'Topics', - key: '.history__citation_topics', - value: true + showModal: false, + filterSections: { + time: [ + { + label: 'First', + key: 'history-is-first', + value: true, + attribute: true + }, + { + label: 'End', + key: 'history-is-last', + value: true, + attribute: true + } + ], + topic: [ + { + label: 'Show', + key: '.history__citation_topics', + value: true + } + ], + metadata: [ + { + label: 'Notes', + key: '.annotation__note', + value: true + }, + { + label: 'Soft validation', + key: '.soft_validation_anchor', + value: true + }, + { + label: 'Valid', + key: 'history-is-valid', + value: true, + attribute: true + }, + { + label: 'Invalid', + key: 'history-is-invalid', + value: true, + attribute: true + }, + { + label: 'Cited', + key: 'data-is-cited', + value: true + } + ] }, - { - label: 'Notes', - key: '.annotation__note', - value: true + nomenclature: '', + tabSelected: { + label: 'All', + key: '', + value: '' }, - { - label: 'Soft validation', - key: '.soft_validation_anchor', - value: true - }], - filter: [ + hideInfo: [], + filterTabs: [ { - label: 'History', - key: 'history-is-first', - value: true + label: 'All', + key: '', + value: '' + }, + { + label: 'Nomenclature', + key: 'history-origin', + value: 'otu', + equal: false }, { label: 'Protonym', @@ -110,9 +177,9 @@ export default { value: 'protonym' }, { - label: 'Valid', - key: 'history-valid-name', - value: true + label: 'OTU (biology)', + key: 'history-origin', + value: 'otu' } ], current: false @@ -129,11 +196,14 @@ export default { }, immediate: true }, - hideInfo: { + filterSections: { handler (newVal) { - this.hideInfo.forEach(item => { - document.querySelectorAll(item.key).forEach(element => { - item.value ? element.classList.remove('hidden') : element.classList.add('hidden') + const keys = Object.keys(newVal) + keys.forEach(key => { + newVal[key].forEach(item => { + document.querySelectorAll(item.key).forEach(element => { + item.value ? element.classList.remove('hidden') : element.classList.add('hidden') + }) }) }) }, @@ -142,9 +212,17 @@ export default { }, methods: { checkFilter (item) { - return (this.filterSelected.every(filter => { - return item.data_attributes[filter.key] == filter.value - }) && (this.current ? item.data_attributes['history-object-id'] === this.nomenclature.reference_object_valid_taxon_name : true)) + const keys = Object.keys(this.filterSections) + return ((!this.tabSelected.hasOwnProperty('equal') && + this.tabSelected.equal ? + item.data_attributes[this.tabSelected.key] === this.tabSelected.value : + item.data_attributes[this.tabSelected.key] != this.tabSelected.value) || + (this.tabSelected.label === 'All')) && + keys.every(key => { + return this.filterSections[key].every(filter => { + return item.data_attributes[filter.key] !== filter.value + }) + }) }, filterSource(source) { let globalIds = source[Object.keys(source)[0]].objects diff --git a/app/javascript/vue/tasks/otu/browse/components/shared/sectionPanel.vue b/app/javascript/vue/tasks/otu/browse/components/shared/sectionPanel.vue index 71fc1fb770..d9dfe37447 100644 --- a/app/javascript/vue/tasks/otu/browse/components/shared/sectionPanel.vue +++ b/app/javascript/vue/tasks/otu/browse/components/shared/sectionPanel.vue @@ -11,7 +11,9 @@
-
+