UI: Fixed widget bundle and widget editor after review
This commit is contained in:
parent
e69c986d53
commit
d23c6c1047
@ -52,11 +52,11 @@ import {
|
|||||||
SaveWidgetTypeAsDialogComponent,
|
SaveWidgetTypeAsDialogComponent,
|
||||||
SaveWidgetTypeAsDialogResult
|
SaveWidgetTypeAsDialogResult
|
||||||
} from '@home/pages/widget/save-widget-type-as-dialog.component';
|
} from '@home/pages/widget/save-widget-type-as-dialog.component';
|
||||||
import { forkJoin, mergeMap, of, Subscription, throwError } from 'rxjs';
|
import { forkJoin, mergeMap, of, Subscription } from 'rxjs';
|
||||||
import { ResizeObserver } from '@juggle/resize-observer';
|
import { ResizeObserver } from '@juggle/resize-observer';
|
||||||
import { widgetEditorCompleter } from '@home/pages/widget/widget-editor.models';
|
import { widgetEditorCompleter } from '@home/pages/widget/widget-editor.models';
|
||||||
import { Observable } from 'rxjs/internal/Observable';
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
import { catchError, map, tap } from 'rxjs/operators';
|
import { map, tap } from 'rxjs/operators';
|
||||||
import { beautifyCss, beautifyHtml, beautifyJs } from '@shared/models/beautify.models';
|
import { beautifyCss, beautifyHtml, beautifyJs } from '@shared/models/beautify.models';
|
||||||
import Timeout = NodeJS.Timeout;
|
import Timeout = NodeJS.Timeout;
|
||||||
|
|
||||||
@ -566,12 +566,9 @@ export class WidgetEditorComponent extends PageComponent implements OnInit, OnDe
|
|||||||
this.widgetService.saveWidgetTypeDetails(this.widget, id, createdTime).pipe(
|
this.widgetService.saveWidgetTypeDetails(this.widget, id, createdTime).pipe(
|
||||||
mergeMap((widgetTypeDetails) => {
|
mergeMap((widgetTypeDetails) => {
|
||||||
const widgetsBundleId = this.route.snapshot.params.widgetsBundleId as string;
|
const widgetsBundleId = this.route.snapshot.params.widgetsBundleId as string;
|
||||||
if (widgetsBundleId) {
|
if (widgetsBundleId && !id) {
|
||||||
return this.widgetService.addWidgetFqnToWidgetBundle(widgetsBundleId, widgetTypeDetails.fqn).pipe(
|
return this.widgetService.addWidgetFqnToWidgetBundle(widgetsBundleId, widgetTypeDetails.fqn).pipe(
|
||||||
map(() => widgetTypeDetails),
|
map(() => widgetTypeDetails)
|
||||||
catchError((error) => this.widgetService.deleteWidgetType(widgetTypeDetails.id.id).pipe(
|
|
||||||
mergeMap(() => throwError(() => error))
|
|
||||||
))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return of(widgetTypeDetails);
|
return of(widgetTypeDetails);
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
<span class="mat-headline-5">{{ widgetsBundle.title }}: {{ 'widget.widgets' | translate }}</span>
|
<span class="mat-headline-5">{{ widgetsBundle.title }}: {{ 'widget.widgets' | translate }}</span>
|
||||||
<span fxFlex></span>
|
<span fxFlex></span>
|
||||||
<button mat-icon-button [disabled]="isLoading$ | async"
|
<button mat-icon-button [disabled]="isLoading$ | async"
|
||||||
*ngIf="editMode"
|
*ngIf="!isReadOnly"
|
||||||
matTooltip="{{ 'widget.add-new-widget' | translate }}"
|
matTooltip="{{ 'widget.add-new-widget' | translate }}"
|
||||||
matTooltipPosition="above"
|
matTooltipPosition="above"
|
||||||
[matMenuTriggerFor]="addWidgetMenu">
|
[matMenuTriggerFor]="addWidgetMenu">
|
||||||
|
|||||||
@ -202,13 +202,18 @@ export class WidgetsBundleWidgetsComponent extends PageComponent implements OnIn
|
|||||||
this.importExport.importWidgetType().subscribe(
|
this.importExport.importWidgetType().subscribe(
|
||||||
(widgetType) => {
|
(widgetType) => {
|
||||||
if (widgetType) {
|
if (widgetType) {
|
||||||
if (this.widgets.some(widget => widget.id.id === widgetType.id.id)) {
|
const isExistWidget = this.widgets.some(widget => widget.id.id === widgetType.id.id);
|
||||||
|
if (isExistWidget) {
|
||||||
this.widgets = this.widgets.map(widget => widget.id.id !== widgetType.id.id ? widget : widgetType);
|
this.widgets = this.widgets.map(widget => widget.id.id !== widgetType.id.id ? widget : widgetType);
|
||||||
} else {
|
} else {
|
||||||
this.widgets.push(widgetType);
|
this.widgets.push(widgetType);
|
||||||
}
|
}
|
||||||
this.isDirty = true;
|
if (this.editMode) {
|
||||||
this.cd.markForCheck();
|
this.isDirty = true;
|
||||||
|
this.cd.markForCheck();
|
||||||
|
} else if (!isExistWidget) {
|
||||||
|
this.widgetsService.addWidgetFqnToWidgetBundle(this.widgetsBundle.id.id, widgetType.fqn).subscribe(() => {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -4759,7 +4759,7 @@
|
|||||||
"no-widgets-text": "No widgets found",
|
"no-widgets-text": "No widgets found",
|
||||||
"management": "Widget management",
|
"management": "Widget management",
|
||||||
"editor": "Widget Editor",
|
"editor": "Widget Editor",
|
||||||
"confirm-to-exit-editor-html": "You have unsaved default widget settings.<br>Are you sure you want to leave this page?",
|
"confirm-to-exit-editor-html": "You have unsaved widget settings.<br>Are you sure you want to leave this page?",
|
||||||
"widget-type-not-found": "Problem loading widget configuration.<br>Probably associated\n widget type was removed.",
|
"widget-type-not-found": "Problem loading widget configuration.<br>Probably associated\n widget type was removed.",
|
||||||
"widget-type-load-error": "Widget wasn't loaded due to the following errors:",
|
"widget-type-load-error": "Widget wasn't loaded due to the following errors:",
|
||||||
"remove": "Remove widget",
|
"remove": "Remove widget",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user