ngx-techlify-core 11.2.4 → 11.2.8
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/ngx-techlify-core.umd.js +52 -35
- package/bundles/ngx-techlify-core.umd.js.map +1 -1
- package/bundles/ngx-techlify-core.umd.min.js +2 -2
- package/bundles/ngx-techlify-core.umd.min.js.map +1 -1
- package/esm2015/lib/core/error-handler.service.js +14 -12
- package/esm2015/lib/note/note-form/note-form.component.js +4 -3
- package/esm2015/lib/note/note-list/note-list.component.js +12 -11
- package/esm2015/lib/searchable-selector/searchable-selector.component.js +7 -2
- package/esm2015/lib/timeline-filter/calculate-timeline.js +3 -3
- package/esm2015/lib/timeline-filter/timeline-filter.component.js +11 -4
- package/fesm2015/ngx-techlify-core.js +45 -28
- package/fesm2015/ngx-techlify-core.js.map +1 -1
- package/lib/note/note-list/note-list.component.d.ts +2 -3
- package/lib/searchable-selector/searchable-selector.component.d.ts +1 -0
- package/lib/timeline-filter/timeline-filter.component.d.ts +4 -0
- package/ngx-techlify-core.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -865,25 +865,27 @@
|
|
|
865
865
|
}
|
|
866
866
|
ErrorHandlerService.prototype.handleError = function (errorResponse, msg) {
|
|
867
867
|
if (msg === void 0) { msg = ''; }
|
|
868
|
-
var _a;
|
|
868
|
+
var _a, _b, _c, _d;
|
|
869
869
|
// 1 - Create empty array to store errors
|
|
870
870
|
var errors = [];
|
|
871
871
|
// 2 - check if the error object is present in the response
|
|
872
|
-
if (errorResponse.error) {
|
|
873
|
-
// 3 -
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
if (errorResponse.error.errors) {
|
|
877
|
-
// 5 - For each error property (which is a form field)
|
|
872
|
+
if (errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error) {
|
|
873
|
+
// 3 - Check for Laravel form validation error messages object
|
|
874
|
+
if ((_a = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error) === null || _a === void 0 ? void 0 : _a.errors) {
|
|
875
|
+
// 4 - For each error property (which is a form field)
|
|
878
876
|
for (var property in errorResponse.error.errors) {
|
|
879
|
-
if (errorResponse.error.errors.hasOwnProperty(property)) {
|
|
880
|
-
//
|
|
881
|
-
var propertyErrors = errorResponse.error.errors[property];
|
|
882
|
-
//
|
|
877
|
+
if ((_b = errorResponse.error.errors) === null || _b === void 0 ? void 0 : _b.hasOwnProperty(property)) {
|
|
878
|
+
// 5 - Extract it's array of errors
|
|
879
|
+
var propertyErrors = (_c = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.error) === null || _c === void 0 ? void 0 : _c.errors[property];
|
|
880
|
+
// 6 - Push all errors in the array to the errors array
|
|
883
881
|
propertyErrors.forEach(function (error) { return errors.push(error); });
|
|
884
882
|
}
|
|
885
883
|
}
|
|
886
884
|
}
|
|
885
|
+
if (errors.length === 0) {
|
|
886
|
+
// 7 - Push the main error message to the array of errors if there is no validation error
|
|
887
|
+
errors.push(errorResponse.error.message ? errorResponse.error.message : (_d = errorResponse.error) === null || _d === void 0 ? void 0 : _d.error);
|
|
888
|
+
}
|
|
887
889
|
}
|
|
888
890
|
var errMessage = errors.length ? errors[0] : msg;
|
|
889
891
|
this.alerter.addAlert("Error: " + errMessage, "warning");
|
|
@@ -1935,10 +1937,11 @@
|
|
|
1935
1937
|
};
|
|
1936
1938
|
//Method to trigger login
|
|
1937
1939
|
NoteFormComponent.prototype.submit = function () {
|
|
1940
|
+
var _a;
|
|
1938
1941
|
return __awaiter(this, void 0, void 0, function () {
|
|
1939
|
-
var model, result,
|
|
1940
|
-
return __generator(this, function (
|
|
1941
|
-
switch (
|
|
1942
|
+
var model, result, _b;
|
|
1943
|
+
return __generator(this, function (_c) {
|
|
1944
|
+
switch (_c.label) {
|
|
1942
1945
|
case 0:
|
|
1943
1946
|
this.noteFormFirstAttempt = true;
|
|
1944
1947
|
if (!this.noteFormGroup.valid) return [3 /*break*/, 5];
|
|
@@ -1946,17 +1949,17 @@
|
|
|
1946
1949
|
if (!this.updateMode) return [3 /*break*/, 2];
|
|
1947
1950
|
return [4 /*yield*/, this.noteService.editNote(model)];
|
|
1948
1951
|
case 1:
|
|
1949
|
-
|
|
1952
|
+
_b = _c.sent();
|
|
1950
1953
|
return [3 /*break*/, 4];
|
|
1951
1954
|
case 2: return [4 /*yield*/, this.noteService.addNote(model)];
|
|
1952
1955
|
case 3:
|
|
1953
|
-
|
|
1954
|
-
|
|
1956
|
+
_b = _c.sent();
|
|
1957
|
+
_c.label = 4;
|
|
1955
1958
|
case 4:
|
|
1956
|
-
result =
|
|
1957
|
-
this.alertService.addAlert("
|
|
1959
|
+
result = _b;
|
|
1960
|
+
this.alertService.addAlert(((_a = this.data) === null || _a === void 0 ? void 0 : _a.labelText) + " saved successfully", "success");
|
|
1958
1961
|
this.dialogRef.close(result);
|
|
1959
|
-
|
|
1962
|
+
_c.label = 5;
|
|
1960
1963
|
case 5: return [2 /*return*/];
|
|
1961
1964
|
}
|
|
1962
1965
|
});
|
|
@@ -1978,7 +1981,7 @@
|
|
|
1978
1981
|
NoteFormComponent.decorators = [
|
|
1979
1982
|
{ type: i0.Component, args: [{
|
|
1980
1983
|
selector: 'app-note-form',
|
|
1981
|
-
template: "<form [formGroup]=\"noteFormGroup\" (ngSubmit)=\"submit()\">\n <div fxLayout=\"column\" class=\"mat-typography\">\n <div mat-dialog-title class=\"text-center\">\n <div>
|
|
1984
|
+
template: "<form [formGroup]=\"noteFormGroup\" (ngSubmit)=\"submit()\">\n <div fxLayout=\"column\" class=\"mat-typography\">\n <div mat-dialog-title class=\"text-center\">\n <div>{{data?.labelText}}</div>\n </div>\n\n <div mat-dialog-content fxLayout=\"column\">\n <div fxLayout=\"row wrap\" fxLayoutAlign=\"space-between\">\n <mat-form-field fxFlex=\"100%\">\n <textarea matInput formControlName=\"note\" placeholder=\"{{data?.labelText}}\" autocomplete=\"off\"\n required></textarea>\n <mat-error *ngIf=\"isFieldValid('note')\">{{\n getErrorMessage(\"note\")\n }}</mat-error>\n </mat-form-field>\n\n <div class=\"my-2\" fxLayout=\"row\" fxLayoutGap=\"30px\" fxLayoutAlign=\"end\" fxFlex=\"100%\">\n <button mat-raised-button type=\"button\" (click)=\"cancel()\">\n Cancel\n </button>\n <button mat-raised-button type=\"submit\" color=\"primary\">Save</button>\n </div>\n </div>\n </div>\n </div>\n</form>",
|
|
1982
1985
|
styles: [""]
|
|
1983
1986
|
},] }
|
|
1984
1987
|
];
|
|
@@ -1992,11 +1995,11 @@
|
|
|
1992
1995
|
]; };
|
|
1993
1996
|
|
|
1994
1997
|
var NoteListComponent = /** @class */ (function () {
|
|
1995
|
-
function NoteListComponent(noteService,
|
|
1998
|
+
function NoteListComponent(noteService, dialog) {
|
|
1996
1999
|
this.noteService = noteService;
|
|
1997
|
-
this.alertService = alertService;
|
|
1998
2000
|
this.dialog = dialog;
|
|
1999
2001
|
this.readonly = false;
|
|
2002
|
+
this.labelText = 'Note';
|
|
2000
2003
|
this.notes = [];
|
|
2001
2004
|
this.displayedColumns = [
|
|
2002
2005
|
'index',
|
|
@@ -2037,7 +2040,8 @@
|
|
|
2037
2040
|
var dialogRef = this.dialog.open(NoteFormComponent, {
|
|
2038
2041
|
width: "400px",
|
|
2039
2042
|
data: {
|
|
2040
|
-
note: { related_model_id: this.relatedModelId, model_type: this.modelType }
|
|
2043
|
+
note: { related_model_id: this.relatedModelId, model_type: this.modelType },
|
|
2044
|
+
labelText: this.labelText,
|
|
2041
2045
|
},
|
|
2042
2046
|
autoFocus: false
|
|
2043
2047
|
});
|
|
@@ -2054,7 +2058,8 @@
|
|
|
2054
2058
|
width: "400px",
|
|
2055
2059
|
data: {
|
|
2056
2060
|
note: note,
|
|
2057
|
-
update: true
|
|
2061
|
+
update: true,
|
|
2062
|
+
labelText: this.labelText
|
|
2058
2063
|
},
|
|
2059
2064
|
autoFocus: false
|
|
2060
2065
|
});
|
|
@@ -2073,8 +2078,8 @@
|
|
|
2073
2078
|
dialogRef = this.dialog.open(ActionPopupComponent, {
|
|
2074
2079
|
width: "400px",
|
|
2075
2080
|
data: {
|
|
2076
|
-
title: "Delete
|
|
2077
|
-
message: "Are you sure to delete
|
|
2081
|
+
title: "Delete " + this.labelText,
|
|
2082
|
+
message: "Are you sure to delete?"
|
|
2078
2083
|
},
|
|
2079
2084
|
autoFocus: false
|
|
2080
2085
|
});
|
|
@@ -2113,19 +2118,19 @@
|
|
|
2113
2118
|
NoteListComponent.decorators = [
|
|
2114
2119
|
{ type: i0.Component, args: [{
|
|
2115
2120
|
selector: 'app-note-list',
|
|
2116
|
-
template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\">\n\n <div fxLayout fxLayoutAlign=\"
|
|
2121
|
+
template: "<div fxLayout=\"column\" fxLayoutGap=\"1.5rem\" class=\"m-4\">\n\n <div fxLayout fxLayoutAlign=\"center center\" fxLayoutGap=\"1rem\">\n <h3 class=\"m-0 font-weight-bold mr-3\">{{labelText}}s</h3>\n <button class=\"d-print-none\" *ngIf=\"!readonly\" mat-raised-button color=\"primary\" type=\"button\"\n (click)=\"addNote()\">+ Add</button>\n </div>\n\n <div class=\"w-00 scroll-container\" infiniteScroll [infiniteScrollDistance]=\"1\" [infiniteScrollThrottle]=\"50\"\n (scrolled)=\"onScroll()\" [scrollWindow]=\"false\">\n <table mat-table [dataSource]=\"notes\" class=\"w-100\" multiTemplateDataRows>\n\n <!-- Index Column -->\n <ng-container matColumnDef=\"index\">\n <th mat-header-cell *matHeaderCellDef> # </th>\n <td mat-cell *matCellDef=\"let note; let i = dataIndex\"> {{ i+1 }} </td>\n </ng-container>\n\n\n <ng-container matColumnDef=\"note\">\n <th mat-header-cell *matHeaderCellDef> {{labelText}} </th>\n <td mat-cell *matCellDef=\"let note\">\n {{note?.note}}\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"actions\">\n <th mat-header-cell *matHeaderCellDef class=\"d-print-none\"> Actions </th>\n <td mat-cell *matCellDef=\"let note\" class=\"d-print-none\">\n <button type=\"button\" mat-icon-button (click)=\"editNote(note)\">\n <mat-icon>edit</mat-icon>\n </button>\n <button type=\"button\" mat-icon-button (click)=\"deleteNote(note)\">\n <mat-icon>delete</mat-icon>\n </button>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n </table>\n </div>\n\n</div>",
|
|
2117
2122
|
styles: [".scroll-container{max-height:400px;overflow-y:auto}"]
|
|
2118
2123
|
},] }
|
|
2119
2124
|
];
|
|
2120
2125
|
NoteListComponent.ctorParameters = function () { return [
|
|
2121
2126
|
{ type: NoteService },
|
|
2122
|
-
{ type: AlertService },
|
|
2123
2127
|
{ type: dialog.MatDialog }
|
|
2124
2128
|
]; };
|
|
2125
2129
|
NoteListComponent.propDecorators = {
|
|
2126
2130
|
relatedModelId: [{ type: i0.Input }],
|
|
2127
2131
|
modelType: [{ type: i0.Input }],
|
|
2128
|
-
readonly: [{ type: i0.Input }]
|
|
2132
|
+
readonly: [{ type: i0.Input }],
|
|
2133
|
+
labelText: [{ type: i0.Input }]
|
|
2129
2134
|
};
|
|
2130
2135
|
|
|
2131
2136
|
var SearchableSelectorComponent_1;
|
|
@@ -2146,6 +2151,7 @@
|
|
|
2146
2151
|
this.edit = false;
|
|
2147
2152
|
this.sort = true;
|
|
2148
2153
|
this.selectionChange = new i0.EventEmitter();
|
|
2154
|
+
this.itemsChange = new i0.EventEmitter();
|
|
2149
2155
|
this.isLoading = false;
|
|
2150
2156
|
this.onChange = function () { };
|
|
2151
2157
|
this.onTouched = function () { };
|
|
@@ -2234,7 +2240,10 @@
|
|
|
2234
2240
|
items = __spread([this.selectedValue], this.items);
|
|
2235
2241
|
else
|
|
2236
2242
|
items = this.items;
|
|
2237
|
-
|
|
2243
|
+
items = items.filter(function (v, i, a) { return a.findIndex(function (v) { return v[_this.valueField] === a[i][_this.valueField]; }) === i; });
|
|
2244
|
+
//Emit the items to any child component
|
|
2245
|
+
this.itemsChange.emit(items);
|
|
2246
|
+
return items;
|
|
2238
2247
|
},
|
|
2239
2248
|
enumerable: false,
|
|
2240
2249
|
configurable: true
|
|
@@ -2411,6 +2420,7 @@
|
|
|
2411
2420
|
searchField: [{ type: i0.Input }],
|
|
2412
2421
|
itemComponent: [{ type: i0.Input }],
|
|
2413
2422
|
selectionChange: [{ type: i0.Output }],
|
|
2423
|
+
itemsChange: [{ type: i0.Output }],
|
|
2414
2424
|
required: [{ type: i0.Input }],
|
|
2415
2425
|
disabled: [{ type: i0.Input }],
|
|
2416
2426
|
value: [{ type: i0.Input }]
|
|
@@ -2618,12 +2628,12 @@
|
|
|
2618
2628
|
};
|
|
2619
2629
|
|
|
2620
2630
|
function calculateTimeline(value) {
|
|
2631
|
+
var date = new Date();
|
|
2621
2632
|
var data = {
|
|
2622
2633
|
'date_from': date,
|
|
2623
2634
|
'date_to': date,
|
|
2624
2635
|
'show_custom_field': false
|
|
2625
2636
|
};
|
|
2626
|
-
var date = new Date();
|
|
2627
2637
|
switch (value) {
|
|
2628
2638
|
case 1: { //Custom
|
|
2629
2639
|
data.show_custom_field = true;
|
|
@@ -2741,10 +2751,14 @@
|
|
|
2741
2751
|
{ value: 11, viewValue: 'Last Year' },
|
|
2742
2752
|
{ value: 12, viewValue: 'All dates' },
|
|
2743
2753
|
];
|
|
2754
|
+
this.labelText = 'Select Timeline';
|
|
2755
|
+
this.dateFrom = 'date_from';
|
|
2756
|
+
this.dateTo = 'date_to';
|
|
2744
2757
|
this.showCustomDateFields = false;
|
|
2745
2758
|
}
|
|
2746
2759
|
Object.defineProperty(TimelineFilterComponent.prototype, "defaultValue", {
|
|
2747
2760
|
set: function (value) {
|
|
2761
|
+
this.timelineValue = value;
|
|
2748
2762
|
this.changeTimeline(value);
|
|
2749
2763
|
},
|
|
2750
2764
|
enumerable: false,
|
|
@@ -2764,8 +2778,8 @@
|
|
|
2764
2778
|
TimelineFilterComponent.prototype.changeTimeline = function (value) {
|
|
2765
2779
|
var timeline = calculateTimeline(value);
|
|
2766
2780
|
if (timeline) {
|
|
2767
|
-
this.setFieldValue(
|
|
2768
|
-
this.setFieldValue(
|
|
2781
|
+
this.setFieldValue(this.dateFrom, timeline.date_from);
|
|
2782
|
+
this.setFieldValue(this.dateTo, timeline.date_to);
|
|
2769
2783
|
this.showCustomDateFields = timeline.show_custom_field;
|
|
2770
2784
|
}
|
|
2771
2785
|
};
|
|
@@ -2774,13 +2788,16 @@
|
|
|
2774
2788
|
TimelineFilterComponent.decorators = [
|
|
2775
2789
|
{ type: i0.Component, args: [{
|
|
2776
2790
|
selector: 'app-timeline-filter',
|
|
2777
|
-
template: "<ng-container [formGroup]=\"form\">\n <mat-form-field>\n <mat-label>
|
|
2791
|
+
template: "<ng-container [formGroup]=\"form\">\n <mat-form-field>\n <mat-label>{{labelText}}</mat-label>\n <mat-select (selectionChange)=\"changeTimeline($event.value)\" [value]=\"timelineValue\">\n <mat-option *ngFor=\"let timeline of timelines\" [value]=\"timeline.value\">\n {{timeline.viewValue}}\n </mat-option>\n </mat-select>\n </mat-form-field>\n\n <ng-container *ngIf=\"showCustomDateFields\">\n <mat-form-field>\n <input matInput formControlName=\"{{dateFrom}}\" [matDatepicker]=\"fromPicker\" (click)=\"fromPicker.open()\"\n placeholder=\"From Date\" readonly />\n <mat-datepicker-toggle matSuffix [for]=\"fromPicker\"></mat-datepicker-toggle>\n <mat-datepicker #fromPicker></mat-datepicker>\n <button mat-button *ngIf=\"getFieldValue(dateFrom)\" matSuffix mat-icon-button\n (click)=\"resetFieldValue(dateFrom)\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n\n <mat-form-field>\n <input matInput formControlName=\"{{dateTo}}\" [matDatepicker]=\"toPicker\" (click)=\"toPicker.open()\"\n placeholder=\"To Date\" readonly />\n <mat-datepicker-toggle matSuffix [for]=\"\"></mat-datepicker-toggle>\n <mat-datepicker #toPicker></mat-datepicker>\n <button mat-button *ngIf=\"getFieldValue(dateTo)\" matSuffix mat-icon-button\n (click)=\"resetFieldValue(dateTo)\">\n <mat-icon>close</mat-icon>\n </button>\n </mat-form-field>\n\n </ng-container>\n</ng-container>",
|
|
2778
2792
|
styles: [""]
|
|
2779
2793
|
},] }
|
|
2780
2794
|
];
|
|
2781
2795
|
TimelineFilterComponent.ctorParameters = function () { return []; };
|
|
2782
2796
|
TimelineFilterComponent.propDecorators = {
|
|
2783
2797
|
timelines: [{ type: i0.Input }],
|
|
2798
|
+
labelText: [{ type: i0.Input }],
|
|
2799
|
+
dateFrom: [{ type: i0.Input }],
|
|
2800
|
+
dateTo: [{ type: i0.Input }],
|
|
2784
2801
|
form: [{ type: i0.Input }],
|
|
2785
2802
|
defaultValue: [{ type: i0.Input }]
|
|
2786
2803
|
};
|