import { DialogSOP } from '../../libappsop/dialogsop'; 
 | 
import { DateTimeSelectorSOP } from '../../libappsop/datetimeselectorsop'; 
 | 
import { EditFieldSOP } from '../../libappsop/editfieldsop'; 
 | 
import { LabelSOP } from '../../libappsop/labelsop'; 
 | 
import { DropDownListSOP } from '../../libappsop/dropdownlistsop'; 
 | 
  
 | 
export interface DialogCurrencyRateFields { 
 | 
  Currency?: string; 
 | 
  Start?: string; 
 | 
  Rate?: string; 
 | 
  RateLabel?: string; 
 | 
} 
 | 
  
 | 
/** 
 | 
 * Currency rate dialog. 
 | 
 */ 
 | 
export class DialogCurrencyRate extends DialogSOP<DialogCurrencyRateFields> { 
 | 
  private readonly _ddlCurrency = new DropDownListSOP('DropDownListCurrency'); 
 | 
  private readonly _dtsStart = new DateTimeSelectorSOP('dsStart'); 
 | 
  private readonly _efRate = new EditFieldSOP('EditFieldRate'); 
 | 
  private readonly _labelRate = new LabelSOP('LabelRate'); 
 | 
  
 | 
  public constructor() { 
 | 
    super('DialogCreateEditCurrencyRate'); 
 | 
  
 | 
    // Set UI element mapping to pair the UI name to the UI element for use in DialogSOP to find the UI object to set value or verify value 
 | 
    // This prevents each new Dialog to duplicate code just to set/verify UI element value 
 | 
    this._uiMap.set('Currency', this._ddlCurrency); 
 | 
    this._uiMap.set('Start', this._dtsStart); 
 | 
    this._uiMap.set('Rate', this._efRate); 
 | 
    this._uiMap.set('RateLabel', this._labelRate); 
 | 
  } 
 | 
  
 | 
  /** 
 | 
   * Gets the currency rate label text by specifying the default and source currency. 
 | 
   * 
 | 
   * @param defautltCurrency Base currency. 
 | 
   * @param sourceCurrency Source currency against base currency. 
 | 
   * @returns Currency rate in the form '<defautltCurrency> to 1 <sourceCurrency>' 
 | 
   */ 
 | 
  public getLabelRateFormat(defautltCurrency: string, sourceCurrency: string): string { 
 | 
    return `${defautltCurrency} to 1 ${sourceCurrency}`; 
 | 
  } 
 | 
} 
 | 
  
 | 
/** 
 | 
 * Expected tooltip for OK button when disabled. 
 | 
 */ 
 | 
export const okButtonDisabledTooltip = { 
 | 
  // Partial prefix indicates precondition defined partially thus use partial match when verifying. 
 | 
  partialRateMustGreaterZero: (rate: string): string => `Rate (${rate}) must be greater than 0.`, 
 | 
  partialRateMustUnique: (): string => 'Currency rate must be unique by currency and start.', 
 | 
}; 
 |