@@ -21,9 +21,7 @@ import { EntityAbility } from "../../permissions/ability/entity-ability";
2121import { UnsavedChangesService } from "../../entity-details/form/unsaved-changes.service" ;
2222import { EntityActionsMenuComponent } from "../../entity-details/entity-actions-menu/entity-actions-menu.component" ;
2323import { ViewComponentContext } from "../../ui/abstract-view/view-component-context" ;
24- import { UntilDestroy , untilDestroyed } from "@ngneat/until-destroy" ;
2524
26- @UntilDestroy ( )
2725@Component ( {
2826 selector : "app-dialog-buttons" ,
2927 imports : [
@@ -50,7 +48,6 @@ export class DialogButtonsComponent<E extends Entity> implements OnInit {
5048 @Input ( ) entity : E ;
5149 @Input ( ) form : EntityForm < E > ;
5250 detailsRoute : string ;
53- canSave : boolean = false ;
5451
5552 @Output ( ) closeView = new EventEmitter < any > ( ) ;
5653
@@ -82,11 +79,6 @@ export class DialogButtonsComponent<E extends Entity> implements OnInit {
8279 }
8380 this . initializeDetailsRouteIfAvailable ( ) ;
8481 }
85- this . form . formGroup . valueChanges
86- . pipe ( untilDestroyed ( this ) )
87- . subscribe ( ( ) => {
88- this . canSave = this . hasFormValue ( ) ;
89- } ) ;
9082 }
9183
9284 private initializeDetailsRouteIfAvailable ( ) {
@@ -132,23 +124,4 @@ export class DialogButtonsComponent<E extends Entity> implements OnInit {
132124 this . close ( ) ;
133125 }
134126 }
135-
136- /**
137- * Checks if any control in the form has a non-empty value.
138- * Returns true if at least one form control contains a value
139- */
140- private hasFormValue ( ) : boolean {
141- return Object . values ( this . form . formGroup . controls ) . some ( ( ctrl ) => {
142- const val = ctrl . value ;
143- if (
144- val === null ||
145- val === undefined ||
146- ( Array . isArray ( val ) && val . length === 0 ) ||
147- JSON . stringify ( val ) === "{}" ||
148- ( typeof val === "string" && val . trim ( ) . length === 0 )
149- )
150- return false ;
151- else return true ;
152- } ) ;
153- }
154127}
0 commit comments