Improve input dialog

This commit is contained in:
syuilo
2018-12-02 20:10:53 +09:00
parent 3a2dc95850
commit 1653977392
26 changed files with 201 additions and 318 deletions

View File

@@ -95,15 +95,6 @@ init((launch) => {
});
},
$input(opts) {
return new Promise<string>((res, rej) => {
const x = window.prompt(opts.title);
if (x) {
res(x);
}
});
},
$notify(message) {
alert(message);
}

View File

@@ -27,8 +27,8 @@ export default Vue.extend({
type: 'warning',
text: this.$t('read-all'),
showCancelButton: true
}).then(res => {
if (!res) return;
}).then(({ canceled }) => {
if (canceled) return;
this.$root.api('notifications/mark_all_as_read');
});

View File

@@ -38,9 +38,11 @@ export default Vue.extend({
},
methods: {
fn() {
this.$input({
this.$root.dialog({
title: this.$t('enter-list-name'),
}).then(async title => {
input: true
}).then(async ({ canceled, result: title }) => {
if (canceled) return;
const list = await this.$root.api('users/lists/create', {
title
});

View File

@@ -120,7 +120,7 @@ export default Vue.extend({
text: this.$t('push-to-list'),
action: async () => {
const lists = await this.$root.api('users/lists/list');
const listId = await this.$root.dialog({
const { canceled, result: listId } = await this.$root.dialog({
type: null,
title: this.$t('select-list'),
select: {
@@ -130,7 +130,7 @@ export default Vue.extend({
},
showCancelButton: true
});
if (!listId) return;
if (canceled) return;
await this.$root.api('users/lists/push', {
listId: listId,
userId: this.user.id