aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/directives/tag/tag-directive.ts
blob: 77a26fc6f72c2094de4fb10394313def7e6c4e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';

export class TagData {
    tag:string;
    tooltip:string;
    id:string;
}

export interface ITagScope extends ng.IScope {
    tagData:TagData;
    onDelete:Function;
    delete:Function;
    hideTooltip:boolean;
    hideDelete:boolean;
    sdcDisable:boolean;
}

export class TagDirective implements ng.IDirective {

    constructor() {
    }

    scope = {
        tagData: '=',
        onDelete: '&',
        hideTooltip: '=',
        hideDelete: '=',
        sdcDisable: '='
    };

    replace = true;
    restrict = 'EA';
    template = ():string => {
        return require('./tag-directive.html');
    };

    link = (scope:ITagScope) => {
        scope.delete = ()=> {
            scope.onDelete({'uniqueId': scope.tagData.id});
        }
    };

    public static factory = ()=> {
        return new TagDirective();
    };

}

TagDirective.factory.$inject = [];