import { Client, EmploymentContract } from "@salaxy/core"; import { SessionService } from "../account/SessionService"; import { IRepository } from "./IRepository"; /** * Implements the salaxy repository pattern for Contracts stored for the current account. */ export declare class ContractRepository implements IRepository { private client; /** List of items in the repository */ list: EmploymentContract[]; /** Currently selected item in the repository */ current: EmploymentContract; constructor(client: Client); /** * Assures the repository initialization: * Initialization is done after successful authentication. * Typically the call to fetch the repository list, but may fetch other stuff from the server. * * @param session - The session service that contains information about the authenticated user. */ init(session: SessionService): void; /** * Reloads the list from the server - called e.g. after delete and add new * @param callback - Optional callback that is called after save and susequent reloadList completes. */ reloadList(callback?: () => any): void; /** * Gets a new blank object with default values, suitable for UI binding. * This is a synchronous method - does not go to the server and it is not 100% reliable in that way. * However, it shoud provide a basic object, good enough for most views. */ getBlank(): EmploymentContract; /** * Sets the current repository item. * If not loaded, starts loading from the server to the current. * @param id - Identifier of the calculation */ setCurrentId(id: string): void; /** * Sets the current calculation * @param item - Item to set as current */ setCurrent(item: EmploymentContract): void; /** * Creates a new item and sets it as current for editing and saving. * The item is not yet sent to server and thus it is not in the list, nor does it have an identifier. */ newCurrent(): void; /** * Saves changes to the current item. * @param callback - Optional callback that is called after save and susequent reloadList completes. */ saveCurrent(callback?: () => any): void; /** * Adds or updates a given item. * Operation is determined based on id: null/''/'new' adds, other string values update. * @param item - Item that is updated. * @param callback - Optional callback that is called after save and susequent reloadList completes. */ save(item: EmploymentContract, callback?: () => any): void; /** * Deletes the given item from repository if possible * @param id - Identifier of the item to delete * @param callback - Optional callback that is called after save and susequent reloadList completes. */ delete(id: string, callback?: () => any): void; /** * Gets the preview HTML for an employment contract. * @param id - Identifier of the contract to get preview for * @param callback - Callback that is called with the preview HTML after the preview has been fetched */ getPreview(id: string, callback: (previewHTML: any) => any): void; /** * Gets an URL for the Employment contract preview. * May be used in linked previews (to new window) or iframes (you may need to sanitize the URL). * @param id IDentifier of the contract. */ getPreviewUrl(id: string): string; }