
דיאלוג באנגולר לא נסגר
קדם ‹ Forums ‹ הייטק ‹ Web Development ‹ דיאלוג באנגולר לא נסגר
-
דיאלוג באנגולר לא נסגר
פורסם ע"י תמר פ. הייטק on 27/08/2023 ב9:29 amיש כאן מישהי תותחית באנגולר שאולי תדע לעזור לי?
יש לי דיאלוג שאני פותחת ע”י לחיצת כפתור, מזינים בו נתונים, ואמור להיסגר בעקבות לחיצה על “שמירה”, במידה והנתונים אכן נשמרו בהצלחה (אם קבלתי 200).
למעשה, הנתונים נשמרים, אני מקבלת סטטוס קוד 200, אבל הדיאלוג לא נסגר.קרה לך? אולי את יודעת מה יכולה להיות הסיבה לכך?
מירי ו הגיבה לפני 1 שנה, 7 חודשים 3 חברות · 3 תגובות -
3 תגובות
-
364
554
0
פעילה בקהילה
תוסיפי את הקוד הרלוונטי, בלתי אפשרי לענות בלי נתונים נוספים.
-
60
178
0
פעילה בקהילה
קצת ארוך, תודה מראש על הסבלנות:
פתיחה של הדיאלוג:
public clickedToAddView() {
this._dialogService.open<SaveViewDialogComponent>(
{
title: $localize
Save View
,content: SaveViewDialogComponent,
width: '375px !important',
height: 'auto',
},
(comp: SaveViewDialogComponent) => (
(comp.listStateKeys = this._listStateKeys$$.value)
)
);
}
הקומפוננטה של הדיאלוג:
export class SaveViewDialogComponent implements OnInit {
@Input() public listStateKeys: ListStateKeys<DataModelKey>;
public newViewFormGroup: UntypedFormGroup;
public errors: FormErrors<any>;
public viewVM: {
viewName: InputViewModel;
saveAsDefault: InputViewModel;
availableForAllUsers: InputViewModel;
};
constructor(
private _store: Store<GlobalState>,
private _logger: Logger,
private _formBuilder: UntypedFormBuilder
) {
this.newViewFormGroup = this._formBuilder.group({
viewName: new UntypedFormControl('', Validators.required),
saveAsDefault: new UntypedFormControl(false),
availableForAllUsers: new UntypedFormControl(true),
});
}
ngOnInit() {
this.viewVM = {
viewName: new InputViewModel({
formControl: this.newViewFormGroup.controls['viewName'],
type: InputType.text,
value: '',
showTitle: false,
error: this.errors ? this.errors['viewName'] : null,
maxLength: 30,
placeholder: $localize
View Name
,}),
saveAsDefault: new InputViewModel({
formControl: this.newViewFormGroup.controls['saveAsDefault'],
title: $localize
Save as Default
,type: InputType.boolean,
value: false,
error: this.errors ? this.errors['saveAsDefault'] : null,
titlePlace: 'after',
maxLength: 30,
}),
availableForAllUsers: new InputViewModel({
formControl: this.newViewFormGroup.controls['availableForAllUsers'],
title: $localize
Available for All Users
,type: InputType.boolean,
value: false,
error: this.errors ? this.errors['availableForAllUsers'] : null,
titlePlace: 'after',
maxLength: 30,
}),
};
}
האפקט שסוגר את הדיאלוג:
public saveNewView$ = createEffect(() =>
this._actions$.pipe(
ofType(listActions.clickedToSaveNewView),
switchMap((action) =>
of(action).pipe(
withLatestFrom(
this._store.select(listSelectors.selectGridViewDto(action))
)
)
),
switchMap(([action, gridViewDto]) =>
this._listService.saveNewGridView(gridViewDto).pipe(
map((savedGridView) =>
listEffectsActions.gridViewSavedSuccessfully({
gridView: savedGridView,
listStateKeys: action.listStateKeys,
})
),
tap(() => {
this._dialogService.close();
}),
catchError((error: HttpErrorResponse) => {
this._logger.error(
An error occurred while saving new Grid View of ${action.listStateKeys.dataModelKey} list. context: ${action.listStateKeys.context}. error: ${error?.message}
);
return of(
listEffectsActions.gridViewSaveFailed({
listStateKeys: action.listStateKeys,
})
);
})
)
)
)
);
-
6
20
0
סטטוס תעסוקתי:חברה חדשה
קשה מאד לקרוא ככה את הקוד צריך לשים את זה בצורה מסודרת אולי בתוך קובץ או משהו
Log in to reply.