enrecipes/app/components/settings/Reset.vue

116 lines
2.6 KiB
Vue
Raw Normal View History

2021-03-21 22:32:04 +05:30
<template>
2021-06-15 16:34:42 +05:30
<Page @loaded="pgLoad" actionBarHidden="true">
<RGridLayout :rtl="RTL" rows="*, auto" columns="auto, *">
2021-06-19 00:07:01 +05:30
<OptionsList title="rest" :items="items" :action="reset" />
2021-04-12 23:39:48 +05:30
<GridLayout
2021-05-25 20:02:53 +05:30
:hidden="toast"
2021-04-12 23:39:48 +05:30
row="1"
2021-06-15 16:34:42 +05:30
class="appbar rtl"
@loaded="abLoad"
2021-04-12 23:39:48 +05:30
columns="auto, *"
>
2021-06-28 17:08:21 +05:30
<Button class="ico" :text="icon.back" @tap="$navigateBack()" />
2021-04-01 16:25:35 +05:30
</GridLayout>
2021-06-15 16:34:42 +05:30
<Toast :onload="tbLoad" :toast="toast" :action="hideToast" />
2021-06-18 18:22:03 +05:30
<Label rowSpan="2" class="edge hal rtl" @swipe="swipeBack" />
<Label
rowSpan="2"
colSpan="2"
class="edge har rtl f"
@swipe="swipeBack"
/>
2021-06-15 16:34:42 +05:30
</RGridLayout>
2021-03-21 22:32:04 +05:30
</Page>
</template>
<script>
2021-06-15 16:34:42 +05:30
import { Observable } from "@nativescript/core";
2021-03-21 22:32:04 +05:30
import { localize } from "@nativescript/localize";
import { mapState, mapActions } from "vuex";
2021-04-12 23:39:48 +05:30
import * as utils from "~/shared/utils";
2021-05-25 20:02:53 +05:30
import OptionsList from "../sub/OptionsList";
import Toast from "../sub/Toast";
2021-06-15 16:34:42 +05:30
let barTimer;
2021-03-21 22:32:04 +05:30
export default {
2021-05-25 20:02:53 +05:30
components: { OptionsList, Toast },
2021-04-12 23:39:48 +05:30
data() {
return {
2021-06-15 16:34:42 +05:30
toast: 0,
appbar: 0,
toastbar: 0,
2021-04-12 23:39:48 +05:30
};
},
2021-03-21 22:32:04 +05:30
computed: {
2021-06-15 16:34:42 +05:30
...mapState(["icon", "RTL"]),
2021-03-21 22:32:04 +05:30
items() {
return [
2021-04-01 16:25:35 +05:30
{},
2021-03-21 22:32:04 +05:30
{
2021-05-25 20:02:53 +05:30
type: "list",
icon: "reset",
2021-06-15 16:34:42 +05:30
rtl: 1,
2021-03-21 22:32:04 +05:30
title: "restCuiL",
2021-05-25 20:02:53 +05:30
data: "cuisines",
2021-03-21 22:32:04 +05:30
},
{
2021-05-25 20:02:53 +05:30
type: "list",
icon: "reset",
2021-06-15 16:34:42 +05:30
rtl: 1,
2021-03-21 22:32:04 +05:30
title: "restCatL",
2021-05-25 20:02:53 +05:30
data: "categories",
2021-03-21 22:32:04 +05:30
},
{
2021-05-25 20:02:53 +05:30
type: "list",
icon: "reset",
2021-06-15 16:34:42 +05:30
rtl: 1,
2021-03-21 22:32:04 +05:30
title: "restYUL",
2021-05-25 20:02:53 +05:30
data: "yieldUnits",
2021-03-21 22:32:04 +05:30
},
{
2021-05-25 20:02:53 +05:30
type: "list",
icon: "reset",
2021-06-15 16:34:42 +05:30
rtl: 1,
2021-03-21 22:32:04 +05:30
title: "restUL",
2021-05-25 20:02:53 +05:30
data: "units",
2021-03-21 22:32:04 +05:30
},
2021-06-15 16:34:42 +05:30
{
type: "info",
title: "restInfo",
},
2021-04-01 16:25:35 +05:30
{},
2021-03-21 22:32:04 +05:30
];
},
},
methods: {
2021-06-19 00:07:01 +05:30
...mapActions(["resetLIs"]),
2021-06-15 16:34:42 +05:30
pgLoad({ object }) {
2021-05-25 20:02:53 +05:30
object.bindingContext = new Observable();
2021-03-21 22:32:04 +05:30
},
2021-06-15 16:34:42 +05:30
abLoad({ object }) {
2021-05-22 14:26:31 +05:30
this.appbar = object;
},
2021-06-15 16:34:42 +05:30
tbLoad({ object }) {
this.toastbar = object;
},
2021-06-19 00:07:01 +05:30
reset(list) {
this.resetLIs(list);
2021-05-22 14:26:31 +05:30
this.showToast();
},
showToast() {
2021-06-15 16:34:42 +05:30
this.animateBar(this.appbar, 0).then(() => {
this.toast = localize("restDone");
2021-06-18 18:22:03 +05:30
this.animateBar(this.toastbar, 1, 1);
2021-04-12 23:39:48 +05:30
});
2021-06-15 16:34:42 +05:30
utils.timer(5, (val) => !val && this.hideToast());
2021-03-21 22:32:04 +05:30
},
2021-06-15 16:34:42 +05:30
hideToast() {
this.animateBar(this.toastbar, 0).then(() => {
this.toast = null;
this.animateBar(this.appbar, 1);
});
2021-05-22 14:26:31 +05:30
},
2021-03-21 22:32:04 +05:30
},
};
</script>