@paperless/angular 0.1.0-alpha.319 → 0.1.0-alpha.320
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/base/form.component.mjs +105 -0
- package/esm2020/lib/base/index.mjs +2 -1
- package/esm2020/lib/modules/table/base/index.mjs +1 -2
- package/esm2020/lib/modules/table/base/table.component.mjs +2 -2
- package/fesm2015/paperless-angular.mjs +104 -104
- package/fesm2015/paperless-angular.mjs.map +1 -1
- package/fesm2020/paperless-angular.mjs +104 -104
- package/fesm2020/paperless-angular.mjs.map +1 -1
- package/lib/{modules/table/base → base}/form.component.d.ts +0 -0
- package/lib/base/index.d.ts +1 -0
- package/lib/modules/table/base/index.d.ts +0 -1
- package/lib/modules/table/base/table.component.d.ts +1 -1
- package/package.json +1 -1
- package/esm2020/lib/modules/table/base/form.component.mjs +0 -105
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { trigger, transition, style, animate } from '@angular/animations';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Component, EventEmitter, Input, Output, ViewChild, Directive, HostListener, ChangeDetectionStrategy, NgModule, Injector, Injectable, HostBinding, TemplateRef, ContentChild, ContentChildren, Host, Pipe } from '@angular/core';
|
|
4
|
+
import { FormControl, FormGroup, FormArray, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
5
5
|
import * as i1$1 from '@angular/common';
|
|
6
6
|
import { CommonModule, DatePipe, CurrencyPipe } from '@angular/common';
|
|
7
7
|
import { __decorate } from 'tslib';
|
|
@@ -57,6 +57,108 @@ const SLIDE_IN_TOP_OUT_BOTTOM = trigger('pSlideInBottomOutTop', [
|
|
|
57
57
|
]),
|
|
58
58
|
]);
|
|
59
59
|
|
|
60
|
+
class BaseFormComponent {
|
|
61
|
+
constructor() {
|
|
62
|
+
this.markedDirty = false;
|
|
63
|
+
}
|
|
64
|
+
scrollToFirstError() {
|
|
65
|
+
const invalidInputs = Array.from(document.getElementsByClassName('ng-invalid'))
|
|
66
|
+
.filter((e) => e?.nodeName?.toLowerCase() !== 'form')
|
|
67
|
+
.sort((a, b) => a.scrollTop - b.scrollTop);
|
|
68
|
+
const first = invalidInputs[0];
|
|
69
|
+
if (first) {
|
|
70
|
+
first.scrollIntoView({
|
|
71
|
+
behavior: 'smooth',
|
|
72
|
+
block: 'center',
|
|
73
|
+
inline: 'center',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
markControlDirty(control) {
|
|
78
|
+
if (control instanceof FormControl) {
|
|
79
|
+
control.markAsDirty({ onlySelf: true });
|
|
80
|
+
control.markAsTouched({ onlySelf: true });
|
|
81
|
+
}
|
|
82
|
+
else if (control instanceof FormGroup) {
|
|
83
|
+
control.markAsDirty();
|
|
84
|
+
control.markAsTouched();
|
|
85
|
+
this.markAllDirty(control);
|
|
86
|
+
}
|
|
87
|
+
else if (control instanceof FormArray) {
|
|
88
|
+
control.markAsDirty();
|
|
89
|
+
control.markAsTouched();
|
|
90
|
+
for (const child of control?.controls) {
|
|
91
|
+
this.markControlDirty(child);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
control.updateValueAndValidity();
|
|
95
|
+
}
|
|
96
|
+
markAllDirty(formGroup) {
|
|
97
|
+
this.markedDirty = true;
|
|
98
|
+
for (const field of Object.keys(formGroup.controls)) {
|
|
99
|
+
const control = formGroup.get(field);
|
|
100
|
+
this.markControlDirty(control);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
getControlError(control) {
|
|
104
|
+
if (!this.hasControlError(control)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
return this.firstControlError(control);
|
|
108
|
+
}
|
|
109
|
+
hasControlError(control, showChildErrors = true) {
|
|
110
|
+
return (control?.dirty && this.firstControlError(control, showChildErrors));
|
|
111
|
+
}
|
|
112
|
+
firstControlError(control, showChildErrors = true) {
|
|
113
|
+
if (control instanceof FormGroup && showChildErrors) {
|
|
114
|
+
const errors = Object.keys(control.controls)
|
|
115
|
+
.map((key) => this.firstControlError(control.controls[key]))
|
|
116
|
+
.filter((val) => !!val);
|
|
117
|
+
return errors[0];
|
|
118
|
+
}
|
|
119
|
+
if (!control?.errors) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const keys = Object.keys(control.errors);
|
|
123
|
+
let err;
|
|
124
|
+
for (const key of keys) {
|
|
125
|
+
if (control.errors[key]) {
|
|
126
|
+
err = key;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return err;
|
|
131
|
+
}
|
|
132
|
+
resetControl(control) {
|
|
133
|
+
control.setErrors(null);
|
|
134
|
+
control.reset();
|
|
135
|
+
control.markAsPristine();
|
|
136
|
+
if (control instanceof FormGroup) {
|
|
137
|
+
this.resetForm(control);
|
|
138
|
+
}
|
|
139
|
+
else if (control instanceof FormArray) {
|
|
140
|
+
for (const child of control?.controls) {
|
|
141
|
+
this.resetControl(child);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
resetForm(formGroup) {
|
|
146
|
+
for (const field of Object.keys(formGroup.controls)) {
|
|
147
|
+
const control = formGroup.get(field);
|
|
148
|
+
this.resetControl(control);
|
|
149
|
+
}
|
|
150
|
+
this.markedDirty = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
BaseFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BaseFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
154
|
+
BaseFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: BaseFormComponent, selector: "ng-component", ngImport: i0, template: ``, isInline: true });
|
|
155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BaseFormComponent, decorators: [{
|
|
156
|
+
type: Component,
|
|
157
|
+
args: [{
|
|
158
|
+
template: ``,
|
|
159
|
+
}]
|
|
160
|
+
}] });
|
|
161
|
+
|
|
60
162
|
class BaseUploadComponent {
|
|
61
163
|
constructor() {
|
|
62
164
|
this.uploaded = false;
|
|
@@ -1862,108 +1964,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImpor
|
|
|
1862
1964
|
|
|
1863
1965
|
const OVERLAY_SERVICES = [OverlayService];
|
|
1864
1966
|
|
|
1865
|
-
class BaseFormComponent {
|
|
1866
|
-
constructor() {
|
|
1867
|
-
this.markedDirty = false;
|
|
1868
|
-
}
|
|
1869
|
-
scrollToFirstError() {
|
|
1870
|
-
const invalidInputs = Array.from(document.getElementsByClassName('ng-invalid'))
|
|
1871
|
-
.filter((e) => e?.nodeName?.toLowerCase() !== 'form')
|
|
1872
|
-
.sort((a, b) => a.scrollTop - b.scrollTop);
|
|
1873
|
-
const first = invalidInputs[0];
|
|
1874
|
-
if (first) {
|
|
1875
|
-
first.scrollIntoView({
|
|
1876
|
-
behavior: 'smooth',
|
|
1877
|
-
block: 'center',
|
|
1878
|
-
inline: 'center',
|
|
1879
|
-
});
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
markControlDirty(control) {
|
|
1883
|
-
if (control instanceof FormControl) {
|
|
1884
|
-
control.markAsDirty({ onlySelf: true });
|
|
1885
|
-
control.markAsTouched({ onlySelf: true });
|
|
1886
|
-
}
|
|
1887
|
-
else if (control instanceof FormGroup) {
|
|
1888
|
-
control.markAsDirty();
|
|
1889
|
-
control.markAsTouched();
|
|
1890
|
-
this.markAllDirty(control);
|
|
1891
|
-
}
|
|
1892
|
-
else if (control instanceof FormArray) {
|
|
1893
|
-
control.markAsDirty();
|
|
1894
|
-
control.markAsTouched();
|
|
1895
|
-
for (const child of control?.controls) {
|
|
1896
|
-
this.markControlDirty(child);
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
control.updateValueAndValidity();
|
|
1900
|
-
}
|
|
1901
|
-
markAllDirty(formGroup) {
|
|
1902
|
-
this.markedDirty = true;
|
|
1903
|
-
for (const field of Object.keys(formGroup.controls)) {
|
|
1904
|
-
const control = formGroup.get(field);
|
|
1905
|
-
this.markControlDirty(control);
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
getControlError(control) {
|
|
1909
|
-
if (!this.hasControlError(control)) {
|
|
1910
|
-
return;
|
|
1911
|
-
}
|
|
1912
|
-
return this.firstControlError(control);
|
|
1913
|
-
}
|
|
1914
|
-
hasControlError(control, showChildErrors = true) {
|
|
1915
|
-
return (control?.dirty && this.firstControlError(control, showChildErrors));
|
|
1916
|
-
}
|
|
1917
|
-
firstControlError(control, showChildErrors = true) {
|
|
1918
|
-
if (control instanceof FormGroup && showChildErrors) {
|
|
1919
|
-
const errors = Object.keys(control.controls)
|
|
1920
|
-
.map((key) => this.firstControlError(control.controls[key]))
|
|
1921
|
-
.filter((val) => !!val);
|
|
1922
|
-
return errors[0];
|
|
1923
|
-
}
|
|
1924
|
-
if (!control?.errors) {
|
|
1925
|
-
return;
|
|
1926
|
-
}
|
|
1927
|
-
const keys = Object.keys(control.errors);
|
|
1928
|
-
let err;
|
|
1929
|
-
for (const key of keys) {
|
|
1930
|
-
if (control.errors[key]) {
|
|
1931
|
-
err = key;
|
|
1932
|
-
break;
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
return err;
|
|
1936
|
-
}
|
|
1937
|
-
resetControl(control) {
|
|
1938
|
-
control.setErrors(null);
|
|
1939
|
-
control.reset();
|
|
1940
|
-
control.markAsPristine();
|
|
1941
|
-
if (control instanceof FormGroup) {
|
|
1942
|
-
this.resetForm(control);
|
|
1943
|
-
}
|
|
1944
|
-
else if (control instanceof FormArray) {
|
|
1945
|
-
for (const child of control?.controls) {
|
|
1946
|
-
this.resetControl(child);
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
}
|
|
1950
|
-
resetForm(formGroup) {
|
|
1951
|
-
for (const field of Object.keys(formGroup.controls)) {
|
|
1952
|
-
const control = formGroup.get(field);
|
|
1953
|
-
this.resetControl(control);
|
|
1954
|
-
}
|
|
1955
|
-
this.markedDirty = false;
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
BaseFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BaseFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1959
|
-
BaseFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: BaseFormComponent, selector: "ng-component", ngImport: i0, template: ``, isInline: true });
|
|
1960
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BaseFormComponent, decorators: [{
|
|
1961
|
-
type: Component,
|
|
1962
|
-
args: [{
|
|
1963
|
-
template: ``,
|
|
1964
|
-
}]
|
|
1965
|
-
}] });
|
|
1966
|
-
|
|
1967
1967
|
const createFormFilters = (values, quickFilters, quickFilterKey) => {
|
|
1968
1968
|
const filters = [];
|
|
1969
1969
|
let quickFilter = null;
|