@abi-software/map-side-bar 2.8.3-beta.0 → 2.8.3-beta.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.8.3-beta.0",
3
+ "version": "2.8.3-beta.2",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
package/src/App.vue CHANGED
@@ -31,7 +31,7 @@
31
31
  @hover-changed="hoverChanged($event)"
32
32
  @connectivity-hovered="onConnectivityHovered"
33
33
  @actionClick="action"
34
- @connectivity-explorer-clicked="onConnectivityExplorerClicked"
34
+ @connectivity-collapse-change="onConnectivityCollapseChange"
35
35
  />
36
36
  </div>
37
37
  </template>
@@ -344,7 +344,7 @@ export default {
344
344
  const filter = entry ? entry.filter : []
345
345
  this.$refs.sideBar.openConnectivitySearch(filter, query)
346
346
  },
347
- onConnectivityExplorerClicked: function () {
347
+ onConnectivityCollapseChange: function () {
348
348
  this.connectivityEntry = [...exampleConnectivityInput]
349
349
  }
350
350
  },
@@ -2,10 +2,10 @@
2
2
  <div class="connectivity-card-container" ref="container">
3
3
  <div class="connectivity-card" ref="card">
4
4
  <div class="seperator-path"></div>
5
- <div v-loading="loading" class="card" @click="cardClicked(entry)">
6
- <div class="title">{{ capitalise(entry.label) }}</div>
5
+ <div v-loading="loading" class="card-content" @click="cardClicked(entry)">
6
+ <div class="card-title">{{ capitalise(entry.label) }}</div>
7
7
  <template v-for="field in displayFields" :key="field">
8
- <div class="details" v-if="entry[field]">
8
+ <div class="card-details" v-if="entry[field]">
9
9
  <strong>{{ field }}:</strong> {{ entry[field] }}
10
10
  </div>
11
11
  </template>
@@ -31,12 +31,23 @@ export default {
31
31
  type: Object,
32
32
  default: () => {},
33
33
  },
34
+ connectivityEntry: {
35
+ type: Array,
36
+ default: () => [],
37
+ },
34
38
  },
