@abi-software/map-side-bar 2.2.0 → 2.2.1-alpha-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.
@@ -1,338 +1,347 @@
1
- <template>
2
- <div ref="container">
3
- <div v-if="!drawerOpen" @click="toggleDrawer" class="open-tab">
4
- <el-icon><el-icon-arrow-left /></el-icon>
5
- </div>
6
- <el-drawer
7
- class="side-bar my-drawer"
8
- v-model="drawerOpen"
9
- :teleported="false"
10
- :modal-append-to-body="false"
11
- size="584"
12
- :with-header="false"
13
- :wrapperClosable="false"
14
- :modal="false"
15
- modal-class="sidebar-body"
16
- :z-index="10"
17
- :lock-scroll="false"
18
- >
19
- <div class="box-card">
20
- <div v-if="drawerOpen" @click="close" class="close-tab">
21
- <el-icon><el-icon-arrow-right /></el-icon>
22
- </div>
23
- <div class="sidebar-container">
24
- <Tabs
25
- v-if="tabs.length > 1"
26
- :tabTitles="tabs"
27
- :activeId="activeId"
28
- @titleClicked="tabClicked"
29
- />
30
- <template v-for="tab in tabs" key="tab.id">
31
- <SidebarContent
32
- class="sidebar-content-container"
33
- v-show="tab.id === activeId"
34
- :contextCardEntry="tab.contextCard"
35
- :envVars="envVars"
36
- :ref="tab.id"
37
- @search-changed="searchChanged(tab.id, $event)"
38
- @hover-changed="hoverChanged($event)"
39
- />
40
- </template>
41
- </div>
42
- </div>
43
- </el-drawer>
44
- </div>
45
- </template>
46
-
47
- <script>
48
- import {
49
- ArrowLeft as ElIconArrowLeft,
50
- ArrowRight as ElIconArrowRight,
51
- } from '@element-plus/icons-vue'
52
- /* eslint-disable no-alert, no-console */
53
- import { ElDrawer as Drawer, ElIcon as Icon } from 'element-plus'
54
- import SidebarContent from './SidebarContent.vue'
55
- import EventBus from './EventBus.js'
56
- import Tabs from './Tabs.vue'
57
-
58
- /**
59
- * Aims to provide a sidebar for searching capability for SPARC portal.
60
- */
61
- export default {
62
- components: {
63
- SidebarContent,
64
- Tabs,
65
- ElIconArrowLeft,
66
- ElIconArrowRight,
67
- Drawer,
68
- Icon
69
- },
70
- name: 'SideBar',
71
- props: {
72
- /**
73
- * The option to show side bar.
74
- */
75
- visible: {
76
- type: Boolean,
77
- default: false,
78
- },
79
- /**
80
- * The environment variables object with
81
- * `API_LOCATION`, `ALGOLIA_KEY`, `ALGOLIA_ID`,
82
- * `ALGOLIA_INDEX`, `PENNSIEVE_API_LOCATION`, `BL_SERVER_URL`,
83
- * `NL_LINK_PREFIX`, `ROOT_URL`
84
- */
85
- envVars: {
86
- type: Object,
87
- default: () => {},
88
- },
89
- /**
90
- * The array of objects to show multiple sidebar contents.
91
- */
92
- tabs: {
93
- type: Array,
94
- default: () => [{ title: 'flatmap', id: 1 }],
95
- },
96
- /**
97
- * The active tab id for default tab.
98
- */
99
- activeId: {
100
- type: Number,
101
- default: 1,
102
- },
103
- /**
104
- * The option to show or hide sidebar on page load.
105
- */
106
- openAtStart: {
107
- type: Boolean,
108
- default: false,
109
- },
110
- },
111
- data: function () {
112
- return {
113
- drawerOpen: false,
114
- }
115
- },
116
- methods: {
117
- /**
118
- * This event is emitted when the mouse hover are changed.
119
- * @arg data
120
- */
121
- hoverChanged: function (data) {
122
- this.$emit('hover-changed', data)
123
- },
124
- /**
125
- * This event is emitted when the search filters are changed.
126
- * @arg `obj` {data, id}
127
- */
128
- searchChanged: function (id, data) {
129
- this.$emit('search-changed', { ...data, id: id })
130
- },
131
- /**
132
- * @vuese
133
- * The function to close sidebar.
134
- */
135
- close: function () {
136
- this.drawerOpen = false
137
- },
138
- /**
139
- * @vuese
140
- * The function to toggle (open and close) sidebar.
141
- */
142
- toggleDrawer: function () {
143
- this.drawerOpen = !this.drawerOpen
144
- },
145
- openSearch: function (facets, query) {
146
- this.drawerOpen = true
147
- // Because refs are in v-for, nextTick is needed here
148
- this.$nextTick(() => {
149
- this.$refs[this.activeId][0].openSearch(facets, query)
150
- })
151
- },
152
- /**
153
- * @vuese
154
- * The function to add filters to sidebar search.
155
- * @arg filter `object`
156
- */
157
- addFilter: function (filter) {
158
- this.drawerOpen = true
159
- filter.AND = true // When we add a filter external, it is currently only with an AND boolean
160
-
161
- // Because refs are in v-for, nextTick is needed here
162
- this.$nextTick(() => {
163
- this.$refs[this.activeId][0].addFilter(filter)
164
- })
165
- },
166
- openNeuronSearch: function (neuron) {
167
- this.drawerOpen = true
168
- // Because refs are in v-for, nextTick is needed here
169
- this.$nextTick(() => {
170
- this.$refs[this.activeId][0].openSearch(
171
- '',
172
- undefined,
173
- 'scicrunch-query-string/',
174
- { field: '*organ.curie', curie: neuron }
175
- )
176
- })
177
- },
178
- getAlgoliaFacets: async function () {
179
- return await this.$refs[this.activeId][0].getAlgoliaFacets()
180
- },
181
- setDrawerOpen: function (value = true) {
182
- this.drawerOpen = value
183
- },
184
- /**
185
- * @vuese
186
- * The function to emit 'tabClicked' event with tab's `id` when user clicks the sidebar tab.
187
- * @arg id
188
- */
189
- tabClicked: function (id) {
190
- /**
191
- * This event is emitted when user click sidebar's tab.
192
- * @arg id
193
- */
194
- this.$emit('tabClicked', id)
195
- },
196
- },
197
- created: function () {
198
- this.drawerOpen = this.openAtStart
199
- },
200
- mounted: function () {
201
- EventBus.on('PopoverActionClick', (payLoad) => {
202
- /**
203
- * This event is emitted when the image is clicked on or the button below the image is clicked on.
204
- * @arg payLoad
205
- */
206
- this.$emit('actionClick', payLoad)
207
- })
208
- EventBus.on('available-facets', (payLoad) => {
209
- this.$emit('search-changed', {
210
- type: 'available-facets',
211
- value: payLoad,
212
- })
213
- })
214
- EventBus.on('contextUpdate', (payLoad) => {
215
- /**
216
- * This event is emitted when the context is updated.
217
- * Example, context update on first load.
218
- * @arg payload
219
- */
220
- this.$emit('contextUpdate', payLoad)
221
- })
222
- EventBus.on('datalink-clicked', (payLoad) => {
223
- /**
224
- * This event is emitted
225
- * when the dataset button or dataset image thumbnail
226
- * from the gallery component is clicked.
227
- * @arg payload
228
- */
229
- this.$emit('datalink-clicked', payLoad);
230
- })
231
- },
232
- }
233
- </script>
234
-
235
- <style lang="scss" scoped>
236
- .box-card {
237
- flex: 3;
238
- height: 100%;
239
- overflow: hidden;
240
- pointer-events: auto;
241
- }
242
-
243
- .side-bar {
244
- position: relative;
245
- height: 100%;
246
- pointer-events: none;
247
- width:600px;
248
- float: right;
249
- }
250
-
251
- :deep(.sidebar-body) {
252
- position: absolute !important;
253
- }
254
-
255
- .side-bar :deep(.el-drawer:focus) {
256
- outline: none;
257
- }
258
-
259
- .sidebar-container {
260
- height: 100%;
261
- flex-flow: column;
262
- display: flex;
263
- }
264
-
265
- .open-tab {
266
- width: 20px;
267
- height: 40px;
268
- z-index: 8;
269
- position: absolute;
270
- top: calc(50vh - 80px);
271
- right: 0px;
272
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
273
- border: solid 1px $app-primary-color;
274
- background-color: #f9f2fc;
275
- text-align: center;
276
- vertical-align: middle;
277
- cursor: pointer;
278
- pointer-events: auto;
279
- }
280
-
281
- .el-icon svg {
282
- font-weight: 600;
283
- margin-top: 24px;
284
- color: $app-primary-color;
285
- cursor: pointer;
286
- pointer-events: auto;
287
- transform: scaleY(2);
288
- text-align: center;
289
- vertical-align: middle;
290
- }
291
-
292
- .close-tab {
293
- float: left;
294
- flex: 1;
295
- width: 20px;
296
- height: 40px;
297
- z-index: 8;
298
- margin-top: calc(50vh - 80px);
299
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
300
- border: solid 1px $app-primary-color;
301
- background-color: #f9f2fc;
302
- text-align: center;
303
- vertical-align: middle;
304
- cursor: pointer;
305
- pointer-events: auto;
306
- }
307
-
308
- :deep(.my-drawer) {
309
- background: rgba(0, 0, 0, 0);
310
- box-shadow: none;
311
- }
312
-
313
- :deep(.my-drawer .el-drawer__body) {
314
- height: 100%;
315
- padding: 0;
316
- }
317
-
318
- .sidebar-content-container {
319
- flex: 1 1 auto;
320
- }
321
- </style>
322
-
323
- <style lang="scss">
324
- .side-bar {
325
- --el-color-primary: #8300BF;
326
- --el-color-primary-light-7: #DAB3EC;
327
- --el-color-primary-light-8: #e6ccf2;
328
- --el-color-primary-light-9: #f3e6f9;
329
- --el-color-primary-light-3: #f3e6f9;
330
- --el-color-primary-dark-2: #7600AC;
331
- }
332
- .el-button--primary {
333
- --el-button-hover-text-color: var(--el-color-primary);
334
- --el-button-hover-link-text-color: var(--el-color-primary-light-5);
335
- --el-button-hover-bg-color: var(--el-color-primary-light-3);
336
- --el-button-hover-border-color: var(--el-color-primary-light-3);
337
- }
338
- </style>
1
+ <template>
2
+ <div ref="container">
3
+ <div v-if="!drawerOpen" @click="toggleDrawer" class="open-tab">
4
+ <el-icon><el-icon-arrow-left /></el-icon>
5
+ </div>
6
+ <el-drawer
7
+ class="side-bar my-drawer"
8
+ v-model="drawerOpen"
9
+ :teleported="false"
10
+ :modal-append-to-body="false"
11
+ size="584"
12
+ :with-header="false"
13
+ :wrapperClosable="false"
14
+ :modal="false"
15
+ modal-class="sidebar-body"
16
+ :z-index="10"
17
+ :lock-scroll="false"
18
+ >
19
+ <div class="box-card">
20
+ <div v-if="drawerOpen" @click="close" class="close-tab">
21
+ <el-icon><el-icon-arrow-right /></el-icon>
22
+ </div>
23
+ <div class="sidebar-container">
24
+ <Tabs
25
+ v-if="tabs.length > 1"
26
+ :tabTitles="tabs"
27
+ :activeId="activeId"
28
+ @titleClicked="tabClicked"
29
+ />
30
+ <template v-for="tab in tabs" key="tab.id">
31
+ <SidebarContent
32
+ class="sidebar-content-container"
33
+ v-show="tab.id === activeId"
34
+ :contextCardEntry="tab.contextCard"
35
+ :envVars="envVars"
36
+ :ref="tab.id"
37
+ @search-changed="searchChanged(tab.id, $event)"
38
+ @hover-changed="hoverChanged($event)"
39
+ />
40
+ </template>
41
+ </div>
42
+ </div>
43
+ </el-drawer>
44
+ </div>
45
+ </template>
46
+
47
+ <script>
48
+ import {
49
+ ArrowLeft as ElIconArrowLeft,
50
+ ArrowRight as ElIconArrowRight,
51
+ } from '@element-plus/icons-vue'
52
+ /* eslint-disable no-alert, no-console */
53
+ import { ElDrawer as Drawer, ElIcon as Icon } from 'element-plus'
54
+ import SidebarContent from './SidebarContent.vue'
55
+ import EventBus from './EventBus.js'
56
+ import Tabs from './Tabs.vue'
57
+
58
+ /**
59
+ * Aims to provide a sidebar for searching capability for SPARC portal.
60
+ */
61
+ export default {
62
+ components: {
63
+ SidebarContent,
64
+ Tabs,
65
+ ElIconArrowLeft,
66
+ ElIconArrowRight,
67
+ Drawer,
68
+ Icon
69
+ },
70
+ name: 'SideBar',
71
+ props: {
72
+ /**
73
+ * The option to show side bar.
74
+ */
75
+ visible: {
76
+ type: Boolean,
77
+ default: false,
78
+ },
79
+ /**
80
+ * The environment variables object with
81
+ * `API_LOCATION`, `ALGOLIA_KEY`, `ALGOLIA_ID`,
82
+ * `ALGOLIA_INDEX`, `PENNSIEVE_API_LOCATION`, `BL_SERVER_URL`,
83
+ * `NL_LINK_PREFIX`, `ROOT_URL`
84
+ */
85
+ envVars: {
86
+ type: Object,
87
+ default: () => {},
88
+ },
89
+ /**
90
+ * The array of objects to show multiple sidebar contents.
91
+ */
92
+ tabs: {
93
+ type: Array,
94
+ default: () => [{ title: 'flatmap', id: 1 }],
95
+ },
96
+ /**
97
+ * The active tab id for default tab.
98
+ */
99
+ activeId: {
100
+ type: Number,
101
+ default: 1,
102
+ },
103
+ /**
104
+ * The option to show or hide sidebar on page load.
105
+ */
106
+ openAtStart: {
107
+ type: Boolean,
108
+ default: false,
109
+ },
110
+ },
111
+ data: function () {
112
+ return {
113
+ drawerOpen: false,
114
+ }
115
+ },
116
+ methods: {
117
+ /**
118
+ * This event is emitted when the mouse hover are changed.
119
+ * @arg data
120
+ */
121
+ hoverChanged: function (data) {
122
+ this.$emit('hover-changed', data)
123
+ },
124
+ /**
125
+ * This event is emitted when the search filters are changed.
126
+ * @arg `obj` {data, id}
127
+ */
128
+ searchChanged: function (id, data) {
129
+ this.$emit('search-changed', { ...data, id: id })
130
+ },
131
+ /**
132
+ * @vuese
133
+ * The function to close sidebar.
134
+ */
135
+ close: function () {
136
+ this.drawerOpen = false
137
+ },
138
+ /**
139
+ * @vuese
140
+ * The function to toggle (open and close) sidebar.
141
+ */
142
+ toggleDrawer: function () {
143
+ this.drawerOpen = !this.drawerOpen
144
+ },
145
+ openSearch: function (facets, query) {
146
+ this.drawerOpen = true
147
+ // Because refs are in v-for, nextTick is needed here
148
+ this.$nextTick(() => {
149
+ this.$refs[this.activeId][0].openSearch(facets, query)
150
+ })
151
+ },
152
+ /**
153
+ * @vuese
154
+ * The function to add filters to sidebar search.
155
+ * @arg filter `object`
156
+ */
157
+ addFilter: function (filter) {
158
+ this.drawerOpen = true
159
+ filter.AND = true // When we add a filter external, it is currently only with an AND boolean
160
+
161
+ // Because refs are in v-for, nextTick is needed here
162
+ this.$nextTick(() => {
163
+ this.$refs[this.activeId][0].addFilter(filter)
164
+ })
165
+ },
166
+ openNeuronSearch: function (neuron) {
167
+ this.drawerOpen = true
168
+ // Because refs are in v-for, nextTick is needed here
169
+ this.$nextTick(() => {
170
+ this.$refs[this.activeId][0].openSearch(
171
+ '',
172
+ undefined,
173
+ 'scicrunch-query-string/',
174
+ { field: '*organ.curie', curie: neuron }
175
+ )
176
+ })
177
+ },
178
+ getAlgoliaFacets: async function () {
179
+ return await this.$refs[this.activeId][0].getAlgoliaFacets()
180
+ },
181
+ setDrawerOpen: function (value = true) {
182
+ this.drawerOpen = value
183
+ },
184
+ /**
185
+ * @vuese
186
+ * The function to emit 'tabClicked' event with tab's `id` when user clicks the sidebar tab.
187
+ * @arg id
188
+ */
189
+ tabClicked: function (id) {
190
+ /**
191
+ * This event is emitted when user click sidebar's tab.
192
+ * @arg id
193
+ */
194
+ this.$emit('tabClicked', id)
195
+ },
196
+ },
197
+ created: function () {
198
+ this.drawerOpen = this.openAtStart
199
+ },
200
+ mounted: function () {
201
+ EventBus.on('PopoverActionClick', (payLoad) => {
202
+ /**
203
+ * This event is emitted when the image is clicked on or the button below the image is clicked on.
204
+ * @arg payLoad
205
+ */
206
+ this.$emit('actionClick', payLoad)
207
+ })
208
+ EventBus.on('number-of-datasets-for-anatomies', (payLoad) => {
209
+ /**
210
+ * This emits a object with keys as anatomy and values as number of datasets for that anatomy.
211
+ * @arg payload
212
+ */
213
+ this.$emit('number-of-datasets-for-anatomies', payLoad)
214
+ })
215
+ EventBus.on('anatomy-in-datasets', (payLoad) => {
216
+ /**
217
+ * This emits a lis of datasets, with the anatomy for each one. Used by flatmap for markers
218
+ * @arg payload
219
+ */
220
+ this.$emit('anatomy-in-datasets', payLoad)
221
+ })
222
+
223
+ EventBus.on('contextUpdate', (payLoad) => {
224
+ /**
225
+ * This event is emitted when the context card is updated.
226
+ * Example, context card update on first load.
227
+ * @arg payload
228
+ */
229
+ this.$emit('contextUpdate', payLoad)
230
+ })
231
+ EventBus.on('datalink-clicked', (payLoad) => {
232
+ /**
233
+ * This event is emitted
234
+ * when the dataset button or dataset image thumbnail
235
+ * from the gallery component is clicked.
236
+ * @arg payload
237
+ */
238
+ this.$emit('datalink-clicked', payLoad);
239
+ })
240
+ },
241
+ }
242
+ </script>
243
+
244
+ <style lang="scss" scoped>
245
+ .box-card {
246
+ flex: 3;
247
+ height: 100%;
248
+ overflow: hidden;
249
+ pointer-events: auto;
250
+ }
251
+
252
+ .side-bar {
253
+ position: relative;
254
+ height: 100%;
255
+ pointer-events: none;
256
+ width:600px;
257
+ float: right;
258
+ }
259
+
260
+ :deep(.sidebar-body) {
261
+ position: absolute !important;
262
+ }
263
+
264
+ .side-bar :deep(.el-drawer:focus) {
265
+ outline: none;
266
+ }
267
+
268
+ .sidebar-container {
269
+ height: 100%;
270
+ flex-flow: column;
271
+ display: flex;
272
+ }
273
+
274
+ .open-tab {
275
+ width: 20px;
276
+ height: 40px;
277
+ z-index: 8;
278
+ position: absolute;
279
+ top: calc(50vh - 80px);
280
+ right: 0px;
281
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
282
+ border: solid 1px $app-primary-color;
283
+ background-color: #f9f2fc;
284
+ text-align: center;
285
+ vertical-align: middle;
286
+ cursor: pointer;
287
+ pointer-events: auto;
288
+ }
289
+
290
+ .el-icon svg {
291
+ font-weight: 600;
292
+ margin-top: 24px;
293
+ color: $app-primary-color;
294
+ cursor: pointer;
295
+ pointer-events: auto;
296
+ transform: scaleY(2);
297
+ text-align: center;
298
+ vertical-align: middle;
299
+ }
300
+
301
+ .close-tab {
302
+ float: left;
303
+ flex: 1;
304
+ width: 20px;
305
+ height: 40px;
306
+ z-index: 8;
307
+ margin-top: calc(50vh - 80px);
308
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
309
+ border: solid 1px $app-primary-color;
310
+ background-color: #f9f2fc;
311
+ text-align: center;
312
+ vertical-align: middle;
313
+ cursor: pointer;
314
+ pointer-events: auto;
315
+ }
316
+
317
+ :deep(.my-drawer) {
318
+ background: rgba(0, 0, 0, 0);
319
+ box-shadow: none;
320
+ }
321
+
322
+ :deep(.my-drawer .el-drawer__body) {
323
+ height: 100%;
324
+ padding: 0;
325
+ }
326
+
327
+ .sidebar-content-container {
328
+ flex: 1 1 auto;
329
+ }
330
+ </style>
331
+
332
+ <style lang="scss">
333
+ .side-bar {
334
+ --el-color-primary: #8300BF;
335
+ --el-color-primary-light-7: #DAB3EC;
336
+ --el-color-primary-light-8: #e6ccf2;
337
+ --el-color-primary-light-9: #f3e6f9;
338
+ --el-color-primary-light-3: #f3e6f9;
339
+ --el-color-primary-dark-2: #7600AC;
340
+ }
341
+ .el-button--primary {
342
+ --el-button-hover-text-color: var(--el-color-primary);
343
+ --el-button-hover-link-text-color: var(--el-color-primary-light-5);
344
+ --el-button-hover-bg-color: var(--el-color-primary-light-3);
345
+ --el-button-hover-border-color: var(--el-color-primary-light-3);
346
+ }
347
+ </style>