superdesk/superdesk-client-core

View on GitHub
scripts/apps/dashboard/directives/Widget.ts

Summary

Maintainability
A
0 mins
Test Coverage
import {ConfigController} from 'apps/dashboard/controllers';

Widget.$inject = ['asset', '$modal'];

/**
 * sdWidget give appropriate template to data assgined to it
 *
 * Usage:
 * <div sd-widget data-widget="widget"></div>
 *
 * Params:
 * @scope {Object} widget
 */
export function Widget(asset, $modal) {
    return {
        templateUrl: asset.templateUrl('apps/dashboard/views/widget.html'),
        restrict: 'A',
        replace: true,
        transclude: true,
        scope: {widget: '=', save: '&', configurable: '='},
        link: function(scope, element, attrs) {
            scope.openConfiguration = function() {
                $modal.open({
                    templateUrl: 'scripts/apps/dashboard/views/configuration.html',
                    controller: ConfigController,
                    scope: scope,
                    size: scope.widget.classes,
                });
            };
        },
    };
}