@abi-software/map-side-bar 1.5.0 → 1.5.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +228 -228
  2. package/LICENSE +201 -201
  3. package/README.md +146 -146
  4. package/babel.config.js +14 -14
  5. package/dist/map-side-bar.common.js +423 -182
  6. package/dist/map-side-bar.common.js.map +1 -1
  7. package/dist/map-side-bar.css +1 -1
  8. package/dist/map-side-bar.umd.js +423 -182
  9. package/dist/map-side-bar.umd.js.map +1 -1
  10. package/dist/map-side-bar.umd.min.js +1 -1
  11. package/dist/map-side-bar.umd.min.js.map +1 -1
  12. package/package-lock.json +14536 -14536
  13. package/package.json +75 -75
  14. package/public/index.html +17 -17
  15. package/src/App.vue +164 -164
  16. package/src/algolia/algolia.js +188 -188
  17. package/src/algolia/utils.js +69 -69
  18. package/src/assets/_variables.scss +43 -43
  19. package/src/assets/styles.scss +7 -7
  20. package/src/components/BadgesGroup.vue +144 -144
  21. package/src/components/Cascader.vue +49 -49
  22. package/src/components/ContextCard.vue +397 -397
  23. package/src/components/DatasetCard.vue +328 -328
  24. package/src/components/EventBus.js +3 -3
  25. package/src/components/ImageGallery.vue +531 -531
  26. package/src/components/SearchFilters.vue +586 -587
  27. package/src/components/SearchHistory.vue +146 -0
  28. package/src/components/SideBar.vue +235 -232
  29. package/src/components/SidebarContent.vue +564 -554
  30. package/src/components/Tabs.vue +78 -78
  31. package/src/components/hardcoded-context-info.js +79 -79
  32. package/src/components/index.js +8 -8
  33. package/src/components/species-map.js +8 -8
  34. package/src/main.js +8 -8
  35. package/src/mixins/S3Bucket.vue +31 -31
  36. package/static.json +6 -6
  37. package/vue.config.js +19 -19
