Skip to content

Commit

Permalink
ConceptSchemeSelection: Allow bookmarking of schemes (#155)
Browse files Browse the repository at this point in the history
By default, the list in the config file is used.
  • Loading branch information
stefandesu committed Jan 8, 2019
1 parent 413e19a commit ab0a3f0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/components/ConceptSchemeSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
:key="scheme.uri + '-scheme-list-' + id + index" >
<font-awesome-icon
:class="$jskos.isContainedIn(scheme, favoriteSchemes) ? 'conceptSchemeSelection-starFavorite' : 'conceptSchemeSelection-starNormal'"
icon="star" />
class="conceptSchemeSelection-star"
icon="star"
@click="toggleFavoriteScheme(scheme)" />
<item-name
:ref="index == 0 ? 'firstScheme' : null"
:item="scheme"
Expand Down Expand Up @@ -164,7 +166,7 @@ export default {
},
favoriteSchemes() {
let schemes = []
for (let uri of this.config.favoriteTerminologyProviders) {
for (let uri of this.$settings.favoriteSchemes || this.config.favoriteTerminologyProviders) {
let scheme = this.$store.getters["objects/get"]({ uri })
if (scheme && !this.$jskos.isContainedIn(scheme, schemes)) {
schemes.push(scheme)
Expand Down Expand Up @@ -238,7 +240,25 @@ export default {
if (this.$refs.conceptSearch) {
this.$refs.conceptSearch.setSearchQuery(query)
}
}
},
toggleFavoriteScheme(scheme) {
if (this.$jskos.isContainedIn(scheme, this.favoriteSchemes)) {
// Remove from favorites
let uris = this.$jskos.getAllUris(scheme)
this.$store.commit({
type: "settings/set",
prop: "favoriteSchemes",
value: this.favoriteSchemes.map(scheme => scheme.uri).filter(uri => !uris.includes(uri))
})
} else {
// Add to favorites
this.$store.commit({
type: "settings/set",
prop: "favoriteSchemes",
value: this.favoriteSchemes.map(scheme => scheme.uri).concat([scheme.uri])
})
}
},
}
}
</script>
Expand Down Expand Up @@ -297,12 +317,21 @@ export default {
flex: 0 1 auto;
}
.conceptSchemeSelection-star {
cursor: pointer;
}
.conceptSchemeSelection-starFavorite {
color: @color-primary-4;
}
.conceptSchemeSelection-starFavorite:hover {
color: @color-primary-1;
}
.conceptSchemeSelection-starNormal {
color: @color-button-faded;
}
.conceptSchemeSelection-starNormal:hover {
color: @color-button-hover;
}
</style>

Expand Down
1 change: 1 addition & 0 deletions src/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const defaultSettings = {
locale: "",
autoInsertLabels: true,
mappingEditorClearOnSave: true,
favoriteSchemes: null,
}

// initial state
Expand Down

0 comments on commit ab0a3f0

Please sign in to comment.