Update language Editor (still not functional)

This commit is contained in:
George Kalampokis 2020-07-10 18:41:20 +03:00
parent aa930f097a
commit 8eb054f9d2
1 changed files with 101 additions and 102 deletions

View File

@ -98,19 +98,18 @@ export class LanguageEditorComponent extends BaseComponent implements OnInit, On
} }
onCallbackSuccess(id?: String): void { onCallbackSuccess(id?: String): void {
this.uiNotificationService.snackBarNotification( this.translate.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.translate.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/reload']).then(() => this.router.navigate(['/language-editor'])); this.router.navigate(['/reload']).then(() => this.router.navigate(['/language-editor']));
} }
onCallbackError(error: any) { onCallbackError(error: any) {
this.uiNotificationService.snackBarNotification( error, SnackBarNotificationLevel.Error); this.uiNotificationService.snackBarNotification(error, SnackBarNotificationLevel.Error);
//this.validateAllFormFields(this.formGroup); //this.validateAllFormFields(this.formGroup);
} }
refreshFn = (ev: Event) => { refreshFn = (ev: Event) => {
if (document.scrollingElement !== undefined) {
if ((ev.srcElement as HTMLDocument).scrollingElement !== undefined) { this.startIndex = Math.floor(document.scrollingElement.scrollTop / this.rowHeight);
this.startIndex = Math.floor((ev.srcElement as HTMLDocument).scrollingElement.scrollTop / this.rowHeight);
this.endIndex = this.startIndex + this.maxElements; this.endIndex = this.startIndex + this.maxElements;
const tempKeys = this.keys.slice(this.startIndex, this.endIndex); const tempKeys = this.keys.slice(this.startIndex, this.endIndex);
this.visibleKeys.length = 0; this.visibleKeys.length = 0;
@ -118,21 +117,21 @@ refreshFn = (ev: Event) => {
this.visibleKeys.push(key); this.visibleKeys.push(key);
} }
} }
} }
findKeys(ev: any) { findKeys(ev: any) {
let tempKeys = []; let tempKeys = [];
if (ev.value === "") { if (ev.value === "") {
tempKeys = this.allkeys; tempKeys = this.allkeys;
} else { } else {
tempKeys = this.allkeys.filter((key) => (this.formGroup.get(key).value as string).toLowerCase().includes(ev.value.toLowerCase())); tempKeys = this.allkeys.filter((key) => (this.formGroup.get(key).value as string).toLowerCase().includes(ev.value.toLowerCase()));
window.scrollTo({top: 0}); window.scrollTo({ top: 0 });
} }
this.keys.length = 0; this.keys.length = 0;
for (const key of tempKeys) { for (const key of tempKeys) {
this.keys.push(key); this.keys.push(key);
} }
this.visibleKeys = this.keys.slice(this.startIndex, this.endIndex); this.visibleKeys = this.keys.slice(this.startIndex, this.endIndex);
} }
} }