use action for close button instead of a directive

This commit is contained in:
Dan Percic 2021-08-22 17:15:21 +03:00
parent 7bd1e2a8e8
commit f947e9ea46
19 changed files with 58 additions and 26 deletions

View File

@ -1,5 +1,8 @@
<section>
<redaction-page-header [showCloseButton]="true"></redaction-page-header>
<redaction-page-header
(closeAction)="routerHistoryService.navigateToLastDossiersScreen()"
[showCloseButton]="true"
></redaction-page-header>
<div class="red-content-inner">
<div class="content-container">

View File

@ -6,6 +6,7 @@ import { CircleButtonTypes, DefaultListingServices, ListingComponent, TableColum
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { LoadingService } from '@services/loading.service';
import { timer } from 'rxjs';
import { RouterHistoryService } from '@services/router-history.service';
@Component({
selector: 'redaction-downloads-list-screen',
@ -18,7 +19,7 @@ export class DownloadsListScreenComponent extends ListingComponent<DownloadStatu
protected readonly _primaryKey = 'storageId';
readonly circleButtonTypes = CircleButtonTypes;
readonly tableHeaderLabel = _('downloads-list.table-header.title');
readonly tableColumnConfigs: TableColumnConfig<DownloadStatusWrapper>[] = [
readonly tableColumnConfigs: readonly TableColumnConfig<DownloadStatusWrapper>[] = [
{ label: _('downloads-list.table-col-names.name') },
{ label: _('downloads-list.table-col-names.size') },
{ label: _('downloads-list.table-col-names.date') },
@ -26,10 +27,11 @@ export class DownloadsListScreenComponent extends ListingComponent<DownloadStatu
];
constructor(
readonly fileDownloadService: FileDownloadService,
private readonly _downloadControllerService: DownloadControllerService,
protected readonly _injector: Injector,
private readonly _loadingService: LoadingService,
protected readonly _injector: Injector
readonly fileDownloadService: FileDownloadService,
readonly routerHistoryService: RouterHistoryService,
private readonly _downloadControllerService: DownloadControllerService
) {
super(_injector);
}

View File

@ -27,7 +27,7 @@ export class LanguageService {
}
document.documentElement.lang = defaultLang;
this._translateService.setDefaultLang(defaultLang);
this._translateService.use(defaultLang).subscribe(() => {});
this._translateService.use(defaultLang).toPromise().then();
}
async changeLanguage(language: string) {

View File

@ -4,7 +4,11 @@
<redaction-admin-side-nav type="settings"></redaction-admin-side-nav>
<div>
<redaction-page-header [pageLabel]="'digital-signature' | translate" [showCloseButton]="currentUser.isUser"></redaction-page-header>
<redaction-page-header
(closeAction)="routerHistoryService.navigateToLastDossiersScreen()"
[pageLabel]="'digital-signature' | translate"
[showCloseButton]="currentUser.isUser"
></redaction-page-header>
<div class="red-content-inner">
<div class="content-container">

View File

@ -1,12 +1,12 @@
import { Component, OnDestroy } from '@angular/core';
import { DigitalSignature, DigitalSignatureControllerService } from '@redaction/red-ui-http';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Toaster } from '@iqser/common-ui';
import { AutoUnsubscribe, IconButtonTypes, Toaster } from '@iqser/common-ui';
import { lastIndexOfEnd } from '@utils/functions';
import { AutoUnsubscribe, IconButtonTypes } from '@iqser/common-ui';
import { LoadingService } from '@services/loading.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { RouterHistoryService } from '@services/router-history.service';
@Component({
selector: 'redaction-digital-signature-screen',
@ -27,6 +27,7 @@ export class DigitalSignatureScreenComponent extends AutoUnsubscribe implements
private readonly _formBuilder: FormBuilder,
private readonly _userService: UserService,
private readonly _loadingService: LoadingService,
readonly routerHistoryService: RouterHistoryService,
private readonly _digitalSignatureControllerService: DigitalSignatureControllerService
) {
super();

View File

@ -4,7 +4,11 @@
<redaction-admin-side-nav type="settings"></redaction-admin-side-nav>
<div>
<redaction-page-header [pageLabel]="'dossier-templates' | translate" [showCloseButton]="currentUser.isUser"></redaction-page-header>
<redaction-page-header
(closeAction)="routerHistoryService.navigateToLastDossiersScreen()"
[pageLabel]="'dossier-templates' | translate"
[showCloseButton]="currentUser.isUser"
></redaction-page-header>
<div class="red-content-inner">
<div class="content-container">

View File

@ -8,6 +8,7 @@ import { DossierTemplateControllerService } from '@redaction/red-ui-http';
import { CircleButtonTypes, DefaultListingServices, IconButtonTypes, ListingComponent, TableColumnConfig } from '@iqser/common-ui';
import { UserService } from '@services/user.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { RouterHistoryService } from '@services/router-history.service';
@Component({
templateUrl: './dossier-templates-listing-screen.component.html',
@ -21,7 +22,7 @@ export class DossierTemplatesListingScreenComponent extends ListingComponent<Dos
readonly circleButtonTypes = CircleButtonTypes;
readonly currentUser = this._userService.currentUser;
readonly tableHeaderLabel = _('dossier-templates-listing.table-header.title');
tableColumnConfigs: TableColumnConfig<DossierTemplateModelWrapper>[] = [
readonly tableColumnConfigs: readonly TableColumnConfig<DossierTemplateModelWrapper>[] = [
{
label: _('dossier-templates-listing.table-col-names.name'),
sortByKey: 'name'
@ -43,6 +44,7 @@ export class DossierTemplatesListingScreenComponent extends ListingComponent<Dos
private readonly _loadingService: LoadingService,
private readonly _appStateService: AppStateService,
private readonly _dialogService: AdminDialogService,
readonly routerHistoryService: RouterHistoryService,
readonly userPreferenceService: UserPreferenceService,
private readonly _dossierTemplateControllerService: DossierTemplateControllerService
) {

View File

@ -5,6 +5,7 @@
<div>
<redaction-page-header
(closeAction)="routerHistoryService.navigateToLastDossiersScreen()"
[buttonConfigs]="buttonConfigs"
[pageLabel]="'license-information' | translate"
[showCloseButton]="currentUser.isUser"

View File

@ -8,6 +8,7 @@ import { ButtonConfig } from '@shared/components/page-header/models/button-confi
import { IconButtonTypes } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { UserService } from '@services/user.service';
import { RouterHistoryService } from '@services/router-history.service';
@Component({
selector: 'redaction-license-information-screen',
@ -16,10 +17,10 @@ import { UserService } from '@services/user.service';
})
export class LicenseInformationScreenComponent implements OnInit {
readonly currentUser = this._userService.currentUser;
readonly buttonConfigs: ButtonConfig[] = [
readonly buttonConfigs: readonly ButtonConfig[] = [
{
label: _('license-info-screen.email-report'),
action: () => this.sendMail(),
action: (): void => this.sendMail(),
type: IconButtonTypes.primary
}
];
@ -48,6 +49,7 @@ export class LicenseInformationScreenComponent implements OnInit {
private readonly _userService: UserService,
readonly appConfigService: AppConfigService,
private readonly _loadingService: LoadingService,
readonly routerHistoryService: RouterHistoryService,
private readonly _translateService: TranslateService,
private readonly _licenseReportController: LicenseReportControllerService
) {

View File

@ -1,7 +1,11 @@
<section>
<div class="overlay-shadow"></div>
<redaction-page-header [pageLabel]="'trash.label' | translate" [showCloseButton]="true"></redaction-page-header>
<redaction-page-header
(closeAction)="routerHistoryService.navigateToLastDossiersScreen()"
[pageLabel]="'trash.label' | translate"
[showCloseButton]="true"
></redaction-page-header>
<div class="red-content-inner">
<div class="content-container">

View File

@ -11,6 +11,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { Observable } from 'rxjs';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { getLeftDateTime } from '@utils/functions';
import { RouterHistoryService } from '@services/router-history.service';
interface DossierListItem extends Dossier {
readonly canRestore: boolean;
@ -53,6 +54,7 @@ export class TrashScreenComponent extends ListingComponent<DossierListItem> impl
protected readonly _injector: Injector,
private readonly _loadingService: LoadingService,
private readonly _dossiersService: DossiersService,
readonly routerHistoryService: RouterHistoryService,
private readonly _appConfigService: AppConfigService,
private readonly _adminDialogService: AdminDialogService
) {

View File

@ -1,5 +1,6 @@
<section *ngIf="!!currentDossier">
<redaction-page-header
(closeAction)="routerHistoryService.navigateToLastDossiersScreen()"
[actionConfigs]="actionConfigs"
[fileAttributeConfigs]="fileAttributeConfigs"
[searchPlaceholder]="'dossier-overview.search' | translate"

View File

@ -37,6 +37,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { annotationFilterChecker } from '@utils/filter-utils';
import { PermissionsService } from '@services/permissions.service';
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { RouterHistoryService } from '@services/router-history.service';
import { FileAttributeConfig } from '@redaction/red-ui-http';
@Component({
@ -53,7 +54,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
readonly actionConfigs: readonly ActionConfig[] = [
{
label: this._translateService.instant('dossier-overview.header-actions.edit'),
action: $event => this.openEditDossierDialog($event),
action: ($event): void => this.openEditDossierDialog($event),
icon: 'iqser:edit',
hide: !this.currentUser.isManager
}
@ -97,7 +98,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
private readonly _dossierDetailsComponent: DossierDetailsComponent;
private _lastScrolledIndex: number;
@ViewChild('needsWorkTemplate', { read: TemplateRef, static: true })
private readonly _needsWorkTemplate: TemplateRef<any>;
private readonly _needsWorkTemplate: TemplateRef<unknown>;
@ViewChild('fileInput') private readonly _fileInput: ElementRef;
@ViewChild(CdkVirtualScrollViewport)
private readonly _scrollViewport: CdkVirtualScrollViewport;
@ -105,10 +106,11 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
constructor(
private readonly _toaster: Toaster,
protected readonly _injector: Injector,
readonly permissionsService: PermissionsService,
private readonly _userService: UserService,
readonly permissionsService: PermissionsService,
private readonly _loadingService: LoadingService,
private readonly _appStateService: AppStateService,
readonly routerHistoryService: RouterHistoryService,
private readonly _appConfigService: AppConfigService,
private readonly _translateService: TranslateService,
private readonly _dialogService: DossiersDialogService,

View File

@ -1,5 +1,6 @@
<section *ngIf="searchResults$ | async as searchResult">
<redaction-page-header
(closeAction)="routerHistoryService.navigateToLastDossiersScreen()"
[searchPlaceholder]="'search.placeholder' | translate"
[searchWidth]="600"
[showCloseButton]="true"

View File

@ -12,6 +12,7 @@ import { fileStatusTranslations } from '../../translations/file-status-translati
import { SearchPositions } from '@shared/components/page-header/models/search-positions.type';
import { DossierWrapper } from '@state/model/dossier.wrapper';
import { TranslateService } from '@ngx-translate/core';
import { RouterHistoryService } from '@services/router-history.service';
interface ListItem {
readonly dossierId: string;
@ -57,13 +58,14 @@ export class SearchScreenComponent extends ListingComponent<ListItem> implements
);
constructor(
private readonly _router: Router,
protected readonly _injector: Injector,
private readonly _searchControllerService: SearchControllerService,
private readonly _activatedRoute: ActivatedRoute,
private readonly _appStateService: AppStateService,
private readonly _loadingService: LoadingService,
private readonly _appStateService: AppStateService,
readonly routerHistoryService: RouterHistoryService,
private readonly _translateService: TranslateService,
private readonly _router: Router
private readonly _searchControllerService: SearchControllerService
) {
super(_injector);
@ -93,11 +95,11 @@ export class SearchScreenComponent extends ListingComponent<ListItem> implements
});
}
setInitialConfig() {
setInitialConfig(): void {
return;
}
updateNavigation(query: string, mustContain?: string) {
updateNavigation(query: string, mustContain?: string): void {
const newQuery = query?.replace(mustContain, `"${mustContain}"`);
const queryParams = newQuery && newQuery !== '' ? { query: newQuery } : {};
this._router.navigate([], { queryParams }).then();

View File

@ -41,11 +41,11 @@
<ng-content></ng-content>
<iqser-circle-button
(action)="closeAction.emit()"
*ngIf="showCloseButton"
[class.ml-6]="actionConfigs"
[tooltip]="'common.close' | translate"
icon="iqser:close"
redactionNavigateLastDossiersScreen
tooltipPosition="below"
></iqser-circle-button>
</div>

View File

@ -1,4 +1,4 @@
import { Component, Input, Optional } from '@angular/core';
import { Component, EventEmitter, Input, Optional, Output } from '@angular/core';
import { ActionConfig } from '@shared/components/page-header/models/action-config.model';
import { ButtonConfig } from '@shared/components/page-header/models/button-config.model';
import { FilterService, SearchService } from '@iqser/common-ui';
@ -23,6 +23,7 @@ export class PageHeaderComponent<T> {
@Input() searchPlaceholder: string;
@Input() searchWidth: number | 'full';
@Input() searchPosition: SearchPosition = SearchPositions.afterFilters;
@Output() readonly closeAction = new EventEmitter();
readonly filters$ = this.filterService?.filterGroups$.pipe(map(all => all.filter(f => f.icon)));
readonly showResetFilters$ = this._showResetFilters$;

View File

@ -31,7 +31,7 @@ export class HelpModeDirective implements OnInit {
this._helpModeService.addElement(this.elementName, element, helperElement);
}
@HostListener('click') onClick() {
@HostListener('click') onClick(): void {
if (this._helpModeService.isHelpModeActive) {
const currentLocale = this._languageService.currentLanguage;
window.open(links[this.elementName][currentLocale]);

View File

@ -16,7 +16,7 @@ export class RouterHistoryService {
});
}
navigateToLastDossiersScreen() {
navigateToLastDossiersScreen(): void {
if (this._router.url === this._lastDossiersScreen) {
this._router.navigate(['/main/dossiers']);
} else {