35
39
  computed: {
36
40
  loading: function () {
37
- // Only when click on overlay paths
38
- if ("detailsReady" in this.entry) {
39
- return !this.entry.detailsReady;
41
+ // for clicking on the flatmap neuron
42
+ if ("ready" in this.entry) {
43
+ return !this.entry.ready;
44
+ }
45
+ // for clicking on the explorer card
46
+ const cEntry = this.connectivityEntry.find(
47
+ (entry) => entry.id === this.entry.id
48
+ );
49
+ if (cEntry) {
50
+ return !cEntry.ready;
40
51
  }
41
52
  return false;
42
53
  },
@@ -48,7 +59,7 @@ export default {
48
59
  },
49
60
  cardClicked: function (data) {
50
61
  if (!this.loading) {
51
- this.$emit("connectivity-card-clicked", data);
62
+ this.$emit("open-connectivity", data);
52
63
  }
53
64
  },
54
65
  },
@@ -62,32 +73,21 @@ export default {
62
73
  min-height: 5rem;
63
74
  }
64
75
 
65
- .card {
76
+ .card-content {
66
77
  padding-top: 18px;
67
78
  padding-left: 6px;
68
79
  cursor: pointer;
69
80
  }
70
81
 
71
- .title {
82
+ .card-title {
72
83
  padding-bottom: 0.75rem;
73
84
  font-weight: bold;
74
85
  line-height: 1.5;
75
86
  letter-spacing: 1.05px;
76
87
  }
77
88
 
78
- .details {
89
+ .card-details {
79
90
  line-height: 1.5;
80
91
  letter-spacing: 1.05px;
81
92
  }
82
-
83
- .button {
84
- margin-right: 3.5rem;
85
- font-family: Asap;
86
- font-size: 14px;
87
- font-weight: normal;
88
- background-color: $app-primary-color;
89
- border: $app-primary-color;
90
- color: white;
91
- margin-top: 8px;
92
- }
93
93
  </style>
@@ -1,7 +1,11 @@
1
1
  <template>
2
- <el-card :body-style="bodyStyle" class="content-card">
2
+ <el-card
3
+ :body-style="bodyStyle"
4
+ class="content-card"
5
+ @mouseleave="hoverChanged(undefined)"
6
+ >
3
7
  <template #header>
4
- <div class="header">
8
+ <div class="header" @mouseleave="hoverChanged(undefined)">
5
9
  <el-input
6
10
  class="search-input"
7
11
  placeholder="Search"
@@ -26,6 +30,10 @@
26
30
  >
27
31
  Reset
28
32
  </el-button>
33
+ <el-radio-group v-model="filterVisibility">
34
+ <el-radio :value="true">Focused</el-radio>
35
+ <el-radio :value="false">Contextual</el-radio>
36
+ </el-radio-group>
29
37
  </div>
30
38
  </template>
31
39
  <SearchFilters
@@ -57,30 +65,29 @@
57
65
  :key="result.id"
58
66
  :ref="'stepItem-' + result.id"
59
67
  class="step-item"
60
- :class="{
61
- 'is-active': expanded === result.id && result.loaded,
62
- 'is-loading': expanded === result.id && !result.loaded,
63
- }"
64
68
  @mouseenter="hoverChanged(result)"
65
69
  >
66
70
  <ConnectivityCard
67
- class="dataset-card"
71
+ v-show="expanded !== result.id"
72
+ class="connectivity-card"
68
73
  :entry="result"
69
- @connectivity-card-clicked="onConnectivityExplorerClicked"
74
+ :connectivityEntry="connectivityEntry"
75
+ @open-connectivity="onConnectivityCollapseChange"
70
76
  />
71
77
  <ConnectivityInfo
72
78
  v-if="expanded === result.id"
73
- :connectivityEntry="connectivityEntry"
79
+ class="connectivity-info"
74
80
  :entryId="result.id"
81
+ :connectivityEntry="connectivityEntry"
75
82
  :availableAnatomyFacets="availableAnatomyFacets"
76
83
  :envVars="envVars"
77
84
  :withCloseButton="true"
78
- @show-connectivity="$emit('show-connectivity', $event)"
79
- @show-reference-connectivities="$emit('show-reference-connectivities', $event)"
85
+ @show-connectivity="onShowConnectivity"
86
+ @show-reference-connectivities="onShowReferenceConnectivities"
80
87
  @connectivity-clicked="onConnectivityClicked"
81
88
  @connectivity-hovered="$emit('connectivity-hovered', $event)"
82
89
  @loaded="onConnectivityInfoLoaded(result)"
83
- @close-connectivity="closeConnectivity(result)"
90
+ @close-connectivity="onConnectivityCollapseChange(result)"
84
91
  />
85
92
  </div>
86
93
  <el-pagination
@@ -112,7 +119,6 @@ import ConnectivityCard from "./ConnectivityCard.vue";
112
119
  import ConnectivityInfo from "./ConnectivityInfo.vue";
113
120
 
114
121
  var initial_state = {
115
- filters: [],
116
122
  searchInput: "",
117
123
  lastSearch: "",
118
124
  results: [],
@@ -158,6 +164,10 @@ export default {
158
164
  type: Object,
159
165
  default: [],
160
166
  },
167
+ connectivityFilterOptions: {
168
+ type: Array,
169
+ default: [],
170
+ },
161
171
  },
162
172
  data: function () {
163
173
  return {
@@ -167,34 +177,12 @@ export default {
167
177
  "flex-flow": "column",
168
178
  display: "flex",
169
179
  },
170
- filterOptions: [
171
- {
172
- id: 3,
173
- key: "flatmap.connectivity.source",
174
- label: "Connectivity",
175
- children: [
176
- {
177
- facetPropPath: "flatmap.connectivity.source",
178
- id: 0,
179
- label: "Origins",
180
- },
181
- {
182
- facetPropPath: "flatmap.connectivity.source",
183
- id: 1,
184
- label: "Components",
185
- },
186
- {
187
- facetPropPath: "flatmap.connectivity.source",
188
- id: 2,
189
- label: "Destinations",
190
- },
191
- ],
192
- },
193
- ],
194
180
  cascaderIsReady: false,
195
- displayConnectivity: false,
181
+ freezeTimeout: undefined,
182
+ freezed: false,
196
183
  initLoading: true,
197
- expanded: ""
184
+ expanded: "",
185
+ filterVisibility: true
198
186
  };
199
187
  },
200
188
  computed: {
@@ -203,8 +191,8 @@ export default {
203
191
  return {
204
192
  numberOfHits: this.numberOfHits,
205
193
  filterFacets: this.filter,
206
- options: this.filterOptions,
207
- showFilters: false
194
+ options: this.connectivityFilterOptions,
195
+ showFilters: true
208
196
  };
209
197
  },
210
198
  paginatedResults: function () {
@@ -212,55 +200,85 @@ export default {
212
200
  },
213
201
  },
214
202
  watch: {
215
- connectivityKnowledge: function (value, oldValue) {
216
- this.expanded = '';
217
- this.initLoading = false;
203
+ connectivityKnowledge: function (newVal, oldVal) {
204
+ this.expanded = ""; // reset expanded state
218
205
  this.loadingCards = false;
219
-
220
- if (JSON.stringify(value) === JSON.stringify(oldValue)) {
221
- return;
206
+ if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
207
+ this.results = newVal;
208
+ this.initLoading = false;
209
+ this.numberOfHits = this.results.length;
210
+ // knowledge is from the neuron click if there is 'ready' property
211
+ if (this.numberOfHits === 1 && !('ready' in this.results[0])) {
212
+ this.onConnectivityCollapseChange(this.results[0]);
213
+ }
222
214
  }
223
-
224
- this.results = value.map((item) => {
225
- return {
226
- ...item,
227
- loaded: false,
228
- };
229
- });
230
- this.numberOfHits = this.results.length;
231
- if (this.numberOfHits === 1) {
232
- this.onConnectivityExplorerClicked(this.results[0]);
215
+ },
216
+ // watch for connectivityEntry changes
217
+ // card should be expanded if there is only one entry and it is ready
218
+ connectivityEntry: function (newVal, oldVal) {
219
+ if (newVal.length === 1 && newVal[0].ready) {
220
+ // if the changed property is connectivity source, do not collapse
221
+ if (
222
+ (newVal[0].connectivitySource !== oldVal[0].connectivitySource) &&
223
+ oldVal[0].ready
224
+ ) {
225
+ return;
226
+ }
227
+ this.collapseChange(newVal[0]);
233
228
  }
234
229
  },
235
230
  paginatedResults: function () {
236
231
  this.loadingCards = false;
237
232
  },
233
+ filterVisibility: function (state) {
234
+ this.filterVisibility = state;
235
+ this.$emit('filter-visibility', this.filterVisibility);
236
+ },
238
237
  },
239
238
  methods: {
239
+ freezeHoverChange: function () {
240
+ this.freezed = true;
241
+ if (this.freezeTimeout) {
242
+ clearTimeout(this.freezeTimeout);
243
+ }
244
+ this.freezeTimeout = setTimeout(() => {
245
+ this.freezed = false;
246
+ }, 3000)
247
+ },
248
+ onShowConnectivity: function (data) {
249
+ this.freezeHoverChange();
250
+ this.$emit('show-connectivity', data);
251
+ },
252
+ onShowReferenceConnectivities: function (data) {
253
+ this.freezeHoverChange();
254
+ this.$emit('show-reference-connectivities', data);
255
+ },
240
256
  onConnectivityClicked: function (data) {
241
257
  this.searchInput = data.query;
242
- this.filters = data.filter;
258
+ this.filter = data.filter;
243
259
  this.searchAndFilterUpdate();
244
260
  },
245
- openConnectivity: function (data) {
246
- this.expanded = data.id;
247
- },
248
- closeConnectivity: function (data) {
249
- this.expanded = '';
261
+ collapseChange:function (data) {
262
+ this.expanded = this.expanded === data.id ? "" : data.id;
250
263
  },
251
- onConnectivityExplorerClicked: function (data) {
252
- if (this.expanded !== data.id) {
253
- data.loaded = false; // reset loading
254
- this.openConnectivity(data);
255
- const entry = this.connectivityEntry.filter(entry => entry.featureId[0] === data.id);
256
- if (entry.length === 0) {
257
- this.$emit("connectivity-explorer-clicked", data);
258
- }
264
+ onConnectivityCollapseChange: function (data) {
265
+ // close connectivity event will not trigger emit
266
+ if (this.connectivityEntry.find(entry => entry.featureId[0] === data.id)) {
267
+ this.collapseChange(data);
268
+ } else {
269
+ this.expanded = "";
270
+ // Make sure to emit the change after the next DOM update
271
+ this.$nextTick(() => {
272
+ this.$emit("connectivity-collapse-change", data);
273
+ });
259
274
  }
260
275
  },
261
276
  hoverChanged: function (data) {
262
- const payload = data ? { ...data, type: "connectivity" } : data;
263
- this.$emit("hover-changed", payload);
277
+ // disable hover changes when show connectivity is clicked
278
+ if (!this.freezed) {
279
+ const payload = data ? { ...data, tabType: "connectivity" } : { tabType: "connectivity" };
280
+ this.$emit("hover-changed", payload);
281
+ }
264
282
  },
265
283
  resetSearch: function () {
266
284
  this.numberOfHits = 0;
@@ -268,9 +286,12 @@ export default {
268
286
  this.loadingCards = false;
269
287
  },
270
288
  resetSearchIfNoActiveSearch: function() {
271
- if (!this.searchInput) this.openSearch([], '');
289
+ const hasValidFacet = this.filter.some(f => f.facet !== "Show all");
290
+ if (!this.searchInput && !hasValidFacet) {
291
+ this.openSearch([], '');
292
+ }
272
293
  },
273
- openSearch: function (filter, search = "", option = { withSearch: true }) {
294
+ openSearch: function (filter, search = "") {
274
295
  this.searchInput = search;
275
296
  this.resetPageNavigation();
276
297
  //Proceed normally if cascader is ready
@@ -289,17 +310,17 @@ export default {
289
310
  this.$refs.filtersRef.checkShowAllBoxes();
290
311
  this.resetSearch();
291
312
  } else if (this.filter) {
292
- if (option.withSearch) {
293
- this.searchKnowledge(this.filter, search);
294
- }
313
+ this.searchKnowledge(this.filter, search);
295
314
  this.$refs.filtersRef.setCascader(this.filter);
315
+ this.searchHistoryUpdate(this.filter, search);
296
316
  }
297
317
  } else {
298
318
  //cascader is not ready, perform search if no filter is set,
299
319
  //otherwise waith for cascader to be ready
300
320
  this.filter = filter;
301
- if ((!filter || filter.length == 0) && option.withSearch) {
321
+ if (!filter || filter.length == 0) {
302
322
  this.searchKnowledge(this.filter, search);
323
+ this.searchHistoryUpdate(this.filter, search);
303
324
  }
304
325
  }
305
326
  },
@@ -325,63 +346,44 @@ export default {
325
346
  clearSearchClicked: function () {
326
347
  this.searchInput = "";
327
348
  this.searchAndFilterUpdate();
328
- this.$refs.filtersRef.checkShowAllBoxes();
329
349
  },
330
350
  searchEvent: function (event = false) {
331
351
  if (event.keyCode === 13 || event instanceof MouseEvent) {
332
352
  this.searchInput = this.searchInput.trim();
333
353
  this.searchAndFilterUpdate();
334
- if (!this.searchInput) {
335
- this.$refs.filtersRef.checkShowAllBoxes();
336
- }
337
354
  }
338
355
  },
339
356
  filterUpdate: function (filters) {
340
- this.filters = [...filters];
357
+ this.filter = [...filters];
341
358
  this.searchAndFilterUpdate();
342
- this.$emit("search-changed", {
343
- value: filters,
344
- type: "filter-update",
345
- });
346
- },
347
- /**
348
- * Transform filters for third level items to perform search
349
- * because cascader keeps adding it back.
350
- */
351
- transformFiltersBeforeSearch: function (filters) {
352
- return filters.map((filter) => {
353
- if (filter.facet2) {
354
- filter.facet = filter.facet2;
355
- delete filter.facet2;
356
- }
357
- return filter;
358
- });
359
+ // this.$emit("search-changed", {
360
+ // value: filters,
361
+ // tabType: "connectivity",
362
+ // type: "filter-update",
363
+ // });
359
364
  },
360
365
  searchAndFilterUpdate: function () {
361
366
  this.resetPageNavigation();
362
- const transformedFilters = this.transformFiltersBeforeSearch(
363
- this.filters
364
- );
365
- this.searchKnowledge(transformedFilters, this.searchInput);
367
+ this.searchKnowledge(this.filter, this.searchInput);
368
+ this.searchHistoryUpdate(this.filter, this.searchInput);
366
369
  },
367
370
  searchHistoryUpdate: function (filters, search) {
368
371
  this.$refs.searchHistory.selectValue = 'Search history';
369
372
  // save history only if there has value
370
- if (search?.trim()) {
371
- this.$refs.searchHistory.addSearchToHistory(
372
- filters,
373
- search
374
- );
373
+ if (filters.length || search?.trim()) {
374
+ this.$refs.searchHistory.addSearchToHistory(this.filter, search);
375
375
  }
376
376
  },
377
377
  searchKnowledge: function (filters, query = "") {
378
378
  this.expanded = "";
379
- this.searchHistoryUpdate(filters, query);
380
379
  this.loadingCards = true;
381
380
  this.scrollToTop();
382
381
  this.$emit("search-changed", {
383
- value: this.searchInput,
384
- type: "query-update",
382
+ // value: this.searchInput,
383
+ // type: "query-update",
384
+ query: query,
385
+ filter: filters,
386
+ tabType: "connectivity",
385
387
  });
386
388
  this.lastSearch = query;
387
389
  },
@@ -395,7 +397,7 @@ export default {
395
397
  pageChange: function (page) {
396
398
  this.start = (page - 1) * this.numberPerPage;
397
399
  this.page = page;
398
- this.searchKnowledge(this.filters, this.searchInput);
400
+ this.searchKnowledge(this.filter, this.searchInput);
399
401
  },
400
402
  scrollToTop: function () {
401
403
  if (this.$refs.content) {
@@ -408,11 +410,10 @@ export default {
408
410
  },
409
411
  searchHistorySearch: function (item) {
410
412
  this.searchInput = item.search;
411
- this.filters = item.filters;
412
- this.searchAndFilterUpdate();
413
+ this.filter = item.filters;
414
+ this.openSearch([...item.filters], item.search);
413
415
  },
414
416
  onConnectivityInfoLoaded: function (result) {
415
- result.loaded = true;
416
417
  const stepItemRef = this.$refs['stepItem-' + result.id];
417
418
  const contentRef = this.$refs['content'];
418
419
  this.$nextTick(() => {
@@ -432,7 +433,7 @@ export default {
432
433
  <style lang="scss" scoped>
433
434
  @import '../assets/pagination.scss';
434
435
 
435
- .dataset-card {
436
+ .connectivity-card {
436
437
  position: relative;
437
438
 
438
439
  &::before {
@@ -472,51 +473,15 @@ export default {
472
473
  font-size: 14px;
473
474
  margin-bottom: 18px;
474
475
  text-align: left;
475
- max-height: 200px;
476
476
  transition: all 0.3s ease;
477
477
 
478
- .dataset-card {
479
- opacity: 1;
480
- visibility: visible;
481
- transition: all 0.3s ease;
478
+ .connectivity-card {
479
+ max-height: 200px;
482
480
  }
483
-
484
- &.is-active {
485
- max-height: 9999px;
481
+ .connectivity-info {
486
482
  background-color: #f7faff;
487
483
  border: 2px solid $app-primary-color;
488
484
  border-radius: var(--el-border-radius-base);
489
-
490
- .dataset-card {
491
- pointer-events: none;
492
-
493
- &::before {
494
- display: none;
495
- }
496
-
497
- + .main {
498
- border: 0 none;
499
- }
500
- }
501
-
502
- &:not(.is-loading) {
503
- .dataset-card {
504
- opacity: 0;
505
- visibility: hidden;
506
- height: 0;
507
- }
508
- }
509
- }
510
-
511
- &.is-loading {
512
- opacity: 0.5;
513
- pointer-events: none;
514
-
515
- :deep(.connectivity-card .title) {
516
- color: $app-primary-color;
517
- font-size: 18px;
518
- letter-spacing: normal;
519
- }
520
485
  }
521
486
  }
522
487
 
@@ -531,6 +496,9 @@ export default {
531
496
  }
532
497
 
533
498
  .header {
499
+ display: flex;
500
+ align-items: center;
501
+
534
502
  .el-button {
535
503
  font-family: inherit;
536
504
 
@@ -538,7 +506,19 @@ export default {
538
506
  &:focus {
539
507
  background: $app-primary-color;
540
508
  box-shadow: -3px 2px 4px #00000040;
541
- color: #fff;
509
+ color: #ffffff;
510
+ }
511
+ }
512
+
513
+ .el-radio-group {
514
+ display: flex;
515
+ flex-direction: column;
516
+ align-items: flex-start;
517
+
518
+ .el-radio {
519
+ color: #ffffff;
520
+ margin-left: 20px;
521
+ height: 20px;
542
522
  }
543
523
  }
544
524
  }