import PageRecord from '../../structures/PageRecord';
import HostRecord from '../../structures/HostRecord';

export abstract class EditorNodeContract {
    protected pageRec!: PageRecord;
    protected nodeRec!: HostRecord;
    protected initialValue: any;

    get page() {
        return this.pageRec;
    }

    set page(page: PageRecord) {
        this.pageRec = page;
    }

    get node() {
        return this.nodeRec;
    }

    set node(node: HostRecord) {
        this.nodeRec = node;
    }

    get identifier() {
        return this.nodeRec.UUID;
    }

    public abstract isDirty(): boolean | Promise<boolean>;
    public abstract writeChangesToNode(): void | Promise<void>;

    public needsSave(): boolean | Promise<boolean> {
        return false;
    }

    public needsLoad(): boolean | Promise<boolean> {
        return false;
    }

    public performSave(): void | Promise<void> {}

    public performLoad(): void | Promise<void> {}

    public performDelete(): void | Promise<void> {}

    public performUIActivation(): void | Promise<void> {}
}
