Skip to content

Commit

Permalink
Merge branch 'master' into bug/6205-popup-height-after-filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Sep 4, 2023
2 parents 8a31d1a + 6405453 commit 96a228c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 21 deletions.
19 changes: 10 additions & 9 deletions packages/survey-angular-ui/src/base-angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export abstract class BaseAngular<T extends Base = Base> extends EmbeddedViewCon
private isModelSubsribed: boolean = false;

public ngDoCheck(): void {
if(this.previousModel !== this.getModel()) {
if (this.previousModel !== this.getModel()) {
this.unMakeBaseElementAngular(this.previousModel);
this.makeBaseElementAngular(this.getModel());
this.onModelChanged();
Expand All @@ -26,7 +26,7 @@ export abstract class BaseAngular<T extends Base = Base> extends EmbeddedViewCon
this.setIsRendering(true);
}

protected onModelChanged() {}
protected onModelChanged() { }

private setIsRendering(val: boolean) {
const model = this.getModel();
Expand All @@ -42,10 +42,11 @@ export abstract class BaseAngular<T extends Base = Base> extends EmbeddedViewCon
ngOnDestroy() {
this.isDestroyed = true;
this.unMakeBaseElementAngular(this.getModel());
this.previousModel = undefined;
}

private makeBaseElementAngular(stateElement: T) {
if(!!stateElement && !(<any>stateElement).__ngImplemented) {
if (!!stateElement && !(<any>stateElement).__ngImplemented) {
this.isModelSubsribed = true;
(<any>stateElement).__ngImplemented = true;
stateElement.iteratePropertiesHash((hash, key) => {
Expand All @@ -70,15 +71,15 @@ export abstract class BaseAngular<T extends Base = Base> extends EmbeddedViewCon
}
}
private unMakeBaseElementAngular(stateElement?: Base) {
if(!!stateElement && this.isModelSubsribed) {
if (!!stateElement && this.isModelSubsribed) {
this.isModelSubsribed = false;
(<any>stateElement).__ngImplemented = false;
stateElement.setPropertyValueCoreHandler = <any>undefined;
stateElement.iteratePropertiesHash((hash, key) => {
var val: any = hash[key];
if (Array.isArray(val)) {
var val: any = val;
val["onArrayChanged"] = () => {};
val["onArrayChanged"] = () => { };
}
});
}
Expand All @@ -87,12 +88,12 @@ export abstract class BaseAngular<T extends Base = Base> extends EmbeddedViewCon
protected update(key?: string): void {
if (this.getIsRendering()) return;
this.beforeUpdate();
if(key && this.getPropertiesToUpdateSync().indexOf(key) > -1) {
if (key && this.getPropertiesToUpdateSync().indexOf(key) > -1) {
this.detectChanges();
this.afterUpdate(true);
} else {
queueMicrotask(() => {
if(!this.isDestroyed) {
if (!this.isDestroyed) {
this.setIsRendering(true);
this.detectChanges();
}
Expand All @@ -115,13 +116,13 @@ export abstract class BaseAngular<T extends Base = Base> extends EmbeddedViewCon
}

protected beforeUpdate(): void {
if(this.getShouldReattachChangeDetector()) {
if (this.getShouldReattachChangeDetector()) {
this.getChangeDetectorRef().detach();
}
this.setIsRendering(true);
}
protected afterUpdate(isSync: boolean = false): void {
if(this.getShouldReattachChangeDetector()) {
if (this.getShouldReattachChangeDetector()) {
this.getChangeDetectorRef().reattach();
}
this.setIsRendering(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ export class ListComponent extends BaseAngular implements AfterViewInit {
return ["renderElements"];
}
ngAfterViewInit(): void {
if(!!this.listContainerElement?.nativeElement) {
if (!!this.listContainerElement?.nativeElement) {
this.model.initListContainerHtmlElement(this.listContainerElement.nativeElement);
}
}
override ngOnDestroy(): void {
this.model.initListContainerHtmlElement(undefined as any);
super.ngOnDestroy();
}
}

AngularComponentFactory.Instance.registerComponent("sv-list", ListComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ModalComponent {
return this.model;
}
ngOnInit(): void {
if(!!settings.showModal) return;
if (!!settings.showModal) return;
this.functionDefined = true;
settings.showModal = (
componentName: string,
Expand Down Expand Up @@ -58,7 +58,9 @@ export class ModalComponent {
};
}
ngOnDestroy() {
if(this.functionDefined) {
this.portalHost?.detach();
this.model?.dispose();
if (this.functionDefined) {
settings.showModal = <any>undefined;
settings.showDialog = <any>undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,24 @@ export class PopupComponent extends BaseAngular<PopupModel> {
super(changeDetectorRef, viewContainerRef);
}
protected override onModelChanged(): void {
if (this.model) {
this.model.resetComponentElement();
this.model.dispose();
}
this.model = createPopupViewModel(this.popupModel, this.viewContainerRef?.element.nativeElement);
}
ngAfterViewInit(): void {
if(!!this.containerRef?.nativeElement) {
if (!!this.containerRef?.nativeElement) {
const container = this.containerRef.nativeElement as HTMLElement;
this.model.setComponentElement(container, this.getTarget ? this.getTarget(container.parentElement as HTMLElement) : container?.parentElement?.parentElement);
}
}
override ngOnInit() {
this.onModelChanged();
}
override ngOnDestroy(): void {
this.model.resetComponentElement();
this.model.dispose();
super.ngOnDestroy();
}
}
8 changes: 6 additions & 2 deletions packages/survey-angular-ui/src/popup.survey.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BaseAngular } from "./base-angular";
selector: "popup-survey",
templateUrl: "./popup.survey.component.html",
styleUrls: ["./popup.survey.component.scss"]
})
})
export class PopupSurveyComponent extends BaseAngular<PopupSurveyModel> implements OnChanges {
@Input() model!: SurveyModel;
@Input() isExpanded?: boolean;
Expand All @@ -24,7 +24,7 @@ export class PopupSurveyComponent extends BaseAngular<PopupSurveyModel> implemen
return false;
}
ngOnChanges(changes: SimpleChanges): void {
if(changes["model"]?.currentValue !== changes["model"]?.previousValue) {
if (changes["model"]?.currentValue !== changes["model"]?.previousValue) {
this.popup = new PopupSurveyModel(null, this.model);
}
if (this.isExpanded !== undefined) {
Expand All @@ -39,4 +39,8 @@ export class PopupSurveyComponent extends BaseAngular<PopupSurveyModel> implemen
this.popup.isShowing = true;
this.changeDetectorRef.detectChanges();
}
override ngOnDestroy(): void {
super.ngOnDestroy();
this.popup.dispose();
}
}
14 changes: 8 additions & 6 deletions packages/survey-angular-ui/src/survey-content.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AngularComponentFactory } from "./component-factory";
@Component({
selector: "survey-content",
templateUrl: "./survey-content.component.html"
})
})
export class SurveyContentComponent extends BaseAngular<SurveyModel> implements OnInit, AfterViewInit {
@Input() model!: SurveyModel;
@ViewChild("surveyContainer", { static: false }) rootEl!: ElementRef<HTMLDivElement>;
Expand All @@ -15,11 +15,11 @@ export class SurveyContentComponent extends BaseAngular<SurveyModel> implements
return this.model;
}
protected override onModelChanged(): void {
if(!!this.previousModel) {
if (!!this.previousModel) {
this.previousModel.destroyResizeObserver();
this.previousModel.renderCallback = <any>undefined;
}
if(!!this.model) {
if (!!this.model) {
this.model.renderCallback = () => {
this.detectChanges();
};
Expand All @@ -28,21 +28,23 @@ export class SurveyContentComponent extends BaseAngular<SurveyModel> implements
}
override ngOnInit(): void {
super.ngOnInit();
if(!!this.model && this.model["needRenderIcons"]) {
if (!!this.model && this.model["needRenderIcons"]) {
SvgRegistry.renderIcons();
}
}
override ngOnDestroy(): void {
super.ngOnDestroy();
if(!!this.model) {
if (!!this.model) {
this.model.rootElement = undefined as any;
this.model.destroyResizeObserver();
this.model.renderCallback = <any>undefined;
}
}
ngAfterViewInit(): void {
this.isSurveyUpdated = true;
}
override ngAfterViewChecked(): void {
if(!!this.model && this.isSurveyUpdated) {
if (!!this.model && this.isSurveyUpdated) {
this.model.afterRenderSurvey(this.rootEl.nativeElement);
this.model.startTimerFromUI();
}
Expand Down

0 comments on commit 96a228c

Please sign in to comment.