@abi-software/map-side-bar 2.4.0-isan-0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "2.4.0-isan-0",
3
+ "version": "2.4.0-isan-2",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
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
  [],
@@ -110,6 +110,10 @@ import {
110
110
  "flatmap"
111
111
  type: String
112
112
  descriptin: (Optional) to link to flatmap
113
+
114
+ "simulation"
115
+ type: String
116
+ descriptin: (Optional) simulation resource
113
117
  * ---------------------------------------
114
118
  */
115
119
 
@@ -143,16 +147,26 @@ export default {
143
147
  };
144
148
  },
145
149
  methods: {
146
- onFlatmapClick: function (payload) {
147
- this.$emit('flatmap-clicked', payload)
150
+ onFlatmapClick: function (data) {
151
+ this.emitPMRActionClick({
152
+ type: 'Flatmap',
153
+ resource: data
154
+ });
155
+ },
156
+ onSimulationClick: function (data) {
157
+ this.emitPMRActionClick({
158
+ type: 'Simulation',
159
+ resource: data,
160
+ });
148
161
  },
149
- onSimulationClick: function (payload) {
150
- const simulationData = {
151
- title: this.entry.title,
162
+ emitPMRActionClick: function (data) {
163
+ const payload = {
164
+ ...data,
165
+ name: this.entry.title,
152
166
  description: this.entry.description,
153
- resource: payload,
167
+ apiLocation: this.envVars.API_LOCATION,
154
168
  };
155
- this.$emit('simulation-clicked', simulationData)
169
+ this.$emit('pmr-action-click', payload);
156
170
  },
157
171
  }
158
172
  };
@@ -45,9 +45,9 @@
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
- @flatmap-clicked="onFlatmapClicked"
50
- @simulation-clicked="onSimulationClicked"
50
+ @pmr-action-click="onPmrActionClick"
51
51
  @search-changed="searchChanged(tab.id, $event)"
52
52
  @hover-changed="hoverChanged($event)"
53
53
  />
@@ -138,6 +138,7 @@ export default {
138
138
  data: function () {
139
139
  return {
140
140
  drawerOpen: false,
141
+ initFilters: { filter: [], searchInput: '' },
141
142
  availableAnatomyFacets: []
142
143
  }
143
144
  },
@@ -178,7 +179,9 @@ export default {
178
179
  this.drawerOpen = !this.drawerOpen
179
180
  },
180
181
  openSearch: function (facets, query) {
181
- this.drawerOpen = true
182
+ this.initFilters.filter = facets;
183
+ this.initFilters.searchInput = query;
184
+ this.drawerOpen = true;
182
185
  // Because refs are in v-for, nextTick is needed here
183
186
  this.$nextTick(() => {
184
187
  const searchTabRef = this.getSearchTabRefById(1);
@@ -248,22 +251,7 @@ export default {
248
251
  setDrawerOpen: function (value = true) {
249
252
  this.drawerOpen = value
250
253
  },
251
- onFlatmapClicked: function (data) {
252
- const payload = {
253
- type: 'Flatmap',
254
- data: data
255
- };
256
- this.$emit('actionClick', payload);
257
- },
258
- onSimulationClicked: function (data) {
259
- const payload = {
260
- type: 'Simulation',
261
- title: 'View simulation',
262
- apiLocation: this.envVars.API_LOCATION,
263
- name: data.title,
264
- description: data.description,
265
- resource: data.resource,
266
- };
254
+ onPmrActionClick: function (payload) {
267
255
  this.$emit('actionClick', payload);
268
256
  },
269
257
  /**
@@ -53,8 +53,7 @@
53
53
  class="dataset-card"
54
54
  :entry="result"
55
55
  :envVars="envVars"
56
- @flatmap-clicked="onFlatmapClicked"
57
- @simulation-clicked="onSimulationClicked"
56
+ @pmr-action-click="onPmrActionClick"
58
57
  @mouseenter="hoverChanged(result)"
59
58
  @mouseleave="hoverChanged(undefined)"
60
59
  ></PMRDatasetCard>
@@ -122,6 +121,7 @@ var initial_state = {
122
121
  numberPerPage: 10,
123
122
  page: 1,
124
123
  pmrResultsOnlyFlag: false,
124
+ noPMRResultsFlag: false,
125
125
  hasSearched: false,
126
126
  contextCardEnabled: false,
127
127
  pmrResults: [],
@@ -158,6 +158,13 @@ export default {
158
158
  type: Object,
159
159
  default: () => initial_state,
160
160
  },
161
+ initFilters: {
162
+ type: Object,
163
+ default: {
164
+ filter: [],
165
+ searchInput: '',
166
+ }
167
+ },
161
168
  envVars: {
162
169
  type: Object,
163
170
  default: () => {},
@@ -166,6 +173,7 @@ export default {
166
173
  data: function () {
167
174
  return {
168
175
  ...this.entry,
176
+ ...this.initFilters,
169
177
  bodyStyle: {
170
178
  flex: '1 1 auto',
171
179
  'flex-flow': 'column',
@@ -199,11 +207,8 @@ export default {
199
207
  hoverChanged: function (data) {
200
208
  this.$emit('hover-changed', data)
201
209
  },
202
- onFlatmapClicked: function (data) {
203
- this.$emit('flatmap-clicked', data);
204
- },
205
- onSimulationClicked: function (payload) {
206
- this.$emit('simulation-clicked', payload)
210
+ onPmrActionClick: function (data) {
211
+ this.$emit('pmr-action-click', data);
207
212
  },
208
213
  // resetSearch: Resets the results, and page, and variable results ratio
209
214
  // Does not: reset filters, search input, or search history
@@ -219,17 +224,20 @@ export default {
219
224
  },
220
225
  // openSearch: Resets the results, populates dataset cards and filters. Will use Algolia and SciCrunch data uness pmr mode is set
221
226
  openSearch: function(filter, search = '', resetSearch = true) {
227
+ this.updatePMROnlyFlag(filter);
228
+
222
229
  if (resetSearch) {
223
230
  this.resetSearch();
224
- this.openAlgoliaSearch(filter, search);
231
+ this.openFilterSearch(filter, search);
225
232
  } else {
226
233
  this.searchAlgolia(filter, search);
234
+ this.openPMRSearch(filter, search);
227
235
  }
228
- this.openPMRSearch(filter, search)
229
236
  },
230
237
 
231
238
  // openPMRSearch: Resets the results, populates dataset cards and filters with PMR data.
232
239
  openPMRSearch: function (filter, search = '') {
240
+ this.loadingCards = true;
233
241
  this.flatmapQueries.updateOffset(this.calculatePMROffest())
234
242
  this.flatmapQueries.updateLimit(this.PMRLimit(this.pmrResultsOnlyFlag))
235
243
  this.flatmapQueries.pmrSearch(filter, search).then((data) => {
@@ -237,11 +245,13 @@ export default {
237
245
  this.results.push(result)
238
246
  })
239
247
  this.pmrNumberOfHits = this.flatmapQueries.numberOfHits
248
+ this.loadingCards = false;
240
249
  })
241
250
  },
242
251
 
243
- // openAlgoliaSearch: Resets the results, populates dataset cards and filters with Algloia and SciCrunch data.
244
- openAlgoliaSearch: function (filter, search = '') {
252
+ // previously openAlgoliaSearch:
253
+ // Resets the results, populates dataset cards and filters with Algloia and SciCrunch data.
254
+ openFilterSearch: function (filter, search = '') {
245
255
  this.searchInput = search
246
256
  //Proceed normally if cascader is ready
247
257
  if (this.cascaderIsReady) {
@@ -259,7 +269,14 @@ export default {
259
269
  this.$refs.filtersRef.checkShowAllBoxes()
260
270
  this.resetSearch()
261
271
  } else if (this.filter) {
262
- this.searchAlgolia(this.filter, search)
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
+ }
263
280
  this.$refs.filtersRef.setCascader(this.filter)
264
281
  }
265
282
  } else {
@@ -267,7 +284,14 @@ export default {
267
284
  //otherwise waith for cascader to be ready
268
285
  this.filter = filter
269
286
  if (!filter || filter.length == 0) {
270
- this.searchAlgolia(this.filter, search)
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
+ }
271
295
  }
272
296
  }
273
297
  },
@@ -307,11 +331,19 @@ export default {
307
331
  }
308
332
  },
309
333
  updatePMROnlyFlag: function (filters) {
310
- const pmrSearchObject = filters.find((tmp) => tmp.facet === 'PMR');
311
- if (pmrSearchObject) {
312
- this.pmrResultsOnlyFlag = true
313
- } else {
314
- this.pmrResultsOnlyFlag = false
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;
315
347
  }
316
348
  },
317
349
  filterUpdate: function (filters) {
@@ -322,8 +354,15 @@ export default {
322
354
 
323
355
  // Note that we cannot use the openSearch function as that modifies filters
324
356
  this.resetSearch()
325
- this.searchAlgolia(filters, this.searchInput)
326
- this.openPMRSearch(filters, this.searchInput)
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
+
327
366
  this.$emit('search-changed', {
328
367
  value: filters,
329
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.map(t => this.lookUpId(t))
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 featureLabels = []
140
+ let featureFacets = []
141
141
  filters.forEach((f) => {
142
- if (f.label !== 'Show all' && f.label !== 'PMR')
143
- featureLabels.push(f.facet)
142
+ if (f.facet !== 'Show all' && f.facet !== 'PMR')
143
+ featureFacets.push(f.facet)
144
144
  })
145
- return featureLabels
145
+ return featureFacets
146
146
  }
147
147
 
148
148