feat(vue): move confirmDialog to LNbits.utils so we can reuse the styling

This commit is contained in:
Eneko Illarramendi 2020-04-23 07:32:45 +02:00
parent 34e6d2a7bb
commit e461e34fc0
7 changed files with 39 additions and 78 deletions

View file

@ -307,7 +307,11 @@ new Vue({
});
},
deleteWallet: function (walletId, user) {
LNbits.href.deleteWallet(walletId, user);
LNbits.utils.confirmDialog(
'Are you sure you want to delete this wallet?'
).onOk(function () {
LNbits.href.deleteWallet(walletId, user);
});
},
fetchPayments: function (checkPending) {
var self = this;

View file

@ -202,17 +202,9 @@
var self = this;
var amilk = _.findWhere(this.amilks, {id: amilkId});
this.$q.dialog({
message: 'Are you sure you want to delete this AMilk link?',
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
}).onOk(function () {
LNbits.utils.confirmDialog(
'Are you sure you want to delete this AMilk link?'
).onOk(function () {
LNbits.api.request(
'DELETE',
'/amilk/api/v1/amilks/' + amilkId,

View file

@ -474,17 +474,9 @@
var self = this;
var indexer = _.findWhere(this.indexers, {id: indexerId});
this.$q.dialog({
message: 'Are you sure you want to delete this Indexer link?',
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
}).onOk(function () {
LNbits.utils.confirmDialog(
'Are you sure you want to delete this Indexer link?'
).onOk(function () {
LNbits.api.request(
'DELETE',
'/diagonalley/api/v1/diagonalley/indexers/' + indexerId,
@ -538,17 +530,9 @@
var self = this;
var order = _.findWhere(this.orders, {id: orderId});
this.$q.dialog({
message: 'Are you sure you want to delete this order link?',
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
}).onOk(function () {
LNbits.utils.confirmDialog(
'Are you sure you want to delete this order link?'
).onOk(function () {
LNbits.api.request(
'DELETE',
'/diagonalley/api/v1/diagonalley/orders/' + orderId,
@ -646,17 +630,9 @@
var self = this;
var product = _.findWhere(this.products, {id: productId});
this.$q.dialog({
message: 'Are you sure you want to delete this products link?',
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
}).onOk(function () {
LNbits.utils.confirmDialog(
'Are you sure you want to delete this products link?'
).onOk(function () {
LNbits.api.request(
'DELETE',
'/diagonalley/api/v1/diagonalley/products/' + productId,

View file

@ -186,17 +186,9 @@
var self = this;
var paywall = _.findWhere(this.paywalls, {id: paywallId});
this.$q.dialog({
message: 'Are you sure you want to delete this paywall link?',
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
}).onOk(function () {
LNbits.utils.confirmDialog(
'Are you sure you want to delete this paywall link?'
).onOk(function () {
LNbits.api.request(
'DELETE',
'/paywall/api/v1/paywalls/' + paywallId,

View file

@ -193,17 +193,9 @@
var self = this;
var tpos = _.findWhere(this.tposs, {id: tposId});
this.$q.dialog({
message: 'Are you sure you want to delete this TPoS?',
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
}).onOk(function () {
LNbits.utils.confirmDialog(
'Are you sure you want to delete this TPoS?'
).onOk(function () {
LNbits.api.request(
'DELETE',
'/tpos/api/v1/tposs/' + tposId,

View file

@ -131,17 +131,9 @@ new Vue({
var self = this;
var link = _.findWhere(this.withdrawLinks, {id: linkId});
this.$q.dialog({
message: 'Are you sure you want to delete this withdraw link?',
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
}).onOk(function () {
LNbits.utils.confirmDialog(
'Are you sure you want to delete this withdraw link?'
).onOk(function () {
LNbits.api.request(
'DELETE',
'/withdraw/api/v1/links/' + linkId,

View file

@ -87,6 +87,19 @@ var LNbits = {
}
},
utils: {
confirmDialog: function (msg) {
return Quasar.plugins.Dialog.create({
message: msg,
ok: {
flat: true,
color: 'orange'
},
cancel: {
flat: true,
color: 'grey'
}
});
},
formatCurrency: function (value, currency) {
return new Intl.NumberFormat(LOCALE, {style: 'currency', currency: currency}).format(value);
},