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.
45 lines
1.3 KiB
45 lines
1.3 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.onVersionClick(this.pageVersions[0]);
|
|
}
|
|
|
|
dismiss() {
|
|
this.modals.dismiss();
|
|
}
|
|
|
|
async onVersionClick(version: PageVersionRecord) {
|
|
this.selectedVersion = version;
|
|
setTimeout(() => {
|
|
if ( this.editor ) {
|
|
this.editor.ionViewDidEnter();
|
|
}
|
|
}, 300);
|
|
}
|
|
}
|