@abi-software/flatmapvuer 0.3.12 → 0.3.13-beta-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.
- package/package.json +1 -1
- package/src/components/FlatmapVuer.vue +108 -12
- package/src/components/MultiFlatmapVuer.vue +49 -28
- package/dist/demo.html +0 -10
- package/dist/flatmapvuer.common.js +0 -16250
- package/dist/flatmapvuer.common.js.map +0 -1
- package/dist/flatmapvuer.css +0 -1
- package/dist/flatmapvuer.umd.js +0 -16260
- package/dist/flatmapvuer.umd.js.map +0 -1
- package/dist/flatmapvuer.umd.min.js +0 -2
- package/dist/flatmapvuer.umd.min.js.map +0 -1
package/package.json
CHANGED
|
@@ -516,9 +516,9 @@ export default {
|
|
|
516
516
|
let myOptions = options;
|
|
517
517
|
if (this.mapImp) {
|
|
518
518
|
if (myOptions) {
|
|
519
|
-
if (!myOptions.className) myOptions.className = "
|
|
519
|
+
if (!myOptions.className) myOptions.className = "custom-popup";
|
|
520
520
|
} else {
|
|
521
|
-
myOptions = { className: "
|
|
521
|
+
myOptions = { className: "custom-popup", positionAtLastClick: true };
|
|
522
522
|
}
|
|
523
523
|
this.mapImp.showPopup(featureId, node, myOptions);
|
|
524
524
|
}
|
|
@@ -614,6 +614,14 @@ export default {
|
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
},
|
|
617
|
+
restoreMapState: function(state) {
|
|
618
|
+
if (state) {
|
|
619
|
+
if (state.viewport)
|
|
620
|
+
this.mapImp.setState(state.viewport);
|
|
621
|
+
if (state.searchTerm)
|
|
622
|
+
this.searchAndShowResult(state.searchTerm, true);
|
|
623
|
+
}
|
|
624
|
+
},
|
|
617
625
|
createFlatmap: function(state) {
|
|
618
626
|
if (!this.mapImp && !this.loading) {
|
|
619
627
|
this.loading = true;
|
|
@@ -687,16 +695,17 @@ export default {
|
|
|
687
695
|
this.pathways = this.mapImp.pathTypes();
|
|
688
696
|
this.$emit("ready", this);
|
|
689
697
|
this.loading = false;
|
|
690
|
-
if (this.
|
|
691
|
-
this.
|
|
692
|
-
else
|
|
693
|
-
this.
|
|
698
|
+
if (this._stateToBeSet)
|
|
699
|
+
this.restoreMapState(this._viewportToBeSet);
|
|
700
|
+
else {
|
|
701
|
+
this.restoreMapState(state);
|
|
702
|
+
}
|
|
694
703
|
});
|
|
695
704
|
} else if (state) {
|
|
696
705
|
if (this.entry == state.entry) {
|
|
697
|
-
this.
|
|
706
|
+
this._stateToBeSet = { viewport: state.viewport, searchTerm: searchTerm };
|
|
698
707
|
if (this.mapImp && !this.loading)
|
|
699
|
-
this.
|
|
708
|
+
this.restoreMapState(this._stateToBeSet);
|
|
700
709
|
}
|
|
701
710
|
}
|
|
702
711
|
},
|
|
@@ -708,17 +717,28 @@ export default {
|
|
|
708
717
|
this.drawerOpen = flag;
|
|
709
718
|
},
|
|
710
719
|
/**
|
|
711
|
-
* Function to display features with annotation matching the provided term
|
|
720
|
+
* Function to display features with annotation matching the provided term,
|
|
721
|
+
* with the option to display the label using displayLabel flag.
|
|
712
722
|
*/
|
|
713
|
-
searchAndShowResult: function(term) {
|
|
723
|
+
searchAndShowResult: function(term, displayLabel) {
|
|
714
724
|
if (this.mapImp) {
|
|
715
725
|
if (term === undefined || term === "") {
|
|
716
726
|
this.mapImp.clearSearchResults();
|
|
717
727
|
return true;
|
|
718
728
|
} else {
|
|
719
|
-
|
|
720
|
-
if (searchResults && searchResults.
|
|
729
|
+
const searchResults = this.mapImp.search(term);
|
|
730
|
+
if (searchResults && searchResults.results &&
|
|
731
|
+
searchResults.results.length > 0) {
|
|
721
732
|
this.mapImp.showSearchResults(searchResults);
|
|
733
|
+
if (displayLabel &&
|
|
734
|
+
searchResults.results[0].featureId &&
|
|
735
|
+
searchResults.results[0].text) {
|
|
736
|
+
this.mapImp.showPopup(
|
|
737
|
+
searchResults.results[0].featureId,
|
|
738
|
+
searchResults.results[0].text,
|
|
739
|
+
{className: "custom-popup", positionAtLastClick: false }
|
|
740
|
+
)
|
|
741
|
+
}
|
|
722
742
|
return true;
|
|
723
743
|
}
|
|
724
744
|
else
|
|
@@ -1461,5 +1481,81 @@ export default {
|
|
|
1461
1481
|
}
|
|
1462
1482
|
}
|
|
1463
1483
|
}
|
|
1484
|
+
|
|
1485
|
+
::v-deep .custom-popup {
|
|
1486
|
+
.mapboxgl-popup-tip {
|
|
1487
|
+
display: none;
|
|
1488
|
+
}
|
|
1489
|
+
.mapboxgl-popup-content {
|
|
1490
|
+
border-radius: 4px;
|
|
1491
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
1492
|
+
pointer-events: none;
|
|
1493
|
+
display: none;
|
|
1494
|
+
background: #fff;
|
|
1495
|
+
font-family: "Asap",sans-serif;
|
|
1496
|
+
font-size: 12pt;
|
|
1497
|
+
color: $app-primary-color;
|
|
1498
|
+
border: 1px solid $app-primary-color;
|
|
1499
|
+
padding-left: 6px;
|
|
1500
|
+
padding-right: 6px;
|
|
1501
|
+
padding-top: 6px;
|
|
1502
|
+
padding-bottom: 6px;
|
|
1503
|
+
display: flex;
|
|
1504
|
+
justify-content: center;
|
|
1505
|
+
align-items: center;
|
|
1506
|
+
&::after,
|
|
1507
|
+
&::before {
|
|
1508
|
+
content: "";
|
|
1509
|
+
display: block;
|
|
1510
|
+
position: absolute;
|
|
1511
|
+
width: 0;
|
|
1512
|
+
height: 0;
|
|
1513
|
+
border-style: solid;
|
|
1514
|
+
flex-shrink: 0;
|
|
1515
|
+
}
|
|
1516
|
+
.mapboxgl-popup-close-button {
|
|
1517
|
+
display: none;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
&.mapboxgl-popup-anchor-bottom {
|
|
1521
|
+
.mapboxgl-popup-content {
|
|
1522
|
+
margin-bottom: 12px;
|
|
1523
|
+
&::after,
|
|
1524
|
+
&::before {
|
|
1525
|
+
top: 100%;
|
|
1526
|
+
border-width: 12px;
|
|
1527
|
+
}
|
|
1528
|
+
/* this border color controlls the color of the triangle (what looks like the fill of the triangle) */
|
|
1529
|
+
&::after {
|
|
1530
|
+
margin-top: -1px;
|
|
1531
|
+
border-color: rgb(255, 255, 255) transparent transparent transparent;
|
|
1532
|
+
}
|
|
1533
|
+
/* this border color controlls the outside, thin border */
|
|
1534
|
+
&::before {
|
|
1535
|
+
margin: 0 auto;
|
|
1536
|
+
border-color: $app-primary-color transparent transparent transparent;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
&.mapboxgl-popup-anchor-top {
|
|
1541
|
+
.mapboxgl-popup-content {
|
|
1542
|
+
margin-top: 18px;
|
|
1543
|
+
&::after,
|
|
1544
|
+
&::before {
|
|
1545
|
+
top: calc(-100% + 6px);
|
|
1546
|
+
border-width: 12px;
|
|
1547
|
+
}
|
|
1548
|
+
/* this border color controlls the color of the triangle (what looks like the fill of the triangle) */
|
|
1549
|
+
&::after {
|
|
1550
|
+
margin-top: 1px;
|
|
1551
|
+
border-color: transparent transparent rgb(255, 255, 255) transparent;
|
|
1552
|
+
}
|
|
1553
|
+
&::before {
|
|
1554
|
+
margin: 0 auto;
|
|
1555
|
+
border-color: transparent transparent $app-primary-color transparent;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1464
1560
|
</style>
|
|
1465
1561
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
placeholder="Select"
|
|
15
15
|
class="select-box"
|
|
16
16
|
popper-class="flatmap_dropdown"
|
|
17
|
-
@change="
|
|
17
|
+
@change="setSpecies"
|
|
18
18
|
v-popover:selectPopover
|
|
19
19
|
>
|
|
20
20
|
<el-option v-for="(item, key) in speciesList" :key="key" :label="key" :value="key">
|
|
@@ -85,6 +85,10 @@ export default {
|
|
|
85
85
|
components: {
|
|
86
86
|
FlatmapVuer
|
|
87
87
|
},
|
|
88
|
+
beforeMount() {
|
|
89
|
+
this._resolveList = [];
|
|
90
|
+
this._initialised = false;
|
|
91
|
+
},
|
|
88
92
|
mounted: function() {
|
|
89
93
|
this.initialise();
|
|
90
94
|
EventBus.$on('onActionClick', (action) =>{
|
|
@@ -100,6 +104,7 @@ export default {
|
|
|
100
104
|
fetch(this.flatmapAPI)
|
|
101
105
|
.then(response => response.json())
|
|
102
106
|
.then(data => {
|
|
107
|
+
this._initialised = true;
|
|
103
108
|
//Check each key in the provided availableSpecies against the one
|
|
104
109
|
//on the server, add them to the Select if the key is found
|
|
105
110
|
Object.keys(this.availableSpecies).forEach(key => {
|
|
@@ -118,21 +123,34 @@ export default {
|
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
});
|
|
121
|
-
|
|
126
|
+
//Use the state species if it does not have any other species information
|
|
127
|
+
let species = this.initial;
|
|
128
|
+
if (this.state) {
|
|
129
|
+
const mapState = this.state.state;
|
|
130
|
+
if ((!mapState || ( !mapState.uuid && !mapState.entry )) && this.state.species)
|
|
131
|
+
species = this.state.species;
|
|
132
|
+
else
|
|
133
|
+
species = undefined;
|
|
134
|
+
}
|
|
135
|
+
if (species) {
|
|
122
136
|
//No state resuming, set the current flatmap to {this.initial}
|
|
123
|
-
if (
|
|
124
|
-
this.activeSpecies =
|
|
137
|
+
if (species && this.speciesList[species] !== undefined) {
|
|
138
|
+
this.activeSpecies = species;
|
|
125
139
|
} else {
|
|
126
140
|
this.activeSpecies = Object.keys(this.speciesList)[0];
|
|
127
141
|
}
|
|
128
|
-
|
|
129
|
-
if (this.$refs[this.activeSpecies])
|
|
130
|
-
this.$refs[this.activeSpecies][0].createFlatmap();
|
|
131
|
-
});
|
|
142
|
+
this.setSpecies(this.activeSpecies, this.state ? this.state.state : undefined, 5);
|
|
132
143
|
}
|
|
144
|
+
resolve();
|
|
145
|
+
this._resolveList.forEach(other => { other(); });
|
|
133
146
|
});
|
|
147
|
+
} else if (this._initialised) {
|
|
148
|
+
//resolve as it has been initialised
|
|
149
|
+
resolve();
|
|
150
|
+
} else {
|
|
151
|
+
//resolve when the list request has been resolved
|
|
152
|
+
this._resolveList.push(resolve);
|
|
134
153
|
}
|
|
135
|
-
resolve();
|
|
136
154
|
})
|
|
137
155
|
},
|
|
138
156
|
FlatmapSelected: function(resource) {
|
|
@@ -162,11 +180,19 @@ export default {
|
|
|
162
180
|
let map = this.getCurrentFlatmap();
|
|
163
181
|
map.showMarkerPopup(featureId, node, options);
|
|
164
182
|
},
|
|
165
|
-
|
|
166
|
-
if (this
|
|
183
|
+
setSpecies: function(species, state, numberOfRetry) {
|
|
184
|
+
if (this.$refs && species in this.$refs) {
|
|
167
185
|
this.activeSpecies = species;
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
this.$refs[this.activeSpecies][0].createFlatmap(state);
|
|
187
|
+
this.$emit('flatmapChanged', this.activeSpecies);
|
|
188
|
+
} else if (numberOfRetry) {
|
|
189
|
+
const retry = numberOfRetry - 1;
|
|
190
|
+
if (retry >= 0) {
|
|
191
|
+
Vue.nextTick(() => {
|
|
192
|
+
this.setSpecies(species, state, retry);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
170
196
|
},
|
|
171
197
|
/**
|
|
172
198
|
* Function to switch to the latest existing map from
|
|
@@ -181,7 +207,7 @@ export default {
|
|
|
181
207
|
if (!species.isLegacy &&
|
|
182
208
|
(species.taxo === state.entry) &&
|
|
183
209
|
(species.biologicalSex === state.biologicalSex)) {
|
|
184
|
-
this.
|
|
210
|
+
this.setSpecies(keys[i], state, 0);
|
|
185
211
|
return;
|
|
186
212
|
}
|
|
187
213
|
}
|
|
@@ -215,6 +241,7 @@ export default {
|
|
|
215
241
|
entry: taxo,
|
|
216
242
|
uuid: uuid,
|
|
217
243
|
viewport: state.state.viewport,
|
|
244
|
+
searchTerm: state.state.searchTerm
|
|
218
245
|
},
|
|
219
246
|
}
|
|
220
247
|
}
|
|
@@ -242,7 +269,10 @@ export default {
|
|
|
242
269
|
return new Promise(() => {
|
|
243
270
|
const mapManager = new (require("@abi-software/flatmap-viewer")).MapManager(this.flatmapAPI);
|
|
244
271
|
//mapManager.findMap_ is an async function so we need to wrap this with a promise
|
|
245
|
-
|
|
272
|
+
const identifier = { taxon: mapState.entry };
|
|
273
|
+
if (mapState.biologicalSex)
|
|
274
|
+
identifier['biologicalSex'] = mapState.biologicalSex;
|
|
275
|
+
mapManager.findMap_(identifier).then(map => {
|
|
246
276
|
if (map.uuid !== mapState.uuid) {
|
|
247
277
|
return this.createLegacyEntry(state, mapState.entry, mapState.uuid);
|
|
248
278
|
}
|
|
@@ -282,26 +312,17 @@ export default {
|
|
|
282
312
|
*/
|
|
283
313
|
setState: function(state) {
|
|
284
314
|
if (state) {
|
|
285
|
-
this.initialise().then(() => {
|
|
286
315
|
//Update state if required
|
|
287
|
-
|
|
316
|
+
this.updateState(state).then(currentState => {
|
|
317
|
+
this.initialise().then(() => {
|
|
288
318
|
if (currentState.species && (currentState.species !== this.activeSpecies)) {
|
|
289
|
-
this.
|
|
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
|
-
}
|
|
319
|
+
this.setSpecies(currentState.species, currentState.state, 5);
|
|
299
320
|
} else if (currentState.state) {
|
|
300
321
|
let map = this.getCurrentFlatmap();
|
|
301
322
|
map.setState(currentState.state);
|
|
302
323
|
}
|
|
303
324
|
});
|
|
304
|
-
})
|
|
325
|
+
});
|
|
305
326
|
}
|
|
306
327
|
},
|
|
307
328
|
resourceSelected: function(action) {
|