mirror of
https://github.com/jcreek/bank-statement-analyser.git
synced 2026-07-15 03:43:46 +00:00
Added a reusable Modal component for the apply tag functionality
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
<template>
|
||||||
|
<div id="app">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn"
|
||||||
|
@click="showModal"
|
||||||
|
>
|
||||||
|
Open Modal!
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<modal
|
||||||
|
v-show="isModalVisible"
|
||||||
|
@close="closeModal"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Modal from '../components/Modal.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'app',
|
||||||
|
components: {
|
||||||
|
Modal,
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isModalVisible: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showModal() {
|
||||||
|
this.isModalVisible = true;
|
||||||
|
},
|
||||||
|
closeModal() {
|
||||||
|
this.isModalVisible = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<template>
|
||||||
|
<transition name="modal-fade">
|
||||||
|
<div class="modal-backdrop">
|
||||||
|
<div class="modal"
|
||||||
|
role="dialog"
|
||||||
|
aria-labelledby="modalTitle"
|
||||||
|
aria-describedby="modalDescription"
|
||||||
|
>
|
||||||
|
<header
|
||||||
|
class="modal-header"
|
||||||
|
id="modalTitle"
|
||||||
|
>
|
||||||
|
<slot name="header">
|
||||||
|
This is the default tile!
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn-close"
|
||||||
|
@click="close"
|
||||||
|
aria-label="Close modal"
|
||||||
|
>
|
||||||
|
x
|
||||||
|
</button>
|
||||||
|
</slot>
|
||||||
|
</header>
|
||||||
|
<section
|
||||||
|
class="modal-body"
|
||||||
|
id="modalDescription"
|
||||||
|
>
|
||||||
|
<slot name="body">
|
||||||
|
I'm the default body!
|
||||||
|
</slot>
|
||||||
|
</section>
|
||||||
|
<footer class="modal-footer">
|
||||||
|
<slot name="footer">
|
||||||
|
I'm the default footer!
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn-green"
|
||||||
|
@click="close"
|
||||||
|
aria-label="Close modal"
|
||||||
|
>
|
||||||
|
Close me!
|
||||||
|
</button>
|
||||||
|
</slot>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'modal',
|
||||||
|
methods: {
|
||||||
|
close() {
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.modal-backdrop {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
background: #FFFFFF;
|
||||||
|
box-shadow: 2px 2px 20px 1px;
|
||||||
|
overflow-x: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header,
|
||||||
|
.modal-footer {
|
||||||
|
padding: 15px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header {
|
||||||
|
border-bottom: 1px solid #eeeeee;
|
||||||
|
color: #4AAE9B;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-footer {
|
||||||
|
border-top: 1px solid #eeeeee;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
position: relative;
|
||||||
|
padding: 20px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-close {
|
||||||
|
border: none;
|
||||||
|
font-size: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #4AAE9B;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-green {
|
||||||
|
color: white;
|
||||||
|
background: #4AAE9B;
|
||||||
|
border: 1px solid #4AAE9B;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+12
-3
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
<ApplyTag />
|
||||||
<AddTransaction v-on:add-transaction="addTransaction" />
|
<AddTransaction v-on:add-transaction="addTransaction" />
|
||||||
<Transactions v-bind:transactions="transactions" v-on:del-transaction="deleteTransaction" />
|
<Transactions v-bind:transactions="transactions" v-on:del-transaction="deleteTransaction" />
|
||||||
</div>
|
</div>
|
||||||
@@ -8,12 +9,14 @@
|
|||||||
<script>
|
<script>
|
||||||
import Transactions from '../components/Transactions';
|
import Transactions from '../components/Transactions';
|
||||||
import AddTransaction from '../components/AddTransaction';
|
import AddTransaction from '../components/AddTransaction';
|
||||||
|
import ApplyTag from '../components/ApplyTag';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'home',
|
name: 'home',
|
||||||
components: {
|
components: {
|
||||||
Transactions,
|
Transactions,
|
||||||
AddTransaction
|
AddTransaction,
|
||||||
|
ApplyTag
|
||||||
},
|
},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
@@ -69,11 +72,17 @@ export default {
|
|||||||
alert('found duplicate transaction, not adding it - ' + newTransaction.date + ' :: ' + newTransaction.description);
|
alert('found duplicate transaction, not adding it - ' + newTransaction.date + ' :: ' + newTransaction.description);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Open a modal to let the user select a tag to apply to the transaction
|
||||||
|
// var newTransactionWithTag = this.applyTag(newTransaction);
|
||||||
|
|
||||||
|
// Add the transaction
|
||||||
this.transactions.push(newTransaction);
|
this.transactions.push(newTransaction);
|
||||||
this.saveTransactions();
|
this.saveTransactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
// applyTag(newTransaction) {
|
||||||
|
|
||||||
|
// },
|
||||||
saveTransactions() {
|
saveTransactions() {
|
||||||
localStorage.setItem("lastname", "Smith");
|
localStorage.setItem("lastname", "Smith");
|
||||||
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
||||||
|
|||||||
Reference in New Issue
Block a user