@abi-software/map-side-bar 2.2.1-alpha-2 → 2.2.1-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,102 +1,102 @@
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
- {
7
- label: 'Data Type',
8
- id: 'item.types',
9
- facetPropPath: 'item.types.name',
10
- facetSubpropPath: 'item.types.subcategory.name'
11
- },
12
- {
13
- label: 'Anatomical Structure',
14
- id: 'anatomy.organ.category',
15
- facetPropPath: 'anatomy.organ.category.name',
16
- facetSubpropPath: 'anatomy.organ.subcategory.name',
17
- facetFilterPath: 'anatomy.organ.name'
18
- },
19
- {
20
- label: 'Species',
21
- id: 'organisms.primary.species',
22
- facetPropPath: 'organisms.primary.species.name',
23
- facetSubpropPath: 'organisms.primary.species.subcategory.name'
24
- },
25
- {
26
- label: 'Experimental Approach',
27
- id: 'item.modalities',
28
- facetPropPath: 'item.modalities.keyword',
29
- facetSubpropPath: 'item.modalities.subcategory.name'
30
- },
31
- {
32
- label: 'Sex',
33
- id: 'attributes.subject.sex',
34
- facetPropPath: 'attributes.subject.sex.value',
35
- facetSubpropPath: 'attributes.subject.sex.subcategory.name'
36
- },
37
- {
38
- label: 'Age Categories',
39
- id: 'attributes.subject.ageCategory',
40
- facetPropPath: 'attributes.subject.ageCategory.value',
41
- facetSubpropPath: 'attributes.subject.ageCategory.subcategory.name'
42
- },
43
- ]
44
-
45
- // Same as above, but these show on the sidebar filters
46
- export const shownFilters = {
47
- 'anatomy.organ.name' : 'Anatomical Structure',
48
- 'organisms.primary.species.name' : 'Species',
49
- 'attributes.subject.sex.value' : 'Sex',
50
- 'attributes.subject.ageCategory.value' : 'Age Categories',
51
- 'item.types.name' : 'Data type',
52
- }
53
-
54
- /* Returns filter for searching algolia. All facets of the same category are joined with OR,
55
- * and each of those results is then joined with an AND.
56
- * i.e. (color:blue OR color:red) AND (shape:circle OR shape:red) */
57
- export function getFilters(selectedFacetArray=undefined) {
58
- // return all datasets if no filter
59
- if (selectedFacetArray === undefined) {
60
- return 'NOT item.published.status:embargo'
61
- }
62
-
63
- // Switch the 'term' attribute to 'label' if 'label' does not exist
64
- selectedFacetArray.forEach(f=>f.label=f.facet)
65
-
66
-
67
- let facets = removeShowAllFacets(selectedFacetArray)
68
-
69
- let filters = "NOT item.published.status:embargo";
70
- filters = `(${filters}) AND `;
71
- const facetPropPaths = facetPropPathMapping.map((f) => f.facetPropPath);
72
- facetPropPaths.map((facetPropPath) => {
73
- let facetsToBool = facets.filter(
74
- (facet) => facet.facetPropPath == facetPropPath
75
- );
76
- let orFilters = "";
77
- let andFilters = "";
78
- facetsToBool.map((facet) => {
79
- let facetPropPathToUse = facet.facetSubPropPath ? facet.facetSubPropPath : facetPropPath // Check if we have a subpath
80
- if (facet.AND){
81
- andFilters += `AND "${facetPropPathToUse}":"${facet.label}"`;
82
- } else {
83
- orFilters += `"${facetPropPathToUse}":"${facet.label}" OR `;
84
- }
85
- });
86
- if (orFilters == "" && andFilters =="") {
87
- return;
88
- }
89
- orFilters = `(${orFilters.substring(0, orFilters.lastIndexOf(" OR "))})` // remove last OR
90
-
91
- filters += `${orFilters + andFilters} AND `; // Put them together
92
- // (Note that we add an extra AND in case there are facets at a higher level)
93
-
94
- filters = filters.split('()AND ').join(''); // Handle case where there where no OR facets
95
- });
96
- console.log('filters about to be applied:', filters)
97
- return filters.substring(0, filters.lastIndexOf(" AND "));
98
- }
99
-
100
- function removeShowAllFacets(facetArray){
101
- 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
+ {
7
+ label: 'Data Type',
8
+ id: 'item.types',
9
+ facetPropPath: 'item.types.name',
10
+ facetSubpropPath: 'item.types.subcategory.name'
11
+ },
12
+ {
13
+ label: 'Anatomical Structure',
14
+ id: 'anatomy.organ.category',
15
+ facetPropPath: 'anatomy.organ.category.name',
16
+ facetSubpropPath: 'anatomy.organ.subcategory.name',
17
+ facetFilterPath: 'anatomy.organ.name'
18
+ },
19
+ {
20
+ label: 'Species',
21
+ id: 'organisms.primary.species',
22
+ facetPropPath: 'organisms.primary.species.name',
23
+ facetSubpropPath: 'organisms.primary.species.subcategory.name'
24
+ },
25
+ {
26
+ label: 'Experimental Approach',
27
+ id: 'item.modalities',
28
+ facetPropPath: 'item.modalities.keyword',
29
+ facetSubpropPath: 'item.modalities.subcategory.name'
30
+ },
31
+ {
32
+ label: 'Sex',
33
+ id: 'attributes.subject.sex',
34
+ facetPropPath: 'attributes.subject.sex.value',
35
+ facetSubpropPath: 'attributes.subject.sex.subcategory.name'
36
+ },
37
+ {
38
+ label: 'Age Categories',
39
+ id: 'attributes.subject.ageCategory',
40
+ facetPropPath: 'attributes.subject.ageCategory.value',
41
+ facetSubpropPath: 'attributes.subject.ageCategory.subcategory.name'
42
+ },
43
+ ]
44
+
45
+ // Same as above, but these show on the sidebar filters
46
+ export const shownFilters = {
47
+ 'anatomy.organ.name' : 'Anatomical Structure',
48
+ 'organisms.primary.species.name' : 'Species',
49
+ 'attributes.subject.sex.value' : 'Sex',
50
+ 'attributes.subject.ageCategory.value' : 'Age Categories',
51
+ 'item.types.name' : 'Data type',
52
+ }
53
+
54
+ /* Returns filter for searching algolia. All facets of the same category are joined with OR,
55
+ * and each of those results is then joined with an AND.
56
+ * i.e. (color:blue OR color:red) AND (shape:circle OR shape:red) */
57
+ export function getFilters(selectedFacetArray=undefined) {
58
+ // return all datasets if no filter
59
+ if (selectedFacetArray === undefined) {
60
+ return 'NOT item.published.status:embargo'
61
+ }
62
+
63
+ // Switch the 'term' attribute to 'label' if 'label' does not exist
64
+ selectedFacetArray.forEach(f=>f.label=f.facet)
65
+
66
+
67
+ let facets = removeShowAllFacets(selectedFacetArray)
68
+
69
+ let filters = "NOT item.published.status:embargo";
70
+ filters = `(${filters}) AND `;
71
+ const facetPropPaths = facetPropPathMapping.map((f) => f.facetPropPath);
72
+ facetPropPaths.map((facetPropPath) => {
73
+ let facetsToBool = facets.filter(
74
+ (facet) => facet.facetPropPath == facetPropPath
75
+ );
76
+ let orFilters = "";
77
+ let andFilters = "";
78
+ facetsToBool.map((facet) => {
79
+ let facetPropPathToUse = facet.facetSubPropPath ? facet.facetSubPropPath : facetPropPath // Check if we have a subpath
80
+ if (facet.AND){
81
+ andFilters += `AND "${facetPropPathToUse}":"${facet.label}"`;
82
+ } else {
83
+ orFilters += `"${facetPropPathToUse}":"${facet.label}" OR `;
84
+ }
85
+ });
86
+ if (orFilters == "" && andFilters =="") {
87
+ return;
88
+ }
89
+ orFilters = `(${orFilters.substring(0, orFilters.lastIndexOf(" OR "))})` // remove last OR
90
+
91
+ filters += `${orFilters + andFilters} AND `; // Put them together
92
+ // (Note that we add an extra AND in case there are facets at a higher level)
93
+
94
+ filters = filters.split('()AND ').join(''); // Handle case where there where no OR facets
95
+ });
96
+ console.log('filters about to be applied:', filters)
97
+ return filters.substring(0, filters.lastIndexOf(" AND "));
98
+ }
99
+
100
+ function removeShowAllFacets(facetArray){
101
+ return facetArray.filter( f => f.label !== 'Show all')
102
102
  }
