mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
create transaction with type and wallet id when comming from wallet page
This commit is contained in:
@@ -7,6 +7,7 @@ class BasePageElement extends BaseElement {
|
|||||||
public pageTitle: string = '';
|
public pageTitle: string = '';
|
||||||
@attr hidetitle: string;
|
@attr hidetitle: string;
|
||||||
@attr customtitle: string;
|
@attr customtitle: string;
|
||||||
|
private _data: any;
|
||||||
constructor(options: OptionType) {
|
constructor(options: OptionType) {
|
||||||
super();
|
super();
|
||||||
if (options?.title) {
|
if (options?.title) {
|
||||||
@@ -34,6 +35,14 @@ class BasePageElement extends BaseElement {
|
|||||||
this.appMain.setTitle(this.pageTitle);
|
this.appMain.setTitle(this.pageTitle);
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setData = (data: any) => {
|
||||||
|
this._data = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
getData = () => {
|
||||||
|
return this._data;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BasePageElement;
|
export default BasePageElement;
|
||||||
|
|||||||
@@ -46,9 +46,8 @@ class AppDropdownElement extends BaseComponentElement {
|
|||||||
this.validator = new Validator(this, this.appForm, this.rules);
|
this.validator = new Validator(this, this.appForm, this.rules);
|
||||||
this.randId = `${name}${randomId()}`;
|
this.randId = `${name}${randomId()}`;
|
||||||
this.update();
|
this.update();
|
||||||
this.appMain.addEventListener('click', this.outsideClick);
|
this.appMain?.addEventListener('click', this.outsideClick);
|
||||||
this.elementDisconnectCallbacks.push((appMain) => {
|
this.elementDisconnectCallbacks.push((appMain) => {
|
||||||
console.log('oslo');
|
|
||||||
appMain.removeEventListener('click', this.outsideClick);
|
appMain.removeEventListener('click', this.outsideClick);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -62,7 +61,6 @@ class AppDropdownElement extends BaseComponentElement {
|
|||||||
elementDisconnected = (): void => {};
|
elementDisconnected = (): void => {};
|
||||||
|
|
||||||
outsideClick = (e) => {
|
outsideClick = (e) => {
|
||||||
console.log(e.target);
|
|
||||||
this.closeDropdown(e);
|
this.closeDropdown(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -209,7 +207,7 @@ class AppDropdownElement extends BaseComponentElement {
|
|||||||
<input
|
<input
|
||||||
class="dropdown-custom-search"
|
class="dropdown-custom-search"
|
||||||
type="text"
|
type="text"
|
||||||
value="${searchPhrase}"
|
value="${searchPhrase || ''}"
|
||||||
app-action="input:app-dropdown#phraseChange"
|
app-action="input:app-dropdown#phraseChange"
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { AppModalElement, AppRootElement } from 'components/';
|
|||||||
import { closest } from 'core/utils';
|
import { closest } from 'core/utils';
|
||||||
import { AppLoaderElement } from 'components/app-loader/AppLoaderElement';
|
import { AppLoaderElement } from 'components/app-loader/AppLoaderElement';
|
||||||
import { ToastPortalElement } from 'components/toast-portal/ToastPortalElement';
|
import { ToastPortalElement } from 'components/toast-portal/ToastPortalElement';
|
||||||
|
import { BasePageElement } from 'common/';
|
||||||
|
|
||||||
@controller
|
@controller
|
||||||
class AppMainElement extends HTMLElement {
|
class AppMainElement extends HTMLElement {
|
||||||
@@ -22,6 +23,7 @@ class AppMainElement extends HTMLElement {
|
|||||||
routechanged: new Event('routechanged'),
|
routechanged: new Event('routechanged'),
|
||||||
tokenchange: new Event('tokenchange'),
|
tokenchange: new Event('tokenchange'),
|
||||||
walletupdate: new Event('walletupdate'),
|
walletupdate: new Event('walletupdate'),
|
||||||
|
transactionupdate: new Event('transactionupdate'),
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -112,12 +114,12 @@ class AppMainElement extends HTMLElement {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
createModal = (element: string) => {
|
createModal = (element: string, data?: any) => {
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
this.appMain.addEventListener('routechanged', this.closeModal);
|
this.appMain.addEventListener('routechanged', this.closeModal);
|
||||||
|
|
||||||
const _appModal = this.createAppModal();
|
const _appModal = this.createAppModal();
|
||||||
const _modalContent = this.createModalContent(element);
|
const _modalContent = this.createModalContent(element, data);
|
||||||
const _modalOverlay = this.createModalOverlay();
|
const _modalOverlay = this.createModalOverlay();
|
||||||
|
|
||||||
_modalOverlay.appendChild(_modalContent);
|
_modalOverlay.appendChild(_modalContent);
|
||||||
@@ -129,6 +131,10 @@ class AppMainElement extends HTMLElement {
|
|||||||
this.dispatchEvent(this.domEvents.walletupdate);
|
this.dispatchEvent(this.domEvents.walletupdate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public triggerTransactionUpdate = () => {
|
||||||
|
this.dispatchEvent(this.domEvents.transactionupdate);
|
||||||
|
};
|
||||||
|
|
||||||
public setTitle = (title: string): void => {
|
public setTitle = (title: string): void => {
|
||||||
if (!title) title = __CONFIG__.appName;
|
if (!title) title = __CONFIG__.appName;
|
||||||
window.document.title = title;
|
window.document.title = title;
|
||||||
@@ -146,10 +152,11 @@ class AppMainElement extends HTMLElement {
|
|||||||
this.appendChild(_loader);
|
this.appendChild(_loader);
|
||||||
};
|
};
|
||||||
|
|
||||||
private createModalContent = (element: string) => {
|
private createModalContent = (element: string, data?: any) => {
|
||||||
const _modalElement = document.createElement(element);
|
const _modalElement = document.createElement(element);
|
||||||
const _divEl = document.createElement('div');
|
const _divEl = document.createElement('div');
|
||||||
_modalElement.setAttribute('data-target', 'app-modal.modalElement');
|
_modalElement.setAttribute('data-target', 'app-modal.modalElement');
|
||||||
|
(_modalElement as BasePageElement).setData({ ...data });
|
||||||
_divEl.setAttribute('data-target', 'app-modal.modalContent');
|
_divEl.setAttribute('data-target', 'app-modal.modalContent');
|
||||||
//_divEl.setAttribute('data-action', 'click:app-main#preventClosing');
|
//_divEl.setAttribute('data-action', 'click:app-main#preventClosing');
|
||||||
_divEl.appendChild(_modalElement);
|
_divEl.appendChild(_modalElement);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class AppPaginationElement extends BaseComponentElement {
|
|||||||
@attr totalItems: number;
|
@attr totalItems: number;
|
||||||
@attr autoInit: string;
|
@attr autoInit: string;
|
||||||
@attr tableLayout: string = 'transactions-table';
|
@attr tableLayout: string = 'transactions-table';
|
||||||
|
@attr colLayout: string = 'col-transactions';
|
||||||
initial: boolean = false;
|
initial: boolean = false;
|
||||||
|
|
||||||
private customRenderItems: () => TemplateResult;
|
private customRenderItems: () => TemplateResult;
|
||||||
@@ -95,14 +96,20 @@ class AppPaginationElement extends BaseComponentElement {
|
|||||||
|
|
||||||
render = (): TemplateResult => {
|
render = (): TemplateResult => {
|
||||||
const { rpp, totalItems, page, items } = this;
|
const { rpp, totalItems, page, items } = this;
|
||||||
|
console.log(items);
|
||||||
|
|
||||||
const renderItem = this.customRenderItem
|
const renderItem = this.customRenderItem
|
||||||
? this.customRenderItem
|
? this.customRenderItem
|
||||||
: (item, iter) => html`<tr>
|
: (item, iter) => html`<tr class="${this.colLayout ? this.colLayout : ''}">
|
||||||
<td class="--left">${iter + 1 + rpp * (page - 1)}</td>
|
<td class="--left">${iter + 1 + rpp * (page - 1)}</td>
|
||||||
<td class="--left">${item.description}</td>
|
<td class="--left">${item.description}</td>
|
||||||
<td class="balance-cell --right">
|
<td class="balance-cell --right">
|
||||||
<span class="balance ${item.amount > 0 ? '--positive' : '--negative'}">
|
<span
|
||||||
|
class="balance ${item.amount > 0 && item?.transactionType?.type != 'expense'
|
||||||
|
? '--positive'
|
||||||
|
: '--negative'}"
|
||||||
|
>
|
||||||
|
${item?.transactionType?.type == 'expense' ? '- ' : ''}
|
||||||
${Number(item.amount).toLocaleString('en-US', {
|
${Number(item.amount).toLocaleString('en-US', {
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
@@ -119,11 +126,11 @@ class AppPaginationElement extends BaseComponentElement {
|
|||||||
return html``;
|
return html``;
|
||||||
} else {
|
} else {
|
||||||
if (items?.length > 0) {
|
if (items?.length > 0) {
|
||||||
return html`<table class="${this.tableLayout}">
|
return items?.map((item, iter) => renderItem(item, iter));
|
||||||
${items?.map((item, iter) => renderItem(item, iter))} ${renderPagination()}
|
|
||||||
</table>`;
|
|
||||||
}
|
}
|
||||||
return html``;
|
return html`<tr>
|
||||||
|
<td>No data</td>
|
||||||
|
</tr>`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -151,7 +158,11 @@ class AppPaginationElement extends BaseComponentElement {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return html`<div class="app-pagination">${renderItems()}</div>`;
|
return html`<div class="app-pagination">
|
||||||
|
<table class="${this.tableLayout}">
|
||||||
|
${renderItems()} ${renderPagination()}
|
||||||
|
</table>
|
||||||
|
</div>`;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class Timer {
|
|||||||
resume = () => {
|
resume = () => {
|
||||||
this.start = Date.now();
|
this.start = Date.now();
|
||||||
window.clearTimeout(this.timerId);
|
window.clearTimeout(this.timerId);
|
||||||
console.log(this.remaining);
|
|
||||||
this.timerId = window.setTimeout(this.callback, this.remaining, ...this.args);
|
this.timerId = window.setTimeout(this.callback, this.remaining, ...this.args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,16 @@ class HistoryPageElement extends BasePageElement {
|
|||||||
this.update();
|
this.update();
|
||||||
this.pagination?.setFetchFunc?.(this.getTransactions, true)!;
|
this.pagination?.setFetchFunc?.(this.getTransactions, true)!;
|
||||||
this.appMain.addEventListener('tokenchange', this.update);
|
this.appMain.addEventListener('tokenchange', this.update);
|
||||||
|
this.appMain.addEventListener('transactionupdate', this.transactionUpdated);
|
||||||
};
|
};
|
||||||
|
|
||||||
elementDisconnected = (appMain: AppMainElement): void => {
|
elementDisconnected = (appMain: AppMainElement): void => {
|
||||||
appMain?.removeEventListener('tokenchange', this.update);
|
appMain?.removeEventListener('tokenchange', this.update);
|
||||||
|
appMain?.removeEventListener('transactionupdate', this.transactionUpdated);
|
||||||
|
};
|
||||||
|
|
||||||
|
transactionUpdated = () => {
|
||||||
|
this.pagination?.executeFetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
getTransactions = async (options): Promise<any> => {
|
getTransactions = async (options): Promise<any> => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { targets, controller } from '@github/catalyst';
|
import { targets, controller, target } from '@github/catalyst';
|
||||||
import { html, TemplateResult } from 'core/utils';
|
import { html, TemplateResult } from 'core/utils';
|
||||||
import { AuthService, TransactionsService, WalletService } from 'services/';
|
import { AuthService, TransactionsService, TransactionTypeService, WalletService } from 'services/';
|
||||||
import { InputFieldElement } from 'components/';
|
import { AppFormElement, InputFieldElement } from 'components/';
|
||||||
import { RouterService } from 'core/services';
|
import { RouterService } from 'core/services';
|
||||||
import { BasePageElement } from 'common/';
|
import { BasePageElement } from 'common/';
|
||||||
import { AppDropdownElement } from 'components/app-dropdown/AppDropdownElement';
|
import { AppDropdownElement } from 'components/app-dropdown/AppDropdownElement';
|
||||||
@@ -9,10 +9,14 @@ import { AppDropdownElement } from 'components/app-dropdown/AppDropdownElement';
|
|||||||
@controller
|
@controller
|
||||||
class TransactionCreateElement extends BasePageElement {
|
class TransactionCreateElement extends BasePageElement {
|
||||||
@targets inputs: Array<InputFieldElement | AppDropdownElement>;
|
@targets inputs: Array<InputFieldElement | AppDropdownElement>;
|
||||||
|
@target appForm: AppFormElement;
|
||||||
private transactionService: TransactionsService;
|
private transactionService: TransactionsService;
|
||||||
|
private transactionTypeService: TransactionTypeService;
|
||||||
private walletService: WalletService;
|
private walletService: WalletService;
|
||||||
|
walletData: any = null;
|
||||||
authService: AuthService;
|
authService: AuthService;
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
|
private initial: boolean = false;
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
title: 'New Transaction',
|
title: 'New Transaction',
|
||||||
@@ -21,8 +25,15 @@ class TransactionCreateElement extends BasePageElement {
|
|||||||
elementConnected = (): void => {
|
elementConnected = (): void => {
|
||||||
this.walletService = new WalletService(this.appMain?.appService);
|
this.walletService = new WalletService(this.appMain?.appService);
|
||||||
this.transactionService = new TransactionsService(this.appMain?.appService);
|
this.transactionService = new TransactionsService(this.appMain?.appService);
|
||||||
|
this.transactionTypeService = new TransactionTypeService(this.appMain?.appService);
|
||||||
this.authService = new AuthService(this.appMain.appService);
|
this.authService = new AuthService(this.appMain.appService);
|
||||||
|
this.walletData = this.getData();
|
||||||
this.update();
|
this.update();
|
||||||
|
if (this.walletData && this.walletData.walletId) {
|
||||||
|
this.setTransactionType();
|
||||||
|
} else {
|
||||||
|
this.initial = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
get nameInput(): InputFieldElement | AppDropdownElement {
|
get nameInput(): InputFieldElement | AppDropdownElement {
|
||||||
@@ -42,6 +53,17 @@ class TransactionCreateElement extends BasePageElement {
|
|||||||
return formObject;
|
return formObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTransactionType = async () => {
|
||||||
|
this.appForm.isValid = false;
|
||||||
|
try {
|
||||||
|
const response = await this.transactionTypeService.getAll();
|
||||||
|
this.walletData.transactionTypeId = response?.find((type) => type.type == this.walletData.transactionType)?.id;
|
||||||
|
} catch (err) {
|
||||||
|
} finally {
|
||||||
|
this.appForm.isValid = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
getWallets = async (options): Promise<void> => {
|
getWallets = async (options): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const response = await this.walletService.getAll(options);
|
const response = await this.walletService.getAll(options);
|
||||||
@@ -49,26 +71,43 @@ class TransactionCreateElement extends BasePageElement {
|
|||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getTypes = async (options): Promise<void> => {
|
||||||
|
try {
|
||||||
|
const response = await this.transactionTypeService.getAll(options);
|
||||||
|
return response;
|
||||||
|
} catch (err) {}
|
||||||
|
};
|
||||||
|
|
||||||
onSubmit = async (values): Promise<void> => {
|
onSubmit = async (values): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
if (!this.validate()) {
|
if (!this.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { description: description, wallet: walletId, amount } = values;
|
const { description: description, wallet: walletId, amount, transactionType: transactionTypeId } = values;
|
||||||
|
|
||||||
const response = await this.transactionService.post({
|
const walletData = this.walletData;
|
||||||
|
|
||||||
|
const formData = {
|
||||||
description,
|
description,
|
||||||
walletId,
|
|
||||||
amount,
|
amount,
|
||||||
});
|
walletId: walletData && walletData.walletId ? walletData.walletId : walletId,
|
||||||
|
transactionTypeId:
|
||||||
|
walletData && walletData.transactionTypeId ? walletData.transactionTypeId : transactionTypeId,
|
||||||
|
};
|
||||||
|
const response = await this.transactionService.post(formData);
|
||||||
|
|
||||||
if (response?.id) {
|
if (response?.id) {
|
||||||
this.appMain.triggerWalletUpdate();
|
this.appMain.triggerTransactionUpdate();
|
||||||
this.appMain.pushToast('success', 'Transaction created successfully!');
|
this.appMain.pushToast('success', 'Transaction created successfully!');
|
||||||
this.routerService.goTo('/history', {
|
|
||||||
walletId: response.id,
|
if (walletData.walletId) {
|
||||||
});
|
this.appMain?.closeModal();
|
||||||
|
} else {
|
||||||
|
this.routerService.goTo('/history', {
|
||||||
|
walletId: response.walletId,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.errorMessage = 'Unable to create transaction!';
|
this.errorMessage = 'Unable to create transaction!';
|
||||||
@@ -86,31 +125,55 @@ class TransactionCreateElement extends BasePageElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render = (): TemplateResult => {
|
render = (): TemplateResult => {
|
||||||
|
const renderInput = (type, name, label, rules, hide?) => {
|
||||||
|
if (hide) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
return html`<input-field
|
||||||
|
data-type="${type}"
|
||||||
|
data-name="${name}"
|
||||||
|
data-label="${label}"
|
||||||
|
data-targets="transaction-create.inputs"
|
||||||
|
data-rules="${rules}"
|
||||||
|
></input-field>`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderDropdown = (fetch, name, label, rules, hide?) => {
|
||||||
|
if (hide) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
return html`<app-dropdown
|
||||||
|
data-name="${name}"
|
||||||
|
data-label="${label}"
|
||||||
|
data-targets="transaction-create.inputs"
|
||||||
|
data-rules="${rules}"
|
||||||
|
data-fetch="${fetch}"
|
||||||
|
></app-dropdown>`;
|
||||||
|
};
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div>Create wallet</div>
|
<div>Create wallet</div>
|
||||||
<app-form data-custom="transaction-create#onSubmit" data-has-cancel="true">
|
<app-form
|
||||||
<input-field
|
data-custom="transaction-create#onSubmit"
|
||||||
data-type="number"
|
data-has-cancel="true"
|
||||||
data-name="amount"
|
data-target="transaction-create.appForm"
|
||||||
data-label="Amount"
|
>
|
||||||
data-targets="transaction-create.inputs"
|
${renderInput('number', 'amount', 'Amount', 'required')}
|
||||||
data-rules="required"
|
${renderInput('text', 'description', 'Description', 'required')}
|
||||||
></input-field>
|
${renderDropdown(
|
||||||
<input-field
|
'transaction-create#getWallets',
|
||||||
data-type="text"
|
'wallet',
|
||||||
data-name="description"
|
'Wallet',
|
||||||
data-label="Description"
|
'required',
|
||||||
data-targets="transaction-create.inputs"
|
this.walletData && this.walletData.walletId
|
||||||
data-rules="required"
|
)}
|
||||||
></input-field>
|
${renderDropdown(
|
||||||
<app-dropdown
|
'transaction-create#getTypes',
|
||||||
data-name="wallet"
|
'transactionType',
|
||||||
data-label="Wallet"
|
'Transaction Type',
|
||||||
data-targets="transaction-create.inputs"
|
'required',
|
||||||
data-rules="required"
|
this.walletData && this.walletData.walletId
|
||||||
data-fetch="transaction-create#getWallets"
|
)}
|
||||||
>
|
|
||||||
</app-dropdown>
|
|
||||||
${this.errorMessage ? html`<div>${this.errorMessage}</div>` : html``}
|
${this.errorMessage ? html`<div>${this.errorMessage}</div>` : html``}
|
||||||
</app-form>
|
</app-form>
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -29,10 +29,17 @@ class WalletPageElement extends BasePageElement {
|
|||||||
this.update();
|
this.update();
|
||||||
this.pagination?.setFetchFunc?.(this.getTransactions, true)!;
|
this.pagination?.setFetchFunc?.(this.getTransactions, true)!;
|
||||||
this.appMain.addEventListener('tokenchange', this.update);
|
this.appMain.addEventListener('tokenchange', this.update);
|
||||||
|
this.appMain.addEventListener('transactionupdate', this.transactionUpdated);
|
||||||
};
|
};
|
||||||
|
|
||||||
elementDisconnected = (appMain: AppMainElement): void => {
|
elementDisconnected = (appMain: AppMainElement): void => {
|
||||||
appMain?.removeEventListener('tokenchange', this.update);
|
appMain?.removeEventListener('tokenchange', this.update);
|
||||||
|
appMain?.removeEventListener('transactionupdate', this.transactionUpdated);
|
||||||
|
};
|
||||||
|
|
||||||
|
transactionUpdated = () => {
|
||||||
|
this.walletHeader?.executeFetch();
|
||||||
|
this.pagination?.executeFetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
getTransactions = async (options): Promise<any> => {
|
getTransactions = async (options): Promise<any> => {
|
||||||
@@ -43,6 +50,7 @@ class WalletPageElement extends BasePageElement {
|
|||||||
options['walletId'] = walletId;
|
options['walletId'] = walletId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
options.embed = 'TransactionType';
|
||||||
const response = await this.transactionsService.getAll(options);
|
const response = await this.transactionsService.getAll(options);
|
||||||
return response;
|
return response;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -69,6 +77,30 @@ class WalletPageElement extends BasePageElement {
|
|||||||
this.walletHeader.nextMonth = header.nextMonth || '0';
|
this.walletHeader.nextMonth = header.nextMonth || '0';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
newExpense = (s): void => {
|
||||||
|
const _modal = this.appMain.appModal;
|
||||||
|
if (_modal) {
|
||||||
|
this.appMain.closeModal();
|
||||||
|
} else {
|
||||||
|
this.appMain.createModal('transaction-create', {
|
||||||
|
walletId: this.routerService?.routerState?.data?.walletId,
|
||||||
|
transactionType: 'expense',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
newGain = (s): void => {
|
||||||
|
const _modal = this.appMain.appModal;
|
||||||
|
if (_modal) {
|
||||||
|
this.appMain.closeModal();
|
||||||
|
} else {
|
||||||
|
this.appMain.createModal('transaction-create', {
|
||||||
|
walletId: this.routerService?.routerState?.data?.walletId,
|
||||||
|
transactionType: 'gain',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render = (): TemplateResult => {
|
render = (): TemplateResult => {
|
||||||
const renderHeader = () => html`<wallet-header
|
const renderHeader = () => html`<wallet-header
|
||||||
data-target="wallet-page.walletHeader"
|
data-target="wallet-page.walletHeader"
|
||||||
@@ -81,7 +113,10 @@ class WalletPageElement extends BasePageElement {
|
|||||||
|
|
||||||
const renderWallet = () => {
|
const renderWallet = () => {
|
||||||
if (this.routerService?.routerState?.data?.walletId) {
|
if (this.routerService?.routerState?.data?.walletId) {
|
||||||
return html`<span>${this.routerService?.routerState?.data?.walletId}</span>`;
|
return html`<div class="wallet-buttons">
|
||||||
|
<button class="btn btn-squared btn-red" app-action="click:wallet-page#newExpense">New Expense</button>
|
||||||
|
<button class="btn btn-squared btn-green" app-action="click:wallet-page#newGain">New Gain</button>
|
||||||
|
</div>`;
|
||||||
}
|
}
|
||||||
return html``;
|
return html``;
|
||||||
};
|
};
|
||||||
|
|||||||
9
src/services/TransactionTypeService.ts
Normal file
9
src/services/TransactionTypeService.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { AppService, BaseService } from 'core/services';
|
||||||
|
|
||||||
|
class TransactionTypeService extends BaseService {
|
||||||
|
constructor(appService: AppService) {
|
||||||
|
super('/transaction-type', appService);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TransactionTypeService;
|
||||||
@@ -2,3 +2,4 @@ export { default as PingService } from './PingService';
|
|||||||
export { default as AuthService } from './AuthService';
|
export { default as AuthService } from './AuthService';
|
||||||
export { default as WalletService } from './WalletService';
|
export { default as WalletService } from './WalletService';
|
||||||
export { default as TransactionsService } from './TransactionsService';
|
export { default as TransactionsService } from './TransactionsService';
|
||||||
|
export { default as TransactionTypeService } from './TransactionTypeService';
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
border-bottom-right-radius: 0.2em;
|
border-bottom-right-radius: 0.2em;
|
||||||
border-bottom-left-radius: 0.2em;
|
border-bottom-left-radius: 0.2em;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
z-index: 1500;
|
||||||
input.dropdown-custom-search {
|
input.dropdown-custom-search {
|
||||||
position: relative;
|
position: relative;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@@ -13,8 +13,28 @@ app-pagination {
|
|||||||
padding: 4px 12px;
|
padding: 4px 12px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 1fr auto;
|
|
||||||
margin: 6px 8px;
|
margin: 6px 8px;
|
||||||
|
&.col-3 {
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
}
|
||||||
|
&.col-2 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
&.col-1 {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
&.col-4 {
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
}
|
||||||
|
&.col-5 {
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
}
|
||||||
|
&.col-6 {
|
||||||
|
grid-template-columns: repeat(6, 1fr);
|
||||||
|
}
|
||||||
|
&.col-transactions {
|
||||||
|
grid-template-columns: auto 1fr auto;
|
||||||
|
}
|
||||||
td,
|
td,
|
||||||
th {
|
th {
|
||||||
margin: 0 12px;
|
margin: 0 12px;
|
||||||
|
|||||||
@@ -5,32 +5,40 @@ $font-weight-semibold: 400;
|
|||||||
$font-weight-bold: 600;
|
$font-weight-bold: 600;
|
||||||
|
|
||||||
$button-map: (
|
$button-map: (
|
||||||
"primary": (
|
'primary': (
|
||||||
$blue-08,
|
$blue-08,
|
||||||
$white,
|
$white,
|
||||||
),
|
),
|
||||||
"disabled": (
|
'disabled': (
|
||||||
$gray-08,
|
$gray-08,
|
||||||
$white,
|
$white,
|
||||||
),
|
),
|
||||||
"secondary": (
|
'secondary': (
|
||||||
$orange-08,
|
$orange-08,
|
||||||
$white,
|
$white,
|
||||||
),
|
),
|
||||||
"alert": (
|
'alert': (
|
||||||
$red-08,
|
$red-08,
|
||||||
$white,
|
$white,
|
||||||
),
|
),
|
||||||
"black": (
|
'black': (
|
||||||
$black,
|
$black,
|
||||||
$white,
|
$white,
|
||||||
),
|
),
|
||||||
"white": (
|
'white': (
|
||||||
$white,
|
$white,
|
||||||
$black,
|
$black,
|
||||||
),
|
),
|
||||||
"yellow": (
|
'yellow': (
|
||||||
$yellow-06,
|
$yellow-06,
|
||||||
$white,
|
$white,
|
||||||
),
|
),
|
||||||
|
'red': (
|
||||||
|
$red-08,
|
||||||
|
$white,
|
||||||
|
),
|
||||||
|
'green': (
|
||||||
|
$green-08,
|
||||||
|
$white,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user