@abi-software/map-side-bar 1.2.2 → 1.3.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.
- package/LICENSE +201 -201
- package/README.md +53 -53
- package/babel.config.js +14 -14
- package/dist/map-side-bar.common.js +1126 -405
- package/dist/map-side-bar.common.js.map +1 -1
- package/dist/map-side-bar.css +1 -1
- package/dist/map-side-bar.umd.js +1126 -405
- package/dist/map-side-bar.umd.js.map +1 -1
- package/dist/map-side-bar.umd.min.js +1 -1
- package/dist/map-side-bar.umd.min.js.map +1 -1
- package/package-lock.json +13698 -13548
- package/package.json +65 -64
- package/public/index.html +17 -17
- package/src/App.vue +133 -130
- package/src/algolia/algolia.js +127 -119
- package/src/algolia/utils.js +51 -51
- package/src/components/BadgesGroup.vue +141 -0
- package/src/components/Cascader.vue +49 -49
- package/src/components/ContextCard.vue +240 -240
- package/src/components/DatasetCard.vue +324 -404
- package/src/components/EventBus.js +3 -3
- package/src/components/ImageGallery.vue +502 -0
- package/src/components/SearchFilters.vue +557 -557
- package/src/components/SideBar.vue +239 -239
- package/src/components/SidebarContent.vue +476 -457
- package/src/components/Tabs.vue +78 -78
- package/src/components/hardcoded-context-info.js +79 -79
- package/src/components/index.js +8 -8
- package/src/components/species-map.js +8 -8
- package/src/main.js +8 -8
- package/static.json +6 -6
- package/vue.config.js +11 -11
- package/scaffold_context_info.json +0 -30
- package/src/components/processFilters.js +0 -22
- package/src/components/scaffold-meta-map.js +0 -29
package/src/algolia/algolia.js
CHANGED
|
@@ -1,119 +1,127 @@
|
|
|
1
|
-
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import algoliasearch from 'algoliasearch'
|
|
3
|
-
|
|
4
|
-
// export `createAlgoliaClient` to use it in page components
|
|
5
|
-
export class AlgoliaClient {
|
|
6
|
-
constructor(algoliaId, algoliaKey, PENNSIEVE_API_LOCATION='https://api.pennsieve.io') {
|
|
7
|
-
this.client = algoliasearch(
|
|
8
|
-
algoliaId,
|
|
9
|
-
algoliaKey
|
|
10
|
-
)
|
|
11
|
-
this.PENNSIEVE_API_LOCATION = PENNSIEVE_API_LOCATION
|
|
12
|
-
}
|
|
13
|
-
initIndex(ALGOLIA_INDEX) {
|
|
14
|
-
this.index = this.client.initIndex(ALGOLIA_INDEX);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getAlgoliaFacets (propPathMapping) {
|
|
18
|
-
const map = new Map(Object.entries(propPathMapping));
|
|
19
|
-
const facetPropPaths = Array.from(map.keys() );
|
|
20
|
-
let facetData = []
|
|
21
|
-
let facetId = 0
|
|
22
|
-
return this.index
|
|
23
|
-
.search('', {
|
|
24
|
-
sortFacetValuesBy: 'alpha',
|
|
25
|
-
facets: facetPropPaths
|
|
26
|
-
})
|
|
27
|
-
.then(response => {
|
|
28
|
-
facetPropPaths.map((facetPropPath) => {
|
|
29
|
-
var children = []
|
|
30
|
-
const responseFacets = response.facets
|
|
31
|
-
if (responseFacets === undefined) {return}
|
|
32
|
-
const responseFacetChildren =
|
|
33
|
-
responseFacets[facetPropPath] == undefined
|
|
34
|
-
? {}
|
|
35
|
-
: responseFacets[facetPropPath]
|
|
36
|
-
Object.keys(responseFacetChildren).map(facet => {
|
|
37
|
-
children.push({
|
|
38
|
-
label: facet,
|
|
39
|
-
id: facetId++,
|
|
40
|
-
facetPropPath: facetPropPath
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
if (children.length > 0) {
|
|
44
|
-
facetData.push({
|
|
45
|
-
label: map.get(facetPropPath),
|
|
46
|
-
id: facetId++,
|
|
47
|
-
children: children,
|
|
48
|
-
key: facetPropPath
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
return facetData
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Returns all DOIs of all versions for a given discover dataset
|
|
57
|
-
_discoverAllDois (discoverId, PENNSIEVE_API_LOCATION='https://api.pennsieve.io') {
|
|
58
|
-
return new Promise(resolve => {
|
|
59
|
-
fetch(`${PENNSIEVE_API_LOCATION}/discover/datasets/${discoverId}/versions`).then(r=>r.json()).then(dataset => {
|
|
60
|
-
resolve(dataset.map(version => version.doi))
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Get all dois given a list of discoverIds
|
|
66
|
-
_expandDois (discoverIds, PENNSIEVE_API_LOCATION='https://api.pennsieve.io') {
|
|
67
|
-
return new Promise(resolve => {
|
|
68
|
-
let promiseList = discoverIds.map(discoverId => this._discoverAllDois(discoverId, PENNSIEVE_API_LOCATION))
|
|
69
|
-
Promise.all(promiseList).then((values) => {
|
|
70
|
-
resolve(values.flat())
|
|
71
|
-
});
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
_processResultsForCards(results) {
|
|
76
|
-
let newResults = []
|
|
77
|
-
let newResult = {}
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
newResult = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
/* eslint-disable no-alert, no-console */
|
|
2
|
+
import algoliasearch from 'algoliasearch'
|
|
3
|
+
|
|
4
|
+
// export `createAlgoliaClient` to use it in page components
|
|
5
|
+
export class AlgoliaClient {
|
|
6
|
+
constructor(algoliaId, algoliaKey, PENNSIEVE_API_LOCATION='https://api.pennsieve.io') {
|
|
7
|
+
this.client = algoliasearch(
|
|
8
|
+
algoliaId,
|
|
9
|
+
algoliaKey
|
|
10
|
+
)
|
|
11
|
+
this.PENNSIEVE_API_LOCATION = PENNSIEVE_API_LOCATION
|
|
12
|
+
}
|
|
13
|
+
initIndex(ALGOLIA_INDEX) {
|
|
14
|
+
this.index = this.client.initIndex(ALGOLIA_INDEX);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getAlgoliaFacets (propPathMapping) {
|
|
18
|
+
const map = new Map(Object.entries(propPathMapping));
|
|
19
|
+
const facetPropPaths = Array.from(map.keys() );
|
|
20
|
+
let facetData = []
|
|
21
|
+
let facetId = 0
|
|
22
|
+
return this.index
|
|
23
|
+
.search('', {
|
|
24
|
+
sortFacetValuesBy: 'alpha',
|
|
25
|
+
facets: facetPropPaths
|
|
26
|
+
})
|
|
27
|
+
.then(response => {
|
|
28
|
+
facetPropPaths.map((facetPropPath) => {
|
|
29
|
+
var children = []
|
|
30
|
+
const responseFacets = response.facets
|
|
31
|
+
if (responseFacets === undefined) {return}
|
|
32
|
+
const responseFacetChildren =
|
|
33
|
+
responseFacets[facetPropPath] == undefined
|
|
34
|
+
? {}
|
|
35
|
+
: responseFacets[facetPropPath]
|
|
36
|
+
Object.keys(responseFacetChildren).map(facet => {
|
|
37
|
+
children.push({
|
|
38
|
+
label: facet,
|
|
39
|
+
id: facetId++,
|
|
40
|
+
facetPropPath: facetPropPath
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
if (children.length > 0) {
|
|
44
|
+
facetData.push({
|
|
45
|
+
label: map.get(facetPropPath),
|
|
46
|
+
id: facetId++,
|
|
47
|
+
children: children,
|
|
48
|
+
key: facetPropPath
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
return facetData
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Returns all DOIs of all versions for a given discover dataset
|
|
57
|
+
_discoverAllDois (discoverId, PENNSIEVE_API_LOCATION='https://api.pennsieve.io') {
|
|
58
|
+
return new Promise(resolve => {
|
|
59
|
+
fetch(`${PENNSIEVE_API_LOCATION}/discover/datasets/${discoverId}/versions`).then(r=>r.json()).then(dataset => {
|
|
60
|
+
resolve(dataset.map(version => version.doi))
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Get all dois given a list of discoverIds
|
|
66
|
+
_expandDois (discoverIds, PENNSIEVE_API_LOCATION='https://api.pennsieve.io') {
|
|
67
|
+
return new Promise(resolve => {
|
|
68
|
+
let promiseList = discoverIds.map(discoverId => this._discoverAllDois(discoverId, PENNSIEVE_API_LOCATION))
|
|
69
|
+
Promise.all(promiseList).then((values) => {
|
|
70
|
+
resolve(values.flat())
|
|
71
|
+
});
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_processResultsForCards(results) {
|
|
76
|
+
let newResults = []
|
|
77
|
+
let newResult = {}
|
|
78
|
+
for (let res of results) {
|
|
79
|
+
newResult = {...res}
|
|
80
|
+
newResult = {
|
|
81
|
+
doi: res.item.curie.split(':')[1],
|
|
82
|
+
name: res.item.name,
|
|
83
|
+
description: res.item.description,
|
|
84
|
+
updated: res.pennsieve.updatedAt,
|
|
85
|
+
publishDate: res.pennsieve.publishDate,
|
|
86
|
+
datasetId: res.objectID,
|
|
87
|
+
detailsReady: false
|
|
88
|
+
}
|
|
89
|
+
newResults.push(newResult)
|
|
90
|
+
}
|
|
91
|
+
return newResults
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get Search results
|
|
96
|
+
* This is using fetch from the Algolia API
|
|
97
|
+
*/
|
|
98
|
+
search (filter, query='', hitsperPage=10, page=1) {
|
|
99
|
+
return new Promise(resolve => {
|
|
100
|
+
this.index
|
|
101
|
+
.search(query, {
|
|
102
|
+
facets:['*'],
|
|
103
|
+
hitsPerPage: hitsperPage,
|
|
104
|
+
page: page-1,
|
|
105
|
+
filters: filter,
|
|
106
|
+
attributesToHighlight: [],
|
|
107
|
+
attributesToRetrieve: [
|
|
108
|
+
'pennsieve.publishDate',
|
|
109
|
+
'pennsieve.updatedAt',
|
|
110
|
+
'item.curie',
|
|
111
|
+
'item.name',
|
|
112
|
+
'item.description',
|
|
113
|
+
'objectID',
|
|
114
|
+
],
|
|
115
|
+
})
|
|
116
|
+
.then(response => {
|
|
117
|
+
let searchData = {
|
|
118
|
+
items: this._processResultsForCards(response.hits),
|
|
119
|
+
total: response.nbHits,
|
|
120
|
+
discoverIds: response.hits.map(r=>r.pennsieve.identifier),
|
|
121
|
+
dois: response.hits.map(r=>r.item.curie.split(':')[1])
|
|
122
|
+
}
|
|
123
|
+
resolve(searchData)
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
}
|
package/src/algolia/utils.js
CHANGED
|
@@ -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
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="categories['All'].size > 1" class="container" ref="container">
|
|
3
|
+
<div>
|
|
4
|
+
View data types:
|
|
5
|
+
</div>
|
|
6
|
+
<template v-for="(item, key) in categories" >
|
|
7
|
+
<el-button
|
|
8
|
+
v-if="item.size > 0"
|
|
9
|
+
:class="[{ 'active': key == active},'tag-button']"
|
|
10
|
+
@click="categoryClicked(key)"
|
|
11
|
+
size="small" :key="key">{{ key + " (" + item.size + ")" }}
|
|
12
|
+
</el-button>
|
|
13
|
+
</template>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
/* eslint-disable no-alert, no-console */
|
|
20
|
+
import Vue from "vue";
|
|
21
|
+
import { Button } from "element-ui";
|
|
22
|
+
import lang from "element-ui/lib/locale/lang/en";
|
|
23
|
+
import locale from "element-ui/lib/locale";
|
|
24
|
+
|
|
25
|
+
locale.use(lang);
|
|
26
|
+
Vue.use(Button);
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: "BadgesGroup",
|
|
30
|
+
props: {
|
|
31
|
+
/**
|
|
32
|
+
* Object containing information for
|
|
33
|
+
* the required viewing.
|
|
34
|
+
*/
|
|
35
|
+
additionalLinks: {
|
|
36
|
+
type: Array,
|
|
37
|
+
default: () => {
|
|
38
|
+
return [];
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
datasetBiolucida: {
|
|
42
|
+
type: Object,
|
|
43
|
+
default: () => {
|
|
44
|
+
return {};
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
entry: {
|
|
48
|
+
type: Object,
|
|
49
|
+
default: () => {
|
|
50
|
+
return {};
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
data: function () {
|
|
55
|
+
return {
|
|
56
|
+
categories: { "All": {size: 1} },
|
|
57
|
+
active: "All"
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
addToCategories: function (array, name) {
|
|
62
|
+
if (array && array.length > 0) {
|
|
63
|
+
this.categories[name] = { size: array.length };
|
|
64
|
+
this.categories["All"].size += array.length;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
addSimulationsToCategories: function (array) {
|
|
68
|
+
if (array && array.length > 0) {
|
|
69
|
+
const size = 1;
|
|
70
|
+
this.categories["Simulations"] = { size };
|
|
71
|
+
this.categories["All"].size += size;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
categoryClicked: function(name) {
|
|
75
|
+
this.active = name;
|
|
76
|
+
this.$emit("categoryChanged", name);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
watch: {
|
|
80
|
+
datasetBiolucida: {
|
|
81
|
+
deep: true,
|
|
82
|
+
immediate: true,
|
|
83
|
+
handler: function (biolucidaData) {
|
|
84
|
+
if ("dataset_images" in biolucidaData) {
|
|
85
|
+
this.addToCategories(biolucidaData["dataset_images"], "Biolucida Images");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
entry: {
|
|
90
|
+
deep: true,
|
|
91
|
+
immediate: true,
|
|
92
|
+
handler: function () {
|
|
93
|
+
this.addToCategories(this.entry.scaffolds, 'Scaffolds');
|
|
94
|
+
this.addToCategories(this.entry.segmentation, 'Segmentations');
|
|
95
|
+
this.addToCategories(this.entry.plots, 'Plots');
|
|
96
|
+
this.addSimulationsToCategories(this.entry.simulation);
|
|
97
|
+
/** disable the following
|
|
98
|
+
this.addToCategories(this.entry.images, 'Images');
|
|
99
|
+
this.addToCategories(this.entry.videos, 'Videos');
|
|
100
|
+
**/
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
108
|
+
<style scoped>
|
|
109
|
+
.tag-button,
|
|
110
|
+
.tag-button:hover,
|
|
111
|
+
.tag-button:focus,
|
|
112
|
+
.tag-button.active
|
|
113
|
+
{
|
|
114
|
+
border-radius: 4px;
|
|
115
|
+
font-size: 0.75rem;
|
|
116
|
+
padding: 0.2rem 0.2rem;
|
|
117
|
+
margin: 0.5rem 0 0 0;
|
|
118
|
+
margin-right: 0.75rem!important;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.tag-button,
|
|
122
|
+
.tag-button:hover,
|
|
123
|
+
.tag-button:focus
|
|
124
|
+
{
|
|
125
|
+
background: #f9f2fc;
|
|
126
|
+
border: 1px solid #8300BF;
|
|
127
|
+
color: #8300BF;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.tag-button.active
|
|
131
|
+
{
|
|
132
|
+
background: #8300BF;
|
|
133
|
+
border: 1px solid #8300BF;
|
|
134
|
+
color: #fff;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.tag-button+.tag-button
|
|
138
|
+
{
|
|
139
|
+
margin-left:0;
|
|
140
|
+
}
|
|
141
|
+
</style>
|
|
@@ -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>
|