@abi-software/flatmapvuer 0.3.11 → 0.3.12
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/dist/flatmapvuer.common.js +306 -127
- package/dist/flatmapvuer.common.js.map +1 -1
- package/dist/flatmapvuer.css +1 -1
- package/dist/flatmapvuer.umd.js +306 -127
- package/dist/flatmapvuer.umd.js.map +1 -1
- package/dist/flatmapvuer.umd.min.js +1 -1
- package/dist/flatmapvuer.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FlatmapVuer.vue +53 -11
- package/src/components/MultiFlatmapVuer.vue +170 -46
- package/src/components/legends/Legends.vue +1 -1
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<div class="beta-popovers">
|
|
13
13
|
<div>
|
|
14
14
|
<el-popover
|
|
15
|
-
:content="warningMessage"
|
|
15
|
+
:content="isLegacy ? 'This is a legacy map, you may view the latest map instead.' : warningMessage"
|
|
16
16
|
placement="right"
|
|
17
17
|
:appendToBody="false"
|
|
18
18
|
trigger="manual"
|
|
@@ -27,7 +27,13 @@
|
|
|
27
27
|
@mouseout="hideToolitip(6)"
|
|
28
28
|
v-popover:warningPopover
|
|
29
29
|
>
|
|
30
|
-
|
|
30
|
+
<template v-if="isLegacy">
|
|
31
|
+
<span class="warning-text">Legacy Map</span>
|
|
32
|
+
<div class="latest-map-text" @click="viewLatestMap">Click here for the latest map</div>
|
|
33
|
+
</template>
|
|
34
|
+
<template v-else>
|
|
35
|
+
<span class="warning-text">Beta</span>
|
|
36
|
+
</template>
|
|
31
37
|
</i>
|
|
32
38
|
</div>
|
|
33
39
|
<el-popover
|
|
@@ -294,6 +300,19 @@ export default {
|
|
|
294
300
|
this.mapImp = undefined;
|
|
295
301
|
},
|
|
296
302
|
methods: {
|
|
303
|
+
viewLatestMap: function() {
|
|
304
|
+
let biologicalSex = this.biologicalSex ? this.biologicalSex : undefined;
|
|
305
|
+
//Human requires special handling
|
|
306
|
+
if (this.entry === "NCBITaxon:9606") {
|
|
307
|
+
biologicalSex = "PATO:0000384";
|
|
308
|
+
}
|
|
309
|
+
const state = {
|
|
310
|
+
entry: this.entry,
|
|
311
|
+
biologicalSex,
|
|
312
|
+
viewport: this.mapImp.getState()
|
|
313
|
+
};
|
|
314
|
+
this.$emit("view-latest-map", state);
|
|
315
|
+
},
|
|
297
316
|
backgroundChangeCallback: function(colour) {
|
|
298
317
|
this.currentBackground = colour;
|
|
299
318
|
if (this.mapImp) {
|
|
@@ -620,13 +639,18 @@ export default {
|
|
|
620
639
|
// be loaded, overriding ``taxon`` and ``biologicalSex``.
|
|
621
640
|
|
|
622
641
|
let identifier = { taxon: this.entry };
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
if (state.
|
|
626
|
-
identifier
|
|
627
|
-
} else if (
|
|
628
|
-
|
|
629
|
-
|
|
642
|
+
//This now handle the uses of uuid when resuming states
|
|
643
|
+
if (state) {
|
|
644
|
+
if (state.uuid) {
|
|
645
|
+
identifier = { uuid: state.uuid };
|
|
646
|
+
} else if (state.entry) {
|
|
647
|
+
identifier.taxon = state.entry;
|
|
648
|
+
if (state.biologicalSex) {
|
|
649
|
+
identifier["biologicalSex"] = state.biologicalSex;
|
|
650
|
+
} else if (identifier.taxon === "NCBITaxon:9606") {
|
|
651
|
+
//For backward compatibility
|
|
652
|
+
identifier["biologicalSex"] ="PATO:0000384";
|
|
653
|
+
}
|
|
630
654
|
}
|
|
631
655
|
} else {
|
|
632
656
|
// Set the bioloicalSex now if map is not resumed from
|
|
@@ -669,8 +693,11 @@ export default {
|
|
|
669
693
|
this.mapImp.setState(state.viewport);
|
|
670
694
|
});
|
|
671
695
|
} else if (state) {
|
|
672
|
-
if (this.entry == state.entry)
|
|
696
|
+
if (this.entry == state.entry) {
|
|
673
697
|
this._viewportToBeSet = state.viewport;
|
|
698
|
+
if (this.mapImp && !this.loading)
|
|
699
|
+
this.mapImp.setState(this._viewportToBeSet);
|
|
700
|
+
}
|
|
674
701
|
}
|
|
675
702
|
},
|
|
676
703
|
showMinimap: function(flag) {
|
|
@@ -755,6 +782,10 @@ export default {
|
|
|
755
782
|
type: String,
|
|
756
783
|
default: "Beta feature - This map is based on the connectivity of a rat. New connectivity and species specificity will be added as the SPARC program progress."
|
|
757
784
|
},
|
|
785
|
+
isLegacy: {
|
|
786
|
+
type: Boolean,
|
|
787
|
+
default: false
|
|
788
|
+
},
|
|
758
789
|
displayLatestChanges: {
|
|
759
790
|
type: Boolean,
|
|
760
791
|
default: false,
|
|
@@ -868,6 +899,15 @@ export default {
|
|
|
868
899
|
vertical-align: 5px;
|
|
869
900
|
}
|
|
870
901
|
|
|
902
|
+
.latest-map-text {
|
|
903
|
+
color: $app-primary-color;;
|
|
904
|
+
font-family: Asap, sans-serif;
|
|
905
|
+
font-size: 12px;
|
|
906
|
+
margin-top: 5px;
|
|
907
|
+
vertical-align: 10px;
|
|
908
|
+
cursor: pointer;
|
|
909
|
+
}
|
|
910
|
+
|
|
871
911
|
.latest-changesicon {
|
|
872
912
|
color: $success;
|
|
873
913
|
|
|
@@ -949,13 +989,15 @@ export default {
|
|
|
949
989
|
.svg-legends-container {
|
|
950
990
|
width:70%;
|
|
951
991
|
height:auto;
|
|
992
|
+
position:relative;
|
|
993
|
+
max-height:140px;
|
|
952
994
|
}
|
|
953
995
|
|
|
954
996
|
.pathway-container {
|
|
955
997
|
float: left;
|
|
956
998
|
padding-left: 16px;
|
|
957
999
|
padding-right: 18px;
|
|
958
|
-
max-height: calc(100% -
|
|
1000
|
+
max-height: calc(100% - 140px);
|
|
959
1001
|
text-align: left;
|
|
960
1002
|
overflow: auto;
|
|
961
1003
|
border: 1px solid rgb(220, 223, 230);
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
:warningMessage="warningMessage"
|
|
37
37
|
:displayLatestChanges="item.displayLatestChanges"
|
|
38
38
|
:latestChangesMessage="item.latestChangesMessage"
|
|
39
|
+
:isLegacy="item.isLegacy"
|
|
39
40
|
:ref="key"
|
|
41
|
+
@view-latest-map="viewLatestMap"
|
|
40
42
|
@resource-selected="FlatmapSelected"
|
|
41
43
|
@ready="FlatmapReady"
|
|
42
44
|
@pan-zoom-callback="panZoomCallback"
|
|
@@ -70,6 +72,13 @@ Vue.use(Option);
|
|
|
70
72
|
Vue.use(Select);
|
|
71
73
|
Vue.use(Popover)
|
|
72
74
|
|
|
75
|
+
const TAXON_UUID = {
|
|
76
|
+
"NCBITaxon:10114": "01fedbf9-d783-509c-a10c-827941ab13da",
|
|
77
|
+
"NCBITaxon:9823": "a336ac04-24db-561f-a25f-1c994fe17410",
|
|
78
|
+
"NCBITaxon:9606": "42ed6323-f645-5fbe-bada-9581819cf689",
|
|
79
|
+
"NCBITaxon:10090": "25285fab-48a0-5620-a6a0-f9a0374837d5",
|
|
80
|
+
"NCBITaxon:9685": "73060497-46a6-52bf-b975-cac511c127cb"
|
|
81
|
+
}
|
|
73
82
|
|
|
74
83
|
export default {
|
|
75
84
|
name: "MultiFlatmapVuer",
|
|
@@ -85,39 +94,45 @@ export default {
|
|
|
85
94
|
methods: {
|
|
86
95
|
initialise: function() {
|
|
87
96
|
return new Promise(resolve => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
if (this.requireInitialisation) {
|
|
98
|
+
//It has not been initialised yet
|
|
99
|
+
this.requireInitialisation = false;
|
|
100
|
+
fetch(this.flatmapAPI)
|
|
101
|
+
.then(response => response.json())
|
|
102
|
+
.then(data => {
|
|
103
|
+
//Check each key in the provided availableSpecies against the one
|
|
104
|
+
//on the server, add them to the Select if the key is found
|
|
105
|
+
Object.keys(this.availableSpecies).forEach(key => {
|
|
106
|
+
for (let i = 0; i < data.length; i++) {
|
|
107
|
+
if (this.availableSpecies[key].taxo === data[i].taxon) {
|
|
108
|
+
if (this.availableSpecies[key].biologicalSex) {
|
|
109
|
+
if (data[i].biologicalSex &&
|
|
110
|
+
data[i].biologicalSex === this.availableSpecies[key].biologicalSex) {
|
|
111
|
+
this.$set(this.speciesList, key, this.availableSpecies[key]);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
this.$set(this.speciesList, key, this.availableSpecies[key]);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
104
118
|
}
|
|
105
119
|
}
|
|
120
|
+
});
|
|
121
|
+
if (!this.state) {
|
|
122
|
+
//No state resuming, set the current flatmap to {this.initial}
|
|
123
|
+
if (this.initial && this.speciesList[this.initial] !== undefined) {
|
|
124
|
+
this.activeSpecies = this.initial;
|
|
125
|
+
} else {
|
|
126
|
+
this.activeSpecies = Object.keys(this.speciesList)[0];
|
|
127
|
+
}
|
|
128
|
+
Vue.nextTick(() => {
|
|
129
|
+
if (this.$refs[this.activeSpecies])
|
|
130
|
+
this.$refs[this.activeSpecies][0].createFlatmap();
|
|
131
|
+
});
|
|
106
132
|
}
|
|
107
133
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.activeSpecies = this.initial;
|
|
111
|
-
} else {
|
|
112
|
-
this.activeSpecies = Object.keys(this.speciesList)[0];
|
|
113
|
-
}
|
|
114
|
-
Vue.nextTick(() => {
|
|
115
|
-
if (this.$refs[this.activeSpecies])
|
|
116
|
-
this.$refs[this.activeSpecies][0].createFlatmap();
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
resolve();
|
|
120
|
-
});
|
|
134
|
+
}
|
|
135
|
+
resolve();
|
|
121
136
|
})
|
|
122
137
|
},
|
|
123
138
|
FlatmapSelected: function(resource) {
|
|
@@ -147,13 +162,104 @@ export default {
|
|
|
147
162
|
let map = this.getCurrentFlatmap();
|
|
148
163
|
map.showMarkerPopup(featureId, node, options);
|
|
149
164
|
},
|
|
150
|
-
flatmapChanged: function(species){
|
|
165
|
+
flatmapChanged: function(species, viewport){
|
|
151
166
|
if (this.activeSpecies != species)
|
|
152
167
|
this.activeSpecies = species;
|
|
153
|
-
this.$refs[this.activeSpecies][0].createFlatmap();
|
|
168
|
+
this.$refs[this.activeSpecies][0].createFlatmap(viewport);
|
|
154
169
|
this.$emit('flatmapChanged', this.activeSpecies);
|
|
155
170
|
},
|
|
156
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Function to switch to the latest existing map from
|
|
173
|
+
* a legacy map of the same species.
|
|
174
|
+
*
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
viewLatestMap: function(state) {
|
|
178
|
+
const keys = Object.keys(this.speciesList);
|
|
179
|
+
for (let i = 0; i < keys.length; i++) {
|
|
180
|
+
const species = this.speciesList[keys[i]];
|
|
181
|
+
if (!species.isLegacy &&
|
|
182
|
+
(species.taxo === state.entry) &&
|
|
183
|
+
(species.biologicalSex === state.biologicalSex)) {
|
|
184
|
+
this.flatmapChanged(keys[i], state);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
* Create a legacy entry with the provided information
|
|
191
|
+
*
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
createLegacyEntry: function(state, taxo, uuid) {
|
|
195
|
+
if (uuid && taxo) {
|
|
196
|
+
let name = "Legacy";
|
|
197
|
+
if (state.species) {
|
|
198
|
+
if (state.species.slice(0, 6) === "Legacy")
|
|
199
|
+
name = state.species;
|
|
200
|
+
else
|
|
201
|
+
name = name + ` ${state.species}`;
|
|
202
|
+
}
|
|
203
|
+
this.$set(
|
|
204
|
+
this.speciesList,
|
|
205
|
+
name,
|
|
206
|
+
{
|
|
207
|
+
taxo: taxo,
|
|
208
|
+
isLegacy: true,
|
|
209
|
+
displayWarning: true
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
return {
|
|
213
|
+
species: name,
|
|
214
|
+
state: {
|
|
215
|
+
entry: taxo,
|
|
216
|
+
uuid: uuid,
|
|
217
|
+
viewport: state.state.viewport,
|
|
218
|
+
},
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
/**
|
|
223
|
+
* Function used to translate the legacy map state to one that can be used in current
|
|
224
|
+
* flatmap if required. If it is a legacy, an Select entry will be added
|
|
225
|
+
*
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
updateState: function(state) {
|
|
229
|
+
return new Promise((resolve) => {
|
|
230
|
+
if (state && state.state) {
|
|
231
|
+
const mapState = state.state;
|
|
232
|
+
//uuid is not in the state, this is a legacy map
|
|
233
|
+
if (!mapState.uuid) {
|
|
234
|
+
if (mapState.entry) {
|
|
235
|
+
const uuid = mapState.entry in TAXON_UUID ? TAXON_UUID[mapState.entry] : undefined;
|
|
236
|
+
const newState = this.createLegacyEntry(state, mapState.entry, uuid);
|
|
237
|
+
resolve(newState ? newState : state);
|
|
238
|
+
}
|
|
239
|
+
} else if (mapState.entry) {
|
|
240
|
+
//uuid is in the state but should be checked if it is the latest map
|
|
241
|
+
//for that taxon
|
|
242
|
+
return new Promise(() => {
|
|
243
|
+
const mapManager = new (require("@abi-software/flatmap-viewer")).MapManager(this.flatmapAPI);
|
|
244
|
+
//mapManager.findMap_ is an async function so we need to wrap this with a promise
|
|
245
|
+
mapManager.findMap_({taxon: mapState.entry}).then(map => {
|
|
246
|
+
if (map.uuid !== mapState.uuid) {
|
|
247
|
+
return this.createLegacyEntry(state, mapState.entry, mapState.uuid);
|
|
248
|
+
}
|
|
249
|
+
}).then(newState => {
|
|
250
|
+
resolve(newState ? newState : state);
|
|
251
|
+
})
|
|
252
|
+
.catch(() => {
|
|
253
|
+
resolve(state);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
//Create a new state and add the legacy map to the select
|
|
258
|
+
}
|
|
259
|
+
resolve(state);
|
|
260
|
+
});
|
|
261
|
+
},
|
|
262
|
+
/**
|
|
157
263
|
* Function used for getting the current states of the scene. This exported states
|
|
158
264
|
* can be imported using the importStates method.
|
|
159
265
|
*
|
|
@@ -177,19 +283,24 @@ export default {
|
|
|
177
283
|
setState: function(state) {
|
|
178
284
|
if (state) {
|
|
179
285
|
this.initialise().then(() => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
this.$
|
|
187
|
-
|
|
286
|
+
//Update state if required
|
|
287
|
+
this.updateState(state).then(currentState => {
|
|
288
|
+
if (currentState.species && (currentState.species !== this.activeSpecies)) {
|
|
289
|
+
this.activeSpecies = currentState.species;
|
|
290
|
+
if (currentState.state) {
|
|
291
|
+
//Wait for next tick when the refs are ready for rendering
|
|
292
|
+
this.$nextTick(() => {
|
|
293
|
+
if (this.activeSpecies in this.$refs) {
|
|
294
|
+
this.$refs[this.activeSpecies][0].createFlatmap(currentState.state);
|
|
295
|
+
this.$emit('flatmapChanged', this.activeSpecies);
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
} else if (currentState.state) {
|
|
300
|
+
let map = this.getCurrentFlatmap();
|
|
301
|
+
map.setState(currentState.state);
|
|
188
302
|
}
|
|
189
|
-
}
|
|
190
|
-
let map = this.getCurrentFlatmap();
|
|
191
|
-
map.setState(state.state);
|
|
192
|
-
}
|
|
303
|
+
});
|
|
193
304
|
})
|
|
194
305
|
}
|
|
195
306
|
},
|
|
@@ -242,7 +353,19 @@ export default {
|
|
|
242
353
|
type: String,
|
|
243
354
|
default: "Beta feature - This map is based on the connectivity of a rat. New connectivity and species specificity will be added as the SPARC program progress."
|
|
244
355
|
},
|
|
245
|
-
availableSpecies: {
|
|
356
|
+
availableSpecies: {
|
|
357
|
+
type: Object,
|
|
358
|
+
default: function() {
|
|
359
|
+
return {
|
|
360
|
+
"Human Female":{taxo: "NCBITaxon:9606", biologicalSex: "PATO:0000383", iconClass:"mapicon-icon_human", displayWarning:true},
|
|
361
|
+
"Human Male":{taxo: "NCBITaxon:9606", biologicalSex: "PATO:0000384", iconClass:"mapicon-icon_human", displayWarning:true},
|
|
362
|
+
"Rat":{taxo: "NCBITaxon:10114", iconClass:"mapicon-icon_rat", displayLatestChanges: true},
|
|
363
|
+
"Mouse":{taxo: "NCBITaxon:10090", iconClass:"mapicon-icon_mouse", displayWarning: true},
|
|
364
|
+
"Pig":{taxo: "NCBITaxon:9823", iconClass:"mapicon-icon_pig", displayWarning: true},
|
|
365
|
+
"Cat":{taxo: "NCBITaxon:9685", iconClass:"mapicon-icon_cat", displayWarning: true},
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
},
|
|
246
369
|
/**
|
|
247
370
|
* State containing state of the flatmap.
|
|
248
371
|
*/
|
|
@@ -266,7 +389,8 @@ export default {
|
|
|
266
389
|
return {
|
|
267
390
|
activeSpecies: undefined,
|
|
268
391
|
appendToBody: false,
|
|
269
|
-
speciesList: {}
|
|
392
|
+
speciesList: {},
|
|
393
|
+
requireInitialisation: true,
|
|
270
394
|
};
|
|
271
395
|
},
|
|
272
396
|
watch: {
|