2020-11-15 10:51:10 +00:00
|
|
|
<template>
|
2020-12-07 14:45:00 +00:00
|
|
|
<Page>
|
2021-01-13 05:02:48 +00:00
|
|
|
<GridLayout columns="*" rows="auto, auto, auto, *, auto" class="dialogContainer" :class="appTheme">
|
2021-01-23 17:20:15 +00:00
|
|
|
<Label row="0" class="er dialogIcon" backgroundColor="#858585" :color="iconColor" :text="icon[helpIcon]" />
|
2021-01-13 05:02:48 +00:00
|
|
|
<Label row="1" class="dialogTitle orkm" :text="`${title}` | L" textWrap='true' />
|
|
|
|
<StackLayout row="2" v-if="filteredRecipes.length || searchQuery" padding="0 24 24">
|
2020-12-29 10:35:19 +00:00
|
|
|
<TextField :hint="'Search' | L" v-model="searchQuery" />
|
2020-11-15 10:51:10 +00:00
|
|
|
</StackLayout>
|
2021-01-13 05:02:48 +00:00
|
|
|
<ScrollView row="3" width="100%" :height="height ? height : ''">
|
2020-12-07 14:45:00 +00:00
|
|
|
<StackLayout>
|
2021-01-23 17:20:15 +00:00
|
|
|
<MDButton v-for="(recipe, index) in filteredRecipes" :key="index" class="actionItem" variant="text" :rippleColor="rippleColor" :text="recipe.title" @loaded="centerLabel" @tap="tapAction(recipe)" />
|
|
|
|
<Label padding="24" lineHeight="6" v-if="!filteredRecipes.length && !searchQuery" :text="'recListEmp' | L" textAlignment="center" textWrap="true" />
|
|
|
|
<Label padding="24" lineHeight="6" v-if="!filteredRecipes.length && searchQuery" :text="'noRecs' | L" textAlignment="center" textWrap="true" />
|
2020-12-07 14:45:00 +00:00
|
|
|
</StackLayout>
|
|
|
|
</ScrollView>
|
2021-01-13 05:02:48 +00:00
|
|
|
<GridLayout row="4" rows="auto" columns="auto, *, auto" class="actionsContainer">
|
2020-12-07 14:45:00 +00:00
|
|
|
<MDButton :rippleColor="rippleColor" variant="text" v-if="action" col="0" class="action orkm pull-left" :text="`${action}` | L" @tap="$modal.close(action)" />
|
|
|
|
<MDButton :rippleColor="rippleColor" variant="text" col="2" class="action orkm pull-right" :text="'CANCEL' | L" @tap="$modal.close(false)" />
|
|
|
|
</GridLayout>
|
2020-12-29 10:35:19 +00:00
|
|
|
</GridLayout>
|
2020-12-07 14:45:00 +00:00
|
|
|
</Page>
|
2020-11-15 10:51:10 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-12-07 14:45:00 +00:00
|
|
|
import {
|
2021-01-13 05:02:48 +00:00
|
|
|
Application
|
2020-12-07 14:45:00 +00:00
|
|
|
}
|
|
|
|
from "@nativescript/core"
|
2021-01-13 05:02:48 +00:00
|
|
|
import {
|
|
|
|
mapState
|
|
|
|
}
|
|
|
|
from "vuex"
|
2020-11-15 10:51:10 +00:00
|
|
|
export default {
|
2021-01-13 05:02:48 +00:00
|
|
|
props: [ "title", "recipes", "height", "action", "helpIcon" ],
|
2020-11-15 10:51:10 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-12-29 10:35:19 +00:00
|
|
|
searchQuery: "",
|
2020-11-15 10:51:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-01-13 05:02:48 +00:00
|
|
|
...mapState( [ 'icon' ] ),
|
2020-11-15 10:51:10 +00:00
|
|
|
appTheme() {
|
|
|
|
return Application.systemAppearance()
|
|
|
|
},
|
2021-01-13 05:02:48 +00:00
|
|
|
isLightMode() {
|
|
|
|
return this.appTheme == "light"
|
|
|
|
},
|
2020-11-15 10:51:10 +00:00
|
|
|
rippleColor() {
|
2021-01-23 17:20:15 +00:00
|
|
|
return "rgba(133,133,133,0.2)"
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
2021-01-13 05:02:48 +00:00
|
|
|
iconColor() {
|
2021-01-23 17:20:15 +00:00
|
|
|
return this.isLightMode ? "#f0f0f0" : "#1A1A1A"
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
|
|
|
filteredRecipes() {
|
2020-12-07 14:45:00 +00:00
|
|
|
return this.recipes.map( ( e, i ) => {
|
|
|
|
return {
|
|
|
|
id: e.id,
|
|
|
|
title: e.title,
|
2020-12-29 10:35:19 +00:00
|
|
|
cuisine: e.cuisine,
|
|
|
|
category: e.category,
|
|
|
|
tags: e.tags.map( e => e.toLowerCase() ).join(),
|
|
|
|
ingredients: e.ingredients.map( e => e.item.toLowerCase() ).join(),
|
2020-12-07 14:45:00 +00:00
|
|
|
}
|
2020-12-29 10:35:19 +00:00
|
|
|
} ).filter( ( e ) => this.recipeFilter( e ) )
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
2020-12-29 10:35:19 +00:00
|
|
|
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2020-12-07 14:45:00 +00:00
|
|
|
tapAction( recipe ) {
|
|
|
|
this.$modal.close( recipe.id )
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
2021-01-23 17:20:15 +00:00
|
|
|
centerLabel( args ) {
|
2020-12-07 14:45:00 +00:00
|
|
|
args.object.android.setGravity( 16 )
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
2020-12-29 10:35:19 +00:00
|
|
|
recipeFilter( e ) {
|
|
|
|
let searchQuery = this.searchQuery.toLowerCase()
|
|
|
|
return e.title.includes( searchQuery ) || e.cuisine.includes( searchQuery ) || e.category.includes( searchQuery ) || e.tags.includes( searchQuery ) || e.ingredients.includes( searchQuery )
|
|
|
|
},
|
2020-11-15 10:51:10 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|