/
ContentBar.vue
373 lines (352 loc) · 9.55 KB
/
ContentBar.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<template>
<div>
<div class="toolbar-flex-container">
<el-select
v-if="entries.length > 1"
:teleported="false"
:model-value="entry.id"
placeholder="Select"
class="select-box"
popper-class="viewer_dropdown"
@change="viewerChanged($event)"
>
<el-option
v-for="entry in entries"
:key="entry.id"
:label="getEntryTitle(entry)"
:value="entry.id"
/>
</el-select>
<div v-else class="toolbar-title">
{{ getEntryTitle(entry) }}
</div>
</div>
<el-row class="icon-group">
<div v-show="contextCardEntry && contextCardVisible" class="hide" @click="contextCardVisible = false">
Hide information
<el-icon><el-icon-arrow-up /></el-icon>
</div>
<div v-show="contextCardEntry && !contextCardVisible" class="hide" @click="contextCardVisible = true">
Show information
<el-icon><el-icon-arrow-down /></el-icon>
</div>
<el-popover
placement="bottom"
:teleported="false"
trigger="manual"
:width="setPopperWidth(slot.id)"
:offset="0"
popper-class="context-card-popover"
:popper-options="popperOptions"
:visible="contextCardVisible"
>
<template #default v-if="contextCardEntry">
<flatmap-context-card
class="flatmap-context-card"
v-if="(contextCardEntry.type == 'Flatmap' ||
contextCardEntry.type == 'MultiFlatmap')"
:mapImpProv="contextCardEntry.mapImpProv"
/>
<context-card
v-if="contextCardEntry.type.toLowerCase() == 'scaffold'"
:entry="contextCardEntry"
:envVars="envVars"
class="context-card"
@context-ready="contextCardVisible = true"
@scaffold-view-clicked="$emit('scaffold-view-clicked', $event)"
/>
</template>
<template #reference>
<el-icon
class="info-icon"
@click="contextCardVisible = !contextCardVisible"
v-show="contextCardEntry">
<el-icon-info-filled/>
</el-icon>
</template>
</el-popover>
<el-popover class="tooltip" content="Close and remove" placement="bottom-end" :show-after="helpDelay"
:teleported=false trigger="hover" popper-class="header-popper" >
<template #reference>
<map-svg-icon icon="close" class="header-icon"
v-show="(activeView !== 'singlepanel') && (entry.mode !== 'main')"
@click="closeAndRemove()"/>
</template>
</el-popover>
</el-row>
</div>
</template>
<script>
/* eslint-disable no-alert, no-console */
import EventBus from './EventBus';
import { MapSvgIcon } from '@abi-software/svg-sprite';
import { mapStores } from 'pinia';
import { useEntriesStore } from '../stores/entries';
import { useSettingsStore } from '../stores/settings';
import { useSplitFlowStore } from '../stores/splitFlow';
import ContextCard from "./ContextCard.vue";
import FlatmapContextCard from './FlatmapContextCard.vue';
import {
ArrowDown as ElIconArrowDown,
ArrowUp as ElIconArrowUp,
InfoFilled as ElIconInfoFilled,
} from '@element-plus/icons-vue'
import {
ElInput as Input,
ElOption as Option,
ElPopover as Popover,
ElRow as Row,
ElSelect as Select,
} from "element-plus";
export default {
name: "ContentBar",
components: {
ElIconArrowDown,
ElIconArrowUp,
ElIconInfoFilled,
Input,
Option,
Popover,
Row,
Select,
ContextCard,
FlatmapContextCard,
MapSvgIcon,
},
props: {
entry: Object,
},
data: function() {
return {
contextCardVisible: false,
slot:{
},
boundariesElement: null, // this is set @vue:mounted by the parent component via the 'setBoundary' method
showDetails: true,
contextCardEntry: undefined,
}
},
computed: {
...mapStores(useEntriesStore, useSettingsStore, useSplitFlowStore),
helpDelay() {
return this.settingsStore.helpDelay;
},
activeView: function() {
return this.splitFlowStore.activeView;
},
envVars: function () {
return {
API_LOCATION: this.settingsStore.sparcApi,
ALGOLIA_INDEX: this.settingsStore.algoliaIndex,
ALGOLIA_KEY: this.settingsStore.algoliaKey,
ALGOLIA_ID: this.settingsStore.algoliaId,
PENNSIEVE_API_LOCATION: this.settingsStore.pennsieveApi,
NL_LINK_PREFIX: this.settingsStore.nlLinkPrefix,
ROOT_URL: this.settingsStore.rootUrl,
};
},
popperOptions: function() {
return {
preventOverflow: {
enabled: true,
boundary: this.boundariesElement,
}
}
},
entries: function() {
return this.entriesStore.entries;
},
},
methods: {
closeAndRemove: function() {
this.splitFlowStore.closeSlot({ id: this.entry.id, entries: this.entries});
EventBus.emit("RemoveEntryRequest", this.entry.id);
},
getEntryTitle: function(entry) {
if (entry) {
let title = entry.label ? entry.label + " ": '';
let type = entry.type;
if (type == "Scaffold")
type = "3D Scaffold";
title += type;
if (entry.datasetId)
title += " (" + entry.datasetId + ")";
else if (entry.discoverId)
title += " (" + entry.discoverId + ")";
return title;
}
return "Viewer";
},
viewerChanged: function(value) {
if (this.entry.id && this.entry.id != value) {
this.splitFlowStore.assignOrSwapPaneWithIds({
source: this.entry.id,
target: value
});
this.$nextTick(() => {
setTimeout(() => {
this.$emit("chooser-changed");
}, 1200);
});
//this.contextCardVisible = false; // Hide all context cards when switching viewers
}
},
// setPopper with is needed as the flatmap context card does not have an image and has smaller with
setPopperWidth: function(slotId) {
let entry = this.entries.find(entry => entry.id === slotId);
if (entry) {
if (entry.type == "Flatmap" || entry.type == "MultiFlatmap") {
return "240px";
} else {
return "440px";
}
}
},
// Set the boundaries element for the popper
setBoundary: function(boundaryElement) {
this.boundariesElement = boundaryElement;
},
setupFlatmapContextCard: function(mapImpProv) {
// flatmap context update
this.contextCardVisible = false; // hide the context card when new map loads
let contextEntry = Object.assign({mapImpProv: mapImpProv.prov}, this.entry);
this.contextCardEntry = contextEntry;
},
setupScaffoldContextCard: function(){
// scaffold context update
if (this.entry.contextCardUrl) {
this.contextCardEntry = { ...this.entry};
}
}
},
mounted: function() {
this.setupScaffoldContextCard();
}
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
@use "../assets/header-icon.scss";
.toolbar-title {
width: 160px;
height: 20px;
color: $app-primary-color;
font-size: 14px;
font-weight: normal;
line-height: 20px;
margin-left: 11px;
margin-top: 4px;
}
.toolbar-flex-container {
display:flex;
flex-direction: row;
.select-box {
width: 177px;
height: 26px;
border-radius: 4px;
border: 1px solid rgb(144, 147, 153);
background-color: #fff;
font-weight: 500;
color: rgb(48, 49, 51);
margin-left: 8px;
margin-top: 3px;
margin-bottom: 2px;
z-index: 5;
:deep(.el-select__wrapper) {
width:177px;
color: $app-primary-color;
height: 26px;
min-height: 26px;
line-height: 26px;
padding-left: 4px;
padding-right: 8px;
background-color: #fff;
border-style: none;
span {
color: $app-primary-color;
}
}
:deep(.el-input__icon) {
line-height: 24px;
color: $lightGrey;
}
}
i .select-box :deep(.el-input__icon) {
color: rgb(48, 49, 51);
height: 24px;
padding-left: 8px;
padding-right: 8px;
}
.text {
margin-left: 8px;
margin-top: 7px;
font-weight: 500;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
line-height:18px;
}
.title {
width: 140px;
color: $app-primary-color;
}
}
.viewer_dropdown {
z-index: 5;
.el-select-dropdown__item {
white-space: nowrap;
text-align: left;
&.is-selected {
color: $app-primary-color;
font-weight: normal;
}
}
}
.hide{
color: $app-primary-color;
cursor: pointer;
margin-right: 6px;
margin-top: 3px;
}
.icon-group {
font-size: 12px;
}
.info-icon {
margin-right: 8px;
font-size: 28px;
color: $app-primary-color;
cursor: pointer;
&::before { // since the icon is a font, we need to adjust the vertical alignment
position: relative;
top: -2px;
}
}
.flatmap-context-card {
width: 240px;
}
.context-card {
width: 440px;
}
:deep(.header-popper.el-popover.el-popper) {
padding: 6px 4px;
font-size:12px;
color: rgb(48, 49, 51);
background-color: #f3ecf6;
border: 1px solid $app-primary-color;
white-space: nowrap;
min-width: unset;
.el-popper__arrow {
&:before {
border-color: $app-primary-color;
background-color: #f3ecf6;
}
}
}
:deep(.context-card-popover.el-popover.el-popper) {
max-width: calc(100vw - 100px);
padding-right: 0px;
width: unset!important;
background: #fff!important;
}
</style>