Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: remove useless DialogService and TooltipService #41

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions projects/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export * from './services/lazy-loader.service';
export * from './services/dialog.service';
export * from './services/media.service';
export * from './directives/input-autosize.directive';
export * from './directives/single-click.directive';
Expand Down
45 changes: 0 additions & 45 deletions projects/core/src/services/dialog.service.ts

This file was deleted.

33 changes: 0 additions & 33 deletions projects/core/src/services/lazy-loader.service.ts

This file was deleted.

2 changes: 1 addition & 1 deletion projects/layout/src/layout.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ngx-layout {
bottom: 0;
left: 0;

&.no-left.no-right .main-content {
&.no-left[no-right='true'] .main-content {
padding: 0;
}

Expand Down
11 changes: 7 additions & 4 deletions projects/layout/src/layout.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
import { AsyncPipe, NgTemplateOutlet } from '@angular/common';
import { ChangeDetectionStrategy, Component, ContentChild, EventEmitter, HostBinding, inject, Input, Output, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, Component, ContentChild, ElementRef, EventEmitter, inject, Input, Output, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';
import { MatIconButton } from '@angular/material/button';
import { MatIcon } from '@angular/material/icon';
import { MatDrawer, MatDrawerContainer, MatDrawerContent } from '@angular/material/sidenav';
Expand Down Expand Up @@ -52,12 +52,11 @@ export class NgxLayoutComponent {
@ContentChild('layoutInfoBoxes') protected layoutInfoBoxesContent?: TemplateRef<unknown>;
@ContentChild('layoutRight') protected layoutRightContent?: TemplateRef<unknown>;

@HostBinding('class.no-right') protected noRight = false;

@ViewChild('sideFilter') protected sideFilter?: MatDrawer;

protected mediaService = inject(NgxMediaService);
protected sidenavService = inject(NgxSidenavService);
protected elementRef = inject<ElementRef<HTMLElement>>(ElementRef);

public get layoutToolbar(): TemplateRef<unknown> | undefined {
return this.layoutToolbarExternal ?? this.layoutToolbarContent;
Expand All @@ -77,7 +76,11 @@ export class NgxLayoutComponent {

public get layoutRight(): TemplateRef<unknown> | undefined {
const value = this.layoutRightExternal ?? this.layoutRightContent;
this.noRight = !value;
if (!value) {
this.elementRef.nativeElement.setAttribute('no-right', 'true');
} else {
this.elementRef.nativeElement.removeAttribute('no-right');
}
return value;
}

Expand Down
1 change: 0 additions & 1 deletion projects/message-box-dialog/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './message-box-dialog.component';
export * from './message-box-dialog.service';
export * from './message-box-dialog.model';
export * from './message-box-dialog.module';
14 changes: 12 additions & 2 deletions projects/message-box-dialog/src/message-box-dialog.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { ChangeDetectionStrategy, Component, inject, ViewEncapsulation } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatToolbarModule } from '@angular/material/toolbar';

import { NgxMessageBoxDialogButtons, NgxMessageBoxDialogData } from './message-box-dialog.model';

Expand All @@ -8,7 +11,14 @@ import { NgxMessageBoxDialogButtons, NgxMessageBoxDialogData } from './message-b
templateUrl: './message-box-dialog.component.html',
styleUrls: ['./message-box-dialog.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [
MatButtonModule,
MatDialogModule,
MatIconModule,
MatToolbarModule
]
})
export class NgxMessageBoxDialogComponent {

Expand Down
24 changes: 0 additions & 24 deletions projects/message-box-dialog/src/message-box-dialog.module.ts

This file was deleted.

60 changes: 30 additions & 30 deletions projects/message-box-dialog/src/message-box-dialog.service.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import { Injectable, Type } from '@angular/core';
import { MatDialogConfig } from '@angular/material/dialog';
import { NgxAbstractLazyModule, NgxDialogService } from '@hug/ngx-core';
import { Observable, take } from 'rxjs';
import { inject, Injectable } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { from, Observable, switchMap, take } from 'rxjs';

import { NgxMessageBoxDialogButtons, NgxMessageBoxDialogData, NgxMessageBoxDialogResponse } from './message-box-dialog.model';

@Injectable({
providedIn: 'root'
})
export class NgxMessageBoxDialogService extends NgxDialogService<NgxMessageBoxDialogResponse, NgxMessageBoxDialogData | string> {

public constructor() {
super({
panelClass: 'no-padding-dialog'
} as MatDialogConfig<NgxMessageBoxDialogData>);
}

public override openDialog$(dialogData: string | NgxMessageBoxDialogData, dialogConfig?: MatDialogConfig<NgxMessageBoxDialogData>): Observable<NgxMessageBoxDialogResponse | undefined> {
let messageBoxDialogData: NgxMessageBoxDialogData;
if (typeof dialogData === 'string') {
messageBoxDialogData = {
text: dialogData,
buttons: NgxMessageBoxDialogButtons.OK
} as NgxMessageBoxDialogData;
} else {
messageBoxDialogData = dialogData;
}
messageBoxDialogData.title = messageBoxDialogData.title || 'Confirmation'; // Translate

return super.openDialog$(messageBoxDialogData, dialogConfig);
export class NgxMessageBoxDialogService {
private dialog = inject(MatDialog);

public open$(dialogData: NgxMessageBoxDialogData | string, additionalDialogConfig?: MatDialogConfig<NgxMessageBoxDialogData>): Observable<NgxMessageBoxDialogResponse | undefined> {
return from(import('./message-box-dialog.component')).pipe(
take(1),
switchMap(dialogComponent => {
let messageBoxDialogData: NgxMessageBoxDialogData;
if (typeof dialogData === 'string') {
messageBoxDialogData = {
text: dialogData,
buttons: NgxMessageBoxDialogButtons.OK
} as NgxMessageBoxDialogData;
} else {
messageBoxDialogData = dialogData;
}
messageBoxDialogData.title = messageBoxDialogData.title || 'Confirmation'; // Translate

const dialogConfig = {
panelClass: 'no-padding-dialog',
data: dialogData
} as MatDialogConfig<NgxMessageBoxDialogData | string>;

return this.dialog.open<unknown, NgxMessageBoxDialogData | string, NgxMessageBoxDialogResponse>(dialogComponent.NgxMessageBoxDialogComponent, { ...dialogConfig, ...(additionalDialogConfig ?? {}) }).afterClosed();
})
);
}

public openConfirmation$(message: string, dialogConfig?: MatDialogConfig<NgxMessageBoxDialogData>): Observable<NgxMessageBoxDialogResponse | undefined> {
Expand All @@ -37,12 +41,8 @@ export class NgxMessageBoxDialogService extends NgxDialogService<NgxMessageBoxDi
buttons: NgxMessageBoxDialogButtons.OK + NgxMessageBoxDialogButtons.CANCEL
} as NgxMessageBoxDialogData;

return this.openDialog$(dialogData, dialogConfig).pipe(
return this.open$(dialogData, dialogConfig).pipe(
take(1)
);
}

protected getModule(): Promise<Type<NgxAbstractLazyModule<unknown>>> {
return import('./message-box-dialog.module').then(m => m.NgxMessageBoxDialogModule);
}
}
1 change: 0 additions & 1 deletion projects/status/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './status-detail';

export * from './status.module';
export * from './status.component';
export * from './status.service';
export * from './status.model';
1 change: 0 additions & 1 deletion projects/status/src/status-detail/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './status-detail.module';
export * from './status-detail.component';
export * from './status-detail-dialog.service';
34 changes: 20 additions & 14 deletions projects/status/src/status-detail/status-detail-dialog.service.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import { Injectable, Type } from '@angular/core';
import { MatDialogConfig } from '@angular/material/dialog';
import { NgxAbstractLazyModule, NgxDialogService } from '@hug/ngx-core';
import { inject, Injectable } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { from, Observable, switchMap, take } from 'rxjs';

import { NgxStatus } from '../status.model';

@Injectable({
providedIn: 'root'
})
export class NgxStatusDetailDialogService extends NgxDialogService<void, NgxStatus> {
public constructor() {
super({
disableClose: false,
hasBackdrop: true,
width: '700px',
panelClass: 'ngx-status-panel'
} as MatDialogConfig<NgxStatus>);
}
export class NgxStatusDetailDialogService {
private dialog = inject(MatDialog);

public open$(dialogData: NgxStatus): Observable<void | undefined> {
return from(import('./status-detail.component')).pipe(
take(1),
switchMap(dialogComponent => {
const dialogConfig = {
disableClose: false,
hasBackdrop: true,
width: '700px',
panelClass: 'ngx-status-panel',
data: dialogData
} as MatDialogConfig<NgxStatus>;

protected getModule(): Promise<Type<NgxAbstractLazyModule<unknown>>> {
return import('./status-detail.module').then(m => m.NgxStatusDetailModule);
return this.dialog.open<unknown, NgxStatus, void>(dialogComponent.NgxStatusDetailComponent, dialogConfig).afterClosed();
})
);
}
}
14 changes: 12 additions & 2 deletions projects/status/src/status-detail/status-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { DatePipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject, ViewEncapsulation } from '@angular/core';
import { MatIconButton } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { NgxMessageBoxType } from '@hug/ngx-message-box';
import { MatIcon } from '@angular/material/icon';
import { NgxMessageBoxComponent, NgxMessageBoxType } from '@hug/ngx-message-box';

import { NgxStatus } from '../status.model';

Expand All @@ -9,7 +12,14 @@ import { NgxStatus } from '../status.model';
styleUrls: ['./status-detail.component.scss'],
templateUrl: './status-detail.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [
DatePipe,
MatIcon,
MatIconButton,
NgxMessageBoxComponent
]
})
export class NgxStatusDetailComponent {
protected fullTextError: string;
Expand Down
24 changes: 0 additions & 24 deletions projects/status/src/status-detail/status-detail.module.ts

This file was deleted.

Loading