superdesk/superdesk-client-core

View on GitHub
scripts/apps/archive/directives/MetaIngest.ts

Summary

Maintainability
A
35 mins
Test Coverage
MetaIngest.$inject = ['ingestSources'];

export function MetaIngest(ingestSources) {
    return {
        scope: {
            item: '=',
        },
        template: '{{ name }}',
        link: function(scope) {
            scope.$watch('item', renderIngest);
            function renderIngest() {
                ingestSources.initialize().then(() => {
                    if (scope.item && scope.item.ingest_provider in ingestSources.providersLookup) {
                        scope.name = ingestSources.providersLookup[scope.item.ingest_provider].name ||
                        ingestSources.providersLookup[scope.item.ingest_provider].search_provider;
                    } else {
                        scope.name = '';
                    }
                });
            }
        },
    };
}