🎨 find by name

Search on word/name, if partially found in resource it will return the resource
This commit is contained in:
Kevin Van Der Werff
2019-10-21 17:11:11 +02:00
parent a0698f09bb
commit b7523dbbbb
3 changed files with 56 additions and 9 deletions

View File

@@ -3,6 +3,8 @@
</template>
<script>
import * as R from 'ramda'
export default {
data() {
return {
@@ -11,7 +13,19 @@ export default {
},
watch: {
searchInput(e) {
console.log(this.$store.getters['data/findByTags']([e]))
const isTag = R.startsWith('#')
const removeFirstChar = x => R.splitAt(1, x)[1]
const words = R.split(' ', e)
const tags = R.filter(isTag, words)
const titles = R.filter(R.compose(R.not, isTag), words)
console.group()
console.log("words:", words)
console.log("tags:", tags)
console.log("titles:", titles)
console.log(this.$store.getters['data/findByName'](titles))
console.log(this.$store.getters['data/findByTags'](R.map(removeFirstChar, tags)))
console.groupEnd()
},
},
methods: {