sidebar-section.component.ts
3.09 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import {Component, Input} from "ng-forward";
@Component({
selector: 'sidebar-section',
templateUrl: 'app/layout/sidebar/sidebar-section.html'
})
/**
* @ngdoc object
* @name sidebar.SidebarSectionComponent
* @description
* This is a widget to render sections to
* SidebarComponent.
*
* <b>Usage example:</b>
* @example
* <pre>
* let section: SidebarSectionComponent = new SidebarSectionComponent('MySection');
* section.addItem({
* title: 'Friends',
* count: 0,
* url: '#',
* className: 'active',
* icon: 'fa-users', //A font-awesome icon class
* subitems: [
* { title: 'Example' }
* ]
* });
* </pre>
*/
export class SidebarSectionComponent {
/**
* @ngdoc property
* @name name
* @propertyOf sidebar.SidebarComponent
* @description
* The name of the section
*/
@Input()
public name: string;
/**
* @ngdoc property
* @name items
* @propertyOf sidebar.SidebarComponent
* @description
* Array of items to render into this sidebar menu
*/
@Input()
public items: any[] = [
{
title: 'Friends',
count: 0,
url: '#',
className: 'active',
icon: 'fa-users'
}
];
/**
* @ngdoc method
* @name constructor
* @methodOf sidebar.SidebarSectionComponent
* @param {string} name The name of the section (optional)
* @description
* The constructor for this component. The name of section
* can be assigned here, optionally
*/
constructor(name?: string) {
this.name = name;
}
/**
* @ngdoc method
* @name addItem
* @methodOf sidebar.SidebarSectionComponent
* @param {Object} item Literal object with properties to render a menu item
* @returns {SidebarSectionComponent} This own component type, using the "Fluent Interface" pattern
* @description
* Use this method to add new items for a section instance
*
* <b>Usage example:</b>
* @example
* <pre>
* section.addItem({
* title: 'Friends',
* count: 0,
* url: '#',
* className: 'active',
* icon: 'fa-users', //A font-awesome icon class
* subitems: [
* { title: 'Example' } //A subitem literal object
* ]
* });
* </pre>
*/
addItem(item: any): SidebarSectionComponent {
this.items.push(item);
return this;
}
/**
* @ngdoc method
* @name setName
* @methodOf sidebar.SidebarSectionComponent
* @param {string} name The name of the section
* @returns {SidebarSectionComponent} This own component type, using the "Fluent Interface" pattern
* @description
* Change the name of the section assigned on constructor
*
* <b>Usage example:</b>
* @example
* <pre>
* section.setName('MyAnotherSection')
* .addItem({
* //Item here
* ...
* });
* </pre>
*/
setName(name: string): SidebarSectionComponent {
this.name = name;
return this;
}
}