@@ -0,0 +1,146 @@
1
+ <template>
2
+ <div class="container">
3
+ <!-- <span v-if="reversedSearchHistory.length > 0" class="title"> Search History </span> -->
4
+ <template v-for="(item, i) in reversedSearchHistory">
5
+ <el-tag class="search-tag" v-if="i < 3" v-bind:key="i" @click="search(item)">{{ item.search }} </el-tag>
6
+ </template>
7
+ <el-select
8
+ v-if="reversedSearchHistory.length > 0"
9
+ :value="selectValue"
10
+ class="m-2 search-select"
11
+ placeholder="Full search History"
12
+ size="small"
13
+ popper-class="sidebar-search-select-popper"
14
+ @change="selectChange"
15
+ >
16
+ <el-option
17
+ v-for="(item, i) in cascaderOptions"
18
+ :key="i"
19
+ :label="item.label"
20
+ :value="item.value"
21
+ />
22
+ </el-select>
23
+ </div>
24
+
25
+ </template>
26
+
27
+ <script>
28
+ /* eslint-disable no-alert, no-console */
29
+ import Vue from "vue";
30
+ import {
31
+ Tag,
32
+ Select,
33
+ } from "element-ui";
34
+
35
+ Vue.use(Tag);
36
+ Vue.use(Select);
37
+ import EventBus from './EventBus';
38
+
39
+ // remove duplicates by stringifying the objects
40
+ const removeDuplicates = function(arrayOfAnything){
41
+ return [...new Set(arrayOfAnything.map(e => JSON.stringify(e)))].map(e => JSON.parse(e))
42
+ }
43
+
44
+ export default {
45
+ name: 'SearchHistory',
46
+ data() {
47
+ return {
48
+ searchHistory: [],
49
+ selectValue: 'Full search history'
50
+ }
51
+
52
+ },
53
+ computed: {
54
+ reversedSearchHistory: function(){
55
+ return removeDuplicates(this.searchHistory.slice().reverse().filter(item => item.search !== ''))
56
+ },
57
+ cascaderOptions: function(){
58
+ return this.reversedSearchHistory.map(item => {
59
+ return {
60
+ value: item.search,
61
+ label: item.search
62
+ }
63
+ })
64
+ }
65
+ },
66
+ methods: {
67
+ getSearchHistory() {
68
+ if (localStorage.getItem('sparc.science-sidebar-search-history')) {
69
+ this.searchHistory = JSON.parse(localStorage.getItem('sparc.science-sidebar-search-history'));
70
+ } else {
71
+ this.searchHistory = [];
72
+ }
73
+ },
74
+ clearSearchHistory() {
75
+ localStorage.removeItem('sparc.science-sidebar-search-history');
76
+ this.searchHistory = [];
77
+ },
78
+ addSearchToHistory(filters, search) {
79
+ filters = [] // disable filters for now
80
+ let searchHistory = JSON.parse(localStorage.getItem('sparc.science-sidebar-search-history'));
81
+ if (searchHistory) {
82
+ searchHistory.push({filters: filters, search: search});
83
+ this.searchHistory = removeDuplicates(searchHistory)
84
+ localStorage.setItem('sparc.science-sidebar-search-history', JSON.stringify(searchHistory));
85
+ } else {
86
+ localStorage.setItem('sparc.science-sidebar-search-history', JSON.stringify([{filters: filters, search: search}]));
87
+ }
88
+ },
89
+ search: function(item) {
90
+ this.$emit("search", item);
91
+ },
92
+ selectChange: function(value) {
93
+ this.selectValue = value;
94
+ this.search({search: value})
95
+ }
96
+ },
97
+ mounted: function () {
98
+ this.getSearchHistory();
99
+ EventBus.$on('search-changed', (data) => {
100
+ this.setSearchHistory(data);
101
+ })
102
+ }
103
+ }
104
+ </script>
105
+
106
+ <style scoped lang="scss">
107
+ @import "~element-ui/packages/theme-chalk/src/tag";
108
+
109
+ .container {
110
+ }
111
+
112
+ .search-tag {
113
+ margin: 0 5px 5px 0;
114
+ cursor: pointer;
115
+ max-width: 100px;
116
+ overflow: hidden;
117
+ text-overflow: ellipsis;
118
+ }
119
+
120
+ .title {
121
+ font-size: 14px;
122
+ font-weight: bold;
123
+ margin-right: 5px;
124
+ // center text vertically
125
+ display: flex;
126
+ align-items: center;
127
+
128
+ }
129
+
130
+ .search-select {
131
+ float: right;
132
+ }
133
+ </style>
134
+
135
+ <style lang="scss">
136
+ .sidebar-search-select-popper {
137
+ font-family: Asap;
138
+ font-size: 14px;
139
+ font-weight: 500;
140
+ font-stretch: normal;
141
+ font-style: normal;
142
+ line-height: normal;
143
+ letter-spacing: normal;
144
+ color: #292b66;
145
+ }
146
+ </style>
@@ -1,232 +1,235 @@
1
- <template>
2
- <div ref="container">
3
- <div v-if="!drawerOpen" @click="toggleDrawer" class="open-tab">
4
- <i class="el-icon-arrow-left"></i>
5
- </div>
6
- <el-drawer
7
- custom-class="my-drawer"
8
- class="side-bar"
9
- :visible.sync="drawerOpen"
10
- :appendToBody="false"
11
- :modal-append-to-body="false"
12
- size=550
13
- :with-header="false"
14
- :wrapperClosable="false"
15
- :modal="false"
16
- >
17
- <div class="box-card">
18
- <div v-if="drawerOpen" @click="close" class="close-tab">
19
- <i class="el-icon-arrow-right"></i>
20
- </div>
21
- <div class="sidebar-container">
22
- <tabs v-if="tabs.length > 1" :tabTitles="tabs" :activeId="activeId"
23
- @titleClicked="tabClicked"/>
24
- <template v-for="tab in tabs">
25
- <sidebar-content class="sidebar-content-container"
26
- v-show="tab.id===activeId" :contextCardEntry="tab.contextCard"
27
- :envVars="envVars"
28
- v-bind:key="tab.id" :ref="tab.id"
29
- @search-changed="searchChanged(tab.id, $event)"/>
30
- </template>
31
- </div>
32
- </div>
33
- </el-drawer>
34
- </div>
35
- </template>
36
-
37
-
38
- <script>
39
- /* eslint-disable no-alert, no-console */
40
- import Vue from "vue";
41
- import {
42
- Drawer,
43
- Icon,
44
- } from "element-ui";
45
- import lang from "element-ui/lib/locale/lang/en";
46
- import locale from "element-ui/lib/locale";
47
- import SidebarContent from './SidebarContent.vue';
48
- import EventBus from './EventBus';
49
- import Tabs from './Tabs'
50
-
51
- locale.use(lang);
52
- Vue.use(Drawer);
53
- Vue.use(Icon);
54
-
55
- export default {
56
- components: {SidebarContent, Tabs },
57
- name: "SideBar",
58
- props: {
59
- visible: {
60
- type: Boolean,
61
- default: false
62
- },
63
- envVars: {
64
- type: Object,
65
- default: () => {}
66
- },
67
- tabs: {
68
- type: Array,
69
- default: () => [{title:'flatmap', id:1}]
70
- },
71
- activeId: {
72
- type: Number,
73
- default: 1
74
- },
75
- openAtStart: {
76
- type: Boolean,
77
- default: false
78
- }
79
- },
80
- data: function () {
81
- return {
82
- drawerOpen: false,
83
- }
84
- },
85
- methods: {
86
- searchChanged: function (id, data) {
87
- this.$emit("search-changed", {...data, id: id});
88
- },
89
- close: function () {
90
- this.drawerOpen = false;
91
- },
92
- toggleDrawer: function () {
93
- this.drawerOpen = !this.drawerOpen;
94
- },
95
- openSearch: function(facets, query){
96
- this.drawerOpen = true;
97
- // Because refs are in v-for, nextTick is needed here
98
- Vue.nextTick(()=>{this.$refs[this.activeId][0].openSearch(facets, query)})
99
- },
100
- addFilter: function(filter){
101
- this.drawerOpen = true;
102
- filter.AND = true // When we add a filter external, it is currently only with an AND boolean
103
-
104
- // Because refs are in v-for, nextTick is needed here
105
- Vue.nextTick(()=>{this.$refs[this.activeId][0].addFilter(filter)})
106
- },
107
- openNeuronSearch: function(neuron){
108
- this.drawerOpen = true;
109
- // Because refs are in v-for, nextTick is needed here
110
- Vue.nextTick(()=>{this.$refs[this.activeId][0].openSearch('', undefined, 'scicrunch-query-string/', {'field': '*organ.curie', 'curie':neuron})})
111
- },
112
- getAlgoliaFacets: async function(){
113
- return await this.$refs[this.activeId][0].getAlgoliaFacets()
114
- },
115
- tabClicked: function(id) {
116
- this.$emit("tabClicked", id);
117
- },
118
- },
119
- created:function() {
120
- this.drawerOpen = this.openAtStart;
121
- },
122
- mounted: function(){
123
- EventBus.$on("PopoverActionClick", (payLoad) => {
124
- this.$emit("actionClick", payLoad);
125
- })
126
- EventBus.$on('available-facets', (payLoad)=> {
127
- this.$emit('search-changed', {
128
- type: 'available-facets',
129
- value: payLoad
130
- })
131
- })
132
- EventBus.$on('contextUpdate', (payLoad)=> {
133
- this.$emit('contextUpdate', payLoad)
134
- })
135
- }
136
- };
137
- </script>
138
-
139
- <!-- Add "scoped" attribute to limit CSS to this component only -->
140
- <style scoped lang="scss">
141
- @import "~element-ui/packages/theme-chalk/src/drawer";
142
- @import "~element-ui/packages/theme-chalk/src/icon";
143
-
144
- .box-card {
145
- flex: 3;
146
- height: 100%;
147
- overflow: hidden;
148
- pointer-events: auto;
149
- }
150
-
151
- .side-bar{
152
- position: relative;
153
- height: 100%;
154
- pointer-events: none;
155
- }
156
-
157
- .side-bar ::v-deep .el-drawer:focus{
158
- outline:none;
159
- }
160
-
161
- .sidebar-container {
162
- height: 100%;
163
- flex-flow: column;
164
- display: flex;
165
- }
166
-
167
- .open-tab{
168
- width: 20px;
169
- height: 40px;
170
- z-index: 8;
171
- position: absolute;
172
- top: calc(50vh - 80px);
173
- right: 0px;
174
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
175
- border: solid 1px $app-primary-color;
176
- background-color: #f9f2fc;
177
- text-align: center;
178
- vertical-align: middle;
179
- cursor: pointer;
180
- pointer-events: auto;
181
- }
182
-
183
- .el-icon-arrow-left,
184
- .el-icon-arrow-right
185
- {
186
- font-weight: 600;
187
- margin-top: 12px;
188
- color: $app-primary-color;
189
- cursor: pointer;
190
- pointer-events: auto;
191
- transform: scaleY(2.0);
192
- text-align: center;
193
- vertical-align: middle;
194
- }
195
-
196
- .close-tab{
197
- float: left;
198
- flex: 1;
199
- width: 20px;
200
- height: 40px;
201
- z-index: 8;
202
- margin-top: calc(50vh - 80px);
203
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
204
- border: solid 1px $app-primary-color;
205
- background-color: #f9f2fc;
206
- text-align: center;
207
- vertical-align: middle;
208
- cursor: pointer;
209
- pointer-events: auto;
210
- }
211
-
212
- .box-card {
213
- flex: 3;
214
- height: 100%;
215
- overflow: hidden;
216
- pointer-events: auto;
217
- }
218
-
219
- ::v-deep .my-drawer {
220
- background: rgba(0,0,0,0);
221
- box-shadow: none;
222
- }
223
-
224
- ::v-deep .my-drawer .el-drawer__body {
225
- height: 100%;
226
- }
227
-
228
- .sidebar-content-container {
229
- flex: 1 1 auto;
230
- }
231
-
232
- </style>
1
+ <template>
2
+ <div ref="container">
3
+ <div v-if="!drawerOpen" @click="toggleDrawer" class="open-tab">
4
+ <i class="el-icon-arrow-left"></i>
5
+ </div>
6
+ <el-drawer
7
+ custom-class="my-drawer"
8
+ class="side-bar"
9
+ :visible.sync="drawerOpen"
10
+ :appendToBody="false"
11
+ :modal-append-to-body="false"
12
+ size=550
13
+ :with-header="false"
14
+ :wrapperClosable="false"
15
+ :modal="false"
16
+ >
17
+ <div class="box-card">
18
+ <div v-if="drawerOpen" @click="close" class="close-tab">
19
+ <i class="el-icon-arrow-right"></i>
20
+ </div>
21
+ <div class="sidebar-container">
22
+ <tabs v-if="tabs.length > 1" :tabTitles="tabs" :activeId="activeId"
23
+ @titleClicked="tabClicked"/>
24
+ <template v-for="tab in tabs">
25
+ <sidebar-content class="sidebar-content-container"
26
+ v-show="tab.id===activeId" :contextCardEntry="tab.contextCard"
27
+ :envVars="envVars"
28
+ v-bind:key="tab.id" :ref="tab.id"
29
+ @search-changed="searchChanged(tab.id, $event)"/>
30
+ </template>
31
+ </div>
32
+ </div>
33
+ </el-drawer>
34
+ </div>
35
+ </template>
36
+
37
+
38
+ <script>
39
+ /* eslint-disable no-alert, no-console */
40
+ import Vue from "vue";
41
+ import {
42
+ Drawer,
43
+ Icon,
44
+ } from "element-ui";
45
+ import lang from "element-ui/lib/locale/lang/en";
46
+ import locale from "element-ui/lib/locale";
47
+ import SidebarContent from './SidebarContent.vue';
48
+ import EventBus from './EventBus';
49
+ import Tabs from './Tabs'
50
+
51
+ locale.use(lang);
52
+ Vue.use(Drawer);
53
+ Vue.use(Icon);
54
+
55
+ export default {
56
+ components: {SidebarContent, Tabs },
57
+ name: "SideBar",
58
+ props: {
59
+ visible: {
60
+ type: Boolean,
61
+ default: false
62
+ },
63
+ envVars: {
64
+ type: Object,
65
+ default: () => {}
66
+ },
67
+ tabs: {
68
+ type: Array,
69
+ default: () => [{title:'flatmap', id:1}]
70
+ },
71
+ activeId: {
72
+ type: Number,
73
+ default: 1
74
+ },
75
+ openAtStart: {
76
+ type: Boolean,
77
+ default: false
78
+ }
79
+ },
80
+ data: function () {
81
+ return {
82
+ drawerOpen: false,
83
+ }
84
+ },
85
+ methods: {
86
+ searchChanged: function (id, data) {
87
+ this.$emit("search-changed", {...data, id: id});
88
+ },
89
+ close: function () {
90
+ this.drawerOpen = false;
91
+ },
92
+ toggleDrawer: function () {
93
+ this.drawerOpen = !this.drawerOpen;
94
+ },
95
+ openSearch: function(facets, query){
96
+ this.drawerOpen = true;
97
+ // Because refs are in v-for, nextTick is needed here
98
+ Vue.nextTick(()=>{this.$refs[this.activeId][0].openSearch(facets, query)})
99
+ },
100
+ addFilter: function(filter){
101
+ this.drawerOpen = true;
102
+ filter.AND = true // When we add a filter external, it is currently only with an AND boolean
103
+
104
+ // Because refs are in v-for, nextTick is needed here
105
+ Vue.nextTick(()=>{this.$refs[this.activeId][0].addFilter(filter)})
106
+ },
107
+ openNeuronSearch: function(neuron){
108
+ this.drawerOpen = true;
109
+ // Because refs are in v-for, nextTick is needed here
110
+ Vue.nextTick(()=>{this.$refs[this.activeId][0].openSearch('', undefined, 'scicrunch-query-string/', {'field': '*organ.curie', 'curie':neuron})})
111
+ },
112
+ getAlgoliaFacets: async function(){
113
+ return await this.$refs[this.activeId][0].getAlgoliaFacets()
114
+ },
115
+ setDrawerOpen: function(value=true){
116
+ this.drawerOpen = value;
117
+ },
118
+ tabClicked: function(id) {
119
+ this.$emit("tabClicked", id);
120
+ },
121
+ },
122
+ created:function() {
123
+ this.drawerOpen = this.openAtStart;
124
+ },
125
+ mounted: function(){
126
+ EventBus.$on("PopoverActionClick", (payLoad) => {
127
+ this.$emit("actionClick", payLoad);
128
+ })
129
+ EventBus.$on('available-facets', (payLoad)=> {
130
+ this.$emit('search-changed', {
131
+ type: 'available-facets',
132
+ value: payLoad
133
+ })
134
+ })
135
+ EventBus.$on('contextUpdate', (payLoad)=> {
136
+ this.$emit('contextUpdate', payLoad)
137
+ })
138
+ }
139
+ };
140
+ </script>
141
+
142
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
143
+ <style scoped lang="scss">
144
+ @import "~element-ui/packages/theme-chalk/src/drawer";
145
+ @import "~element-ui/packages/theme-chalk/src/icon";
146
+
147
+ .box-card {
148
+ flex: 3;
149
+ height: 100%;
150
+ overflow: hidden;
151
+ pointer-events: auto;
152
+ }
153
+
154
+ .side-bar{
155
+ position: relative;
156
+ height: 100%;
157
+ pointer-events: none;
158
+ }
159
+
160
+ .side-bar ::v-deep .el-drawer:focus{
161
+ outline:none;
162
+ }
163
+
164
+ .sidebar-container {
165
+ height: 100%;
166
+ flex-flow: column;
167
+ display: flex;
168
+ }
169
+
170
+ .open-tab{
171
+ width: 20px;
172
+ height: 40px;
173
+ z-index: 8;
174
+ position: absolute;
175
+ top: calc(50vh - 80px);
176
+ right: 0px;
177
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
178
+ border: solid 1px $app-primary-color;
179
+ background-color: #f9f2fc;
180
+ text-align: center;
181
+ vertical-align: middle;
182
+ cursor: pointer;
183
+ pointer-events: auto;
184
+ }
185
+
186
+ .el-icon-arrow-left,
187
+ .el-icon-arrow-right
188
+ {
189
+ font-weight: 600;
190
+ margin-top: 12px;
191
+ color: $app-primary-color;
192
+ cursor: pointer;
193
+ pointer-events: auto;
194
+ transform: scaleY(2.0);
195
+ text-align: center;
196
+ vertical-align: middle;
197
+ }
198
+
199
+ .close-tab{
200
+ float: left;
201
+ flex: 1;
202
+ width: 20px;
203
+ height: 40px;
204
+ z-index: 8;
205
+ margin-top: calc(50vh - 80px);
206
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
207
+ border: solid 1px $app-primary-color;
208
+ background-color: #f9f2fc;
209
+ text-align: center;
210
+ vertical-align: middle;
211
+ cursor: pointer;
212
+ pointer-events: auto;
213
+ }
214
+
215
+ .box-card {
216
+ flex: 3;
217
+ height: 100%;
218
+ overflow: hidden;
219
+ pointer-events: auto;
220
+ }
221
+
222
+ ::v-deep .my-drawer {
223
+ background: rgba(0,0,0,0);
224
+ box-shadow: none;
225
+ }
226
+
227
+ ::v-deep .my-drawer .el-drawer__body {
228
+ height: 100%;
229
+ }
230
+
231
+ .sidebar-content-container {
232
+ flex: 1 1 auto;
233
+ }
234
+
235
+ </style>