enrecipes/app/components/Settings/Reset.vue

113 lines
2.7 KiB
Vue
Raw Permalink Normal View History

2021-03-21 17:02:04 +00:00
<template>
2021-04-01 10:55:35 +00:00
<Page @loaded="onPageLoad" actionBarHidden="true">
<GridLayout rows="*, auto" columns="auto, *">
<ListView
colSpan="2"
rowSpan="2"
class="options-list"
for="item in items"
>
<v-template if="$index == 0">
<Label class="pageTitle" :text="'rest' | L" />
</v-template>
<v-template if="$index == 5">
<Label class="group-info sub tw" :text="'restInfo' | L" />
</v-template>
<v-template if="$index == 6">
<StackLayout class="listSpace"> </StackLayout>
</v-template>
2021-03-21 17:02:04 +00:00
<v-template>
<GridLayout
columns="auto, *"
2021-04-01 10:55:35 +00:00
class="option"
@touch="touch($event, item.type)"
2021-03-21 17:02:04 +00:00
>
2021-04-01 10:55:35 +00:00
<Label class="ico" :text="icon.reset" />
<Label col="1" :text="item.title | L" class="info" />
2021-03-21 17:02:04 +00:00
</GridLayout>
</v-template>
</ListView>
2021-04-12 18:09:48 +00:00
<GridLayout
v-show="!toast"
row="1"
class="appbar"
rows="*"
columns="auto, *"
>
2021-04-01 10:55:35 +00:00
<Button class="ico" :text="icon.back" @tap="$navigateBack()" />
</GridLayout>
2021-04-12 18:09:48 +00:00
<GridLayout
v-show="toast"
row="1"
colSpan="2"
class="appbar snackBar"
columns="*"
@tap="toast = null"
>
<FlexboxLayout minHeight="48" alignItems="center">
<Label class="title msg" :text="toast" />
</FlexboxLayout>
</GridLayout>
2021-03-21 17:02:04 +00:00
</GridLayout>
</Page>
</template>
<script>
import { Observable } from "@nativescript/core";
import { localize } from "@nativescript/localize";
import { mapState, mapActions } from "vuex";
2021-04-12 18:09:48 +00:00
import * as utils from "~/shared/utils";
2021-03-21 17:02:04 +00:00
export default {
2021-04-12 18:09:48 +00:00
data() {
return {
toast: null,
};
},
2021-03-21 17:02:04 +00:00
computed: {
...mapState(["icon"]),
items() {
return [
2021-04-01 10:55:35 +00:00
{},
2021-03-21 17:02:04 +00:00
{
type: "cuisines",
title: "restCuiL",
},
{
type: "categories",
title: "restCatL",
},
{
type: "yieldUnits",
title: "restYUL",
},
{
type: "units",
title: "restUL",
},
2021-04-01 10:55:35 +00:00
{},
{},
2021-03-21 17:02:04 +00:00
];
},
},
methods: {
...mapActions(["resetListItemsAction"]),
onPageLoad(args) {
const page = args.object;
page.bindingContext = new Observable();
},
// RESET
resetListItems(listName) {
this.resetListItemsAction(listName);
2021-04-12 18:09:48 +00:00
this.toast = localize("restDone");
utils.timer(5, (val) => {
if (!val) this.toast = val;
});
2021-03-21 17:02:04 +00:00
},
2021-04-01 10:55:35 +00:00
touch({ object, action }, type) {
object.className = action.match(/down|move/) ? "option fade" : "option";
if (action == "up") this.resetListItems(type);
},
2021-03-21 17:02:04 +00:00
},
};
</script>