@abi-software/map-side-bar 2.4.0-isan-1 → 2.4.0-isan-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/map-side-bar.js +27 -14
- package/dist/map-side-bar.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/App.vue +13 -0
- package/src/components/SideBar.vue +5 -1
- package/src/components/SidebarContent.vue +56 -13
- package/src/flatmapQueries/flatmapQueries.js +10 -10
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
/>
|
|
7
7
|
<div class="options-container">
|
|
8
8
|
<div>Click arrow to open sidebar</div>
|
|
9
|
+
<el-button @click="openPMRSearch">PMR Search</el-button>
|
|
9
10
|
<el-button @click="openSearch">search Uberon from refs</el-button>
|
|
10
11
|
<el-button @click="singleFacets">Add heart to Filter</el-button>
|
|
11
12
|
<el-button @click="addStomach">Add stomach to Filter</el-button>
|
|
@@ -146,6 +147,18 @@ export default {
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
},
|
|
150
|
+
openPMRSearch: function () {
|
|
151
|
+
this.$refs.sideBar.openSearch(
|
|
152
|
+
[
|
|
153
|
+
{
|
|
154
|
+
facet: "PMR",
|
|
155
|
+
term: "Data type",
|
|
156
|
+
facetPropPath: "item.types.name",
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
'cardiovascular multiscale model'
|
|
160
|
+
);
|
|
161
|
+
},
|
|
149
162
|
openSearch: function () {
|
|
150
163
|
this.$refs.sideBar.openSearch(
|
|
151
164
|
[],
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
v-show="tab.id === activeTabId"
|
|
46
46
|
:contextCardEntry="tab.contextCard"
|
|
47
47
|
:envVars="envVars"
|
|
48
|
+
:initFilters="initFilters"
|
|
48
49
|
:ref="'searchTab_' + tab.id"
|
|
49
50
|
@pmr-action-click="onPmrActionClick"
|
|
50
51
|
@search-changed="searchChanged(tab.id, $event)"
|
|
@@ -137,6 +138,7 @@ export default {
|
|
|
137
138
|
data: function () {
|
|
138
139
|
return {
|
|
139
140
|
drawerOpen: false,
|
|
141
|
+
initFilters: { filter: [], searchInput: '' },
|
|
140
142
|
availableAnatomyFacets: []
|
|
141
143
|
}
|
|
142
144
|
},
|
|
@@ -177,7 +179,9 @@ export default {
|
|
|
177
179
|
this.drawerOpen = !this.drawerOpen
|
|
178
180
|
},
|
|
179
181
|
openSearch: function (facets, query) {
|
|
180
|
-
this.
|
|
182
|
+
this.initFilters.filter = facets;
|
|
183
|
+
this.initFilters.searchInput = query;
|
|
184
|
+
this.drawerOpen = true;
|
|
181
185
|
// Because refs are in v-for, nextTick is needed here
|
|
182
186
|
this.$nextTick(() => {
|
|
183
187
|
const searchTabRef = this.getSearchTabRefById(1);
|
|
@@ -121,6 +121,7 @@ var initial_state = {
|
|
|
121
121
|
numberPerPage: 10,
|
|
122
122
|
page: 1,
|
|
123
123
|
pmrResultsOnlyFlag: false,
|
|
124
|
+
noPMRResultsFlag: false,
|
|
124
125
|
hasSearched: false,
|
|
125
126
|
contextCardEnabled: false,
|
|
126
127
|
pmrResults: [],
|
|
@@ -157,6 +158,13 @@ export default {
|
|
|
157
158
|
type: Object,
|
|
158
159
|
default: () => initial_state,
|
|
159
160
|
},
|
|
161
|
+
initFilters: {
|
|
162
|
+
type: Object,
|
|
163
|
+
default: {
|
|
164
|
+
filter: [],
|
|
165
|
+
searchInput: '',
|
|
166
|
+
}
|
|
167
|
+
},
|
|
160
168
|
envVars: {
|
|
161
169
|
type: Object,
|
|
162
170
|
default: () => {},
|
|
@@ -165,6 +173,7 @@ export default {
|
|
|
165
173
|
data: function () {
|
|
166
174
|
return {
|
|
167
175
|
...this.entry,
|
|
176
|
+
...this.initFilters,
|
|
168
177
|
bodyStyle: {
|
|
169
178
|
flex: '1 1 auto',
|
|
170
179
|
'flex-flow': 'column',
|
|
@@ -215,17 +224,20 @@ export default {
|
|
|
215
224
|
},
|
|
216
225
|
// openSearch: Resets the results, populates dataset cards and filters. Will use Algolia and SciCrunch data uness pmr mode is set
|
|
217
226
|
openSearch: function(filter, search = '', resetSearch = true) {
|
|
227
|
+
this.updatePMROnlyFlag(filter);
|
|
228
|
+
|
|
218
229
|
if (resetSearch) {
|
|
219
230
|
this.resetSearch();
|
|
220
|
-
this.
|
|
231
|
+
this.openFilterSearch(filter, search);
|
|
221
232
|
} else {
|
|
222
233
|
this.searchAlgolia(filter, search);
|
|
234
|
+
this.openPMRSearch(filter, search);
|
|
223
235
|
}
|
|
224
|
-
this.openPMRSearch(filter, search)
|
|
225
236
|
},
|
|
226
237
|
|
|
227
238
|
// openPMRSearch: Resets the results, populates dataset cards and filters with PMR data.
|
|
228
239
|
openPMRSearch: function (filter, search = '') {
|
|
240
|
+
this.loadingCards = true;
|
|
229
241
|
this.flatmapQueries.updateOffset(this.calculatePMROffest())
|
|
230
242
|
this.flatmapQueries.updateLimit(this.PMRLimit(this.pmrResultsOnlyFlag))
|
|
231
243
|
this.flatmapQueries.pmrSearch(filter, search).then((data) => {
|
|
@@ -233,11 +245,13 @@ export default {
|
|
|
233
245
|
this.results.push(result)
|
|
234
246
|
})
|
|
235
247
|
this.pmrNumberOfHits = this.flatmapQueries.numberOfHits
|
|
248
|
+
this.loadingCards = false;
|
|
236
249
|
})
|
|
237
250
|
},
|
|
238
251
|
|
|
239
|
-
// openAlgoliaSearch:
|
|
240
|
-
|
|
252
|
+
// previously openAlgoliaSearch:
|
|
253
|
+
// Resets the results, populates dataset cards and filters with Algloia and SciCrunch data.
|
|
254
|
+
openFilterSearch: function (filter, search = '') {
|
|
241
255
|
this.searchInput = search
|
|
242
256
|
//Proceed normally if cascader is ready
|
|
243
257
|
if (this.cascaderIsReady) {
|
|
@@ -255,7 +269,14 @@ export default {
|
|
|
255
269
|
this.$refs.filtersRef.checkShowAllBoxes()
|
|
256
270
|
this.resetSearch()
|
|
257
271
|
} else if (this.filter) {
|
|
258
|
-
|
|
272
|
+
if (this.pmrResultsOnlyFlag) {
|
|
273
|
+
this.openPMRSearch(this.filter, search);
|
|
274
|
+
} else if (this.noPMRResultsFlag) {
|
|
275
|
+
this.searchAlgolia(this.filter, search);
|
|
276
|
+
} else {
|
|
277
|
+
this.searchAlgolia(this.filter, search);
|
|
278
|
+
this.openPMRSearch(this.filter, search);
|
|
279
|
+
}
|
|
259
280
|
this.$refs.filtersRef.setCascader(this.filter)
|
|
260
281
|
}
|
|
261
282
|
} else {
|
|
@@ -263,7 +284,14 @@ export default {
|
|
|
263
284
|
//otherwise waith for cascader to be ready
|
|
264
285
|
this.filter = filter
|
|
265
286
|
if (!filter || filter.length == 0) {
|
|
266
|
-
|
|
287
|
+
if (this.pmrResultsOnlyFlag) {
|
|
288
|
+
this.openPMRSearch(this.filter, search);
|
|
289
|
+
} else if (this.noPMRResultsFlag) {
|
|
290
|
+
this.searchAlgolia(this.filter, search);
|
|
291
|
+
} else {
|
|
292
|
+
this.searchAlgolia(this.filter, search);
|
|
293
|
+
this.openPMRSearch(this.filter, search);
|
|
294
|
+
}
|
|
267
295
|
}
|
|
268
296
|
}
|
|
269
297
|
},
|
|
@@ -303,11 +331,19 @@ export default {
|
|
|
303
331
|
}
|
|
304
332
|
},
|
|
305
333
|
updatePMROnlyFlag: function (filters) {
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
334
|
+
const dataTypeFilters = filters.filter((item) => item.facetPropPath === 'item.types.name');
|
|
335
|
+
const pmrFilter = dataTypeFilters.filter((item) => item.facet === 'PMR');
|
|
336
|
+
const showAllFilter = dataTypeFilters.filter((item) => item.facet === 'Show all');
|
|
337
|
+
|
|
338
|
+
this.pmrResultsOnlyFlag = false;
|
|
339
|
+
this.noPMRResultsFlag = false;
|
|
340
|
+
|
|
341
|
+
if (dataTypeFilters.length === 1 && pmrFilter.length === 1) {
|
|
342
|
+
this.pmrResultsOnlyFlag = true;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (dataTypeFilters.length > 0 && pmrFilter.length === 0 && showAllFilter.length === 0) {
|
|
346
|
+
this.noPMRResultsFlag = true;
|
|
311
347
|
}
|
|
312
348
|
},
|
|
313
349
|
filterUpdate: function (filters) {
|
|
@@ -318,8 +354,15 @@ export default {
|
|
|
318
354
|
|
|
319
355
|
// Note that we cannot use the openSearch function as that modifies filters
|
|
320
356
|
this.resetSearch()
|
|
321
|
-
|
|
322
|
-
|
|
357
|
+
if (this.pmrResultsOnlyFlag) {
|
|
358
|
+
this.openPMRSearch(filters, this.searchInput)
|
|
359
|
+
} else if (this.noPMRResultsFlag) {
|
|
360
|
+
this.searchAlgolia(filters, this.searchInput)
|
|
361
|
+
} else {
|
|
362
|
+
this.searchAlgolia(filters, this.searchInput)
|
|
363
|
+
this.openPMRSearch(filters, this.searchInput)
|
|
364
|
+
}
|
|
365
|
+
|
|
323
366
|
this.$emit('search-changed', {
|
|
324
367
|
value: filters,
|
|
325
368
|
type: 'filter-update',
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
function transformKeyValueArrayToObject(data) {
|
|
2
2
|
try {
|
|
3
|
-
let result = data.values.map(valueArray =>
|
|
3
|
+
let result = data.values.map(valueArray =>
|
|
4
4
|
data.keys.reduce((acc, key, index) => {
|
|
5
5
|
acc[key] = valueArray[index];
|
|
6
6
|
return acc;
|
|
7
7
|
}, {})
|
|
8
8
|
)
|
|
9
9
|
return result
|
|
10
|
-
} catch (error) {
|
|
10
|
+
} catch (error) {
|
|
11
11
|
console.error(`Error occured during conversion of Key Value Array to Object: ${error}`)
|
|
12
12
|
return {}
|
|
13
13
|
}
|
|
@@ -49,8 +49,8 @@ let FlatmapQueries = function () {
|
|
|
49
49
|
this.createTermSQL = function (terms) {
|
|
50
50
|
let sql = ''
|
|
51
51
|
let validFilter = false
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
|
|
53
|
+
|
|
54
54
|
if (terms && terms.length > 0) {
|
|
55
55
|
sql += 'and '
|
|
56
56
|
terms.forEach((t, i) => {
|
|
@@ -84,7 +84,7 @@ let FlatmapQueries = function () {
|
|
|
84
84
|
// add filters for the terms
|
|
85
85
|
const termsSql = this.createTermSQL(terms)
|
|
86
86
|
sql += termsSql
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
// Add the text search
|
|
89
89
|
if (search && search !== '') {
|
|
90
90
|
sql += `and (t.pmr_text match '${search}')`
|
|
@@ -108,7 +108,7 @@ let FlatmapQueries = function () {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
this.convertTermsToIds = function (terms) {
|
|
111
|
-
return terms.
|
|
111
|
+
return terms.filter(t => this.lookUpId(t))
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
this.labelSQL = function (){
|
|
@@ -137,12 +137,12 @@ let FlatmapQueries = function () {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
this.processFilters = function (filters) {
|
|
140
|
-
let
|
|
140
|
+
let featureFacets = []
|
|
141
141
|
filters.forEach((f) => {
|
|
142
|
-
if (f.
|
|
143
|
-
|
|
142
|
+
if (f.facet !== 'Show all' && f.facet !== 'PMR')
|
|
143
|
+
featureFacets.push(f.facet)
|
|
144
144
|
})
|
|
145
|
-
return
|
|
145
|
+
return featureFacets
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
|