2017-12-24 10:36:31 +02:00
|
|
|
const smalltalk = require('smalltalk');
|
|
|
|
|
|
|
|
class Dialogs {
|
2020-11-19 14:34:49 +02:00
|
|
|
async alert(message: string, title = '') {
|
2017-12-24 10:36:31 +02:00
|
|
|
await smalltalk.alert(title, message);
|
|
|
|
}
|
|
|
|
|
2020-11-19 14:34:49 +02:00
|
|
|
async confirm(message: string, title = '', options: any = {}) {
|
2017-12-24 10:36:31 +02:00
|
|
|
try {
|
2020-11-19 14:34:49 +02:00
|
|
|
await smalltalk.confirm(title, message, options);
|
2017-12-24 10:36:31 +02:00
|
|
|
return true;
|
|
|
|
} catch (error) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-19 14:34:49 +02:00
|
|
|
async prompt(message: string, title = '', defaultValue = '', options: any = null) {
|
2017-12-24 10:36:31 +02:00
|
|
|
if (options === null) options = {};
|
|
|
|
|
|
|
|
try {
|
|
|
|
const answer = await smalltalk.prompt(title, message, defaultValue, options);
|
|
|
|
return answer;
|
|
|
|
} catch (error) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const dialogs = new Dialogs();
|
|
|
|
|
2020-11-19 14:34:49 +02:00
|
|
|
export default dialogs;
|