@abi-software/map-side-bar 1.1.17 → 1.2.0-beta.0

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,52 +1,52 @@
1
- /* eslint-disable no-alert, no-console */
2
-
3
- // Mapping between display categories and their Algolia index property path
4
- // Used for populating the Dataset Search Results facet menu dynamically
5
- export const facetPropPathMapping = {
6
- 'anatomy.organ.name' : 'Anatomical Structure',
7
- 'organisms.primary.species.name' : 'Species',
8
- 'item.modalities.keyword' : 'Experimental Approach',
9
- 'attributes.subject.sex.value' : 'Sex',
10
- 'attributes.subject.ageCategory.value' : 'Age Categories',
11
- }
12
-
13
- /* Returns filter for searching algolia. All facets of the same category are joined with OR,
14
- * and each of those results is then joined with an AND.
15
- * i.e. (color:blue OR color:red) AND (shape:circle OR shape:red) */
16
- export function getFilters(selectedFacetArray=undefined) {
17
-
18
- // return all datasets if no filter
19
- if (selectedFacetArray === undefined) {
20
- return 'NOT item.published.status:embargo'
21
- }
22
-
23
- // Switch the 'term' attribute to 'label' if 'label' does not exist
24
- selectedFacetArray.forEach(f=>f.label=f.facet)
25
-
26
-
27
- let facets = removeShowAllFacets(selectedFacetArray)
28
-
29
- let filters = "NOT item.published.status:embargo";
30
- filters = `(${filters}) AND `;
31
-
32
- const facetPropPaths = Object.keys(facetPropPathMapping);
33
- facetPropPaths.map((facetPropPath) => {
34
- const facetsToOr = facets.filter(
35
- (facet) => facet.facetPropPath == facetPropPath
36
- );
37
- var filter = "";
38
- facetsToOr.map((facet) => {
39
- filter += `"${facetPropPath}":"${facet.label}" OR `;
40
- });
41
- if (filter == "") {
42
- return;
43
- }
44
- filter = `(${filter.substring(0, filter.lastIndexOf(" OR "))})`;
45
- filters += `${filter} AND `;
46
- });
47
- return filters.substring(0, filters.lastIndexOf(" AND "));
48
- }
49
-
50
- function removeShowAllFacets(facetArray){
51
- return facetArray.filter( f => f.label !== 'Show all')
1
+ /* eslint-disable no-alert, no-console */
2
+
3
+ // Mapping between display categories and their Algolia index property path
4
+ // Used for populating the Dataset Search Results facet menu dynamically
5
+ export const facetPropPathMapping = {
6
+ 'anatomy.organ.name' : 'Anatomical Structure',
7
+ 'organisms.primary.species.name' : 'Species',
8
+ 'item.modalities.keyword' : 'Experimental Approach',
9
+ 'attributes.subject.sex.value' : 'Sex',
10
+ 'attributes.subject.ageCategory.value' : 'Age Categories',
11
+ }
12
+
13
+ /* Returns filter for searching algolia. All facets of the same category are joined with OR,
14
+ * and each of those results is then joined with an AND.
15
+ * i.e. (color:blue OR color:red) AND (shape:circle OR shape:red) */
16
+ export function getFilters(selectedFacetArray=undefined) {
17
+
18
+ // return all datasets if no filter
19
+ if (selectedFacetArray === undefined) {
20
+ return 'NOT item.published.status:embargo'
21
+ }
22
+
23
+ // Switch the 'term' attribute to 'label' if 'label' does not exist
24
+ selectedFacetArray.forEach(f=>f.label=f.facet)
25
+
26
+
27
+ let facets = removeShowAllFacets(selectedFacetArray)
28
+
29
+ let filters = "NOT item.published.status:embargo";
30
+ filters = `(${filters}) AND `;
31
+
32
+ const facetPropPaths = Object.keys(facetPropPathMapping);
33
+ facetPropPaths.map((facetPropPath) => {
34
+ const facetsToOr = facets.filter(
35
+ (facet) => facet.facetPropPath == facetPropPath
36
+ );
37
+ var filter = "";
38
+ facetsToOr.map((facet) => {
39
+ filter += `"${facetPropPath}":"${facet.label}" OR `;
40
+ });
41
+ if (filter == "") {
42
+ return;
43
+ }
44
+ filter = `(${filter.substring(0, filter.lastIndexOf(" OR "))})`;
45
+ filters += `${filter} AND `;
46
+ });
47
+ return filters.substring(0, filters.lastIndexOf(" AND "));
48
+ }
49
+
50
+ function removeShowAllFacets(facetArray){
51
+ return facetArray.filter( f => f.label !== 'Show all')
52
52
  }
@@ -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,157 +1,157 @@
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" class="context-card card" >
7
- <img :src="entry.banner" class="context-image card-left">
8
- <div class="card-right">
9
- <div class="title">{{contextData.heading}}</div>
10
- <div>{{contextData.description}}</div>
11
- <template v-for="(view, i) in contextData.views">
12
- <br v-bind:key="i"/>
13
- <span v-bind:key="i+'_1'" @click="openViewFile(view)" class="scaffold-view"><img :src="getFileFromPath(view.thumbnail)"> {{view.description}}</span>
14
- </template>
15
- </div>
16
- </el-card>
17
- </div>
18
- </div>
19
- </template>
20
-
21
-
22
- <script>
23
- /* eslint-disable no-alert, no-console */
24
- import Vue from "vue";
25
- import { Link, Icon, Card, Button, Select, Input } from "element-ui";
26
- import lang from "element-ui/lib/locale/lang/en";
27
- import locale from "element-ui/lib/locale";
28
- import EventBus from "./EventBus"
29
-
30
- locale.use(lang);
31
- Vue.use(Link);
32
- Vue.use(Icon);
33
- Vue.use(Card);
34
- Vue.use(Button);
35
- Vue.use(Select);
36
- Vue.use(Input);
37
-
38
-
39
-
40
- export default {
41
- name: "contextCard",
42
- props: {
43
- /**
44
- * Object containing information for
45
- * the required viewing.
46
- */
47
- entry: Object,
48
- },
49
- data: function () {
50
- return {
51
- contextData: {},
52
- showDetails: true,
53
- showContextCard: true
54
- };
55
- },
56
- watch: {
57
- 'entry.contextCardUrl': {
58
- handler(val){
59
- if (val) {
60
- this.getContextFile(val)
61
- this.showContextCard = true
62
- } else {
63
- this.showContextCard = false
64
- }
65
- },
66
- immediate: true
67
- }
68
- },
69
- methods: {
70
- getContextFile: function (contextFileUrl) {
71
- fetch(contextFileUrl)
72
- .then((response) =>{
73
- if (!response.ok){
74
- throw Error(response.statusText)
75
- } else {
76
- return response.json()
77
- }
78
- })
79
- .then((data) => {
80
- this.contextData = data
81
- })
82
- .catch(() => {
83
- //set defaults if we hit an error
84
- this.thumbnail = require('@/../assets/missing-image.svg')
85
- this.discoverId = undefined
86
- });
87
- },
88
- removeDoubleFilesPath: function(path){
89
- if (path.includes('files/files/')){
90
- return path.replace('files/files/', 'files/')
91
- } else {
92
- return path
93
- }
94
- },
95
- getFileFromPath: function(path){
96
- path = this.removeDoubleFilesPath(path)
97
- return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
98
- },
99
- openViewFile: function(view){
100
-
101
- // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
102
- this.entry.viewUrl = view.path.split('/')[view.path.split('/').length-1]
103
- this.entry.type = 'Scaffold View'
104
- EventBus.$emit("PopoverActionClick", this.entry)
105
- }
106
- }
107
- };
108
- </script>
109
-
110
- <!-- Add "scoped" attribute to limit CSS to this component only -->
111
- <style scoped>
112
-
113
- .hide{
114
- color: #e4e7ed;
115
- cursor: pointer;
116
- }
117
-
118
- .context-card{
119
- background-color: white;
120
- }
121
-
122
- .context-card >>> .el-card__body {
123
- padding: 0px;
124
- display: flex;
125
- width: 516px;
126
- }
127
-
128
- .context-image{
129
- width: 250px
130
- }
131
-
132
- .card {
133
- padding-top: 18px;
134
- margin-bottom: 18px;
135
- position: relative;
136
- border: solid 1px #e4e7ed;
137
- display: flex;
138
- }
139
-
140
- .card-left{
141
- flex: 1
142
- }
143
-
144
- .card-right {
145
- flex: 1.3;
146
- padding-left: 6px;
147
- }
148
-
149
- .cursor-pointer {
150
- cursor: pointer;
151
- height: 25px;
152
- }
153
-
154
- .title{
155
- font-weight: bold;
156
- }
157
- </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" class="context-card card" >
7
+ <img :src="entry.banner" class="context-image card-left">
8
+ <div class="card-right">
9
+ <div class="title">{{contextData.heading}}</div>
10
+ <div>{{contextData.description}}</div>
11
+ <template v-for="(view, i) in contextData.views">
12
+ <br v-bind:key="i"/>
13
+ <span v-bind:key="i+'_1'" @click="openViewFile(view)" class="scaffold-view"><img :src="getFileFromPath(view.thumbnail)"> {{view.description}}</span>
14
+ </template>
15
+ </div>
16
+ </el-card>
17
+ </div>
18
+ </div>
19
+ </template>
20
+
21
+
22
+ <script>
23
+ /* eslint-disable no-alert, no-console */
24
+ import Vue from "vue";
25
+ import { Link, Icon, Card, Button, Select, Input } from "element-ui";
26
+ import lang from "element-ui/lib/locale/lang/en";
27
+ import locale from "element-ui/lib/locale";
28
+ import EventBus from "./EventBus"
29
+
30
+ locale.use(lang);
31
+ Vue.use(Link);
32
+ Vue.use(Icon);
33
+ Vue.use(Card);
34
+ Vue.use(Button);
35
+ Vue.use(Select);
36
+ Vue.use(Input);
37
+
38
+
39
+
40
+ export default {
41
+ name: "contextCard",
42
+ props: {
43
+ /**
44
+ * Object containing information for
45
+ * the required viewing.
46
+ */
47
+ entry: Object,
48
+ },
49
+ data: function () {
50
+ return {
51
+ contextData: {},
52
+ showDetails: true,
53
+ showContextCard: true
54
+ };
55
+ },
56
+ watch: {
57
+ 'entry.contextCardUrl': {
58
+ handler(val){
59
+ if (val) {
60
+ this.getContextFile(val)
61
+ this.showContextCard = true
62
+ } else {
63
+ this.showContextCard = false
64
+ }
65
+ },
66
+ immediate: true
67
+ }
68
+ },
69
+ methods: {
70
+ getContextFile: function (contextFileUrl) {
71
+ fetch(contextFileUrl)
72
+ .then((response) =>{
73
+ if (!response.ok){
74
+ throw Error(response.statusText)
75
+ } else {
76
+ return response.json()
77
+ }
78
+ })
79
+ .then((data) => {
80
+ this.contextData = data
81
+ })
82
+ .catch(() => {
83
+ //set defaults if we hit an error
84
+ this.thumbnail = require('@/../assets/missing-image.svg')
85
+ this.discoverId = undefined
86
+ });
87
+ },
88
+ removeDoubleFilesPath: function(path){
89
+ if (path.includes('files/files/')){
90
+ return path.replace('files/files/', 'files/')
91
+ } else {
92
+ return path
93
+ }
94
+ },
95
+ getFileFromPath: function(path){
96
+ path = this.removeDoubleFilesPath(path)
97
+ return `${this.entry.apiLocation}s3-resource/${this.entry.discoverId}/${this.entry.version}/files/${path}`
98
+ },
99
+ openViewFile: function(view){
100
+
101
+ // note that we assume that the view file is in the same directory as the scaffold (viewUrls take relative paths)
102
+ this.entry.viewUrl = view.path.split('/')[view.path.split('/').length-1]
103
+ this.entry.type = 'Scaffold View'
104
+ EventBus.$emit("PopoverActionClick", this.entry)
105
+ }
106
+ }
107
+ };
108
+ </script>
109
+
110
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
111
+ <style scoped>
112
+
113
+ .hide{
114
+ color: #e4e7ed;
115
+ cursor: pointer;
116
+ }
117
+
118
+ .context-card{
119
+ background-color: white;
120
+ }
121
+
122
+ .context-card >>> .el-card__body {
123
+ padding: 0px;
124
+ display: flex;
125
+ width: 516px;
126
+ }
127
+
128
+ .context-image{
129
+ width: 250px
130
+ }
131
+
132
+ .card {
133
+ padding-top: 18px;
134
+ margin-bottom: 18px;
135
+ position: relative;
136
+ border: solid 1px #e4e7ed;
137
+ display: flex;
138
+ }
139
+
140
+ .card-left{
141
+ flex: 1
142
+ }
143
+
144
+ .card-right {
145
+ flex: 1.3;
146
+ padding-left: 6px;
147
+ }
148
+
149
+ .cursor-pointer {
150
+ cursor: pointer;
151
+ height: 25px;
152
+ }
153
+
154
+ .title{
155
+ font-weight: bold;
156
+ }
157
+ </style>