#33 Displaying The Properties Of A Deposit
Sunday, January 19, 2020
In this article we will pick up where we left off from the last article. In the last article we added a lot of additional information to our account details page. One of the components that we added to the details was a list showing the deposits that have already been made as well as the ability to add a new deposit. For the moment though when you click to view a deposit or create one we just print information to the console. By the time we are done with this article we will have created a new view that we can use to edit an existing deposit as well as add a new one.
Parts
- Part 45: Adjusting Shares
- Part 44: Plan Percentages
- Part 43: Home Securities
- Part 42: Updating Plans
- Part 41: Plan Details View
- Part 40: Portfolio Getters
- Part 39: Portfolio Plan
- Part 38: Portfolio Category
- Part 37: Account Securities
- Part 36: Account Transfer
- Part 35: View Account Security
- Part 34: Updating Deposit
- Part 33: View Account Deposit
- Part 32: Display Account Details
- Part 31: Account Getters
- Part 30: Deposits And Securities
- Part 29: Add Accounts Details
- Part 28: Refactoring Accounts
- Part 27: Add Security Models
- Part 26: Edit Security Details
- Part 25: View Security Details
- Part 24: Navigating To Details
- Part 23: Getters Validation
- Part 22: Query Parameters
- Part 21: Tab Entries
- Part 20: Tab Header
- Part 19: List View
- Part 18: Vuex Getters
- Part 17: End Domain Model
- Part 16: Start Domain Model
- Part 15: Pop Routes
- Part 14: Push Routes
- Part 13: Removing Accounts
- Part 12: Vuex (Decorators)
- Part 11: Vuex (Accounts)
- Part 10: The App Bar (Settings)
- Part 9: Remove Consumer Rxjs
- Part 8: The App Bar (Back)
- Part 7: Structuring Our App
- Part 6: Animation Between Views
- Part 5: Navigation Fade
- Part 4: Navigation Requests
- Part 3: Fade Animations (cont.)
- Part 2: Fade Animations
- Part 1: Splash Screen
Code Snippets
types.ts (1:02)
...
export enum Routes {
...
AccountsDeposit,
...
}
...
routing-service.ts (1:23)
...
const accountsDeposit = new RouteEntry({
component: () => import(/* webpackChunkName: "accounts-deposit" */ "../../views/AccountsDeposit.vue"),
name: "accounts-deposit",
parent: accountsDetails,
path: "/accounts-deposit",
route: Routes.AccountsDeposit,
});
...
export class RoutingService {
...
private readonly _routes = [
...
accountsDeposit,
...
];
...
}
AccountsDeposit.vue (3:22)
<template lang="pug">
div deposit
</template>
AccountsDetails.vue (3:45)
<script lang="tsx">
...
export default class AccountsDetails extends Vue {
...
private handleClickAccountDeposit(deposit: AccountDepositModel) {
this.routingService.navigateTo(Routes.AccountsDeposit, {
query: { id: `${deposit.id}` },
});
}
...
private handleClickCreateAccountDeposit() {
this.routingService.navigateTo(Routes.AccountsDeposit, {
query: { id: "0" },
});
}
...
}
</script>
Advertisement
AccountsDeposit.vue (4:58)
<script lang="ts">
import { Component, Inject, Vue } from "vue-property-decorator";
import { Routes, RoutingService } from "@/components/routing";
import {
AccountDepositModel,
Action,
ActionFn,
ACTION_PUSH_ROUTE,
Getter,
GETTER_ACCOUNT_DEPOSIT,
GetterAccountDeposit,
PayloadPushRoute,
} from "@/store";
interface IQuery {
id: string;
}
@Component
export default class AccountsDeposit extends Vue {
@Action(ACTION_PUSH_ROUTE) private readonly pushRoute!: ActionFn<PayloadPushRoute>;
@Getter(GETTER_ACCOUNT_DEPOSIT) private readonly getterDeposit!: GetterAccountDeposit;
@Inject() private readonly routingService!: RoutingService;
private accountId = 0;
private id = 0;
private created() {
this.id = this.routingService.queryParam<IQuery, number>((x) => x.id, parseInt);
if (this.id <= 0) {
return;
}
const deposit = this.getterDeposit(this.id);
this.load(deposit);
}
private load(deposit: AccountDepositModel) {
this.accountId = deposit.accountId;
if (this.routingService.isPreviousRoute(Routes.AccountsDetails) === false) {
this.pushRoute(
this.routingService.createRoute(Routes.AccountsDetails, {
query: { id: `${this.accountId}` },
}),
);
}
console.log(deposit);
}
}
</script>
Terminal
npm install --save moment
package.json (11:17)
{
...
"dependencies": {
...
"moment": "^2.24.0",
...
},
...
}
AccountsDeposit.vue (11:27)
<script lang="ts">
...
import moment from "moment";
import DetailsActionButtons from "@/components/DetailsActionButtons.vue";
...
@Component({
components: {
DetailsActionButtons,
},
})
export default class AccountsDeposit extends Vue {
...
private amount = 0;
private date = moment(Date.now()).format("YYYY-MM-DD");
...
private load(deposit: AccountDepositModel) {
...
this.amount = deposit.amount;
this.date = moment(deposit.date).format("YYYY-MM-DD");
}
private save() {
console.log("save");
}
}
</script>
AccountsDeposit.vue (14:00)
<template lang="pug">
form
div.inputs
label Amount
input(
type="number"
v-model.number="amount")
label Date
input(
type="date"
v-model="date")
DetailsActionButtons(v-bind:save="save")/
</template>
AccountsDeposit.vue (15:57)
<style lang="sass" scoped>
@import "../bourbon/bourbon"
@import "../bitters/functions"
@import "../bitters/variables"
.inputs
@include padding(null 0.25rem)
</style>
Exciton Interactive LLC