@unifylib/ui-lib 1.0.3 → 1.1.3
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/ng-package.json +7 -7
- package/package.json +14 -12
- package/src/lib/base-model/SearchStrConfig.ts +12 -12
- package/src/lib/base-model/api-response.ts +23 -23
- package/src/lib/base-model/audit-log-entry.ts +7 -7
- package/src/lib/base-model/button-action-settings.ts +29 -25
- package/src/lib/base-model/column-def.model.ts +34 -34
- package/src/lib/base-model/do-action-request.ts +11 -11
- package/src/lib/base-model/feature-item.ts +9 -0
- package/src/lib/base-model/field-action.ts +7 -7
- package/src/lib/base-model/field-filter.model.ts +7 -14
- package/src/lib/base-model/field-info.ts +102 -98
- package/src/lib/base-model/field-predicate.model.ts +7 -7
- package/src/lib/base-model/filter-request.ts +27 -27
- package/src/lib/base-model/filter.model.ts +49 -49
- package/src/lib/base-model/get-items-list.ts +24 -24
- package/src/lib/base-model/index.ts +11 -11
- package/src/lib/base-model/items-total.model.ts +12 -0
- package/src/lib/base-model/line-item.model.ts +18 -0
- package/src/lib/base-model/lookupItem.ts +21 -21
- package/src/lib/base-model/null-snackmessage.ts +9 -9
- package/src/lib/base-model/page-info.ts +54 -51
- package/src/lib/base-model/report-request.model.ts +33 -33
- package/src/lib/base-model/response-envelop.model.ts +15 -15
- package/src/lib/base-model/snack-message.model.ts +14 -14
- package/src/lib/base-model/snackmessage-interface.ts +7 -7
- package/src/lib/base-model/table-column.interface.ts +29 -29
- package/src/lib/base-model/table-page-user-action.interface.ts +33 -33
- package/src/lib/base-model/workflow/workflow-steps.model.ts +9 -9
- package/src/lib/base-model/workflow/workflow.model.ts +52 -52
- package/src/lib/components/action-comment/action-comment.component.css +52 -0
- package/src/lib/components/action-comment/action-comment.component.html +47 -0
- package/src/lib/components/{rejection-comment → action-comment}/action-comment.component.spec.ts +23 -23
- package/src/lib/components/{rejection-comment → action-comment}/action-comment.component.ts +102 -86
- package/src/lib/components/action-confirmation/action-confirmation.component.css +46 -34
- package/src/lib/components/action-confirmation/action-confirmation.component.html +32 -18
- package/src/lib/components/action-confirmation/action-confirmation.component.spec.ts +23 -23
- package/src/lib/components/action-confirmation/action-confirmation.component.ts +58 -58
- package/src/lib/components/activity-report-form/activity-report-form.component.html +110 -109
- package/src/lib/components/activity-report-form/activity-report-form.component.scss +69 -0
- package/src/lib/components/activity-report-form/activity-report-form.component.spec.ts +25 -25
- package/src/lib/components/activity-report-form/activity-report-form.component.ts +616 -605
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.html +8 -0
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.scss +0 -0
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.spec.ts +25 -0
- package/src/lib/components/advanced-filter/field-filter/field-filter.component.ts +55 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.html +36 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.scss +130 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.spec.ts +25 -0
- package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.ts +186 -0
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.css +51 -51
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.html +23 -23
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.spec.ts +23 -23
- package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.ts +69 -69
- package/src/lib/components/audit-log-list/audit-log.component.html +26 -23
- package/src/lib/components/audit-log-list/audit-log.component.scss +50 -0
- package/src/lib/components/audit-log-list/audit-log.component.spec.ts +25 -25
- package/src/lib/components/audit-log-list/audit-log.component.ts +114 -116
- package/src/lib/components/auto-complete/auto-complete.component.css +55 -14
- package/src/lib/components/auto-complete/auto-complete.component.html +45 -29
- package/src/lib/components/auto-complete/auto-complete.component.spec.ts +23 -23
- package/src/lib/components/auto-complete/auto-complete.component.ts +331 -330
- package/src/lib/components/base-form/base-form.component.html +59 -58
- package/src/lib/components/base-form/base-form.component.scss +68 -0
- package/src/lib/components/base-form/base-form.component.spec.ts +25 -25
- package/src/lib/components/base-form/base-form.component.ts +323 -305
- package/src/lib/components/base-form-canvas/base-form-canvas.component.css +196 -22
- package/src/lib/components/base-form-canvas/base-form-canvas.component.html +1095 -1006
- package/src/lib/components/base-form-canvas/base-form-canvas.component.spec.ts +23 -23
- package/src/lib/components/base-form-canvas/base-form-canvas.component.ts +680 -573
- package/src/lib/components/base-input-dialog/base-input-dialog.component.css +67 -0
- package/src/lib/components/base-input-dialog/base-input-dialog.component.html +47 -42
- package/src/lib/components/base-input-dialog/base-input-dialog.component.spec.ts +23 -23
- package/src/lib/components/base-input-dialog/base-input-dialog.component.ts +77 -78
- package/src/lib/components/base-table/base-table.component.html +268 -242
- package/src/lib/components/base-table/base-table.component.scss +140 -31
- package/src/lib/components/base-table/base-table.component.spec.ts +25 -25
- package/src/lib/components/base-table/base-table.component.ts +621 -568
- package/src/lib/components/button-actions/button-actions.component.html +27 -28
- package/src/lib/components/button-actions/button-actions.component.scss +101 -6
- package/src/lib/components/button-actions/button-actions.component.spec.ts +23 -23
- package/src/lib/components/button-actions/button-actions.component.ts +70 -72
- package/src/lib/components/editable-base-table/editable-base-table.component.html +337 -372
- package/src/lib/components/editable-base-table/editable-base-table.component.scss +126 -44
- package/src/lib/components/editable-base-table/editable-base-table.component.spec.ts +25 -25
- package/src/lib/components/editable-base-table/editable-base-table.component.ts +579 -570
- package/src/lib/components/equation-builder/equation-builder.component.css +39 -0
- package/src/lib/components/equation-builder/equation-builder.component.html +31 -31
- package/src/lib/components/equation-builder/equation-builder.component.spec.ts +23 -23
- package/src/lib/components/equation-builder/equation-builder.component.ts +119 -121
- package/src/lib/components/item-line-editor/item-line-editor.component.html +102 -0
- package/src/lib/components/item-line-editor/item-line-editor.component.scss +152 -0
- package/src/lib/components/item-line-editor/item-line-editor.component.spec.ts +23 -0
- package/src/lib/components/item-line-editor/item-line-editor.component.ts +306 -0
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.css +19 -11
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.html +38 -38
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.spec.ts +23 -23
- package/src/lib/components/multi-auto-complete/multi-auto-complete.component.ts +315 -317
- package/src/lib/components/paginator/paginator.component.css +65 -25
- package/src/lib/components/paginator/paginator.component.html +30 -34
- package/src/lib/components/paginator/paginator.component.ts +87 -94
- package/src/lib/components/report-details-dialog/report-details-dialog.component.css +17 -17
- package/src/lib/components/report-details-dialog/report-details-dialog.component.html +16 -16
- package/src/lib/components/report-details-dialog/report-details-dialog.component.spec.ts +23 -23
- package/src/lib/components/report-details-dialog/report-details-dialog.component.ts +111 -113
- package/src/lib/components/report-form/report-form.component.html +92 -94
- package/src/lib/components/report-form/report-form.component.scss +51 -0
- package/src/lib/components/report-form/report-form.component.spec.ts +25 -25
- package/src/lib/components/report-form/report-form.component.ts +599 -588
- package/src/lib/components/search-bar/search-bar.component.html +51 -62
- package/src/lib/components/search-bar/search-bar.component.scss +63 -8
- package/src/lib/components/search-bar/search-bar.component.spec.ts +25 -25
- package/src/lib/components/search-bar/search-bar.component.ts +68 -70
- package/src/lib/components/section-form-canvas/section-form-canvas.component.html +43 -0
- package/src/lib/components/section-form-canvas/section-form-canvas.component.scss +81 -0
- package/src/lib/components/section-form-canvas/section-form-canvas.component.spec.ts +23 -0
- package/src/lib/components/section-form-canvas/section-form-canvas.component.ts +67 -0
- package/src/lib/components/shared/action-button/action-button.component.html +12 -0
- package/src/lib/components/shared/action-button/action-button.component.scss +45 -0
- package/src/lib/components/shared/action-button/action-button.component.ts +51 -0
- package/src/lib/components/shared/action-card/action-card.component.html +78 -0
- package/src/lib/components/shared/action-card/action-card.component.scss +238 -0
- package/src/lib/components/shared/action-card/action-card.component.ts +56 -0
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.css +135 -54
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.html +36 -22
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.spec.ts +23 -23
- package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.ts +71 -45
- package/src/lib/components/shared-list/shared-list.component.html +17 -17
- package/src/lib/components/shared-list/shared-list.component.spec.ts +23 -23
- package/src/lib/components/shared-list/shared-list.component.ts +53 -53
- package/src/lib/components/snackbar-static/snackbar-static.component.html +20 -0
- package/src/lib/components/snackbar-static/snackbar-static.component.scss +135 -0
- package/src/lib/components/snackbar-static/snackbar-static.component.ts +26 -0
- package/src/lib/components/title-bar/title-bar.component.html +35 -31
- package/src/lib/components/title-bar/title-bar.component.scss +126 -23
- package/src/lib/components/title-bar/title-bar.component.spec.ts +23 -23
- package/src/lib/components/title-bar/title-bar.component.ts +126 -119
- package/src/lib/services/backend-service.ts +287 -286
- package/src/lib/services/index.ts +3 -3
- package/src/lib/services/top-panel.ts +17 -17
- package/src/lib/services/trigger-form.service.ts +11 -11
- package/src/lib/share-module/shared-module.ts +10 -10
- package/src/lib/utils/base-utils.ts +102 -102
- package/src/lib/validators/date-range-validator.ts +31 -31
- package/src/lib/validators/index.ts +3 -3
- package/src/lib/validators/match-list.validator.ts +10 -10
- package/src/lib/validators/multi-email-validator.ts +15 -15
- package/src/public-api.ts +29 -21
- package/tsconfig.lib.json +15 -15
- package/tsconfig.lib.prod.json +11 -11
- package/tsconfig.spec.json +15 -15
- package/src/lib/components/rejection-comment/action-comment.component.css +0 -33
- package/src/lib/components/rejection-comment/action-comment.component.html +0 -46
- package/src/lib/styles/invoiceq-theme.scss +0 -252
- package/src/lib/styles/styles.scss +0 -1723
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
|
|
2
|
+
import {AbstractControl, FormsModule} from "@angular/forms";
|
|
3
|
+
import {CommonModule} from "@angular/common";
|
|
4
|
+
import {MatButtonModule} from "@angular/material/button";
|
|
5
|
+
import {MatIconModule} from "@angular/material/icon";
|
|
6
|
+
import {BaseFormCanvasComponent} from "../base-form-canvas/base-form-canvas.component";
|
|
7
|
+
import {FieldInfo, EMPTY_PAGE_INFO, PageInfo} from "../../base-model";
|
|
8
|
+
import {FormGroup} from "@angular/forms";
|
|
9
|
+
import {TranslateModule} from "@ngx-translate/core";
|
|
10
|
+
import {LineItem} from "../../base-model/line-item.model";
|
|
11
|
+
import {ItemsTotal} from "../../base-model/items-total.model";
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'app-item-line-editor',
|
|
14
|
+
templateUrl: './item-line-editor.component.html',
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [
|
|
17
|
+
CommonModule,
|
|
18
|
+
FormsModule,
|
|
19
|
+
MatButtonModule,
|
|
20
|
+
MatIconModule,
|
|
21
|
+
BaseFormCanvasComponent,
|
|
22
|
+
TranslateModule
|
|
23
|
+
],
|
|
24
|
+
styleUrls: ['./item-line-editor.component.scss']
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export class ItemLineEditorComponent implements OnChanges {
|
|
29
|
+
@Input() noDataFoundIcon: string;
|
|
30
|
+
@Input() noDataFoundTitle: string;
|
|
31
|
+
@Input() noDataFoundSubtitle: string;
|
|
32
|
+
|
|
33
|
+
@Input() pageInfo: PageInfo;
|
|
34
|
+
@Input() columnHeaderWidths: string[];
|
|
35
|
+
@Input() title: string;
|
|
36
|
+
@Input() subtitle: string;
|
|
37
|
+
@Input() allowAdd: boolean = true;
|
|
38
|
+
@Input() allowDelete: boolean = true;
|
|
39
|
+
@Input() editable: boolean = true;
|
|
40
|
+
@Input() currency: string;
|
|
41
|
+
@Input() fields: FieldInfo[] = [];
|
|
42
|
+
|
|
43
|
+
private baseFieldsSnapshot: FieldInfo[] | undefined;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@Input() items: LineItem[] = [this.blankItem()];
|
|
47
|
+
|
|
48
|
+
@Output() itemsChange = new EventEmitter<LineItem[]>();
|
|
49
|
+
@Output() itemSaved = new EventEmitter<{ index: number, item: any }>();
|
|
50
|
+
@Output() itemDeleted = new EventEmitter<{ index: number }>();
|
|
51
|
+
@Output() totalsChange = new EventEmitter<ItemsTotal>();
|
|
52
|
+
@Output() editStateChange = new EventEmitter<{ index: number, editing: boolean }>();
|
|
53
|
+
formRefs: (FormGroup | undefined)[] = [];
|
|
54
|
+
|
|
55
|
+
editing: boolean[] = [true];
|
|
56
|
+
noDataFound: boolean = false
|
|
57
|
+
|
|
58
|
+
get headerFields(): FieldInfo[] {
|
|
59
|
+
return (this.fields || []).filter(f => f.visible && f.row === 1 && f.type !== 'spacer');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get hasInvalidEditingForm(): boolean {
|
|
63
|
+
if (!this.formRefs || !this.editing) return false;
|
|
64
|
+
for (let i = 0; i < this.formRefs.length; i++) {
|
|
65
|
+
const frm = this.formRefs[i];
|
|
66
|
+
if (this.editing[i] && frm && frm.invalid) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get canAddNew(): boolean {
|
|
74
|
+
return !this.hasInvalidEditingForm;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
canSave(index: number): boolean {
|
|
78
|
+
const frm = this.formRefs?.[index];
|
|
79
|
+
if (!this.editing?.[index]) return true;
|
|
80
|
+
return !!frm && frm.valid;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
labelOf(field: FieldInfo): string {
|
|
84
|
+
const configuredKey = field.label ? field.label : field.property;
|
|
85
|
+
return configuredKey.startsWith(this.pageInfo.labelsSection)
|
|
86
|
+
? configuredKey
|
|
87
|
+
: `${this.pageInfo.labelsSection}.${configuredKey}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private blankItem() {
|
|
91
|
+
return { gtinCode: '', description: '', unitPrice: null, qty: null, discount: null, total: null };
|
|
92
|
+
}
|
|
93
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
94
|
+
if (changes['items'] && changes['items'].currentValue) {
|
|
95
|
+
const len = (this.items || []).length;
|
|
96
|
+
this.noDataFound = len <= 0;
|
|
97
|
+
if (changes['items'].firstChange) {
|
|
98
|
+
this.formRefs = new Array(len).fill(undefined);
|
|
99
|
+
this.editing = len > 0 ? new Array(len).fill(false) : [true];
|
|
100
|
+
} else {
|
|
101
|
+
const oldLen = this.editing?.length || 0;
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (!this.formRefs) this.formRefs = [];
|
|
105
|
+
if (this.formRefs.length > len) {
|
|
106
|
+
this.formRefs = this.formRefs.slice(0, len);
|
|
107
|
+
} else {
|
|
108
|
+
while (this.formRefs.length < len) this.formRefs.push(undefined);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if (!this.editing) this.editing = [];
|
|
113
|
+
if (this.editing.length > len) {
|
|
114
|
+
this.editing = this.editing.slice(0, len);
|
|
115
|
+
} else {
|
|
116
|
+
for (let i = this.editing.length; i < len; i++) {
|
|
117
|
+
this.editing[i] = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if (oldLen === 0 && len > 0 && this.editing[0] === undefined) {
|
|
123
|
+
this.editing[0] = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
this.emitTotals();
|
|
127
|
+
}
|
|
128
|
+
if (changes['fields'] && changes['fields'].currentValue) {
|
|
129
|
+
this.baseFieldsSnapshot = (this.fields || []).map(f => ({...f}));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onFormUpdated(form: FormGroup, index: number) {
|
|
134
|
+
const discountCtrl = form.get('discount');
|
|
135
|
+
|
|
136
|
+
if (discountCtrl) {
|
|
137
|
+
|
|
138
|
+
const existing = discountCtrl.validator ? [discountCtrl.validator] : [];
|
|
139
|
+
discountCtrl.setValidators([
|
|
140
|
+
...existing,
|
|
141
|
+
this.discountValidator(index)
|
|
142
|
+
]);
|
|
143
|
+
|
|
144
|
+
discountCtrl.updateValueAndValidity({ emitEvent: false });
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.formRefs[index] = form;
|
|
148
|
+
try {
|
|
149
|
+
const emittedItems = this.items.map((it, i) => {
|
|
150
|
+
if (i !== index) return it;
|
|
151
|
+
const v = this.getCurrentValues(i) || it || {};
|
|
152
|
+
const up = Number(v?.unitPrice || 0);
|
|
153
|
+
const q = Number(v?.qty || 0);
|
|
154
|
+
const disc = Number(v?.discount || 0);
|
|
155
|
+
const total = Math.max(0, up * q - disc);
|
|
156
|
+
return { ...it, ...v, total };
|
|
157
|
+
});
|
|
158
|
+
this.itemsChange.emit(emittedItems);
|
|
159
|
+
} catch (_e) {
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
this.emitTotals();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
addNewItem() {
|
|
166
|
+
this.items.push(this.blankItem());
|
|
167
|
+
this.formRefs.push(undefined);
|
|
168
|
+
this.editing.push(true);
|
|
169
|
+
|
|
170
|
+
this.restoreFieldsFromSnapshot();
|
|
171
|
+
this.itemsChange.emit([...this.items]);
|
|
172
|
+
this.editStateChange.emit({ index: this.items.length - 1, editing: true });
|
|
173
|
+
this.emitTotals();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
saveRow(index: number) {
|
|
177
|
+
|
|
178
|
+
const frm = this.formRefs?.[index];
|
|
179
|
+
if (this.editing[index] && frm && frm.invalid) {
|
|
180
|
+
|
|
181
|
+
Object.values(frm.controls).forEach(c => c.markAsTouched());
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const v = this.getCurrentValues(index);
|
|
185
|
+
if (!v) return;
|
|
186
|
+
this.items[index] = { ...v, total: this.calcLineTotal(index) };
|
|
187
|
+
|
|
188
|
+
this.editing[index] = false;
|
|
189
|
+
|
|
190
|
+
this.setFieldsReadonly(true);
|
|
191
|
+
this.itemsChange.emit([...this.items]);
|
|
192
|
+
this.itemSaved.emit({ index, item: this.items[index] });
|
|
193
|
+
this.editStateChange.emit({ index, editing: false });
|
|
194
|
+
this.emitTotals();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
deleteItem(index: number) {
|
|
198
|
+
if (index < 0 || index >= this.items.length) return;
|
|
199
|
+
this.items.splice(index, 1);
|
|
200
|
+
this.formRefs.splice(index, 1);
|
|
201
|
+
this.editing.splice(index, 1);
|
|
202
|
+
|
|
203
|
+
this.itemsChange.emit([...this.items]);
|
|
204
|
+
this.itemDeleted.emit({ index });
|
|
205
|
+
this.emitTotals();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
clearAll() {
|
|
209
|
+
this.items = [this.blankItem()];
|
|
210
|
+
this.formRefs = [undefined];
|
|
211
|
+
this.editing = [true];
|
|
212
|
+
this.itemsChange.emit([...this.items]);
|
|
213
|
+
this.emitTotals();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
getCurrentValues(index: number) {
|
|
217
|
+
const isEditing = this.editing[index];
|
|
218
|
+
const frm = this.formRefs[index];
|
|
219
|
+
|
|
220
|
+
const base = this.items[index] || {};
|
|
221
|
+
const src = (isEditing && frm) ? { ...base, ...frm.value } : { ...base };
|
|
222
|
+
if (!src) return null;
|
|
223
|
+
const val: any = { ...src };
|
|
224
|
+
val.unitPrice = val.unitPrice === null || val.unitPrice === '' ? null : Number(val.unitPrice);
|
|
225
|
+
val.qty = val.qty === null || val.qty === '' ? null : Number(val.qty);
|
|
226
|
+
val.discount = val.discount === null || val.discount === '' ? null : Number(val.discount);
|
|
227
|
+
return val;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
calcLineTotal(index: number): number {
|
|
231
|
+
const val = this.getCurrentValues(index);
|
|
232
|
+
if (!val) return Number(this.items[index]?.total || 0);
|
|
233
|
+
return Math.max(0, (val.unitPrice || 0) * (val.qty || 0) - (val.discount || 0));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
get subtotal(): number {
|
|
237
|
+
return this.items.reduce((s, _it, i) => {
|
|
238
|
+
const v = this.getCurrentValues(i);
|
|
239
|
+
const up = Number(v?.unitPrice || 0);
|
|
240
|
+
const q = Number(v?.qty || 0);
|
|
241
|
+
return s + (up * q);
|
|
242
|
+
}, 0);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
get discountTotal(): number {
|
|
246
|
+
return this.items.reduce((s, _it, i) => {
|
|
247
|
+
const v = this.getCurrentValues(i);
|
|
248
|
+
return s + Number(v?.discount || 0);
|
|
249
|
+
}, 0);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
get grandTotal(): number {
|
|
253
|
+
return this.items.reduce((s, _it, i) => s + this.calcLineTotal(i), 0);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
trackByIndex(index: number, _item: any) {
|
|
257
|
+
return index;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
editRow(index: number) {
|
|
261
|
+
this.editing[index] = true;
|
|
262
|
+
this.restoreFieldsFromSnapshot();
|
|
263
|
+
this.editStateChange.emit({ index, editing: true });
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private emitTotals() {
|
|
267
|
+
this.totalsChange.emit({
|
|
268
|
+
subtotal: this.subtotal,
|
|
269
|
+
discount: this.discountTotal,
|
|
270
|
+
grandTotal: this.grandTotal
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private setFieldsReadonly(state: boolean) {
|
|
275
|
+
this.fields = (this.fields || []).map(f => ({ ...f, readonly: state }));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private restoreFieldsFromSnapshot() {
|
|
279
|
+
if (this.baseFieldsSnapshot && this.baseFieldsSnapshot.length) {
|
|
280
|
+
this.fields = this.baseFieldsSnapshot.map(f => ({...f}));
|
|
281
|
+
} else {
|
|
282
|
+
this.setFieldsReadonly(false);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
get gridTemplate() {
|
|
287
|
+
return this.columnHeaderWidths.join(' ');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private discountValidator(index: number) {
|
|
291
|
+
return (control: AbstractControl) => {
|
|
292
|
+
const val = this.getCurrentValues(index);
|
|
293
|
+
if (!val) return null;
|
|
294
|
+
|
|
295
|
+
const totalBeforeDiscount = (val.unitPrice ?? 0) * (val.qty ?? 0);
|
|
296
|
+
const discount = val.discount ?? null;
|
|
297
|
+
|
|
298
|
+
if (discount != null && discount > totalBeforeDiscount) {
|
|
299
|
+
return { discountTooHigh: true };
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return null;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
::ng-deep .main-multi-auto {
|
|
2
|
-
|
|
3
|
-
.matField {
|
|
4
|
-
margin-bottom: 24px !important;
|
|
5
|
-
.mat-form-field-wrapper {
|
|
6
|
-
padding: 0 !important;
|
|
7
|
-
margin-bottom: 0 !important;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
::ng-deep .main-multi-auto {
|
|
2
|
+
|
|
3
|
+
.matField {
|
|
4
|
+
margin-bottom: 24px !important;
|
|
5
|
+
.mat-form-field-wrapper {
|
|
6
|
+
padding: 0 !important;
|
|
7
|
+
margin-bottom: 0 !important;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
.full-width {
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.chip-input {
|
|
16
|
+
flex: 1 1 auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
<ng-container *ngIf="this.field" class="main-multi-auto">
|
|
2
|
-
<div class="matField" (click)="this.filterLookupItems('', autocompleteTrigger)">
|
|
3
|
-
<mat-form-field
|
|
4
|
-
<mat-label>{{ getLabel() }}</mat-label>
|
|
5
|
-
<mat-chip-listbox #chipList [selectable]="true">
|
|
6
|
-
<mat-chip
|
|
7
|
-
*ngFor="let item of selectedItems"
|
|
8
|
-
[removable]="true"
|
|
9
|
-
(removed)="remove(item)">
|
|
10
|
-
{{ itemNameByLag(item) }}
|
|
11
|
-
<mat-icon matChipRemove>cancel</mat-icon>
|
|
12
|
-
</mat-chip>
|
|
13
|
-
<input class="
|
|
14
|
-
[id]="getId()" #itemInput
|
|
15
|
-
[formControl]="multiControl"
|
|
16
|
-
[matAutocomplete]="auto" matInput
|
|
17
|
-
[readonly]="readonly"
|
|
18
|
-
[required]="isRequired"
|
|
19
|
-
(keydown)="onKeydown($event, autocompleteTrigger)"
|
|
20
|
-
[disabled]="field.readonly"
|
|
21
|
-
#autocompleteTrigger="matAutocompleteTrigger"
|
|
22
|
-
>
|
|
23
|
-
</mat-chip-listbox>
|
|
24
|
-
|
|
25
|
-
<mat-icon class="arrow_drop_down_autocomplete">arrow_drop_down</mat-icon>
|
|
26
|
-
<mat-autocomplete #auto="matAutocomplete" autoActiveFirstOption [displayWith]="displayFn"
|
|
27
|
-
(optionSelected)="selected($event.option.value)">
|
|
28
|
-
<ng-container *ngIf="!field.readonly">
|
|
29
|
-
<mat-option *ngFor="let item of lookupItems$ | async" [value]="item"
|
|
30
|
-
[disabled]="field.readonly || isSelected(item)"
|
|
31
|
-
(click)="$event.stopPropagation(); autocompleteTrigger.openPanel()">
|
|
32
|
-
{{ itemNameByLag(item) }}
|
|
33
|
-
</mat-option>
|
|
34
|
-
</ng-container>
|
|
35
|
-
</mat-autocomplete>
|
|
36
|
-
</mat-form-field>
|
|
37
|
-
</div>
|
|
38
|
-
</ng-container>
|
|
1
|
+
<ng-container *ngIf="this.field" class="main-multi-auto">
|
|
2
|
+
<div class="matField" (click)="this.filterLookupItems('', autocompleteTrigger)">
|
|
3
|
+
<mat-form-field class="full-width" appearance="outline" floatLabel="always">
|
|
4
|
+
<mat-label>{{ getLabel() }}</mat-label>
|
|
5
|
+
<mat-chip-listbox #chipList [selectable]="true">
|
|
6
|
+
<mat-chip
|
|
7
|
+
*ngFor="let item of selectedItems"
|
|
8
|
+
[removable]="true"
|
|
9
|
+
(removed)="remove(item)">
|
|
10
|
+
{{ itemNameByLag(item) }}
|
|
11
|
+
<mat-icon matChipRemove>cancel</mat-icon>
|
|
12
|
+
</mat-chip>
|
|
13
|
+
<input class="chip-input" type="text"
|
|
14
|
+
[id]="getId()" #itemInput
|
|
15
|
+
[formControl]="multiControl"
|
|
16
|
+
[matAutocomplete]="auto" matInput
|
|
17
|
+
[readonly]="readonly"
|
|
18
|
+
[required]="isRequired"
|
|
19
|
+
(keydown)="onKeydown($event, autocompleteTrigger)"
|
|
20
|
+
[disabled]="field.readonly"
|
|
21
|
+
#autocompleteTrigger="matAutocompleteTrigger"
|
|
22
|
+
>
|
|
23
|
+
</mat-chip-listbox>
|
|
24
|
+
|
|
25
|
+
<mat-icon class="arrow_drop_down_autocomplete">arrow_drop_down</mat-icon>
|
|
26
|
+
<mat-autocomplete #auto="matAutocomplete" autoActiveFirstOption [displayWith]="displayFn"
|
|
27
|
+
(optionSelected)="selected($event.option.value)">
|
|
28
|
+
<ng-container *ngIf="!field.readonly">
|
|
29
|
+
<mat-option *ngFor="let item of lookupItems$ | async" [value]="item"
|
|
30
|
+
[disabled]="field.readonly || isSelected(item)"
|
|
31
|
+
(click)="$event.stopPropagation(); autocompleteTrigger.openPanel()">
|
|
32
|
+
{{ itemNameByLag(item) }}
|
|
33
|
+
</mat-option>
|
|
34
|
+
</ng-container>
|
|
35
|
+
</mat-autocomplete>
|
|
36
|
+
</mat-form-field>
|
|
37
|
+
</div>
|
|
38
|
+
</ng-container>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { MultiAutoCompleteComponent } from './multi-auto-complete.component';
|
|
4
|
-
|
|
5
|
-
describe('MultiAutoCompleteComponent', () => {
|
|
6
|
-
let component: MultiAutoCompleteComponent;
|
|
7
|
-
let fixture: ComponentFixture<MultiAutoCompleteComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
imports: [MultiAutoCompleteComponent]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
|
|
15
|
-
fixture = TestBed.createComponent(MultiAutoCompleteComponent);
|
|
16
|
-
component = fixture.componentInstance;
|
|
17
|
-
fixture.detectChanges();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should create', () => {
|
|
21
|
-
expect(component).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { MultiAutoCompleteComponent } from './multi-auto-complete.component';
|
|
4
|
+
|
|
5
|
+
describe('MultiAutoCompleteComponent', () => {
|
|
6
|
+
let component: MultiAutoCompleteComponent;
|
|
7
|
+
let fixture: ComponentFixture<MultiAutoCompleteComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [MultiAutoCompleteComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(MultiAutoCompleteComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|