mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -2,6 +2,7 @@ import { attr, controller, target } from '@github/catalyst';
|
|||||||
import { html, TemplateResult } from 'core/utils';
|
import { html, TemplateResult } from 'core/utils';
|
||||||
import { BaseComponentElement } from 'common/';
|
import { BaseComponentElement } from 'common/';
|
||||||
import { CircleLoaderElement } from 'components/circle-loader/CircleLoaderElement';
|
import { CircleLoaderElement } from 'components/circle-loader/CircleLoaderElement';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
@controller
|
@controller
|
||||||
class AppPaginationElement extends BaseComponentElement {
|
class AppPaginationElement extends BaseComponentElement {
|
||||||
@@ -36,7 +37,7 @@ class AppPaginationElement extends BaseComponentElement {
|
|||||||
this.fetchFunc = fetchFunc;
|
this.fetchFunc = fetchFunc;
|
||||||
if (autoInit) {
|
if (autoInit) {
|
||||||
const options = {
|
const options = {
|
||||||
rpp: this.rpp || 5,
|
rpp: this.rpp || 10,
|
||||||
page: this.page || 1,
|
page: this.page || 1,
|
||||||
};
|
};
|
||||||
this.executeFetch(options);
|
this.executeFetch(options);
|
||||||
@@ -100,7 +101,7 @@ class AppPaginationElement extends BaseComponentElement {
|
|||||||
const renderItem = this.customRenderItem
|
const renderItem = this.customRenderItem
|
||||||
? this.customRenderItem
|
? this.customRenderItem
|
||||||
: (item, iter) => html`<tr class="${this.colLayout ? this.colLayout : ''}">
|
: (item, iter) => html`<tr class="${this.colLayout ? this.colLayout : ''}">
|
||||||
<td class="--left">${iter + 1 + rpp * (page - 1)}</td>
|
<td class="--left">${dayjs(item.transactionDate).format("MMM DD 'YY")}</td>
|
||||||
<td class="--left">${item.description}</td>
|
<td class="--left">${item.description}</td>
|
||||||
<td class="balance-cell --right">
|
<td class="balance-cell --right">
|
||||||
<span
|
<span
|
||||||
@@ -138,7 +139,7 @@ class AppPaginationElement extends BaseComponentElement {
|
|||||||
const pageRange = Math.ceil(totalItems / rpp);
|
const pageRange = Math.ceil(totalItems / rpp);
|
||||||
return html`
|
return html`
|
||||||
<div class="paginate">
|
<div class="paginate">
|
||||||
<span class="--total">${totalItems} Total Items</span>
|
<span class="--total">(${items?.length}) / ${totalItems} Total Items</span>
|
||||||
<div class="--footer">
|
<div class="--footer">
|
||||||
<span class="--pages">Page ${page} of ${pageRange}</span>
|
<span class="--pages">Page ${page} of ${pageRange}</span>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class InputFieldElement extends BaseComponentElement {
|
|||||||
@attr type: string;
|
@attr type: string;
|
||||||
@attr label: string;
|
@attr label: string;
|
||||||
@attr rules: string;
|
@attr rules: string;
|
||||||
|
@attr pattern: string;
|
||||||
@attr customAction: string;
|
@attr customAction: string;
|
||||||
@target main: HTMLElement;
|
@target main: HTMLElement;
|
||||||
@target inp: HTMLElement;
|
@target inp: HTMLElement;
|
||||||
@@ -102,6 +103,20 @@ class InputFieldElement extends BaseComponentElement {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderInput = (type) => {
|
const renderInput = (type) => {
|
||||||
|
if (this.pattern) {
|
||||||
|
return html` <input
|
||||||
|
type="${this.type}"
|
||||||
|
pattern="${this.pattern}"
|
||||||
|
step="0.01"
|
||||||
|
data-target="input-field.inp"
|
||||||
|
id="${this.randId}"
|
||||||
|
app-action="
|
||||||
|
input:input-field#inputChange
|
||||||
|
blur:input-field#validateDisplay
|
||||||
|
${this.customAction ? this.customAction : ''}
|
||||||
|
"
|
||||||
|
/>`;
|
||||||
|
}
|
||||||
return html` <input
|
return html` <input
|
||||||
type="${this.type}"
|
type="${this.type}"
|
||||||
data-target="input-field.inp"
|
data-target="input-field.inp"
|
||||||
|
|||||||
@@ -186,6 +186,21 @@ class SubscriptionCreateElement extends BasePageElement {
|
|||||||
></input-field>`;
|
></input-field>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderNumericInput = (pattern, name, label, rules, hide?, customAction?) => {
|
||||||
|
if (hide) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
return html`<input-field
|
||||||
|
data-type="number"
|
||||||
|
data-pattern="${pattern}"
|
||||||
|
data-name="${name}"
|
||||||
|
data-label="${label}"
|
||||||
|
data-targets="transaction-create.inputs"
|
||||||
|
data-rules="${rules}"
|
||||||
|
custom-action="${customAction}"
|
||||||
|
></input-field>`;
|
||||||
|
};
|
||||||
|
|
||||||
const renderDropdown = (fetch, name, label, rules, hide?) => {
|
const renderDropdown = (fetch, name, label, rules, hide?) => {
|
||||||
if (hide) {
|
if (hide) {
|
||||||
return html``;
|
return html``;
|
||||||
@@ -200,7 +215,7 @@ class SubscriptionCreateElement extends BasePageElement {
|
|||||||
};
|
};
|
||||||
return html`
|
return html`
|
||||||
<div slot="inputs">
|
<div slot="inputs">
|
||||||
${renderInput('number', 'amount', 'Amount', 'required')}
|
${renderNumericInput('^d+(?:.d{1,2})?$', 'amount', 'Amount', 'required', false)}
|
||||||
${renderInput('text', 'description', 'Description', 'required')}
|
${renderInput('text', 'description', 'Description', 'required')}
|
||||||
${renderInput('date', 'startDate', 'Start date', 'required')}
|
${renderInput('date', 'startDate', 'Start date', 'required')}
|
||||||
${renderInput('checkbox', 'hasEnd', 'Existing End Date', '', false, 'change:subscription-create#onCheck')}
|
${renderInput('checkbox', 'hasEnd', 'Existing End Date', '', false, 'change:subscription-create#onCheck')}
|
||||||
|
|||||||
@@ -150,6 +150,21 @@ class TransactionCreateElement extends BasePageElement {
|
|||||||
></input-field>`;
|
></input-field>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderNumericInput = (pattern, name, label, rules, hide?, customAction?) => {
|
||||||
|
if (hide) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
return html`<input-field
|
||||||
|
data-type="number"
|
||||||
|
data-pattern="${pattern}"
|
||||||
|
data-name="${name}"
|
||||||
|
data-label="${label}"
|
||||||
|
data-targets="transaction-create.inputs"
|
||||||
|
data-rules="${rules}"
|
||||||
|
custom-action="${customAction}"
|
||||||
|
></input-field>`;
|
||||||
|
};
|
||||||
|
|
||||||
const renderDropdown = (fetch, name, label, rules, hide?) => {
|
const renderDropdown = (fetch, name, label, rules, hide?) => {
|
||||||
if (hide) {
|
if (hide) {
|
||||||
return html``;
|
return html``;
|
||||||
@@ -169,7 +184,7 @@ class TransactionCreateElement extends BasePageElement {
|
|||||||
data-has-cancel="true"
|
data-has-cancel="true"
|
||||||
data-target="transaction-create.appForm"
|
data-target="transaction-create.appForm"
|
||||||
>
|
>
|
||||||
${renderInput('number', 'amount', 'Amount', 'required')}
|
${renderNumericInput('^d+(?:.d{1,2})?$', 'amount', 'Amount', 'required', false)}
|
||||||
${renderInput('text', 'description', 'Description', 'required')}
|
${renderInput('text', 'description', 'Description', 'required')}
|
||||||
${renderInput('date', 'transactionDate', 'Transaction date', 'required')}
|
${renderInput('date', 'transactionDate', 'Transaction date', 'required')}
|
||||||
${renderDropdown(
|
${renderDropdown(
|
||||||
|
|||||||
Reference in New Issue
Block a user