private _createLayout()

in legacy/src/Calendar/Dialogs.ts [96:164]


    private _createLayout() {
        this._$container = $(domElem("div"))
            .addClass("edit-event-container")
            .appendTo(this._element);
        this._$contributedContent = $(domElem("div"))
            .addClass("contributed-content-container")
            .appendTo(this._element);
        const membersPromise = this._options.membersPromise;
        let content;
        if (this._source.getEnhancer) {
            this._source.getEnhancer().then(
                enhancer => {
                    const options = {
                        calendarEvent: this._calendarEvent,
                        isEdit: this._options.isEdit,
                        categoriesPromise: this._source.getCategories.bind(this, this._options.query),
                        validStateChangedHandler: (valid: boolean) => {
                            this._contributionsValid = valid;

                            // Erhm...
                            e => {
                                this._validate(true);
                            };
                        },
                        membersPromise: this._options.membersPromise,
                        getIterations: !!(<any>this._source).getIterations
                            ? (<any>this._source).getIterations.bind(this._source)
                            : null,
                    };
                    Controls_Contributions.createContributedControl<Calendar_Contracts.IDialogContent>(
                        this._$contributedContent,
                        enhancer.addDialogId,
                        $.extend(options, { bowtieVersion: 2 }),
                        Context.getDefaultWebContext(),
                    ).then(
                        (control: Calendar_Contracts.IDialogContent) => {
                            try {
                                this._contributedControl = control;
                                if (this._contributedControl.getContributedHeight) {
                                    this._contributedControl.getContributedHeight().then((height: number) => {
                                        this._$contributedContent.find(".external-content-host").css("height", height);
                                    });
                                } else {
                                    this._$contributedContent.find(".external-content-host").css("height", 0);
                                }
                                this._contributedControl.getTitle().then((title: string) => {
                                    this.setTitle(title);
                                });
                                this._contributedControl.getFields().then((fields: Calendar_Contracts.IAddEventContent) => {
                                    this._content = fields;
                                    this._renderContent();
                                });
                            } catch (error) {
                                this._renderContent();
                            }
                        },
                        error => {
                            this._renderContent();
                        },
                    );
                },
                error => {
                    this._renderContent();
                },
            );
        } else {
            this._renderContent();
        }
    }