@yomotech/view-toolkit 0.0.31 → 0.0.32
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 -0
- package/package.json +38 -49
- package/src/lib/app-version.ts +2 -0
- package/src/lib/components/autocomplete/autocomplete.css +0 -0
- package/src/lib/components/autocomplete/autocomplete.html +23 -0
- package/src/lib/components/autocomplete/autocomplete.ts +71 -0
- package/src/lib/components/button/button.css +0 -0
- package/src/lib/components/button/button.html +1 -0
- package/src/lib/components/button/button.ts +11 -0
- package/src/lib/components/date/date.css +0 -0
- package/src/lib/components/date/date.html +1 -0
- package/src/lib/components/date/date.ts +11 -0
- package/src/lib/components/dropdown/dropdown.css +0 -0
- package/src/lib/components/dropdown/dropdown.html +1 -0
- package/src/lib/components/dropdown/dropdown.ts +11 -0
- package/src/lib/components/error-message/error-message.css +0 -0
- package/src/lib/components/error-message/error-message.html +1 -0
- package/src/lib/components/error-message/error-message.ts +11 -0
- package/src/lib/components/label/label.css +0 -0
- package/src/lib/components/label/label.html +7 -0
- package/src/lib/components/label/label.ts +33 -0
- package/src/lib/components/string/string.css +0 -0
- package/src/lib/components/string/string.html +4 -0
- package/src/lib/components/string/string.ts +22 -0
- package/src/lib/components/textbox/textbox.css +0 -0
- package/src/lib/components/textbox/textbox.html +7 -0
- package/src/lib/components/textbox/textbox.ts +33 -0
- package/src/lib/components/time/time.css +0 -0
- package/src/lib/components/time/time.html +1 -0
- package/src/lib/components/time/time.ts +11 -0
- package/src/lib/containers/card/card.component.css +0 -0
- package/src/lib/containers/card/card.component.html +450 -0
- package/src/lib/containers/card/card.component.ts +474 -0
- package/src/lib/containers/form/form.component.css +101 -0
- package/src/lib/containers/form/form.component.html +305 -0
- package/src/lib/containers/form/form.component.ts +333 -0
- package/src/lib/containers/grid/grid.component.css +0 -0
- package/src/lib/containers/grid/grid.component.html +212 -0
- package/src/lib/containers/grid/grid.component.ts +228 -0
- package/src/lib/containers/header-menu/header-menu.component.css +0 -0
- package/src/lib/containers/header-menu/header-menu.component.html +72 -0
- package/src/lib/containers/header-menu/header-menu.component.ts +105 -0
- package/src/lib/containers/logs/logs.component.css +160 -0
- package/src/lib/containers/logs/logs.component.html +89 -0
- package/src/lib/containers/logs/logs.component.ts +29 -0
- package/src/lib/containers/model/model.component.css +0 -0
- package/src/lib/containers/model/model.component.html +351 -0
- package/src/lib/containers/model/model.component.ts +436 -0
- package/src/lib/containers/pagination/pagination.component.css +0 -0
- package/src/lib/containers/pagination/pagination.component.html +41 -0
- package/src/lib/containers/pagination/pagination.component.ts +100 -0
- package/src/lib/containers/side-menu/side-menu.component.css +173 -0
- package/src/lib/containers/side-menu/side-menu.component.html +126 -0
- package/src/lib/containers/side-menu/side-menu.component.ts +458 -0
- package/src/lib/services/app-version-reset.service.ts +59 -0
- package/src/lib/services/config.service.ts +144 -0
- package/src/lib/services/couchdb.ts +275 -0
- package/src/lib/services/mobile-keycloak.service.ts +116 -0
- package/src/lib/services/network-log.service.ts +27 -0
- package/src/lib/services/notification.service.ts +26 -0
- package/src/lib/services/request.service.ts +125 -0
- package/src/lib/services/utility.service.ts +600 -0
- package/src/lib/view-toolkit.module.ts +57 -0
- package/src/lib/view-toolkit.spec.ts +23 -0
- package/src/lib/view-toolkit.ts +15 -0
- package/src/public-api.ts +25 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/fesm2022/yomotech-view-toolkit.mjs +0 -3597
- package/fesm2022/yomotech-view-toolkit.mjs.map +0 -1
- package/types/yomotech-view-toolkit.d.ts +0 -648
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, Output } from '@angular/core';
|
|
3
|
+
import { FormsModule } from '@angular/forms';
|
|
4
|
+
import { UtilityService } from '../../services/utility.service';
|
|
5
|
+
import { RequestService } from '../../services/request.service';
|
|
6
|
+
|
|
7
|
+
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
8
|
+
import { SimpleChanges } from '@angular/core';
|
|
9
|
+
import { OAuthService } from 'angular-oauth2-oidc';
|
|
10
|
+
import { CapacitorHttp } from '@capacitor/core';
|
|
11
|
+
|
|
12
|
+
import { NzIconModule } from 'ng-zorro-antd/icon';
|
|
13
|
+
import { NzButtonModule } from 'ng-zorro-antd/button';
|
|
14
|
+
import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
|
|
15
|
+
import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal';
|
|
16
|
+
|
|
17
|
+
import { DatePickerModule } from 'primeng/datepicker';
|
|
18
|
+
import { Platform } from '@angular/cdk/platform';
|
|
19
|
+
import { PaginationComponent } from '../pagination/pagination.component';
|
|
20
|
+
import { String as StringComponent } from '../../components/string/string';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@Component({
|
|
24
|
+
selector: 'vl-card',
|
|
25
|
+
imports: [
|
|
26
|
+
CommonModule,
|
|
27
|
+
FormsModule,
|
|
28
|
+
NzIconModule,
|
|
29
|
+
DatePickerModule,
|
|
30
|
+
NzButtonModule,
|
|
31
|
+
NzDatePickerModule,
|
|
32
|
+
NzModalModule,
|
|
33
|
+
// StringComponent,
|
|
34
|
+
PaginationComponent,
|
|
35
|
+
StringComponent
|
|
36
|
+
],
|
|
37
|
+
standalone: true,
|
|
38
|
+
templateUrl: './card.component.html',
|
|
39
|
+
styleUrl: './card.component.css',
|
|
40
|
+
})
|
|
41
|
+
export class CardComponent {
|
|
42
|
+
@Input() itemInfo: any = {};
|
|
43
|
+
@Input() currentPage: number = 0;
|
|
44
|
+
@Input() pageSize: number = 5;
|
|
45
|
+
@Input() selectedLanguageInfo: any = {};
|
|
46
|
+
@Input() mobileDisplay: boolean = false;
|
|
47
|
+
@Input() pages: number[] = [];
|
|
48
|
+
@Output() cardButtonClick: EventEmitter<any> = new EventEmitter();
|
|
49
|
+
@Output() cardHeaderButtonClick: EventEmitter<any> = new EventEmitter();
|
|
50
|
+
@Output() linkDetails: EventEmitter<any> = new EventEmitter();
|
|
51
|
+
@Output() imageDetails: EventEmitter<any> = new EventEmitter();
|
|
52
|
+
@Output() onPageSizeChange: EventEmitter<any> = new EventEmitter();
|
|
53
|
+
@Output() onPageChange: EventEmitter<any> = new EventEmitter();
|
|
54
|
+
cardPerRow: string = "md:col-6 lg:col-";
|
|
55
|
+
isLoading: boolean = false;
|
|
56
|
+
layoutSchemaCopy: any = {};
|
|
57
|
+
headerSchemaCopy: any = {};
|
|
58
|
+
footerSchemaCopy: any = {};
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
constructor(
|
|
62
|
+
private utilityService: UtilityService,
|
|
63
|
+
private platform: Platform,
|
|
64
|
+
private http: HttpClient,
|
|
65
|
+
private cdr: ChangeDetectorRef,
|
|
66
|
+
private zone: NgZone,
|
|
67
|
+
private modalService: NzModalService,
|
|
68
|
+
private oauthService: OAuthService,
|
|
69
|
+
private requestService: RequestService) {
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ngOnInit() {
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
76
|
+
if ((this.platform.ANDROID || this.platform.IOS) && !this.platform?.isBrowser) {
|
|
77
|
+
this.mobileDisplay = true;
|
|
78
|
+
}
|
|
79
|
+
if (changes['itemInfo']) {
|
|
80
|
+
if (this.itemInfo.layoutSchema) {
|
|
81
|
+
this.layoutSchemaCopy = JSON.parse(JSON.stringify(this.itemInfo.layoutSchema));
|
|
82
|
+
}
|
|
83
|
+
if (this.itemInfo.header) {
|
|
84
|
+
this.headerSchemaCopy = JSON.parse(JSON.stringify(this.itemInfo.header));
|
|
85
|
+
}
|
|
86
|
+
if (this.itemInfo.footer) {
|
|
87
|
+
this.footerSchemaCopy = JSON.parse(JSON.stringify(this.itemInfo.footer));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if ((changes['selectedLanguageInfo'] || this.selectedLanguageInfo) && this.selectedLanguageInfo.selectedLanguage) {
|
|
91
|
+
this.itemInfo.footer = this.updatebuttonLanguage(this.footerSchemaCopy, this.selectedLanguageInfo.selectedLanguage)
|
|
92
|
+
this.itemInfo.header = this.updatebuttonLanguage(this.headerSchemaCopy, this.selectedLanguageInfo.selectedLanguage)
|
|
93
|
+
this.itemInfo.layoutSchema = this.updateLayoutLanguage(this.layoutSchemaCopy, this.selectedLanguageInfo.selectedLanguage)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private safeUpdate(fn: () => void) {
|
|
98
|
+
if (NgZone.isInAngularZone()) {
|
|
99
|
+
fn();
|
|
100
|
+
this.cdr.markForCheck();
|
|
101
|
+
} else {
|
|
102
|
+
this.zone.run(() => {
|
|
103
|
+
fn();
|
|
104
|
+
this.cdr.markForCheck();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
forceNumericKeyboard(event: any) {
|
|
110
|
+
const input = event?.target as HTMLInputElement;
|
|
111
|
+
if (input && input.tagName === 'INPUT') {
|
|
112
|
+
input.setAttribute('inputmode', 'numeric'); // Android
|
|
113
|
+
input.setAttribute('pattern', '[0-9:]*'); // iOS
|
|
114
|
+
input.setAttribute('type', 'tel'); // strongest signal
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
onDateTyping(event: any) {
|
|
119
|
+
const input = event.target as HTMLInputElement;
|
|
120
|
+
if (!input) return;
|
|
121
|
+
let digits = input.value.replace(/\D/g, '');
|
|
122
|
+
digits = digits.substring(0, 8);
|
|
123
|
+
let formatted = '';
|
|
124
|
+
if (digits.length <= 4) {
|
|
125
|
+
formatted = digits;
|
|
126
|
+
} else if (digits.length <= 6) {
|
|
127
|
+
formatted = `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
128
|
+
} else {
|
|
129
|
+
formatted = `${digits.slice(0, 4)}-${digits.slice(4, 6)}-${digits.slice(6)}`;
|
|
130
|
+
}
|
|
131
|
+
input.value = formatted;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
updatebuttonLanguage<T>(
|
|
135
|
+
schema: T,
|
|
136
|
+
translations: Record<string, string>
|
|
137
|
+
): T {
|
|
138
|
+
const cloned = JSON.parse(JSON.stringify(schema));
|
|
139
|
+
|
|
140
|
+
const walk = (obj: any) => {
|
|
141
|
+
if (!obj || typeof obj !== 'object') return;
|
|
142
|
+
|
|
143
|
+
// ✅ Replace direct caption (e.g. button.caption)
|
|
144
|
+
if (typeof obj.caption === 'string') {
|
|
145
|
+
const original = obj.caption;
|
|
146
|
+
obj.caption = translations[original] ?? original;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ✅ Replace modalTitle if present
|
|
150
|
+
if (typeof obj.modalTitle === 'string') {
|
|
151
|
+
const original = obj.modalTitle;
|
|
152
|
+
obj.modalTitle = translations[original] ?? original;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 🔁 Recurse
|
|
156
|
+
Object.keys(obj).forEach((key) => {
|
|
157
|
+
const value = obj[key];
|
|
158
|
+
if (typeof value === 'object') {
|
|
159
|
+
walk(value);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
walk(cloned);
|
|
165
|
+
return cloned;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
updateLayoutLanguage<T>(
|
|
170
|
+
schema: T,
|
|
171
|
+
translations: Record<string, string>
|
|
172
|
+
): T {
|
|
173
|
+
// Deep clone to avoid mutating original schema
|
|
174
|
+
const cloned = JSON.parse(JSON.stringify(schema));
|
|
175
|
+
|
|
176
|
+
const walk = (obj: any) => {
|
|
177
|
+
if (!obj || typeof obj !== 'object') return;
|
|
178
|
+
|
|
179
|
+
// ✅ If label.caption exists → translate it
|
|
180
|
+
if (obj.label && typeof obj.label.caption === 'string') {
|
|
181
|
+
const originalCaption = obj.label.caption;
|
|
182
|
+
obj.label.caption =
|
|
183
|
+
translations[originalCaption] ?? originalCaption;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// 🔁 Recurse into object properties
|
|
187
|
+
Object.keys(obj).forEach((key) => {
|
|
188
|
+
const value = obj[key];
|
|
189
|
+
if (typeof value === 'object') {
|
|
190
|
+
walk(value);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
walk(cloned);
|
|
196
|
+
return cloned;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
dateChangeEvent(filter: any, value: any) {
|
|
200
|
+
const scope = this.getScope(filter.scope.reference);
|
|
201
|
+
const field = filter.scope?.reference.split('/').pop();
|
|
202
|
+
this.itemInfo.propertySchema[scope][field].value = value
|
|
203
|
+
this.applyDateFilter(this.extractFilterValues(this.itemInfo.propertySchema[scope]))
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async applyDateFilter(filters: any) {
|
|
207
|
+
const from = filters.fromDateFilter ? new Date(filters.fromDateFilter) : null;
|
|
208
|
+
const to = filters.toDateFilter ? new Date(filters.toDateFilter) : null;
|
|
209
|
+
if (to && from) {
|
|
210
|
+
const formattedFrom = this.formatToOffsetISO(from);
|
|
211
|
+
const formattedTo = this.formatToOffsetISO(to);
|
|
212
|
+
const keycloakInfo: any = await this.utilityService.getLocalStorage('KeycloakInfo');
|
|
213
|
+
const logined: any = await this.utilityService.getLocalStorage('loginedUser');
|
|
214
|
+
this.safeUpdate(() => this.isLoading = true);
|
|
215
|
+
if (this.platform.ANDROID || this.platform.IOS) {
|
|
216
|
+
let saveOrder = await this.getSaveOrder(keycloakInfo?.token, keycloakInfo, formattedFrom, formattedTo)
|
|
217
|
+
this.itemInfo.data = saveOrder?.length > 0 ? saveOrder : []
|
|
218
|
+
this.safeUpdate(() => this.isLoading = false);
|
|
219
|
+
} else {
|
|
220
|
+
this.requestService.getSaveOrder(logined?.token, logined, formattedFrom, formattedTo).subscribe((saveOrders: any) => {
|
|
221
|
+
const updatedData = this.utilityService.restoreDatesFromStorage(saveOrders, this.itemInfo.propertySchema);
|
|
222
|
+
this.itemInfo.data = updatedData?.length > 0 ? updatedData : []
|
|
223
|
+
this.safeUpdate(() => this.isLoading = false);
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async getSaveOrder(
|
|
230
|
+
token: string,
|
|
231
|
+
userInfo: any,
|
|
232
|
+
fromDate: any,
|
|
233
|
+
toDate: any
|
|
234
|
+
) {
|
|
235
|
+
if (!token) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const company = userInfo.p5_plant
|
|
240
|
+
? `${userInfo.p5_group}/${userInfo.p5_client}/${userInfo.p5_plant}`
|
|
241
|
+
: `${userInfo.p5_group}/${userInfo.p5_client}/`;
|
|
242
|
+
|
|
243
|
+
const url = `${userInfo.p5_backend_url}/assetsmobileservice/Zeiterfassung/requestBookedTimeRecording`;
|
|
244
|
+
|
|
245
|
+
try {
|
|
246
|
+
const response = await CapacitorHttp.post({
|
|
247
|
+
url,
|
|
248
|
+
params: {
|
|
249
|
+
resourceNo: userInfo.p5_resource_no,
|
|
250
|
+
workDayFrom: fromDate,
|
|
251
|
+
workDayTo: toDate,
|
|
252
|
+
company,
|
|
253
|
+
appVersion: '1',
|
|
254
|
+
},
|
|
255
|
+
headers: {
|
|
256
|
+
Authorization: `Bearer ${token}`, // ✅ REQUIRED
|
|
257
|
+
Accept: 'application/json',
|
|
258
|
+
},
|
|
259
|
+
// ❗ NO BODY needed for this endpoint
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
console.log('getSaveOrder response:', response.data);
|
|
263
|
+
return response.data;
|
|
264
|
+
|
|
265
|
+
} catch (error) {
|
|
266
|
+
console.error('Failed to fetch saved orders', error);
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
formatToOffsetISO(date: Date): string {
|
|
272
|
+
if (!date) return "";
|
|
273
|
+
|
|
274
|
+
const pad = (n: number, len = 2) => String(n).padStart(len, "0");
|
|
275
|
+
const year = date.getFullYear();
|
|
276
|
+
const month = pad(date.getMonth() + 1);
|
|
277
|
+
const day = pad(date.getDate());
|
|
278
|
+
const hours = pad(date.getHours());
|
|
279
|
+
const minutes = pad(date.getMinutes());
|
|
280
|
+
const seconds = pad(date.getSeconds());
|
|
281
|
+
const ms = pad(date.getMilliseconds(), 4); // 4-digit milliseconds
|
|
282
|
+
|
|
283
|
+
// timezone offset
|
|
284
|
+
const offset = -date.getTimezoneOffset(); // in minutes
|
|
285
|
+
const offSign = offset >= 0 ? "+" : "-";
|
|
286
|
+
const offHours = pad(Math.floor(Math.abs(offset) / 60));
|
|
287
|
+
const offMinutes = pad(Math.abs(offset) % 60);
|
|
288
|
+
|
|
289
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}:${ms}${offSign}${offHours}:${offMinutes}`;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
extractFilterValues(schema: Record<string, any>): Record<string, any> {
|
|
293
|
+
return Object.keys(schema).reduce((acc, key) => {
|
|
294
|
+
if (key.includes('Filter') && schema[key]?.value !== undefined) {
|
|
295
|
+
acc[key] = schema[key].value;
|
|
296
|
+
}
|
|
297
|
+
return acc;
|
|
298
|
+
}, {} as Record<string, any>);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
invokeOnPageSizeChange(pageSize: any) {
|
|
302
|
+
this.onPageSizeChange.emit(pageSize);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
invokeGoToPage(page: any) {
|
|
306
|
+
this.onPageChange.emit(page);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
invokeOnCardHeader(element: any) {
|
|
310
|
+
this.cardHeaderButtonClick.emit(element);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
invokeOnCardFooter(element: any) {
|
|
314
|
+
// this.cardHeaderButtonClick.emit(element);
|
|
315
|
+
this.d4_SaveAll();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
async invokeButtonClick(layout: any, record: any, recordIndex: any) {
|
|
319
|
+
if (layout?.option?.action === "delete" && layout?.option?.storageType == "localstorage") {
|
|
320
|
+
if (layout?.option?.deleteMessage) {
|
|
321
|
+
this.showConfirm(layout?.option, recordIndex);
|
|
322
|
+
}
|
|
323
|
+
} else if (layout?.option?.action === "save" && layout?.option?.storageType === "database") {
|
|
324
|
+
const final_array = this.utilityService.convertToDailyLogs(record);
|
|
325
|
+
await this.saveToDb(final_array, recordIndex, layout.option.data_url)
|
|
326
|
+
} else {
|
|
327
|
+
this.cardButtonClick.emit({ layout: layout, record: record, recordIndex: recordIndex });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
showConfirm(option: any, recordIndex: any) {
|
|
332
|
+
this.modalService.confirm({
|
|
333
|
+
nzTitle: this.selectedLanguageInfo && this.selectedLanguageInfo?.selectedLanguage['Confirm'] ? this.selectedLanguageInfo.selectedLanguage['Confirm'] : 'Confirm',
|
|
334
|
+
nzContent: this.selectedLanguageInfo && this.selectedLanguageInfo?.selectedLanguage[option.deleteMessage] ? this.selectedLanguageInfo.selectedLanguage[option.deleteMessage] : option.deleteMessage,
|
|
335
|
+
nzOkText: this.selectedLanguageInfo && this.selectedLanguageInfo?.selectedLanguage['Delete'] ? this.selectedLanguageInfo.selectedLanguage['Delete'] : 'Delete',
|
|
336
|
+
nzCancelText: this.selectedLanguageInfo && this.selectedLanguageInfo?.selectedLanguage['Cancel'] ? this.selectedLanguageInfo.selectedLanguage['Cancel'] : 'Cancel',
|
|
337
|
+
nzOnOk: () => this.deleteRecord(recordIndex, option.data_url)
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async d4_SaveAll() {
|
|
342
|
+
let allOrders: any[] = [];
|
|
343
|
+
for (let i = 0; i < this.itemInfo.data.length; i++) {
|
|
344
|
+
const element = this.itemInfo.data[i];
|
|
345
|
+
const dailyLogs = this.utilityService.convertToDailyLogs(element);
|
|
346
|
+
if (Array.isArray(dailyLogs)) {
|
|
347
|
+
allOrders.push(...dailyLogs);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
await this.saveToDb(allOrders, null, true);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
deleteRecord(recordIndex: any, data_url: any) {
|
|
355
|
+
this.itemInfo.data.splice(recordIndex, 1);
|
|
356
|
+
this.utilityService.setLocalStorage('timeRecords', JSON.stringify(this.itemInfo.data));
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
deleteAllRecord() {
|
|
360
|
+
this.itemInfo.data = []
|
|
361
|
+
this.utilityService.setLocalStorage('timeRecords', JSON.stringify(this.itemInfo.data));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async saveToDb(orders: any, orderIndex?: any, data_url?: any, deleteAll: boolean = false) {
|
|
365
|
+
this.safeUpdate(() => this.isLoading = true);
|
|
366
|
+
const token = this.oauthService.getAccessToken(); // whatever you have
|
|
367
|
+
const logined: any = await this.utilityService.getLocalStorage('loginedUser');
|
|
368
|
+
const keycloakInfo: any = await this.utilityService.getLocalStorage('KeycloakInfo');
|
|
369
|
+
let saveobject = {
|
|
370
|
+
ressourceNo: logined?.p5_resource_no ? logined.p5_resource_no : keycloakInfo?.p5_resource_no,
|
|
371
|
+
returnTimeRecordingLine: orders
|
|
372
|
+
}
|
|
373
|
+
if (this.platform.ANDROID || this.platform.IOS) {
|
|
374
|
+
const res = await this.mobileSaveDb(keycloakInfo.token, keycloakInfo, saveobject, orderIndex, data_url, deleteAll);
|
|
375
|
+
} else {
|
|
376
|
+
this.webSaveDb(token, logined, saveobject, orderIndex, data_url, deleteAll);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
webSaveDb(token: any, userInfo: any, order: any = {}, orderIndex?: any, dataUrl?: any, deleteAll: boolean = false) {
|
|
381
|
+
if (token) {
|
|
382
|
+
const headers = new HttpHeaders({
|
|
383
|
+
'Authorization': `Bearer ${token}`,
|
|
384
|
+
'Accept': 'application/json'
|
|
385
|
+
});
|
|
386
|
+
let url2: any = `${userInfo.p5_backend_url}/assetsmobileservice/Zeiterfassung/registerTimeRecording?company=${userInfo.p5_group}/${userInfo.p5_client}/${userInfo.p5_plant ? userInfo.p5_plant : " "}&appVersion=1&resourceNo=${userInfo.p5_resource_no}`
|
|
387
|
+
this.http.post(url2, order, { headers }).subscribe({
|
|
388
|
+
next: res => {
|
|
389
|
+
this.safeUpdate(() => this.isLoading = false);
|
|
390
|
+
if (orderIndex && orderIndex > -1) {
|
|
391
|
+
this.deleteRecord(orderIndex, dataUrl)
|
|
392
|
+
} else {
|
|
393
|
+
this.deleteAllRecord();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async mobileSaveDb(token: string, userInfo: any, order: any = {}, orderIndex: number, dataUrl: any, deleteAll: boolean = false) {
|
|
401
|
+
if (!token) {
|
|
402
|
+
console.log("NO-token", token);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const company = userInfo.p5_plant
|
|
407
|
+
? `${userInfo.p5_group}/${userInfo.p5_client}/${userInfo.p5_plant}`
|
|
408
|
+
: `${userInfo.p5_group}/${userInfo.p5_client}/`;
|
|
409
|
+
|
|
410
|
+
const url = `${userInfo.p5_backend_url}/assetsmobileservice/Zeiterfassung/registerTimeRecording`;
|
|
411
|
+
|
|
412
|
+
try {
|
|
413
|
+
const response = await CapacitorHttp.post({
|
|
414
|
+
url,
|
|
415
|
+
params: {
|
|
416
|
+
company,
|
|
417
|
+
appVersion: '1',
|
|
418
|
+
resourceNo: userInfo.p5_resource_no,
|
|
419
|
+
},
|
|
420
|
+
headers: {
|
|
421
|
+
Authorization: `Bearer ${token}`,
|
|
422
|
+
Accept: 'application/json',
|
|
423
|
+
'Content-Type': 'application/json',
|
|
424
|
+
},
|
|
425
|
+
data: order,
|
|
426
|
+
});
|
|
427
|
+
if (orderIndex != null && orderIndex > -1) {
|
|
428
|
+
this.deleteRecord(orderIndex, dataUrl);
|
|
429
|
+
} else {
|
|
430
|
+
this.deleteAllRecord();
|
|
431
|
+
}
|
|
432
|
+
this.safeUpdate(() => this.isLoading = false);
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
return response.data;
|
|
436
|
+
|
|
437
|
+
} catch (error) {
|
|
438
|
+
this.safeUpdate(() => this.isLoading = false);
|
|
439
|
+
console.error('Failed to save time recording', error);
|
|
440
|
+
throw error;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
showLinkDetails(option: any, record: any) {
|
|
445
|
+
this.linkDetails.emit({ option: option, record: record })
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
showImageDetails(option: any, record: any) {
|
|
449
|
+
this.imageDetails.emit({ option: option, record: record })
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
getProperty(scope: any) {
|
|
453
|
+
const property = scope ? scope.split('/').pop() : '';
|
|
454
|
+
return { key: property, productSchema: this.itemInfo.propertySchema[this.getScope(scope)][property] };
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
getStyleWithoutClasses(styleObject: any) {
|
|
458
|
+
if (!styleObject) {
|
|
459
|
+
return { classes: '', style: {} };
|
|
460
|
+
}
|
|
461
|
+
const { classes, ...styleWithoutClasses } = styleObject;
|
|
462
|
+
return { classes: classes && classes.length > 0 ? classes[0] : '', style: styleWithoutClasses };
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
getScope(scope: any) {
|
|
466
|
+
let propertyScope = "";
|
|
467
|
+
let start = scope?.indexOf("#/") + 2;
|
|
468
|
+
let end = scope?.indexOf("/", start);
|
|
469
|
+
if (start && end) {
|
|
470
|
+
propertyScope = scope.substring(start, end);
|
|
471
|
+
}
|
|
472
|
+
return propertyScope;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
min-height: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.form-renderer {
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
min-height: 0;
|
|
12
|
+
overflow-y: auto;
|
|
13
|
+
overflow-x: hidden;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
padding: 12px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.section-card {
|
|
19
|
+
border: 1px solid #e5e7eb;
|
|
20
|
+
border-radius: var(--radius-sm, 8px);
|
|
21
|
+
padding: 12px;
|
|
22
|
+
margin-bottom: 12px;
|
|
23
|
+
background: #ffffff;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.section-header {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
margin-bottom: 10px;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.section-title {
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
color: #0f172a;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.section-body {
|
|
41
|
+
position: relative;
|
|
42
|
+
width: 100%;
|
|
43
|
+
min-height: 78px;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.field-row {
|
|
48
|
+
position: relative;
|
|
49
|
+
min-width: 0;
|
|
50
|
+
width: 100%;
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.field-row input,
|
|
55
|
+
.field-row select,
|
|
56
|
+
.field-row nz-select,
|
|
57
|
+
.field-row textarea,
|
|
58
|
+
.field-row button {
|
|
59
|
+
max-width: 100%;
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@media (max-width: 768px) {
|
|
64
|
+
.section-body {
|
|
65
|
+
grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.field-row {
|
|
69
|
+
grid-column: span 1 !important;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@media (min-width: 769px) and (max-width: 1024px) {
|
|
74
|
+
.section-body {
|
|
75
|
+
grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.field-row {
|
|
79
|
+
grid-column: span 6 !important;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host-context(.mobile-frame) .section-body,
|
|
84
|
+
:host-context(.device-mobile) .section-body {
|
|
85
|
+
grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:host-context(.mobile-frame) .field-row,
|
|
89
|
+
:host-context(.device-mobile) .field-row {
|
|
90
|
+
grid-column: span 1 !important;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:host-context(.tablet-frame) .section-body,
|
|
94
|
+
:host-context(.device-tablet) .section-body {
|
|
95
|
+
grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host-context(.tablet-frame) .field-row,
|
|
99
|
+
:host-context(.device-tablet) .field-row {
|
|
100
|
+
grid-column: span 6 !important;
|
|
101
|
+
}
|