API Docs for: 2.0.20133.2
Show:

File: src\internal\ui\caseManagement\manageCaseCommunications.ts

/// <reference path="../../../../packages/jquery.TypeScript.DefinitelyTyped.2.2.1/Content/Scripts/typings/jquery/jquery.d.ts" />
/// <reference path="../../packages.ts" />
/// <reference path="../constants.ts" />
/// <reference path="../uiComponent.ts"/>
/// <reference path="constants.ts" /> 
/// <reference path="createCaseConfig.ts" /> 
/// <reference path="manageCaseCommunicationConfig.ts" /> 
/**
 * @module UI
 * @submodule CaseManagement
 * @namespace ui
 */

/**
 * manageCaseCommunication UI Module
 * @class manageCaseCommunication
 * @static
 */
namespace internal.ui.caseManagement.manageCaseCommunication {

    export function render(config: ManageCaseCommunicationConfig): JQueryPromise<any> {
        return ui.renderComponent(ManageCaseCommunicationComponent, config, CASEMANAGEMENT_COMPONENT);
    }

    export class ManageCaseCommunicationComponent extends UIComponent {
        private static DEFAULT_CASE_COMMUNICATION_PATH = "commercial/cases";

        constructor(config: ManageCaseCommunicationConfig) {
            super(config, LOAD_TIMEOUT_MS, REPORT_HEIGHT_CHANGE);
        }

        public getComponentUrl(): string {
            return this.getManageCommunicationsUrl(<ManageCaseCommunicationConfig>this.config);
        }

        public getComponentSdk(): ComponentSDK {
            return {};
        }

        // Override this method in the UI component to use a different xframe proxy url if needed
        public getXframeProxyUrl(): string {
            return `${utils.getOriginFromUrl(this.getComponentUrl())}/${DEFAULT_XFRAME_PROXY_PATH}/`;
        }

        private getManageCommunicationsUrl(config: ManageCaseCommunicationConfig): string {
            let values: any = {};

            let locale = config.locale ? config.locale : DEFAULT_LOCALE;

            // don't pass preview flag at all if it isn't in the config
            if (config.preview) values[CASE_PREVIEW] = true;

            // always use nochrome in the sdk
            values[CASE_NOCHROME] = DEFAULT_NOCHROME;

            if (!config.caseNumber) {
                throw "Error in ManageCaseCommunicationComponent component. Case number is a required parameter";
            }

            return utils.appendParams(`https://${getCaseBaseUrl(config)}/${locale}/${ManageCaseCommunicationComponent.DEFAULT_CASE_COMMUNICATION_PATH}/${config[CASE_NUMBER]}`,
                values);
        }
    }
}