mirror of
https://github.com/romancm/gamebrary
synced 2024-11-15 07:57:19 +00:00
Replaced sweet alert success alerts with my own toasts
This commit is contained in:
parent
70932e614e
commit
0304bd7ed4
6 changed files with 12 additions and 35 deletions
|
@ -109,7 +109,7 @@ import GameSearch from '@/components/GameSearch/GameSearch';
|
||||||
import { mapState, mapGetters } from 'vuex';
|
import { mapState, mapGetters } from 'vuex';
|
||||||
import firebase from 'firebase/app';
|
import firebase from 'firebase/app';
|
||||||
import 'firebase/firestore';
|
import 'firebase/firestore';
|
||||||
import { $success, $error } from '@/shared/modals';
|
import { $error } from '@/shared/modals';
|
||||||
|
|
||||||
const db = firebase.firestore();
|
const db = firebase.firestore();
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ export default {
|
||||||
updateLists() {
|
updateLists() {
|
||||||
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
|
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
$success('List saved');
|
this.$bus.$emit('TOAST', { message: 'List saved' });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
$error('Authentication error');
|
$error('Authentication error');
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<script>
|
<script>
|
||||||
import GameRating from '@/components/GameDetail/GameRating';
|
import GameRating from '@/components/GameDetail/GameRating';
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
import { $success, $error } from '@/shared/modals';
|
import { $error } from '@/shared/modals';
|
||||||
import firebase from 'firebase/app';
|
import firebase from 'firebase/app';
|
||||||
import 'firebase/firestore';
|
import 'firebase/firestore';
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ export default {
|
||||||
|
|
||||||
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
|
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
$success('List saved');
|
this.$bus.$emit('TOAST', { message: 'Game added to list' });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
$error('Authentication error');
|
$error('Authentication error');
|
||||||
|
@ -148,7 +148,7 @@ export default {
|
||||||
|
|
||||||
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
|
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
$success('List saved');
|
this.$bus.$emit('TOAST', { message: 'Game removed' });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
$error('Authentication error');
|
$error('Authentication error');
|
||||||
|
|
|
@ -179,14 +179,7 @@ export default {
|
||||||
this.$emit('scroll');
|
this.$emit('scroll');
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
||||||
swal({
|
this.$bus.$emit('TOAST', { message: 'List added' });
|
||||||
position: 'bottom-end',
|
|
||||||
title: 'List added',
|
|
||||||
type: 'success',
|
|
||||||
toast: true,
|
|
||||||
showConfirmButton: false,
|
|
||||||
timer: 1500,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import ListOptions from '@/components/Lists/ListOptions';
|
||||||
import GameBoardPlaceholder from '@/components/GameBoard/GameBoardPlaceholder';
|
import GameBoardPlaceholder from '@/components/GameBoard/GameBoardPlaceholder';
|
||||||
import Onboard from '@/components/GameBoard/Onboard';
|
import Onboard from '@/components/GameBoard/Onboard';
|
||||||
import Panel from '@/components/Panel/Panel';
|
import Panel from '@/components/Panel/Panel';
|
||||||
import { $success, $error, swal } from '@/shared/modals';
|
import { $error, swal } from '@/shared/modals';
|
||||||
import List from '@/components/GameBoard/List';
|
import List from '@/components/GameBoard/List';
|
||||||
import draggable from 'vuedraggable';
|
import draggable from 'vuedraggable';
|
||||||
import { mapState, mapGetters } from 'vuex';
|
import { mapState, mapGetters } from 'vuex';
|
||||||
|
@ -127,20 +127,18 @@ export default {
|
||||||
deleteList(index) {
|
deleteList(index) {
|
||||||
this.$store.commit('REMOVE_LIST', index);
|
this.$store.commit('REMOVE_LIST', index);
|
||||||
this.updateLists();
|
this.updateLists();
|
||||||
$success('List deleted');
|
this.$bus.$emit('TOAST', { message: 'List deleted' });
|
||||||
},
|
},
|
||||||
|
|
||||||
dragEnd() {
|
dragEnd() {
|
||||||
this.dragging = false;
|
this.dragging = false;
|
||||||
this.draggingId = null;
|
this.draggingId = null;
|
||||||
|
this.$bus.$emit('TOAST', { message: 'Collection updated' });
|
||||||
this.updateLists();
|
this.updateLists();
|
||||||
},
|
},
|
||||||
|
|
||||||
updateLists(force) {
|
updateLists(force) {
|
||||||
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: !force })
|
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: !force })
|
||||||
.then(() => {
|
|
||||||
$success('List saved');
|
|
||||||
})
|
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
$error('Authentication error');
|
$error('Authentication error');
|
||||||
});
|
});
|
||||||
|
|
|
@ -107,7 +107,7 @@ import 'firebase/auth';
|
||||||
import Gravatar from 'vue-gravatar';
|
import Gravatar from 'vue-gravatar';
|
||||||
import Panel from '@/components/Panel/Panel';
|
import Panel from '@/components/Panel/Panel';
|
||||||
import ToggleSwitch from '@/components/ToggleSwitch/ToggleSwitch';
|
import ToggleSwitch from '@/components/ToggleSwitch/ToggleSwitch';
|
||||||
import { $success, $error, swal } from '@/shared/modals';
|
import { $error, swal } from '@/shared/modals';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
|
||||||
const db = firebase.firestore();
|
const db = firebase.firestore();
|
||||||
|
@ -180,12 +180,9 @@ export default {
|
||||||
// TODO: use async/await
|
// TODO: use async/await
|
||||||
db.collection('settings').doc(this.user.uid).delete()
|
db.collection('settings').doc(this.user.uid).delete()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
$success('Settings deleted');
|
|
||||||
|
|
||||||
db.collection('lists').doc(this.user.uid).delete()
|
db.collection('lists').doc(this.user.uid).delete()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
$success('Game lists deleted');
|
this.$bus.$emit('TOAST', { message: 'Account deleted' });
|
||||||
$success('Account deleted');
|
|
||||||
this.$store.commit('CLEAR_SESSION');
|
this.$store.commit('CLEAR_SESSION');
|
||||||
this.$router.push({ name: 'home' });
|
this.$router.push({ name: 'home' });
|
||||||
})
|
})
|
||||||
|
@ -215,7 +212,7 @@ export default {
|
||||||
db.collection('settings').doc(this.user.uid).set(this.localSettings, { merge: true })
|
db.collection('settings').doc(this.user.uid).set(this.localSettings, { merge: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$store.commit('SET_SETTINGS', this.localSettings);
|
this.$store.commit('SET_SETTINGS', this.localSettings);
|
||||||
$success('Settings saved');
|
this.$bus.$emit('TOAST', { message: 'Settings saved' });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
$error('There was an error saving your settings');
|
$error('There was an error saving your settings');
|
||||||
|
|
|
@ -12,15 +12,4 @@ export function $error(title) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function $success(title) {
|
|
||||||
swal({
|
|
||||||
position: 'bottom-end',
|
|
||||||
title,
|
|
||||||
type: 'success',
|
|
||||||
toast: true,
|
|
||||||
showConfirmButton: false,
|
|
||||||
timer: 1500,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export { swal };
|
export { swal };
|
||||||
|
|
Loading…
Reference in a new issue