You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/app/components/version-modal/version-modal.component.ts

46 lines
1.4 KiB

import {Component, Input, OnInit, ViewChild} from '@angular/core';
import {AlertController, ModalController} from '@ionic/angular';
import {EditorService} from '../../service/editor.service';
import {PageVersionRecord} from '../../structures/PageRecord';
import {EditorPage} from '../../pages/editor/editor.page';
@Component({
selector: 'app-version-modal',
templateUrl: './version-modal.component.html',
styleUrls: ['./version-modal.component.scss'],
})
export class VersionModalComponent implements OnInit {
@Input() pageId: string;
@ViewChild('editor') editor: EditorPage;
public pageVersions: PageVersionRecord[] = [];
public selectedVersion?: PageVersionRecord;
constructor(
protected alerts: AlertController,
protected modals: ModalController,
protected editorService: EditorService,
) {
console.log('version modal', this);
}
async ngOnInit() {
this.pageVersions = await this.editorService.loadPageVersions(this.pageId);
this.selectedVersion = this.pageVersions[0];
setTimeout(() => {
this.onVersionClick(this.pageVersions[0]);
}, 100);
}
dismiss() {
this.modals.dismiss();
}
async onVersionClick(version: PageVersionRecord) {
this.selectedVersion = version;
if ( this.editor ) {
this.editor.ionViewDidEnter();
}
}
}