component-with-loading.ts 785 Bytes
namespace noosfero {

    const NOOSFERO_DEFAULT_LOADING_MESSAGE_KEY = "noosfero.progress_indicator_message";

    /**
     * Interface to be used on components where we will add the loading progress behavior 
     */
    export interface ComponentWithLoading {
        loadingConfig: ComponentLoadingConfig;
    }
    export interface ComponentLoadingConfig {
        getLoadingMessageKey(): string;
        getCurrentPromise(): ng.IPromise<any>;
    }

    export function setupDefaultLoadingConfig(component: ComponentWithLoading, messageKey: string) {
        component.loadingConfig = <ComponentLoadingConfig>{
            getLoadingMessageKey: () => NOOSFERO_DEFAULT_LOADING_MESSAGE_KEY,
            getCurrentPromise: () => (<any>component)["currentPromise"]
        };
    }

}