2020-10-21 17:54:45 +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, ${stretch? '*':'auto'}, auto`" class="dialogContainer" :class="appTheme">
|
|
|
|
<Label row="0" class="bx dialogIcon" backgroundColor="#adb5bd" :color="iconColor" :text="icon[helpIcon]" />
|
|
|
|
<Label row="1" class="dialogTitle orkm" :text="`${title}` | L" />
|
|
|
|
<ScrollView row="2" width="100%">
|
2020-12-07 14:45:00 +00:00
|
|
|
<StackLayout>
|
2021-01-13 05:02:48 +00:00
|
|
|
<MDButton v-for="(item, index) in newList" :key="index" class="actionItem" :color="title==='srt' && sortType=== item ? '#ff5200':''" variant="text" :rippleColor="rippleColor" :text="`${localized(item)}${title==='srt' && sortType=== item ? '*':''}`" @loaded="onLabelLoaded" @tap="tapAction(item)"
|
2020-12-29 10:35:19 +00:00
|
|
|
@longPress="removeItem(index)" />
|
2020-12-07 14:45:00 +00:00
|
|
|
</StackLayout>
|
|
|
|
</ScrollView>
|
2021-01-13 05:02:48 +00:00
|
|
|
<GridLayout row="3" 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)" />
|
2021-01-13 05:02:48 +00:00
|
|
|
<MDButton :rippleColor="rippleColor" variant="text" col="2" class="action orkm pull-right" :text="'cBtn' | L" @tap="$modal.close(false)" />
|
2020-12-07 14:45:00 +00:00
|
|
|
</GridLayout>
|
2020-12-29 10:35:19 +00:00
|
|
|
</GridLayout>
|
2020-12-07 14:45:00 +00:00
|
|
|
</Page>
|
2020-10-21 17:54:45 +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"
|
2020-12-29 10:35:19 +00:00
|
|
|
import * as Toast from "nativescript-toast"
|
|
|
|
import {
|
|
|
|
localize
|
|
|
|
}
|
|
|
|
from "@nativescript/localize"
|
|
|
|
import {
|
|
|
|
mapState,
|
|
|
|
mapActions
|
|
|
|
}
|
|
|
|
from "vuex"
|
|
|
|
import ConfirmDialog from "./ConfirmDialog.vue"
|
2020-10-21 17:54:45 +00:00
|
|
|
export default {
|
2021-01-13 05:02:48 +00:00
|
|
|
props: [ "title", "list", "stretch", "action", "helpIcon" ],
|
2020-12-29 10:35:19 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
newList: this.list,
|
|
|
|
}
|
|
|
|
},
|
2020-10-24 18:02:35 +00:00
|
|
|
computed: {
|
2021-01-13 05:02:48 +00:00
|
|
|
...mapState( [ "sortType", 'icon' ] ),
|
2020-11-03 19:57:31 +00:00
|
|
|
appTheme() {
|
2020-10-24 18:02:35 +00:00
|
|
|
return Application.systemAppearance()
|
|
|
|
},
|
2021-01-13 05:02:48 +00:00
|
|
|
isLightMode() {
|
|
|
|
return this.appTheme == "light"
|
|
|
|
},
|
2020-11-10 18:28:48 +00:00
|
|
|
rippleColor() {
|
2021-01-13 05:02:48 +00:00
|
|
|
return this.isLightMode ? "rgba(134,142,150,0.2)" : "rgba(206,212,218,0.1)"
|
2020-11-10 18:28:48 +00:00
|
|
|
},
|
2021-01-13 05:02:48 +00:00
|
|
|
iconColor() {
|
|
|
|
return this.isLightMode ? "#f1f3f5" : "#212529"
|
2020-11-10 18:28:48 +00:00
|
|
|
},
|
2020-10-22 18:36:50 +00:00
|
|
|
},
|
2020-10-21 17:54:45 +00:00
|
|
|
methods: {
|
2020-12-29 10:35:19 +00:00
|
|
|
...mapActions( [ "removeListItemAction" ] ),
|
|
|
|
localized( item ) {
|
2021-01-13 05:02:48 +00:00
|
|
|
if ( this.title !== 'lang' )
|
2020-12-29 10:35:19 +00:00
|
|
|
return localize( item )
|
|
|
|
else
|
|
|
|
return item
|
|
|
|
},
|
2020-12-07 14:45:00 +00:00
|
|
|
tapAction( item ) {
|
|
|
|
this.$modal.close( item )
|
2020-10-21 17:54:45 +00:00
|
|
|
},
|
2020-12-07 14:45:00 +00:00
|
|
|
onLabelLoaded( args ) {
|
|
|
|
args.object.android.setGravity( 16 )
|
2020-11-10 18:28:48 +00:00
|
|
|
},
|
2020-12-29 10:35:19 +00:00
|
|
|
deletionConfirmation( type, description ) {
|
|
|
|
return this.$showModal( ConfirmDialog, {
|
|
|
|
props: {
|
2021-01-13 05:02:48 +00:00
|
|
|
title: 'conf',
|
2020-12-29 10:35:19 +00:00
|
|
|
description,
|
2021-01-13 05:02:48 +00:00
|
|
|
cancelButtonText: "cBtn",
|
|
|
|
okButtonText: "rBtn",
|
|
|
|
helpIcon: 'fail',
|
|
|
|
bgColor: '#c92a2a',
|
2020-12-29 10:35:19 +00:00
|
|
|
},
|
|
|
|
} )
|
|
|
|
},
|
|
|
|
removeItem( index ) {
|
|
|
|
let item = this.newList[ index ]
|
|
|
|
let vm = this
|
|
|
|
|
2021-01-13 05:02:48 +00:00
|
|
|
function removeListItem( type, listName, desc ) {
|
|
|
|
vm.deletionConfirmation( type, `${localize(desc)} "${localize(item)}"\n\n${localize('rmLIInfo')}` ).then( action => {
|
|
|
|
if ( action != null && action )
|
2020-12-29 10:35:19 +00:00
|
|
|
vm.removeListItemAction( {
|
|
|
|
item,
|
|
|
|
listName
|
|
|
|
} )
|
|
|
|
} )
|
|
|
|
}
|
|
|
|
switch ( this.title ) {
|
2021-01-13 05:02:48 +00:00
|
|
|
case "cui":
|
|
|
|
removeListItem( 'cuisine', "cuisines", "rmCuiInfo" )
|
2020-12-29 10:35:19 +00:00
|
|
|
break;
|
2021-01-13 05:02:48 +00:00
|
|
|
case "cat":
|
|
|
|
removeListItem( "category", "categories", "rmCatInfo" )
|
2020-12-29 10:35:19 +00:00
|
|
|
break;
|
2021-01-13 05:02:48 +00:00
|
|
|
case "yieldU":
|
|
|
|
removeListItem( "yield unit", "yieldUnits", "rmYUInfo" )
|
2020-12-29 10:35:19 +00:00
|
|
|
break;
|
2021-01-13 05:02:48 +00:00
|
|
|
case "Unit":
|
|
|
|
removeListItem( "unit", "units", "rmUInfo" )
|
2020-12-29 10:35:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
2020-10-21 17:54:45 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|