Skip to content

Commit

Permalink
[ATL-58] Transform search data JSON to a human friendly format in ann…
Browse files Browse the repository at this point in the history
…otations tab
  • Loading branch information
oleg-odysseus authored and alex-odysseus committed Oct 29, 2024
1 parent ad1ed68 commit 965b08d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions js/components/conceptAddBox/concept-add-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ define([

sharedState.activeConceptSet(conceptSet);

const filterConcept = JSON.parse(localStorage?.getItem('data-filter-concept') || null);
const filterConceptSet = JSON.parse(localStorage?.getItem('data-filter-conceptset') || null);
const filterSource = localStorage?.getItem('filter-source') || null;
const filterData = JSON.parse(localStorage?.getItem('filter-data') || null);
const datasAdded = JSON.parse(localStorage?.getItem('data-add-selected-concept') || null) || [];
const dataSearch = { filterConceptSet, filterConcept }
const dataSearch = { filterData, filterSource }
const payloadAdd = this.conceptsToAdd().map(item => {
return {
"searchData": dataSearch,
Expand Down
18 changes: 12 additions & 6 deletions js/components/faceted-datatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,21 @@ define(['knockout', 'text!./faceted-datatable.html', 'crossfilter', 'utils/Commo

self.updateFilters = function (data, event) {
const currentPath = window.location?.href;
if(currentPath?.includes('/conceptset/')){
self.setDataLocalStorage(data, 'data-filter-conceptset');
if (currentPath?.includes('/conceptset/')) {
if (currentPath?.includes('/included-sourcecodes')) {
localStorage.setItem('filter-source', 'Included Source Codes');
} else if (currentPath?.includes('/included')) {
localStorage.setItem('filter-source', 'Included Concepts');
}
self.setDataLocalStorage(data, 'filter-data');
}
const isAddConcept = currentPath?.split('?').reduce((prev, curr) => prev || curr.includes('search'), false) &&
currentPath?.split('?').reduce((prev, curr) => prev || curr.includes('query'), false) ||
currentPath?.includes('/concept/')
currentPath?.split('?').reduce((prev, curr) => prev || curr.includes('query'), false) ||
currentPath?.includes('/concept/')

if(isAddConcept){
self.setDataObjectLocalStorage(data, 'data-filter-concept')
if (isAddConcept) {
localStorage.setItem('filter-source', 'Search');
self.setDataObjectLocalStorage(data, 'filter-data')
}
var facet = data.facet;
data.selected(!data.selected());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ define([
if (r.searchData === null || r.searchData === undefined || !r.searchData) {
return 'N/A';
} else {
return `<p>${JSON.stringify(r.searchData)}</p>`
return `<p>${r.searchData}</p>`
}
},
sortable: false
Expand Down Expand Up @@ -101,7 +101,7 @@ define([

objectMap(obj) {
const newObject = {};
const keysNotToParse = ['createdBy', 'createdDate', 'vocabularyVersion', 'conceptSetVersion'];
const keysNotToParse = ['createdBy', 'createdDate', 'vocabularyVersion', 'conceptSetVersion', 'searchData'];
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'string' && !keysNotToParse.includes(key)) {
newObject[key] = JSON.parse(obj[key] || null);
Expand Down
4 changes: 2 additions & 2 deletions js/pages/concept-sets/conceptset-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ define([
}

removeDataFilterStorage(){
localStorage.removeItem('data-filter-conceptset');
localStorage.removeItem('filter-data');
localStorage.removeItem('filter-source');
localStorage.removeItem('data-remove-selected-concept');
localStorage.removeItem('data-filter-concept');
localStorage.removeItem('data-add-selected-concept');
}

Expand Down
4 changes: 2 additions & 2 deletions js/pages/vocabulary/components/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,14 @@ define([
}

async executeSearch() {
const filterObjString = localStorage.getItem('data-filter-concept')
const filterObjString = localStorage.getItem('filter-data')
let filterObj = filterObjString ? JSON.parse(filterObjString): {}

filterObj = {
...filterObj,
searchText: this.currentSearch()
}
localStorage.setItem('data-filter-concept', JSON.stringify(filterObj))
localStorage.setItem('filter-data', JSON.stringify(filterObj))

if (!this.currentSearch() && !this.showAdvanced()) {
this.data([]);
Expand Down

0 comments on commit 965b08d

Please sign in to comment.