mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
refactor(scan): improve structure of init method and format code
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { PromptModalData, UiModalService, UiPromptModalComponent } from '@ui/modal';
|
||||
import {
|
||||
PromptModalData,
|
||||
UiModalService,
|
||||
UiPromptModalComponent,
|
||||
} from '@ui/modal';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ScanAdapter } from './scan-adapter';
|
||||
import { Config } from '@core/config';
|
||||
@@ -14,9 +18,14 @@ export class DevScanAdapter implements ScanAdapter {
|
||||
private _config = inject(Config);
|
||||
|
||||
async init(): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(coerceBooleanProperty(this._config.get('dev-scanner')));
|
||||
});
|
||||
const enabled = localStorage.getItem('dev_scan_adapter_enabled') === 'true';
|
||||
if (enabled) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(coerceBooleanProperty(this._config.get('dev-scanner')));
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
scan(): Observable<string> {
|
||||
@@ -25,7 +34,8 @@ export class DevScanAdapter implements ScanAdapter {
|
||||
content: UiPromptModalComponent,
|
||||
title: 'Scannen',
|
||||
data: {
|
||||
message: 'Diese Eingabemaske dient nur zu Entwicklungs und Testzwecken.',
|
||||
message:
|
||||
'Diese Eingabemaske dient nur zu Entwicklungs und Testzwecken.',
|
||||
placeholder: 'Scan Code',
|
||||
confirmText: 'weiter',
|
||||
cancelText: 'abbrechen',
|
||||
|
||||
@@ -27,7 +27,10 @@ export class ScanditScanAdapter implements ScanAdapter {
|
||||
) {}
|
||||
|
||||
async init(): Promise<boolean> {
|
||||
if (this._environmentService.isTablet()) {
|
||||
const enabled =
|
||||
localStorage.getItem('scandit_scan_adapter_enabled') === 'true';
|
||||
|
||||
if (enabled || this._environmentService.isTablet()) {
|
||||
try {
|
||||
await configure({
|
||||
licenseKey: this._config.get('licence.scandit'),
|
||||
@@ -88,7 +91,11 @@ export class ScanditScanAdapter implements ScanAdapter {
|
||||
|
||||
createOverlay() {
|
||||
const overlay = this._overlay.create({
|
||||
positionStrategy: this._overlay.position().global().centerHorizontally().centerVertically(),
|
||||
positionStrategy: this._overlay
|
||||
.position()
|
||||
.global()
|
||||
.centerHorizontally()
|
||||
.centerVertically(),
|
||||
hasBackdrop: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user