@abi-software/map-side-bar 2.1.0 → 2.2.1-alpha-1

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