@@ -1,43 +1,43 @@
1
- // Primary colors
2
- $purple: #8300BF;
3
- $darkBlue: #24245B;
4
- $grey: #303133;
5
-
6
- // Secondary colors
7
- $lightPurple: #BC00FC;
8
- $blue: #0026FF;
9
-
10
- // Status colors
11
- $success: #5e9f69;
12
- $warning: #FF8400;
13
- $danger: #b51d09;
14
-
15
- // Text colors
16
- $neutralGrey: #616161;
17
- $mediumGrey: #606266;
18
- $lightGrey: #909399;
19
-
20
- // Line colors
21
- $lineColor1: #DCDFE6;
22
- $lineColor2: #E4E7ED;
23
-
24
- // Background colors
25
- $background: #F5F7FA;
26
- $cochlear: #FFFFFF;
27
-
28
- //Search box colors
29
- $darkGrey: #606266;
30
-
31
- $app-primary-color: $purple;
32
- $app-secondary-color: $darkBlue;
33
- $text-color: $grey;
34
- $input-text: $grey;
35
-
36
- $system-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
37
- $font-family: 'Asap', sans-serif;
38
-
39
- // Viewport Sizes
40
- $viewport-sm: 20rem;
41
- $viewport-md: 47rem;
42
- $viewport-lg: 64rem;
43
- $viewport-xlg: 120rem;
1
+ // Primary colors
2
+ $purple: #8300BF;
3
+ $darkBlue: #24245B;
4
+ $grey: #303133;
5
+
6
+ // Secondary colors
7
+ $lightPurple: #BC00FC;
8
+ $blue: #0026FF;
9
+
10
+ // Status colors
11
+ $success: #5e9f69;
12
+ $warning: #FF8400;
13
+ $danger: #b51d09;
14
+
15
+ // Text colors
16
+ $neutralGrey: #616161;
17
+ $mediumGrey: #606266;
18
+ $lightGrey: #909399;
19
+
20
+ // Line colors
21
+ $lineColor1: #DCDFE6;
22
+ $lineColor2: #E4E7ED;
23
+
24
+ // Background colors
25
+ $background: #F5F7FA;
26
+ $cochlear: #FFFFFF;
27
+
28
+ //Search box colors
29
+ $darkGrey: #606266;
30
+
31
+ $app-primary-color: $purple;
32
+ $app-secondary-color: $darkBlue;
33
+ $text-color: $grey;
34
+ $input-text: $grey;
35
+
36
+ $system-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
37
+ $font-family: 'Asap', sans-serif;
38
+
39
+ // Viewport Sizes
40
+ $viewport-sm: 20rem;
41
+ $viewport-md: 47rem;
42
+ $viewport-lg: 64rem;
43
+ $viewport-xlg: 120rem;
@@ -1,6 +1,6 @@
1
- @import url('https://fonts.googleapis.com/css?family=Asap:400,400i,500,600,700&display=swap');
2
-
3
- @import '_variables';
4
-
5
- /* icon font path, required */
6
- $--color-primary: $app-primary-color !default;
1
+ @import url('https://fonts.googleapis.com/css?family=Asap:400,400i,500,600,700&display=swap');
2
+
3
+ @import '_variables';
4
+
5
+ /* icon font path, required */
6
+ $--color-primary: $app-primary-color !default;
@@ -1,124 +1,124 @@
1
- <template>
2
- <div v-if="categories['All'].size > 1" class="container" ref="container">
3
- <div>View data types:</div>
4
- <template v-for="(item, key) in categories">
5
- <el-button
6
- v-if="item.size > 0"
7
- :class="[{ active: key == active }, 'tag-button']"
8
- @click="categoryClicked(key)"
9
- size="small"
10
- :key="key"
11
- >{{ key + ' (' + item.size + ')' }}
12
- </el-button>
13
- </template>
14
- </div>
15
- </template>
16
-
17
- <script>
18
- /* eslint-disable no-alert, no-console */
19
- import { ElButton as Button } from 'element-plus'
20
-
21
- export default {
22
- name: 'BadgesGroup',
23
- components: { Button },
24
- props: {
25
- /**
26
- * Object containing information for
27
- * the required viewing.
28
- */
29
- additionalLinks: {
30
- type: Array,
31
- default: () => {
32
- return []
33
- },
34
- },
35
- datasetBiolucida: {
36
- type: Object,
37
- default: () => {
38
- return {}
39
- },
40
- },
41
- entry: {
42
- type: Object,
43
- default: () => {
44
- return {}
45
- },
46
- },
47
- },
48
- data: function () {
49
- return {
50
- //Always start with 1 image - the dataset thumbnail itself
51
- categories: { All: { size: 1 }, Dataset: { size: 1 } },
52
- active: 'All',
53
- }
54
- },
55
- methods: {
56
- addToCategories: function (array, name) {
57
- if (array && array.length > 0) {
58
- this.categories[name] = { size: array.length }
59
- this.categories['All'].size += array.length
60
- }
61
- },
62
- addSimulationsToCategories: function (array) {
63
- if (array && array.length > 0) {
64
- const size = 1
65
- this.categories['Simulations'] = { size }
66
- this.categories['All'].size += size
67
- }
68
- },
69
- categoryClicked: function (name) {
70
- this.active = name
71
- this.$emit('categoryChanged', name)
72
- },
73
- },
74
- watch: {
75
- datasetBiolucida: {
76
- deep: true,
77
- immediate: true,
78
- handler: function (biolucidaData) {
79
- if ('dataset_images' in biolucidaData) {
80
- this.addToCategories(biolucidaData['dataset_images'], 'Images')
81
- }
82
- },
83
- },
84
- entry: {
85
- deep: true,
86
- immediate: true,
87
- handler: function () {
88
- this.addToCategories(this.entry.scaffolds, 'Scaffolds')
89
- this.addToCategories(this.entry.segmentation, 'Segmentations')
90
- this.addToCategories(this.entry.plots, 'Plots')
91
- this.addSimulationsToCategories(this.entry.simulation)
92
- /** disable the following
93
- this.addToCategories(this.entry.images, 'Images');
94
- this.addToCategories(this.entry.videos, 'Videos');
95
- **/
96
- },
97
- },
98
- },
99
- }
100
- </script>
101
-
102
- <style lang="scss" scoped>
103
- .container {
104
- .tag-button.el-button {
105
- border-radius: 4px!important;
106
- font-size: 0.75rem!important;
107
- padding: 0.2rem 0.2rem!important;
108
- margin: 0.5rem 0 0 0!important;
109
- margin-right: 0.75rem !important;
110
- background: #f9f2fc!important;
111
- border: 1px solid $app-primary-color!important;
112
- color: $app-primary-color!important;
113
- &.active {
114
- background: $app-primary-color!important;
115
- border: 1px solid $app-primary-color!important;
116
- color: #fff!important;
117
- }
118
- }
119
-
120
- .tag-button + .tag-button {
121
- margin-left: 0!important;
122
- }
123
- }
124
- </style>
1
+ <template>
2
+ <div v-if="categories['All'].size > 1" class="container" ref="container">
3
+ <div>View data types:</div>
4
+ <template v-for="(item, key) in categories">
5
+ <el-button
6
+ v-if="item.size > 0"
7
+ :class="[{ active: key == active }, 'tag-button']"
8
+ @click="categoryClicked(key)"
9
+ size="small"
10
+ :key="key"
11
+ >{{ key + ' (' + item.size + ')' }}
12
+ </el-button>
13
+ </template>
14
+ </div>
15
+ </template>
16
+
17
+ <script>
18
+ /* eslint-disable no-alert, no-console */
19
+ import { ElButton as Button } from 'element-plus'
20
+
21
+ export default {
22
+ name: 'BadgesGroup',
23
+ components: { Button },
24
+ props: {
25
+ /**
26
+ * Object containing information for
27
+ * the required viewing.
28
+ */
29
+ additionalLinks: {
30
+ type: Array,
31
+ default: () => {
32
+ return []
33
+ },
34
+ },
35
+ datasetBiolucida: {
36
+ type: Object,
37
+ default: () => {
38
+ return {}
39
+ },
40
+ },
41
+ entry: {
42
+ type: Object,
43
+ default: () => {
44
+ return {}
45
+ },
46
+ },
47
+ },
48
+ data: function () {
49
+ return {
50
+ //Always start with 1 image - the dataset thumbnail itself
51
+ categories: { All: { size: 1 }, Dataset: { size: 1 } },
52
+ active: 'All',
53
+ }
54
+ },
55
+ methods: {
56
+ addToCategories: function (array, name) {
57
+ if (array && array.length > 0) {
58
+ this.categories[name] = { size: array.length }
59
+ this.categories['All'].size += array.length
60
+ }
61
+ },
62
+ addSimulationsToCategories: function (array) {
63
+ if (array && array.length > 0) {
64
+ const size = 1
65
+ this.categories['Simulations'] = { size }
66
+ this.categories['All'].size += size
67
+ }
68
+ },
69
+ categoryClicked: function (name) {
70
+ this.active = name
71
+ this.$emit('categoryChanged', name)
72
+ },
73
+ },
74
+ watch: {
75
+ datasetBiolucida: {
76
+ deep: true,
77
+ immediate: true,
78
+ handler: function (biolucidaData) {
79
+ if ('dataset_images' in biolucidaData) {
80
+ this.addToCategories(biolucidaData['dataset_images'], 'Images')
81
+ }
82
+ },
83
+ },
84
+ entry: {
85
+ deep: true,
86
+ immediate: true,
87
+ handler: function () {
88
+ this.addToCategories(this.entry.scaffolds, 'Scaffolds')
89
+ this.addToCategories(this.entry.segmentation, 'Segmentations')
90
+ this.addToCategories(this.entry.plots, 'Plots')
91
+ this.addSimulationsToCategories(this.entry.simulation)
92
+ /** disable the following
93
+ this.addToCategories(this.entry.images, 'Images');
94
+ this.addToCategories(this.entry.videos, 'Videos');
95
+ **/
96
+ },
97
+ },
98
+ },
99
+ }
100
+ </script>
101
+
102
+ <style lang="scss" scoped>
103
+ .container {
104
+ .tag-button.el-button {
105
+ border-radius: 4px!important;
106
+ font-size: 0.75rem!important;
107
+ padding: 0.2rem 0.2rem!important;
108
+ margin: 0.5rem 0 0 0!important;
109
+ margin-right: 0.75rem !important;
110
+ background: #f9f2fc!important;
111
+ border: 1px solid $app-primary-color!important;
112
+ color: $app-primary-color!important;
113
+ &.active {
114
+ background: $app-primary-color!important;
115
+ border: 1px solid $app-primary-color!important;
116
+ color: #fff!important;
117
+ }
118
+ }
119
+
120
+ .tag-button + .tag-button {
121
+ margin-left: 0!important;
122
+ }
123
+ }
124
+ </style>