Skip to content

Commit

Permalink
feat: create functionality to save current tags to tag collection
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Mar 1, 2021
1 parent 517648d commit baf0cc0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions components/pages/posts/navigation/search/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
<transition name="page">
<SearchTagCollections
v-if="tagCollections.isActive"
:search-tags="search.tags"
@toggleTagCollections="toggleTagCollections"
@mergeToSearchTags="mergeSearchTags"
/>
Expand Down
51 changes: 47 additions & 4 deletions components/pages/posts/navigation/search/SearchTagCollections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@
</section>

<!-- CTA -->
<footer class="text-center">
<NuxtLink class="text-sm" to="/premium">Create more</NuxtLink>
<footer class="space-y-1 text-sm text-center">
<NuxtLink to="/premium">Create more</NuxtLink>

<p class="text-xs text-default-text-muted">Or</p>

<button
class="text-sm color-util"
type="button"
@click="saveSearchTagsToTagCollection"
>
Create from current tags
</button>
</footer>
</menu>
</div>
Expand All @@ -75,12 +85,26 @@ export default {
Error,
},
props: {
searchTags: {
type: Array,
default() {
return []
},
},
},
computed: {
...mapGetters('user', ['getTagCollections']),
},
methods: {
...mapActions('booru', ['tagsManager']),
...mapActions('user', ['customTagCollectionsManager']),
toggleTagCollections() {
this.$emit('toggleTagCollections')
},
addTagCollectionToTags(tagCollectionIndex) {
this.$emit(
Expand All @@ -91,8 +115,27 @@ export default {
this.toggleTagCollections()
},
toggleTagCollections() {
this.$emit('toggleTagCollections')
saveSearchTagsToTagCollection() {
if (!this.searchTags.length) {
return
}
const tagCollectionName = prompt(
'Choose a name for the new Tag Collection.'
)
if (!tagCollectionName) {
alert('Wrong input, only text please.')
return
}
this.customTagCollectionsManager({
operation: 'add',
value: {
name: tagCollectionName,
tags: this.searchTags,
},
})
},
},
}
Expand Down

0 comments on commit baf0cc0

Please sign in to comment.