@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
|
@@ -1640,22 +1640,10 @@
|
|
|
1640
1640
|
}
|
|
1641
1641
|
BaseComponent.prototype.getQSId = function () {
|
|
1642
1642
|
var id = Utils.getValueByNameInQS("id");
|
|
1643
|
-
if (typeof id ===
|
|
1643
|
+
if (typeof id === 'undefined' || id == '')
|
|
1644
1644
|
return null;
|
|
1645
1645
|
return id;
|
|
1646
1646
|
};
|
|
1647
|
-
BaseComponent.prototype.showLoading = function () {
|
|
1648
|
-
var panelLoading = $("#pnlLoading");
|
|
1649
|
-
panelLoading.show();
|
|
1650
|
-
};
|
|
1651
|
-
BaseComponent.prototype.hideLoading = function () {
|
|
1652
|
-
var panelLoading = $("#pnlLoading");
|
|
1653
|
-
panelLoading.hide();
|
|
1654
|
-
};
|
|
1655
|
-
BaseComponent.prototype.handleError = function (e) {
|
|
1656
|
-
this.hideLoading();
|
|
1657
|
-
Alerts.ErrorOccurred();
|
|
1658
|
-
};
|
|
1659
1647
|
return BaseComponent;
|
|
1660
1648
|
}());
|
|
1661
1649
|
|
|
@@ -1668,37 +1656,52 @@
|
|
|
1668
1656
|
}
|
|
1669
1657
|
BaseEditComponent.prototype.isActionAdding = function () {
|
|
1670
1658
|
var id = Utils.getValueByNameInQS("id");
|
|
1671
|
-
if (typeof id ===
|
|
1659
|
+
if (typeof id === 'undefined' || id == '')
|
|
1672
1660
|
return true;
|
|
1673
1661
|
return false;
|
|
1674
1662
|
};
|
|
1675
1663
|
BaseEditComponent.prototype.getEntityId = function () {
|
|
1676
1664
|
return this.getQSId();
|
|
1677
1665
|
};
|
|
1678
|
-
BaseEditComponent.prototype.
|
|
1679
|
-
if (
|
|
1666
|
+
BaseEditComponent.prototype.isControlValid = function (name, formGroup) {
|
|
1667
|
+
if (formGroup === void 0) { formGroup = null; }
|
|
1668
|
+
return !this.isControlInvalid(name, formGroup);
|
|
1669
|
+
};
|
|
1670
|
+
BaseEditComponent.prototype.isControlInvalid = function (name, formGroup) {
|
|
1671
|
+
if (formGroup === void 0) { formGroup = null; }
|
|
1672
|
+
if (typeof name === 'undefined' || name == '') {
|
|
1680
1673
|
return false;
|
|
1681
1674
|
}
|
|
1682
|
-
|
|
1675
|
+
var fg = (formGroup) ? formGroup : this.formGroup;
|
|
1676
|
+
if (!fg) {
|
|
1683
1677
|
return false;
|
|
1684
1678
|
}
|
|
1685
|
-
if (
|
|
1686
|
-
return (
|
|
1687
|
-
(
|
|
1679
|
+
if (fg.get(name)) {
|
|
1680
|
+
return (this.formSubmitted && fg.get(name).invalid) ||
|
|
1681
|
+
(fg.get(name).touched && fg.get(name).invalid);
|
|
1688
1682
|
}
|
|
1689
1683
|
return false;
|
|
1690
1684
|
};
|
|
1691
|
-
|
|
1692
|
-
|
|
1685
|
+
//FormGroup functions
|
|
1686
|
+
BaseEditComponent.prototype.getFormValue = function (name, formGroup) {
|
|
1687
|
+
if (formGroup === void 0) { formGroup = null; }
|
|
1688
|
+
var fg = (formGroup) ? formGroup : this.formGroup;
|
|
1689
|
+
return fg.controls[name].value;
|
|
1693
1690
|
};
|
|
1694
|
-
BaseEditComponent.prototype.setFormValue = function (name, value) {
|
|
1695
|
-
|
|
1691
|
+
BaseEditComponent.prototype.setFormValue = function (name, value, formGroup) {
|
|
1692
|
+
if (formGroup === void 0) { formGroup = null; }
|
|
1693
|
+
var fg = (formGroup) ? formGroup : this.formGroup;
|
|
1694
|
+
fg.controls[name].setValue(value);
|
|
1696
1695
|
};
|
|
1697
|
-
BaseEditComponent.prototype.getFormGroupValue = function (groupName, name) {
|
|
1698
|
-
|
|
1696
|
+
BaseEditComponent.prototype.getFormGroupValue = function (groupName, name, formGroup) {
|
|
1697
|
+
if (formGroup === void 0) { formGroup = null; }
|
|
1698
|
+
var fg = (formGroup) ? formGroup : this.formGroup;
|
|
1699
|
+
return fg.controls[groupName].get(name).value;
|
|
1699
1700
|
};
|
|
1700
|
-
BaseEditComponent.prototype.setFormGroupValue = function (groupName, name, value) {
|
|
1701
|
-
|
|
1701
|
+
BaseEditComponent.prototype.setFormGroupValue = function (groupName, name, value, formGroup) {
|
|
1702
|
+
if (formGroup === void 0) { formGroup = null; }
|
|
1703
|
+
var fg = (formGroup) ? formGroup : this.formGroup;
|
|
1704
|
+
fg.controls[groupName].get(name).setValue(value);
|
|
1702
1705
|
};
|
|
1703
1706
|
return BaseEditComponent;
|
|
1704
1707
|
}(BaseComponent));
|
|
@@ -1946,11 +1949,11 @@
|
|
|
1946
1949
|
if (control.controls != null) {
|
|
1947
1950
|
Object.keys(control.controls).forEach(function (k) {
|
|
1948
1951
|
var child = control.controls[k];
|
|
1949
|
-
_this.getValidationMessages(child, k).forEach(function (m) { return messages.push(m); });
|
|
1952
|
+
_this.getValidationMessages(child, _this.getControlName(child, k)).forEach(function (m) { return messages.push(m); });
|
|
1950
1953
|
});
|
|
1951
1954
|
}
|
|
1952
1955
|
else {
|
|
1953
|
-
_this.getValidationMessages(control, k).forEach(function (m) { return messages.push(m); });
|
|
1956
|
+
_this.getValidationMessages(control, _this.getControlName(control, k)).forEach(function (m) { return messages.push(m); });
|
|
1954
1957
|
}
|
|
1955
1958
|
});
|
|
1956
1959
|
return messages;
|
|
@@ -1962,21 +1965,74 @@
|
|
|
1962
1965
|
for (var errorName in state.errors) {
|
|
1963
1966
|
if (state.errors.hasOwnProperty(errorName)) {
|
|
1964
1967
|
switch (errorName) {
|
|
1965
|
-
case
|
|
1968
|
+
case 'required':
|
|
1966
1969
|
messages.push(thing + " is required");
|
|
1967
1970
|
break;
|
|
1968
|
-
case
|
|
1971
|
+
case 'minlength':
|
|
1969
1972
|
messages.push(thing + " must be at least " + state.errors["minlength"].requiredLength + " characters");
|
|
1970
1973
|
break;
|
|
1971
|
-
case
|
|
1974
|
+
case 'pattern':
|
|
1972
1975
|
messages.push(thing + " contains illegal characters");
|
|
1973
1976
|
break;
|
|
1977
|
+
case 'format':
|
|
1978
|
+
messages.push(thing + " format mismatch");
|
|
1979
|
+
break;
|
|
1980
|
+
case 'maxlength':
|
|
1981
|
+
messages.push(thing + " must have maximum " + state.errors["maxlength"].requiredLength + " characters");
|
|
1982
|
+
break;
|
|
1983
|
+
case 'specialcharacters':
|
|
1984
|
+
messages.push(thing + " contains special characters");
|
|
1985
|
+
break;
|
|
1974
1986
|
}
|
|
1975
1987
|
}
|
|
1976
1988
|
}
|
|
1977
1989
|
}
|
|
1978
1990
|
return messages;
|
|
1979
1991
|
};
|
|
1992
|
+
/**
|
|
1993
|
+
* Get Control Name
|
|
1994
|
+
* @param control
|
|
1995
|
+
* @param thingName
|
|
1996
|
+
*/
|
|
1997
|
+
ValidationSummaryComponent.prototype.getControlName = function (control, thingName) {
|
|
1998
|
+
var value = this.getControlTitle(control);
|
|
1999
|
+
return value ? value : thingName;
|
|
2000
|
+
};
|
|
2001
|
+
/**
|
|
2002
|
+
* Retrieve tilte of control
|
|
2003
|
+
* @param control
|
|
2004
|
+
*/
|
|
2005
|
+
ValidationSummaryComponent.prototype.getControlTitle = function (control) {
|
|
2006
|
+
if (control === null || control === void 0 ? void 0 : control.nativeElement) {
|
|
2007
|
+
var controlTitle = this.getTitleAttribute(control.nativeElement);
|
|
2008
|
+
if (controlTitle) {
|
|
2009
|
+
return controlTitle;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
return undefined;
|
|
2013
|
+
};
|
|
2014
|
+
/**
|
|
2015
|
+
* Return title attribute of form control
|
|
2016
|
+
*/
|
|
2017
|
+
ValidationSummaryComponent.prototype.getTitleAttribute = function (nativeElement) {
|
|
2018
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2019
|
+
var title;
|
|
2020
|
+
switch (nativeElement.tagName) {
|
|
2021
|
+
// For Kendo time and date picker element title is assigned to the 4th child control.
|
|
2022
|
+
case "KENDO-TIMEPICKER":
|
|
2023
|
+
case "KENDO-DATEPICKER":
|
|
2024
|
+
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');
|
|
2025
|
+
break;
|
|
2026
|
+
// For Kendo numaric element title is assigned to the 2nd child control.
|
|
2027
|
+
case "KENDO-NUMERICTEXTBOX":
|
|
2028
|
+
title = (_f = (_e = nativeElement.children[0]) === null || _e === void 0 ? void 0 : _e.children[0]) === null || _f === void 0 ? void 0 : _f.getAttribute('title');
|
|
2029
|
+
break;
|
|
2030
|
+
default:
|
|
2031
|
+
title = nativeElement.getAttribute('title');
|
|
2032
|
+
break;
|
|
2033
|
+
}
|
|
2034
|
+
return title;
|
|
2035
|
+
};
|
|
1980
2036
|
return ValidationSummaryComponent;
|
|
1981
2037
|
}(BaseEditComponent));
|
|
1982
2038
|
|
|
@@ -1984,11 +2040,31 @@
|
|
|
1984
2040
|
__extends(FormValidationSummaryComponent, _super);
|
|
1985
2041
|
function FormValidationSummaryComponent() {
|
|
1986
2042
|
var _this = _super.call(this) || this;
|
|
1987
|
-
_this.
|
|
2043
|
+
_this.visible = false;
|
|
2044
|
+
_this.customerrors = [];
|
|
2045
|
+
/*
|
|
2046
|
+
0 - only FormValidation messages
|
|
2047
|
+
1 - only Custom messages
|
|
2048
|
+
2 - all
|
|
2049
|
+
*/
|
|
2050
|
+
_this.viewtype = 0;
|
|
1988
2051
|
return _this;
|
|
1989
2052
|
}
|
|
1990
2053
|
FormValidationSummaryComponent.prototype.getErrors = function () {
|
|
1991
|
-
|
|
2054
|
+
if (this.viewtype == 1) {
|
|
2055
|
+
return this.customerrors;
|
|
2056
|
+
}
|
|
2057
|
+
var formValidationMessages = this.getFormValidationMessages();
|
|
2058
|
+
if (this.viewtype == 0) {
|
|
2059
|
+
return formValidationMessages;
|
|
2060
|
+
}
|
|
2061
|
+
var messages = [];
|
|
2062
|
+
if (formValidationMessages.length > 0) {
|
|
2063
|
+
messages.push.apply(messages, __spread(formValidationMessages));
|
|
2064
|
+
}
|
|
2065
|
+
if (this.customerrors.length > 0) {
|
|
2066
|
+
messages.push.apply(messages, __spread(this.customerrors));
|
|
2067
|
+
}
|
|
1992
2068
|
return messages;
|
|
1993
2069
|
};
|
|
1994
2070
|
return FormValidationSummaryComponent;
|
|
@@ -1996,12 +2072,14 @@
|
|
|
1996
2072
|
FormValidationSummaryComponent.decorators = [
|
|
1997
2073
|
{ type: i0.Component, args: [{
|
|
1998
2074
|
selector: "anatoly-form-validation-summary",
|
|
1999
|
-
template: "<div class=\"callout callout-danger\" *ngIf=\"
|
|
2075
|
+
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"
|
|
2000
2076
|
},] }
|
|
2001
2077
|
];
|
|
2002
2078
|
FormValidationSummaryComponent.ctorParameters = function () { return []; };
|
|
2003
2079
|
FormValidationSummaryComponent.propDecorators = {
|
|
2004
|
-
|
|
2080
|
+
visible: [{ type: i0.Input }],
|
|
2081
|
+
customerrors: [{ type: i0.Input }],
|
|
2082
|
+
viewtype: [{ type: i0.Input }]
|
|
2005
2083
|
};
|
|
2006
2084
|
|
|
2007
2085
|
var ItemValidationSummaryComponent = /** @class */ (function (_super) {
|
|
@@ -2014,7 +2092,7 @@
|
|
|
2014
2092
|
ItemValidationSummaryComponent.decorators = [
|
|
2015
2093
|
{ type: i0.Component, args: [{
|
|
2016
2094
|
selector: "anatoly-item-validation-summary",
|
|
2017
|
-
template: "<ul class=\"list-unstyled\" *ngIf=\"
|
|
2095
|
+
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"
|
|
2018
2096
|
},] }
|
|
2019
2097
|
];
|
|
2020
2098
|
ItemValidationSummaryComponent.ctorParameters = function () { return []; };
|
|
@@ -2023,6 +2101,45 @@
|
|
|
2023
2101
|
controlTitle: [{ type: i0.Input }]
|
|
2024
2102
|
};
|
|
2025
2103
|
|
|
2104
|
+
/*
|
|
2105
|
+
<file>
|
|
2106
|
+
Project:
|
|
2107
|
+
@osovitny/anatoly
|
|
2108
|
+
|
|
2109
|
+
Authors:
|
|
2110
|
+
Vadim Osovitny
|
|
2111
|
+
Anatoly Osovitny
|
|
2112
|
+
|
|
2113
|
+
Created:
|
|
2114
|
+
28 Jun 2020
|
|
2115
|
+
|
|
2116
|
+
Version:
|
|
2117
|
+
1.0
|
|
2118
|
+
|
|
2119
|
+
Copyright (c) 2016-2020 Osovitny Inc. All rights reserved.
|
|
2120
|
+
</file>
|
|
2121
|
+
*/
|
|
2122
|
+
var NativeElementDirective = /** @class */ (function () {
|
|
2123
|
+
function NativeElementDirective(el, control) {
|
|
2124
|
+
this.el = el;
|
|
2125
|
+
this.control = control;
|
|
2126
|
+
}
|
|
2127
|
+
NativeElementDirective.prototype.ngOnInit = function () {
|
|
2128
|
+
// sets the localization key to the control
|
|
2129
|
+
this.control.control.nativeElement = this.el.nativeElement;
|
|
2130
|
+
};
|
|
2131
|
+
return NativeElementDirective;
|
|
2132
|
+
}());
|
|
2133
|
+
NativeElementDirective.decorators = [
|
|
2134
|
+
{ type: i0.Directive, args: [{
|
|
2135
|
+
selector: '[formControl], [formControlName]'
|
|
2136
|
+
},] }
|
|
2137
|
+
];
|
|
2138
|
+
NativeElementDirective.ctorParameters = function () { return [
|
|
2139
|
+
{ type: i0.ElementRef },
|
|
2140
|
+
{ type: forms.NgControl }
|
|
2141
|
+
]; };
|
|
2142
|
+
|
|
2026
2143
|
/*
|
|
2027
2144
|
<file>
|
|
2028
2145
|
Project:
|
|
@@ -2057,7 +2174,7 @@
|
|
|
2057
2174
|
FroalaEditorModuleWithProviders,
|
|
2058
2175
|
FroalaViewModuleWithProviders,
|
|
2059
2176
|
],
|
|
2060
|
-
|
|
2177
|
+
exports: [
|
|
2061
2178
|
SubscribePlanButtonComponent,
|
|
2062
2179
|
UpgradePlanButtonComponent,
|
|
2063
2180
|
BuyAccessButtonComponent,
|
|
@@ -2068,9 +2185,11 @@
|
|
|
2068
2185
|
ItemValidationSummaryComponent,
|
|
2069
2186
|
HtmlEditorComponent,
|
|
2070
2187
|
FormsHtmlEditorComponent,
|
|
2071
|
-
ContentHeaderComponent
|
|
2188
|
+
ContentHeaderComponent,
|
|
2189
|
+
//Directives
|
|
2190
|
+
NativeElementDirective
|
|
2072
2191
|
],
|
|
2073
|
-
|
|
2192
|
+
declarations: [
|
|
2074
2193
|
SubscribePlanButtonComponent,
|
|
2075
2194
|
UpgradePlanButtonComponent,
|
|
2076
2195
|
BuyAccessButtonComponent,
|
|
@@ -2081,8 +2200,10 @@
|
|
|
2081
2200
|
ItemValidationSummaryComponent,
|
|
2082
2201
|
HtmlEditorComponent,
|
|
2083
2202
|
FormsHtmlEditorComponent,
|
|
2084
|
-
ContentHeaderComponent
|
|
2085
|
-
|
|
2203
|
+
ContentHeaderComponent,
|
|
2204
|
+
//Directives
|
|
2205
|
+
NativeElementDirective
|
|
2206
|
+
]
|
|
2086
2207
|
},] }
|
|
2087
2208
|
];
|
|
2088
2209
|
|