@abi-software/map-side-bar 1.3.1 → 1.3.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,49 +1,49 @@
1
- <script>
2
- /* eslint-disable no-alert, no-console */
3
- import { Cascader } from "element-ui";
4
-
5
- export default {
6
- name: 'CustomCascader',
7
- extends: Cascader,
8
- methods:{
9
- //Modify this internal function to disable Show all tags
10
- computePresentTags() {
11
- const { isDisabled, leafOnly, showAllLevels, separator, collapseTags } = this;
12
- const checkedNodes = this.getCheckedNodes(leafOnly);
13
- const tags = [];
14
- const genTag = node => ({
15
- node,
16
- key: node.uid,
17
- text: node.getText(showAllLevels, separator),
18
- hitState: false,
19
- closable: !isDisabled && !node.isDisabled
20
- });
21
- let customNodes = checkedNodes.filter(node =>
22
- {
23
- return !(node.getText(showAllLevels, separator).includes("Show all"));
24
- }
25
- );
26
- if (customNodes.length) {
27
- const [first, ...rest] = customNodes;
28
- const restCount = rest.length;
29
- tags.push(genTag(first));
30
- if (restCount) {
31
- if (collapseTags) {
32
- tags.push({
33
- key: -1,
34
- text: `+ ${restCount}`,
35
- closable: false
36
- });
37
- } else {
38
- rest.forEach(node => tags.push(genTag(node)));
39
- }
40
- }
41
- }
42
- this.checkedNodes = checkedNodes;
43
- this.presentTags = tags;
44
- this.$emit("tags-changed", this.presentTags);
45
- }
46
- }
47
- }
48
-
49
- </script>
1
+ <script>
2
+ /* eslint-disable no-alert, no-console */
3
+ import { Cascader } from "element-ui";
4
+
5
+ export default {
6
+ name: 'CustomCascader',
7
+ extends: Cascader,
8
+ methods:{
9
+ //Modify this internal function to disable Show all tags
10
+ computePresentTags() {
11
+ const { isDisabled, leafOnly, showAllLevels, separator, collapseTags } = this;
12
+ const checkedNodes = this.getCheckedNodes(leafOnly);
13
+ const tags = [];
14
+ const genTag = node => ({
15
+ node,
16
+ key: node.uid,
17
+ text: node.getText(showAllLevels, separator),
18
+ hitState: false,
19
+ closable: !isDisabled && !node.isDisabled
20
+ });
21
+ let customNodes = checkedNodes.filter(node =>
22
+ {
23
+ return !(node.getText(showAllLevels, separator).includes("Show all"));
24
+ }
25
+ );
26
+ if (customNodes.length) {
27
+ const [first, ...rest] = customNodes;
28
+ const restCount = rest.length;
29
+ tags.push(genTag(first));
30
+ if (restCount) {
31
+ if (collapseTags) {
32
+ tags.push({
33
+ key: -1,
34
+ text: `+ ${restCount}`,
35
+ closable: false
36
+ });
37
+ } else {
38
+ rest.forEach(node => tags.push(genTag(node)));
39
+ }
40
+ }
41
+ }
42
+ this.checkedNodes = checkedNodes;
43
+ this.presentTags = tags;
44
+ this.$emit("tags-changed", this.presentTags);
45
+ }
46
+ }
47
+ }
48
+
49
+ </script>
@@ -1,241 +1,258 @@
1
- <template>
2
- <div class="context-card-container" ref="container">
3
- <div v-show="showContextCard">
4
- <div v-show="showDetails" class="hide" @click="showDetails = !showDetails">Hide information<i class="el-icon-arrow-up"></i></div>
5
- <div v-show="!showDetails" class="hide" @click="showDetails = !showDetails">Show information<i class="el-icon-arrow-down"></i></div>
6
- <el-card v-if="showDetails && Object.keys(contextData).length !== 0" v-loading="loading" class="context-card card" >
7
- <div class="card-left">
8
- <img :src="entry.banner" class="context-image">
9
- </div>
10
- <div class="card-right">
11
- <div class="title">{{contextData.heading}}</div>
12
- <div>{{contextData.description}}</div>
13
- <br/>
14
- <div v-if="contextData.views && contextData.views.length > 0" class="subtitle">Scaffold Views</div>
15
- <template v-for="(view, i) in contextData.views">
16
- <span v-bind:key="i+'_1'" @click="openViewFile(view)" class="context-card-item">
17
- <img class="key-image" :src="getFileFromPath(view.thumbnail)">
18
- {{view.description}}
19
- </span>
20
- <br v-bind:key="i"/>
21
- </template>
22
- <div style="margin-bottom: 16px;"/>
23
- <div v-if="contextData.samples && contextData.samples.length > 0" class="subtitle">Samples on Scaffold</div>
24
- <template v-for="(sample, i) in contextData.samples">
25
- <span v-bind:key="i+'_3'" class="context-card-item" @click="toggleSampleDetails(i)">
26
- <div v-bind:key="i+'_6'" style="display: flex">
27
- <div v-if="sample.color" class="color-box" :style="'background-color:'+ sample.color"></div>
28
- <img class="key-image" v-else-if="sample.thumbnail" :src="getFileFromPath(sample.thumbnail)">
29
- {{sample.heading}}
30
- <i class="el-icon-warning-outline info"></i>
31
- </div>
32
- </span>
33
- <div v-bind:key="i+'_4'" v-if="sampleDetails[i]">
34
- {{sample.description}}
35
- <a v-bind:key="i+'_5'" v-if="sampleDetails[i]" :href="generateFileLink(sample.path)" target="_blank">View Source</a>
36
- </div>
37
- <br v-bind:key="i+'_2'"/>
38
- </template>
39
- </div>
40
- </el-card>
41
- </div>
42
- </div>
43
- </template>
44
-
45
-
46
- <script>
47
- /* eslint-disable no-alert, no-console */
48
- import Vue from "vue";
49
- import { Link, Icon, Card, Button, Select, Input } from "element-ui";
50
- import lang from "element-ui/lib/locale/lang/en";
51
- import locale from "element-ui/lib/locale";
52
- import EventBus from "./EventBus"
53
- import hardcoded_info from './hardcoded-context-info'
54
-
55
- locale.use(lang);
56
- Vue.use(Link);
57
- Vue.use(Icon);
58
- Vue.use(Card);
59
- Vue.use(Button);
60
- Vue.use(Select);
61
- Vue.use(Input);
62
-
63
-
64
- export default {
65
- name: "contextCard",
66
- props: {
67
- /**
68
- * Object containing information for
69
- * the required viewing.
70
- */
71
- entry: Object,
72
- },
73
- data: function () {
74
- return {
75
- contextData: {},
76
- showDetails: true,
77
- showContextCard: true,
78
- sampleDetails: {},
79
- loading: false
80
- };
81
- },
82
- watch: {
83
- 'entry.contextCardUrl': {
84
- handler(val){
85
- if (val) {
86
- // used for hardcoding data
87
- if (val === true){
88
- this.contextData = hardcoded_info[this.entry.discoverId]
89
- } else {
90
- this.getContextFile(val)
91
- this.showContextCard = true
92
- }
93
- } else {
94
- this.showContextCard = false
95
- }
96
- },
97
- immediate: true
98
- }
99
- },
100
- methods: {
101
- getContextFile: function (contextFileUrl) {
102
- this.loading = true
103
- fetch(contextFileUrl)
104
- .then((response) =>{
105
- if (!response.ok){
106
- throw Error(response.statusText)
107
- } else {
108
- return response.json()
109
- }
110
- })
111
- .then((data) => {
112
- this.contextData = data
113
- console.log(data)
114
- this.loading = false
115
- })
116
- .catch(() => {
117
- //set defaults if we hit an error
118
- this.thumbnail = require('@/../assets/missing-image.svg')
119
- this.discoverId = undefined
120
- this.loading = false
121
- });
122
- },
123
- removeDoubleFilesPath: function(path){
124
- if (path.includes('files/')){
125
- return path.replace('files/', '')
126
- } else if (path.includes('files\\')) {
127
- return path.replace('files\\', '')
128
- } else {
129
- return path
130
- }
131
- },
132
- toggleSampleDetails: function(i){
133
- if (this.sampleDetails[i] === undefined){
134
- Vue.set(this.sampleDetails, i, true)
135
- } else {
136
- Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
137
- }
138
- },
139
- getFileFromPath: function(path){
140
- // for hardcoded data
141
- if(this.entry.contextCardUrl === true){
142
- return path
143
- }
144
- path = this.removeDoubleFilesPath(path)
145
- return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
146
- },
147
- generateFileLink(path){
148
- return `https://sparc.science/file/${this.entry.discoverId}/${this.entry.version}?path=${encodeURI(path)}`
149
-
150
- },
151
- openViewFile: function(view){
152
- // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
153
- this.entry.viewUrl = `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
154
- this.entry.type = 'Scaffold View'
155
- EventBus.$emit("PopoverActionClick", this.entry)
156
- }
157
- }
158
- };
159
- </script>
160
-
161
- <!-- Add "scoped" attribute to limit CSS to this component only -->
162
- <style scoped>
163
-
164
- .hide{
165
- color: #e4e7ed;
166
- cursor: pointer;
167
- }
168
-
169
- .context-card{
170
- background-color: white;
171
- max-height: 10 50px;
172
- padding: 8px;
173
- font-size: 14px;
174
- }
175
-
176
- .context-card-item{
177
- cursor: pointer;
178
- padding-bottom: 8px;
179
- }
180
-
181
- .key-image {
182
- width: 25px;
183
- height: auto;
184
- }
185
-
186
- .context-card >>> .el-card__body {
187
- padding: 0px;
188
- display: flex;
189
- width: 516px;
190
- }
191
-
192
- .context-image{
193
- width: 250px;
194
- height: auto;
195
- }
196
-
197
- .color-box {
198
- width: 16px;
199
- height: 16px;
200
- border: solid 1px #8300bf;
201
- border-radius: 2px;
202
- margin-right: 8px;
203
- }
204
-
205
- .card {
206
- margin-bottom: 18px;
207
- position: relative;
208
- border: solid 1px #e4e7ed;
209
- display: flex;
210
- width: 500px;
211
- max-height: 480px;
212
- }
213
-
214
- .card-left{
215
- flex: 1
216
- }
217
-
218
- .card-right {
219
- flex: 1.3;
220
- padding-left: 6px;
221
- }
222
-
223
- .cursor-pointer {
224
- cursor: pointer;
225
- height: 25px;
226
- }
227
-
228
- .info{
229
- transform: rotate(180deg);
230
- color: #8300bf;
231
- margin-left: 8px;
232
- }
233
-
234
- .title{
235
- font-weight: bold;
236
- }
237
-
238
- .subtitle{
239
- font-weight: bold;
240
- }
241
- </style>
1
+ <template>
2
+ <div class="context-card-container" ref="container">
3
+ <div v-show="showContextCard">
4
+ <div v-show="showDetails" class="hide" @click="showDetails = !showDetails">Hide information<i class="el-icon-arrow-up"></i></div>
5
+ <div v-show="!showDetails" class="hide" @click="showDetails = !showDetails">Show information<i class="el-icon-arrow-down"></i></div>
6
+ <el-card v-if="showDetails && Object.keys(contextData).length !== 0" v-loading="loading" class="context-card" >
7
+ <div class="card-left">
8
+ <img :src="entry.banner" class="context-image">
9
+ </div>
10
+ <div class="card-right scrollbar">
11
+ <div class="title">{{contextData.heading}}</div>
12
+ <div>{{contextData.description}}</div>
13
+ <br/>
14
+ <div v-if="contextData.views && contextData.views.length > 0" class="subtitle">Scaffold Views</div>
15
+ <template v-for="(view, i) in contextData.views">
16
+ <span v-bind:key="i+'_1'" @click="openViewFile(view)" class="context-card-item">
17
+ <img class="key-image" :src="getFileFromPath(view.thumbnail)">
18
+ {{view.description}}
19
+ </span>
20
+ <br v-bind:key="i"/>
21
+ </template>
22
+ <div style="margin-bottom: 16px;"/>
23
+ <div v-if="contextData.samples && contextData.samples.length > 0" class="subtitle">Samples on Scaffold</div>
24
+ <template v-for="(sample, i) in contextData.samples">
25
+ <span v-bind:key="i+'_3'" class="context-card-item" @click="toggleSampleDetails(i)">
26
+ <div v-bind:key="i+'_6'" style="display: flex">
27
+ <div v-if="sample.color" class="color-box" :style="'background-color:'+ sample.color"></div>
28
+ <img class="key-image" v-else-if="sample.thumbnail" :src="getFileFromPath(sample.thumbnail)">
29
+ {{sample.heading}}
30
+ <i class="el-icon-warning-outline info"></i>
31
+ </div>
32
+ </span>
33
+ <div v-bind:key="i+'_4'" v-if="sampleDetails[i]">
34
+ {{sample.description}}
35
+ <a v-bind:key="i+'_5'" v-if="sampleDetails[i]" :href="generateFileLink(sample.path)" target="_blank">View Source</a>
36
+ </div>
37
+ <br v-bind:key="i+'_2'"/>
38
+ </template>
39
+ </div>
40
+ </el-card>
41
+ </div>
42
+ </div>
43
+ </template>
44
+
45
+
46
+ <script>
47
+ /* eslint-disable no-alert, no-console */
48
+ import Vue from "vue";
49
+ import { Link, Icon, Card, Button, Select, Input } from "element-ui";
50
+ import lang from "element-ui/lib/locale/lang/en";
51
+ import locale from "element-ui/lib/locale";
52
+ import EventBus from "./EventBus"
53
+ import hardcoded_info from './hardcoded-context-info'
54
+
55
+ locale.use(lang);
56
+ Vue.use(Link);
57
+ Vue.use(Icon);
58
+ Vue.use(Card);
59
+ Vue.use(Button);
60
+ Vue.use(Select);
61
+ Vue.use(Input);
62
+
63
+
64
+ export default {
65
+ name: "contextCard",
66
+ props: {
67
+ /**
68
+ * Object containing information for
69
+ * the required viewing.
70
+ */
71
+ entry: Object,
72
+ },
73
+ data: function () {
74
+ return {
75
+ contextData: {},
76
+ showDetails: true,
77
+ showContextCard: true,
78
+ sampleDetails: {},
79
+ loading: false
80
+ };
81
+ },
82
+ watch: {
83
+ 'entry.contextCardUrl': {
84
+ handler(val){
85
+ if (val) {
86
+ // used for hardcoding data
87
+ if (val === true){
88
+ this.contextData = hardcoded_info[this.entry.discoverId]
89
+ } else {
90
+ this.getContextFile(val)
91
+ this.showContextCard = true
92
+ }
93
+ } else {
94
+ this.showContextCard = false
95
+ }
96
+ },
97
+ immediate: true
98
+ }
99
+ },
100
+ methods: {
101
+ getContextFile: function (contextFileUrl) {
102
+ this.loading = true
103
+ fetch(contextFileUrl)
104
+ .then((response) =>{
105
+ if (!response.ok){
106
+ throw Error(response.statusText)
107
+ } else {
108
+ return response.json()
109
+ }
110
+ })
111
+ .then((data) => {
112
+ this.contextData = data
113
+ console.log(data)
114
+ this.loading = false
115
+ })
116
+ .catch(() => {
117
+ //set defaults if we hit an error
118
+ this.thumbnail = require('@/../assets/missing-image.svg')
119
+ this.discoverId = undefined
120
+ this.loading = false
121
+ });
122
+ },
123
+ removeDoubleFilesPath: function(path){
124
+ if (path.includes('files/')){
125
+ return path.replace('files/', '')
126
+ } else if (path.includes('files\\')) {
127
+ return path.replace('files\\', '')
128
+ } else {
129
+ return path
130
+ }
131
+ },
132
+ toggleSampleDetails: function(i){
133
+ if (this.sampleDetails[i] === undefined){
134
+ Vue.set(this.sampleDetails, i, true)
135
+ } else {
136
+ Vue.set(this.sampleDetails, i, !this.sampleDetails[i])
137
+ }
138
+ },
139
+ getFileFromPath: function(path){
140
+ // for hardcoded data
141
+ if(this.entry.contextCardUrl === true){
142
+ return path
143
+ }
144
+ path = this.removeDoubleFilesPath(path)
145
+ return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
146
+ },
147
+ generateFileLink(path){
148
+ return `https://sparc.science/file/${this.entry.discoverId}/${this.entry.version}?path=${encodeURI(path)}`
149
+
150
+ },
151
+ openViewFile: function(view){
152
+ // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
153
+ this.entry.viewUrl = `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/${view.path}`
154
+ this.entry.type = 'Scaffold View'
155
+ EventBus.$emit("PopoverActionClick", this.entry)
156
+ }
157
+ }
158
+ };
159
+ </script>
160
+
161
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
162
+ <style scoped>
163
+
164
+ .hide{
165
+ color: #e4e7ed;
166
+ cursor: pointer;
167
+ }
168
+
169
+ .context-card{
170
+ background-color: white;
171
+ max-height: 10 50px;
172
+ padding: 8px;
173
+ font-size: 14px;
174
+ margin-bottom: 18px;
175
+ position: relative;
176
+ border: solid 1px #e4e7ed;
177
+ display: flex;
178
+ width: 500px;
179
+ max-height: 258px;
180
+ }
181
+
182
+ .context-card-item{
183
+ cursor: pointer;
184
+ padding-bottom: 8px;
185
+ }
186
+
187
+ .key-image {
188
+ width: 25px;
189
+ height: auto;
190
+ }
191
+
192
+ .context-card >>> .el-card__body {
193
+ padding: 0px;
194
+ display: flex;
195
+ width: 516px;
196
+ }
197
+
198
+ .context-image{
199
+ width: 250px;
200
+ height: auto;
201
+ }
202
+
203
+ .color-box {
204
+ width: 16px;
205
+ height: 16px;
206
+ border: solid 1px #8300bf;
207
+ border-radius: 2px;
208
+ margin-right: 8px;
209
+ }
210
+
211
+ .card-left{
212
+ flex: 1
213
+ }
214
+
215
+ .card-right {
216
+ flex: 1.3;
217
+ padding-left: 6px;
218
+ overflow-y: scroll;
219
+ scrollbar-width: thin;
220
+ }
221
+
222
+ .cursor-pointer {
223
+ cursor: pointer;
224
+ height: 25px;
225
+ }
226
+
227
+ .info{
228
+ transform: rotate(180deg);
229
+ color: #8300bf;
230
+ margin-left: 8px;
231
+ }
232
+
233
+ .title{
234
+ font-weight: bold;
235
+ }
236
+
237
+ .subtitle{
238
+ font-weight: bold;
239
+ }
240
+
241
+ .scrollbar::-webkit-scrollbar-track {
242
+ border-radius: 10px;
243
+ background-color: #f5f5f5;
244
+ }
245
+
246
+ .scrollbar::-webkit-scrollbar {
247
+ width: 12px;
248
+ right: -12px;
249
+ background-color: #f5f5f5;
250
+ }
251
+
252
+ .scrollbar::-webkit-scrollbar-thumb {
253
+ border-radius: 4px;
254
+ box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.06);
255
+ background-color: #979797;
256
+ }
257
+
258
+ </style>