Add src/client/types/toast.ts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1c72e31ea8
commit
2ddc4a113c
62
src/client/types/toast.ts
Normal file
62
src/client/types/toast.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import journey_wrapper from "./wrapper";
|
||||||
|
import { focus_leg } from "../helper/nav";
|
||||||
|
|
||||||
|
interface toaster {
|
||||||
|
show: boolean,
|
||||||
|
title: String,
|
||||||
|
desc: String,
|
||||||
|
special: String,
|
||||||
|
acceptText: String,
|
||||||
|
cancelText: String,
|
||||||
|
func: () => void,
|
||||||
|
}
|
||||||
|
|
||||||
|
const default_toaster = {
|
||||||
|
show: false,
|
||||||
|
title: ' ',
|
||||||
|
desc: ' ',
|
||||||
|
special: ' ',
|
||||||
|
acceptText: ' ',
|
||||||
|
cancelText: ' ',
|
||||||
|
func: () => { }
|
||||||
|
}
|
||||||
|
|
||||||
|
class toast {
|
||||||
|
data: toaster = default_toaster;
|
||||||
|
|
||||||
|
reset = function (): void {
|
||||||
|
this.data.show = false
|
||||||
|
this.data.title = ' '
|
||||||
|
this.data.desc = ' '
|
||||||
|
this.data.special = ' '
|
||||||
|
this.data.acceptText = ' '
|
||||||
|
this.data.cancelText = ' '
|
||||||
|
this.data.func = () => { };
|
||||||
|
}
|
||||||
|
constructor() {
|
||||||
|
this.reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
impexp = function (is_import: boolean, journey: journey_wrapper): void {
|
||||||
|
this.data.show = true;
|
||||||
|
this.data.title = is_import ? 'Import' : 'Export';
|
||||||
|
this.data.desc = ''
|
||||||
|
this.data.special = JSON.stringify(journey.data).toEncoded();
|
||||||
|
this.data.acceptText = is_import ? 'load' : ''
|
||||||
|
this.data.cancelText = 'cancel'
|
||||||
|
this.data.func = () => { journey.import_data(JSON.parse(this.data.special.toDecoded().toString())); this.reset(toast); }
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_leg = function (v: number, journey: journey_wrapper): void {
|
||||||
|
this.data.show = true;
|
||||||
|
this.data.title = `Delete Leg`;
|
||||||
|
this.data.desc = `Remove leg <${journey.leg_get(v).title || v}>`
|
||||||
|
this.data.special = '';
|
||||||
|
this.data.acceptText = 'delete'
|
||||||
|
this.data.cancelText = 'cancel'
|
||||||
|
this.data.func = () => { journey.rm_leg(v); focus_leg(journey); this.reset(toast); }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default toast;
|
Loading…
x
Reference in New Issue
Block a user