@osovitny/anatoly 2.0.18 → 2.0.20
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/bundles/osovitny-anatoly.umd.js +164 -43
- package/bundles/osovitny-anatoly.umd.js.map +1 -1
- package/bundles/osovitny-anatoly.umd.min.js +2 -2
- package/bundles/osovitny-anatoly.umd.min.js.map +1 -1
- package/esm2015/lib/ui/components/base-edit.component.js +28 -19
- package/esm2015/lib/ui/components/base.component.js +3 -16
- package/esm2015/lib/ui/components/validation/form-validation-summary.component.js +27 -5
- package/esm2015/lib/ui/components/validation/item-validation-summary.component.js +2 -2
- package/esm2015/lib/ui/components/validation/validation-summary.component.js +61 -8
- package/esm2015/lib/ui/directives/native-element.directive.js +41 -0
- package/esm2015/lib/ui/ui.module.js +16 -10
- package/fesm2015/osovitny-anatoly.js +163 -49
- package/fesm2015/osovitny-anatoly.js.map +1 -1
- package/lib/ui/components/base-edit.component.d.ts +7 -6
- package/lib/ui/components/base.component.d.ts +0 -3
- package/lib/ui/components/validation/form-validation-summary.component.d.ts +4 -2
- package/lib/ui/components/validation/validation-summary.component.d.ts +15 -0
- package/lib/ui/directives/native-element.directive.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Swal from 'sweetalert2';
|
|
2
2
|
import { v4 } from 'uuid';
|
|
3
|
-
import { Injectable, ɵɵdefineInjectable, Injector, NgModule, Optional, SkipSelf, Component, Input } from '@angular/core';
|
|
3
|
+
import { Injectable, ɵɵdefineInjectable, Injector, NgModule, Optional, SkipSelf, Component, Input, Directive, ElementRef } from '@angular/core';
|
|
4
4
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
5
5
|
import { HttpClient, HttpResponse } from '@angular/common/http';
|
|
6
6
|
import { map, tap } from 'rxjs/operators';
|
|
7
7
|
import { BehaviorSubject } from 'rxjs';
|
|
8
8
|
import { CommonModule } from '@angular/common';
|
|
9
|
-
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
9
|
+
import { NgControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
10
10
|
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
|
|
11
11
|
|
|
12
12
|
/*
|
|
@@ -1351,23 +1351,11 @@ ContentHeaderComponent.propDecorators = {
|
|
|
1351
1351
|
*/
|
|
1352
1352
|
class BaseComponent {
|
|
1353
1353
|
getQSId() {
|
|
1354
|
-
|
|
1355
|
-
if (typeof id ===
|
|
1354
|
+
var id = Utils.getValueByNameInQS("id");
|
|
1355
|
+
if (typeof id === 'undefined' || id == '')
|
|
1356
1356
|
return null;
|
|
1357
1357
|
return id;
|
|
1358
1358
|
}
|
|
1359
|
-
showLoading() {
|
|
1360
|
-
let panelLoading = $("#pnlLoading");
|
|
1361
|
-
panelLoading.show();
|
|
1362
|
-
}
|
|
1363
|
-
hideLoading() {
|
|
1364
|
-
let panelLoading = $("#pnlLoading");
|
|
1365
|
-
panelLoading.hide();
|
|
1366
|
-
}
|
|
1367
|
-
handleError(e) {
|
|
1368
|
-
this.hideLoading();
|
|
1369
|
-
Alerts.ErrorOccurred();
|
|
1370
|
-
}
|
|
1371
1359
|
}
|
|
1372
1360
|
|
|
1373
1361
|
/*
|
|
@@ -1394,38 +1382,47 @@ class BaseEditComponent extends BaseComponent {
|
|
|
1394
1382
|
this.formSubmitted = false;
|
|
1395
1383
|
}
|
|
1396
1384
|
isActionAdding() {
|
|
1397
|
-
|
|
1398
|
-
if (typeof id ===
|
|
1385
|
+
var id = Utils.getValueByNameInQS("id");
|
|
1386
|
+
if (typeof id === 'undefined' || id == '')
|
|
1399
1387
|
return true;
|
|
1400
1388
|
return false;
|
|
1401
1389
|
}
|
|
1402
1390
|
getEntityId() {
|
|
1403
1391
|
return this.getQSId();
|
|
1404
1392
|
}
|
|
1405
|
-
|
|
1406
|
-
|
|
1393
|
+
isControlValid(name, formGroup = null) {
|
|
1394
|
+
return !this.isControlInvalid(name, formGroup);
|
|
1395
|
+
}
|
|
1396
|
+
isControlInvalid(name, formGroup = null) {
|
|
1397
|
+
if (typeof name === 'undefined' || name == '') {
|
|
1407
1398
|
return false;
|
|
1408
1399
|
}
|
|
1409
|
-
|
|
1400
|
+
let fg = (formGroup) ? formGroup : this.formGroup;
|
|
1401
|
+
if (!fg) {
|
|
1410
1402
|
return false;
|
|
1411
1403
|
}
|
|
1412
|
-
if (
|
|
1413
|
-
return (
|
|
1414
|
-
(
|
|
1404
|
+
if (fg.get(name)) {
|
|
1405
|
+
return (this.formSubmitted && fg.get(name).invalid) ||
|
|
1406
|
+
(fg.get(name).touched && fg.get(name).invalid);
|
|
1415
1407
|
}
|
|
1416
1408
|
return false;
|
|
1417
1409
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1410
|
+
//FormGroup functions
|
|
1411
|
+
getFormValue(name, formGroup = null) {
|
|
1412
|
+
let fg = (formGroup) ? formGroup : this.formGroup;
|
|
1413
|
+
return fg.controls[name].value;
|
|
1420
1414
|
}
|
|
1421
|
-
setFormValue(name, value) {
|
|
1422
|
-
this.formGroup
|
|
1415
|
+
setFormValue(name, value, formGroup = null) {
|
|
1416
|
+
let fg = (formGroup) ? formGroup : this.formGroup;
|
|
1417
|
+
fg.controls[name].setValue(value);
|
|
1423
1418
|
}
|
|
1424
|
-
getFormGroupValue(groupName, name) {
|
|
1425
|
-
|
|
1419
|
+
getFormGroupValue(groupName, name, formGroup = null) {
|
|
1420
|
+
let fg = (formGroup) ? formGroup : this.formGroup;
|
|
1421
|
+
return fg.controls[groupName].get(name).value;
|
|
1426
1422
|
}
|
|
1427
|
-
setFormGroupValue(groupName, name, value) {
|
|
1428
|
-
this.formGroup
|
|
1423
|
+
setFormGroupValue(groupName, name, value, formGroup = null) {
|
|
1424
|
+
let fg = (formGroup) ? formGroup : this.formGroup;
|
|
1425
|
+
fg.controls[groupName].get(name).setValue(value);
|
|
1429
1426
|
}
|
|
1430
1427
|
}
|
|
1431
1428
|
BaseEditComponent.propDecorators = {
|
|
@@ -1729,16 +1726,16 @@ class ValidationSummaryComponent extends BaseEditComponent {
|
|
|
1729
1726
|
}
|
|
1730
1727
|
getFormValidationMessages() {
|
|
1731
1728
|
let messages = [];
|
|
1732
|
-
Object.keys(this.formGroup.controls).forEach(
|
|
1729
|
+
Object.keys(this.formGroup.controls).forEach(k => {
|
|
1733
1730
|
var control = this.formGroup.controls[k];
|
|
1734
1731
|
if (control.controls != null) {
|
|
1735
|
-
Object.keys(control.controls).forEach(
|
|
1732
|
+
Object.keys(control.controls).forEach(k => {
|
|
1736
1733
|
var child = control.controls[k];
|
|
1737
|
-
this.getValidationMessages(child, k).forEach(
|
|
1734
|
+
this.getValidationMessages(child, this.getControlName(child, k)).forEach(m => messages.push(m));
|
|
1738
1735
|
});
|
|
1739
1736
|
}
|
|
1740
1737
|
else {
|
|
1741
|
-
this.getValidationMessages(control, k).forEach(
|
|
1738
|
+
this.getValidationMessages(control, this.getControlName(control, k)).forEach(m => messages.push(m));
|
|
1742
1739
|
}
|
|
1743
1740
|
});
|
|
1744
1741
|
return messages;
|
|
@@ -1750,21 +1747,74 @@ class ValidationSummaryComponent extends BaseEditComponent {
|
|
|
1750
1747
|
for (let errorName in state.errors) {
|
|
1751
1748
|
if (state.errors.hasOwnProperty(errorName)) {
|
|
1752
1749
|
switch (errorName) {
|
|
1753
|
-
case
|
|
1750
|
+
case 'required':
|
|
1754
1751
|
messages.push(`${thing} is required`);
|
|
1755
1752
|
break;
|
|
1756
|
-
case
|
|
1753
|
+
case 'minlength':
|
|
1757
1754
|
messages.push(`${thing} must be at least ${state.errors["minlength"].requiredLength} characters`);
|
|
1758
1755
|
break;
|
|
1759
|
-
case
|
|
1756
|
+
case 'pattern':
|
|
1760
1757
|
messages.push(`${thing} contains illegal characters`);
|
|
1761
1758
|
break;
|
|
1759
|
+
case 'format':
|
|
1760
|
+
messages.push(`${thing} format mismatch`);
|
|
1761
|
+
break;
|
|
1762
|
+
case 'maxlength':
|
|
1763
|
+
messages.push(`${thing} must have maximum ${state.errors["maxlength"].requiredLength} characters`);
|
|
1764
|
+
break;
|
|
1765
|
+
case 'specialcharacters':
|
|
1766
|
+
messages.push(`${thing} contains special characters`);
|
|
1767
|
+
break;
|
|
1762
1768
|
}
|
|
1763
1769
|
}
|
|
1764
1770
|
}
|
|
1765
1771
|
}
|
|
1766
1772
|
return messages;
|
|
1767
1773
|
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Get Control Name
|
|
1776
|
+
* @param control
|
|
1777
|
+
* @param thingName
|
|
1778
|
+
*/
|
|
1779
|
+
getControlName(control, thingName) {
|
|
1780
|
+
let value = this.getControlTitle(control);
|
|
1781
|
+
return value ? value : thingName;
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Retrieve tilte of control
|
|
1785
|
+
* @param control
|
|
1786
|
+
*/
|
|
1787
|
+
getControlTitle(control) {
|
|
1788
|
+
if (control === null || control === void 0 ? void 0 : control.nativeElement) {
|
|
1789
|
+
let controlTitle = this.getTitleAttribute(control.nativeElement);
|
|
1790
|
+
if (controlTitle) {
|
|
1791
|
+
return controlTitle;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
return undefined;
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* Return title attribute of form control
|
|
1798
|
+
*/
|
|
1799
|
+
getTitleAttribute(nativeElement) {
|
|
1800
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1801
|
+
let title;
|
|
1802
|
+
switch (nativeElement.tagName) {
|
|
1803
|
+
// For Kendo time and date picker element title is assigned to the 4th child control.
|
|
1804
|
+
case "KENDO-TIMEPICKER":
|
|
1805
|
+
case "KENDO-DATEPICKER":
|
|
1806
|
+
title = (_d = (_c = (_b = (_a = nativeElement.children[0]) === null || _a === void 0 ? void 0 : _a.children[0]) === null || _b === void 0 ? void 0 : _b.children[0]) === null || _c === void 0 ? void 0 : _c.children[0]) === null || _d === void 0 ? void 0 : _d.getAttribute('title');
|
|
1807
|
+
break;
|
|
1808
|
+
// For Kendo numaric element title is assigned to the 2nd child control.
|
|
1809
|
+
case "KENDO-NUMERICTEXTBOX":
|
|
1810
|
+
title = (_f = (_e = nativeElement.children[0]) === null || _e === void 0 ? void 0 : _e.children[0]) === null || _f === void 0 ? void 0 : _f.getAttribute('title');
|
|
1811
|
+
break;
|
|
1812
|
+
default:
|
|
1813
|
+
title = nativeElement.getAttribute('title');
|
|
1814
|
+
break;
|
|
1815
|
+
}
|
|
1816
|
+
return title;
|
|
1817
|
+
}
|
|
1768
1818
|
}
|
|
1769
1819
|
|
|
1770
1820
|
/*
|
|
@@ -1788,22 +1838,44 @@ class ValidationSummaryComponent extends BaseEditComponent {
|
|
|
1788
1838
|
class FormValidationSummaryComponent extends ValidationSummaryComponent {
|
|
1789
1839
|
constructor() {
|
|
1790
1840
|
super();
|
|
1791
|
-
this.
|
|
1841
|
+
this.visible = false;
|
|
1842
|
+
this.customerrors = [];
|
|
1843
|
+
/*
|
|
1844
|
+
0 - only FormValidation messages
|
|
1845
|
+
1 - only Custom messages
|
|
1846
|
+
2 - all
|
|
1847
|
+
*/
|
|
1848
|
+
this.viewtype = 0;
|
|
1792
1849
|
}
|
|
1793
1850
|
getErrors() {
|
|
1794
|
-
|
|
1851
|
+
if (this.viewtype == 1) {
|
|
1852
|
+
return this.customerrors;
|
|
1853
|
+
}
|
|
1854
|
+
let formValidationMessages = this.getFormValidationMessages();
|
|
1855
|
+
if (this.viewtype == 0) {
|
|
1856
|
+
return formValidationMessages;
|
|
1857
|
+
}
|
|
1858
|
+
var messages = [];
|
|
1859
|
+
if (formValidationMessages.length > 0) {
|
|
1860
|
+
messages.push(...formValidationMessages);
|
|
1861
|
+
}
|
|
1862
|
+
if (this.customerrors.length > 0) {
|
|
1863
|
+
messages.push(...this.customerrors);
|
|
1864
|
+
}
|
|
1795
1865
|
return messages;
|
|
1796
1866
|
}
|
|
1797
1867
|
}
|
|
1798
1868
|
FormValidationSummaryComponent.decorators = [
|
|
1799
1869
|
{ type: Component, args: [{
|
|
1800
1870
|
selector: "anatoly-form-validation-summary",
|
|
1801
|
-
template: "<div class=\"callout callout-danger\" *ngIf=\"
|
|
1871
|
+
template: "<div class=\"callout callout-danger\" *ngIf=\"visible\">\r\n <h6 class=\"box-title\">There are problems with the form</h6>\r\n <ul>\r\n <li *ngFor=\"let error of getErrors()\"><span>{{error}}</span></li>\r\n </ul>\r\n</div>\r\n\r\n"
|
|
1802
1872
|
},] }
|
|
1803
1873
|
];
|
|
1804
1874
|
FormValidationSummaryComponent.ctorParameters = () => [];
|
|
1805
1875
|
FormValidationSummaryComponent.propDecorators = {
|
|
1806
|
-
|
|
1876
|
+
visible: [{ type: Input }],
|
|
1877
|
+
customerrors: [{ type: Input }],
|
|
1878
|
+
viewtype: [{ type: Input }]
|
|
1807
1879
|
};
|
|
1808
1880
|
|
|
1809
1881
|
/*
|
|
@@ -1832,7 +1904,7 @@ class ItemValidationSummaryComponent extends ValidationSummaryComponent {
|
|
|
1832
1904
|
ItemValidationSummaryComponent.decorators = [
|
|
1833
1905
|
{ type: Component, args: [{
|
|
1834
1906
|
selector: "anatoly-item-validation-summary",
|
|
1835
|
-
template: "<ul class=\"list-unstyled\" *ngIf=\"
|
|
1907
|
+
template: "<ul class=\"list-unstyled\" *ngIf=\"isControlInvalid(controlName)\">\r\n <li *ngFor=\"let error of getValidationMessages(formGroup.get(controlName), controlTitle)\">\r\n <span class=\"help-block\">{{ error }}</span>\r\n </li>\r\n</ul>\r\n\r\n"
|
|
1836
1908
|
},] }
|
|
1837
1909
|
];
|
|
1838
1910
|
ItemValidationSummaryComponent.ctorParameters = () => [];
|
|
@@ -1841,6 +1913,44 @@ ItemValidationSummaryComponent.propDecorators = {
|
|
|
1841
1913
|
controlTitle: [{ type: Input }]
|
|
1842
1914
|
};
|
|
1843
1915
|
|
|
1916
|
+
/*
|
|
1917
|
+
<file>
|
|
1918
|
+
Project:
|
|
1919
|
+
@osovitny/anatoly
|
|
1920
|
+
|
|
1921
|
+
Authors:
|
|
1922
|
+
Vadim Osovitny
|
|
1923
|
+
Anatoly Osovitny
|
|
1924
|
+
|
|
1925
|
+
Created:
|
|
1926
|
+
28 Jun 2020
|
|
1927
|
+
|
|
1928
|
+
Version:
|
|
1929
|
+
1.0
|
|
1930
|
+
|
|
1931
|
+
Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
|
|
1932
|
+
</file>
|
|
1933
|
+
*/
|
|
1934
|
+
class NativeElementDirective {
|
|
1935
|
+
constructor(el, control) {
|
|
1936
|
+
this.el = el;
|
|
1937
|
+
this.control = control;
|
|
1938
|
+
}
|
|
1939
|
+
ngOnInit() {
|
|
1940
|
+
// sets the localization key to the control
|
|
1941
|
+
this.control.control.nativeElement = this.el.nativeElement;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
NativeElementDirective.decorators = [
|
|
1945
|
+
{ type: Directive, args: [{
|
|
1946
|
+
selector: '[formControl], [formControlName]'
|
|
1947
|
+
},] }
|
|
1948
|
+
];
|
|
1949
|
+
NativeElementDirective.ctorParameters = () => [
|
|
1950
|
+
{ type: ElementRef },
|
|
1951
|
+
{ type: NgControl }
|
|
1952
|
+
];
|
|
1953
|
+
|
|
1844
1954
|
/*
|
|
1845
1955
|
<file>
|
|
1846
1956
|
Project:
|
|
@@ -1872,7 +1982,7 @@ AnatolyUIModule.decorators = [
|
|
|
1872
1982
|
FroalaEditorModuleWithProviders,
|
|
1873
1983
|
FroalaViewModuleWithProviders,
|
|
1874
1984
|
],
|
|
1875
|
-
|
|
1985
|
+
exports: [
|
|
1876
1986
|
SubscribePlanButtonComponent,
|
|
1877
1987
|
UpgradePlanButtonComponent,
|
|
1878
1988
|
BuyAccessButtonComponent,
|
|
@@ -1883,9 +1993,11 @@ AnatolyUIModule.decorators = [
|
|
|
1883
1993
|
ItemValidationSummaryComponent,
|
|
1884
1994
|
HtmlEditorComponent,
|
|
1885
1995
|
FormsHtmlEditorComponent,
|
|
1886
|
-
ContentHeaderComponent
|
|
1996
|
+
ContentHeaderComponent,
|
|
1997
|
+
//Directives
|
|
1998
|
+
NativeElementDirective
|
|
1887
1999
|
],
|
|
1888
|
-
|
|
2000
|
+
declarations: [
|
|
1889
2001
|
SubscribePlanButtonComponent,
|
|
1890
2002
|
UpgradePlanButtonComponent,
|
|
1891
2003
|
BuyAccessButtonComponent,
|
|
@@ -1896,8 +2008,10 @@ AnatolyUIModule.decorators = [
|
|
|
1896
2008
|
ItemValidationSummaryComponent,
|
|
1897
2009
|
HtmlEditorComponent,
|
|
1898
2010
|
FormsHtmlEditorComponent,
|
|
1899
|
-
ContentHeaderComponent
|
|
1900
|
-
|
|
2011
|
+
ContentHeaderComponent,
|
|
2012
|
+
//Directives
|
|
2013
|
+
NativeElementDirective
|
|
2014
|
+
]
|
|
1901
2015
|
},] }
|
|
1902
2016
|
];
|
|
1903
2017
|
|