Implement keyboard shortcuts and workflow changes

This commit is contained in:
2026-08-25 18:51:03 +05:30
parent 1b2ef5126e
commit fa2522e678
36 changed files with 1865 additions and 181 deletions
+7 -47
View File
@@ -37,11 +37,12 @@ import { ErrorDialogComponent } from './shared/error-dialog/error-dialog.compone
/** Custom Items */
import { Alert } from './core/alert/alert.model';
import { KeyboardShortcutsConfiguration } from './keyboards-shortcut-config';
import { Dates } from './core/utils/dates';
import { animate, style, transition, trigger } from '@angular/animations';
import { I18nService } from './core/i18n/i18n.service';
import { ThemingService } from './shared/theme-toggle/theming.service';
import { KeyboardShortcutService } from './core/services/keyboard-shortcut.service';
import { ShortcutSuggestionService } from './core/services/shortcut-suggestion.service';
/** Initialize Logger */
const log = new Logger('MifosX');
@@ -97,8 +98,6 @@ registerLocaleData(localeSW);
standalone: false
})
export class WebAppComponent implements OnInit, OnDestroy {
buttonConfig: KeyboardShortcutsConfiguration;
i18nService: I18nService;
private authSubscription: Subscription;
@@ -132,7 +131,9 @@ export class WebAppComponent implements OnInit, OnDestroy {
private dateUtils: Dates,
private idle: IdleTimeoutService,
private dialog: MatDialog,
private documentationLinks: DocumentationLinksService
private documentationLinks: DocumentationLinksService,
private keyboardShortcutService: KeyboardShortcutService,
private shortcutSuggestionService: ShortcutSuggestionService
) {}
@HostBinding('class') public cssClass: string;
@@ -246,7 +247,6 @@ export class WebAppComponent implements OnInit, OnDestroy {
verticalPosition: 'top'
});
});
this.buttonConfig = new KeyboardShortcutsConfiguration();
// initialize language and date format if they are null.
if (!localStorage.getItem('mifosXLanguage')) {
@@ -269,6 +269,8 @@ export class WebAppComponent implements OnInit, OnDestroy {
this.authSubscription = this.authenticationService.isAuthenticated$.subscribe((loggedIn) => {
if (loggedIn) {
this.idle.start();
this.keyboardShortcutService.initShortcuts();
this.shortcutSuggestionService.init();
} else {
this.idle.stop();
}
@@ -311,46 +313,4 @@ export class WebAppComponent implements OnInit, OnDestroy {
help() {
this.documentationLinks.open('userManual');
}
// Monitor all keyboard events and excute keyboard shortcuts
@HostListener('window:keydown', ['$event'])
onKeydownHandler(event: KeyboardEvent) {
const routeD = this.buttonConfig.buttonCombinations.find(
(x) =>
x.ctrlKey === event.ctrlKey && x.shiftKey === event.shiftKey && x.altKey === event.altKey && x.key === event.key
);
if (!(routeD === undefined)) {
switch (routeD.id) {
case 'logout':
this.logout();
break;
case 'help':
this.help();
break;
case 'runReport':
document.getElementById('runReport').click();
break;
case 'cancel':
const cancelButtons = document.querySelectorAll('button');
const filteredcancelButtons = Array.prototype.filter.call(cancelButtons, function (el: any) {
return el.textContent.trim() === 'Cancel';
});
if (filteredcancelButtons.length > 0) {
filteredcancelButtons[0].click();
}
break;
case 'submit':
const submitButton = document.querySelectorAll('button');
const filteredSubmitButton = Array.prototype.filter.call(submitButton, function (el: any) {
return el.textContent.trim() === 'Submit';
});
if (filteredSubmitButton.length > 0) {
filteredSubmitButton[0].click();
}
break;
default:
this.router.navigate([routeD.route], { relativeTo: this.activatedRoute });
}
}
}
}