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

Fix #26349: Template Builder change auto save and publish to just auto save #26494

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<p-tabView
[styleClass]="(featureFlagIsOn$ | async) && 'dot-template-builder__new-template-builder'"
>
[styleClass]="(featureFlagIsOn$ | async) && 'dot-template-builder__new-template-builder'">
<p-tabPanel
[header]="item.type === 'advanced' ? ('code' | dm) : ('design' | dm)"
data-testId="builder"
>
data-testId="builder">
<ng-container *ngIf="item.type === 'advanced'; else elseBlock">
<dot-template-advanced
[didTemplateChanged]="didTemplateChanged"
[body]="item.body"
(updateTemplate)="onTemplateItemChange($event)"
(updateTemplate)="updateTemplate.emit($event)"
(save)="save.emit($event)"
(cancel)="cancel.emit()"
></dot-template-advanced>
(cancel)="cancel.emit()"></dot-template-advanced>
</ng-container>
<ng-template #elseBlock>
<ng-template #enabledComponent>
Expand All @@ -21,8 +18,7 @@
[themeId]="item.theme"
[containerMap]="item.containers"
(templateChange)="onTemplateItemChange($event)"
data-testId="new-template-builder"
>
data-testId="new-template-builder">
<dot-global-message toolbar-left></dot-global-message>
</dotcms-template-builder-lib>
</ng-template>
Expand All @@ -33,13 +29,11 @@
[layout]="item.layout"
(saveAndPublish)="saveAndPublish.emit($event)"
(updateTemplate)="onTemplateItemChange($event)"
(save)="save.emit($event)"
></dot-edit-layout-designer>
(save)="save.emit($event)"></dot-edit-layout-designer>
</ng-template>
<ng-container
*dotShowHideFeature="featureFlag; alternate: disabledComponent"
[ngTemplateOutlet]="enabledComponent"
></ng-container>
[ngTemplateOutlet]="enabledComponent"></ng-container>
</ng-template>
</p-tabPanel>
<p-tabPanel [header]="'Permissions' | dm">
Expand All @@ -56,8 +50,7 @@
#historyIframe
[src]="historyUrl"
(custom)="custom.emit($event)"
data-testId="historyIframe"
></dot-iframe>
data-testId="historyIframe"></dot-iframe>
</dot-portlet-box>
</ng-template>
</p-tabPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ describe('DotTemplateBuilderComponent', () => {
expect(component.updateTemplate.emit).toHaveBeenCalledWith(EMPTY_TEMPLATE_DESIGN);
});

it('should emit save and publish event from dot-edit-layout-designer automatically on template updates', () => {
it('should emit save event from dot-edit-layout-designer automatically on template updates', () => {
fakeAsync(() => {
spyOn(component.saveAndPublish, 'emit');
spyOn(component.save, 'emit');
const builder = de.query(By.css('dot-edit-layout-designer'));
builder.triggerEventHandler('saveAndPublish', EMPTY_TEMPLATE_DESIGN);
builder.triggerEventHandler('save', EMPTY_TEMPLATE_DESIGN);
tick(AUTOSAVE_DEBOUNCE_TIME);
expect(component.saveAndPublish.emit).toHaveBeenCalledWith(EMPTY_TEMPLATE_DESIGN);
expect(component.save.emit).toHaveBeenCalledWith(EMPTY_TEMPLATE_DESIGN);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ export class DotTemplateBuilderComponent implements OnInit, OnDestroy {
this.templateUpdate$
.pipe(debounceTime(AUTOSAVE_DEBOUNCE_TIME), takeUntil(this.destroy$))
.subscribe((templateItem) => {
this.saveAndPublish.emit(templateItem);
this.save.emit(templateItem);
});
}

private subscribeOnChangeBeforeLeaveHandler(): void {
this.dotRouterService.pageLeaveRequest$.pipe(takeUntil(this.destroy$)).subscribe(() => {
this.saveAndPublish.emit(this.lastTemplate);
this.save.emit(this.lastTemplate);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
(click)="editTemplateProps()"
data-testId="editTemplateButton"
pButton
icon="pi pi-pencil"
></button>
icon="pi pi-pencil"></button>
<dot-api-link [href]="vm.apiLink"></dot-api-link>
</ng-container>
</dot-portlet-toolbar>
Expand All @@ -22,8 +21,7 @@
(saveAndPublish)="saveAndPublishTemplate($event)"
(save)="saveTemplate($event)"
(cancel)="cancelTemplate()"
(custom)="onCustomEvent($event)"
></dot-template-builder>
(custom)="onCustomEvent($event)"></dot-template-builder>
</ng-container>
</dot-portlet-base>
</ng-container>