aboutsummaryrefslogtreecommitdiffstats
path: root/stories/ng2-component-lab/checklist.component.exp.ts
blob: 4700a743cca80332d6723cadfdc617f84e2337c9 (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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import { experimentOn } from '@islavi/ng2-component-lab';
import { ChecklistItemModel } from "../../src/angular/checklist/models/ChecklistItem";
import { ChecklistModel } from "../../src/angular/checklist/models/Checklist";

const styleCode = 'h5{color:red;} pre{background-color: #d1d1d1; padding: 10px;}';
const checklistValuesExample1 = [];

const checkListExample1: ChecklistModel =  new ChecklistModel(checklistValuesExample1,
    [new ChecklistItemModel('apple'),
        new ChecklistItemModel('banana'),
        new ChecklistItemModel('orange')]);

const checklistValuesExample2 = [];
const checkListExample2: ChecklistModel =  new ChecklistModel(checklistValuesExample2,
    [new ChecklistItemModel('apple', false, false, null, 0),
        new ChecklistItemModel('banana', false, false, null, 1),
        new ChecklistItemModel('orange', false, false, null, 2)]);

const checklistValuesExample3 = [];
const checkListExample3: ChecklistModel =  new ChecklistModel(checklistValuesExample3,
    [new ChecklistItemModel('apple', false, true),
        new ChecklistItemModel('banana'),
        new ChecklistItemModel('orange', false, true)]);

const checklistValuesExample4 = [];
const checkListExample4: ChecklistModel =  new ChecklistModel(checklistValuesExample4,
    [new ChecklistItemModel('apple', true, true),
        new ChecklistItemModel('banana', true),
        new ChecklistItemModel('orange')]);

const checklistValuesExample5 = [];
const innerChecklistValues = [];
const checkListExample5: ChecklistModel =  new ChecklistModel(checklistValuesExample5,
    [new ChecklistItemModel('apple', false, false,
            new ChecklistModel(innerChecklistValues,
                            [new ChecklistItemModel('red'), new ChecklistItemModel('green'), new ChecklistItemModel('yellow')])),
        new ChecklistItemModel('banana'),
        new ChecklistItemModel('orange')]);

const checklistFirstLevelValuesExample6 = [];
const checklistSecondLevelValuesExample6 = [];
const checklistThirdLevelValuesExample6 = [];
const checkListExample6: ChecklistModel =  new ChecklistModel(checklistFirstLevelValuesExample6,
    [new ChecklistItemModel('1', false, false,
        new ChecklistModel(checklistSecondLevelValuesExample6, [new ChecklistItemModel('1.1'),
                                                                new ChecklistItemModel('1.2', false, false, new ChecklistModel(checklistThirdLevelValuesExample6, [new ChecklistItemModel('1.2.1'),
                                                                                                                                                                    new ChecklistItemModel('1.2.2'),
                                                                                                                                                                    new ChecklistItemModel('1.2.3')])),
                                                                new ChecklistItemModel('1.3')])),
        new ChecklistItemModel('2'),
        new ChecklistItemModel('3')]);

export default experimentOn('Checklist')
    .group("Checklist",[
      {
        id: 'checklist',
        showSource: true,
        context: {
            checklistModel: checkListExample1,
            checklistValues: checklistValuesExample1
        },
        styles: [styleCode],
        title: 'Checklist',
        description: `
            <pre>
            <h5>The checklistModel parameter:</h5>
            const checklistValues = [];
            const checklistModel: ChecklistModel =
                new ChecklistModel(checklistValues,
                [new ChecklistItemModel('apple'),
                new ChecklistItemModel('banana'),
                new ChecklistItemModel('orange')]);
            </pre>
        `,
        template: `
            <span>Selected values: {{checklistValues.toString()}}</span>
            <sdc-checklist [checklistModel]="checklistModel"></sdc-checklist>
        `,
      },
      {
        id: 'checklistWithValues',
        showSource: true,
        context: {
            checklistModel: checkListExample2,
            checklistValues: checklistValuesExample2
        },
        styles: [styleCode],
        title: 'Checklist with values',
        description: `
            <pre>
                <h5>The checklistModel parameter:</h5>
                const checklistValues = [];
                const checklistModel: ChecklistModel =  new ChecklistModel(checklistValues,
                    [new ChecklistItemModel('apple', false, false, null, 0),
                    new ChecklistItemModel('banana', false, false, null, 1),
                    new ChecklistItemModel('orange', false, false, null, 2)]);
            </pre>
        `,
        template: `
            <span>Selected values: {{checklistValues.toString()}}</span>
            <sdc-checklist [checklistModel]="checklistModel"></sdc-checklist>
        `
    },
    {
        id: 'checklistWithSomeCheckedItems',
        title: 'Checklist with some checked items',
        showSource: true,
        context: {
            checklistModel: checkListExample3,
            checklistValues: checklistValuesExample3
        },
        styles: [styleCode],
        description: `
            <pre><h5>The checklistModel parameter:</h5>
            const checklistValues = [];
            const checklistModel: ChecklistModel =  new ChecklistModel(checklistValues,
                [new ChecklistItemModel('apple', false, true),
                new ChecklistItemModel('banana'),
                new ChecklistItemModel('orange', false, true)]);
            </pre>
        `,
        template: `
            <span>Selected values: {{checklistValues.toString()}}</span>
            <sdc-checklist [checklistModel]="checklistModel"></sdc-checklist>
        `
    },
    {
        id: 'checklistWithSomeDisabledItems',
        title: 'Checklist with some disabled items',
        showSource: true,
        context: {
            checklistModel: checkListExample4,
            checklistValues: checklistValuesExample4
        },
        styles: [styleCode],
        description: `
            <pre><h5>The checklistModel parameter:</h5>
            const checklistValues = [];
            const checklistModel: ChecklistModel =  new ChecklistModel(checklistValues,
                [new ChecklistItemModel('apple', true, true),
                new ChecklistItemModel('banana', true),
                new ChecklistItemModel('orange')]);
            </pre>
        `,
        template: `
            <span>Selected values: {{checklistValues.toString()}}</span>
            <sdc-checklist [checklistModel]="checklistModel"></sdc-checklist>
        `
    },
    {
        id: 'twoLevelsChecklist',
        title: 'Multi-levels checklist',
        showSource: true,
        context: {
            checklistModel: checkListExample5,
            checklistValues: checklistValuesExample5,
            innerChecklistValues: innerChecklistValues
        },
        styles: [styleCode],
        description: `
            <pre>
            <h5>The checklistModel parameter:</h5>
            const checklistValues = [];
            const innerChecklistValues = [];
            const checklistModel: ChecklistModel =  new ChecklistModel(checklistValues,
                        [new ChecklistItemModel('apple', false, false,new ChecklistModel(innerChecklistValues,[new ChecklistItemModel('red'),
                                                                                                                        new ChecklistItemModel('green'),
                                                                                                                        new ChecklistItemModel('yellow')])),
                        new ChecklistItemModel('banana'),
                        new ChecklistItemModel('orange')]);</pre>
        `,
        template: `
            <div>Selected values: {{checklistValues.toString()}}</div>
            <div>Inner checklist selected values: {{innerChecklistValues.toString()}}</div>
            <sdc-checklist [checklistModel]="checklistModel"></sdc-checklist>
        `
    },
    {
        id: 'multiLevelsChecklist',
        title: 'Multi-levels checklist',
        showSource: true,
        context: {
            checklistModel: checkListExample6,
            checklistFirstLevelValues: checklistFirstLevelValuesExample6,
            checklistSecondLevelValues: checklistSecondLevelValuesExample6,
            checklistThirdLevelValues: checklistThirdLevelValuesExample6
        },
        styles: [styleCode],
        description: `
            <pre><h5>The checklistModel parameter:</h5>
            const checklistFirstLevelValues = [];
            const checklistSecondLevelValues = [];
            const checklistThirdLevelValues = [];
            const checklistModel: ChecklistModel =  new ChecklistModel(checklistFirstLevelValues,
                [new ChecklistItemModel('1', false, false,
                new ChecklistModel(checklistSecondLevelValues, [new ChecklistItemModel('1.1'),
                new ChecklistItemModel('1.2', false, false,
                new ChecklistModel(checklistThirdLevelValues, [new ChecklistItemModel('1.2.1'),
                    new ChecklistItemModel('1.2.2'),
                    new ChecklistItemModel('1.2.3')])),
                    new ChecklistItemModel('1.3')])),
            new ChecklistItemModel('2'),
            new ChecklistItemModel('3')]);
            </pre>
        `,
        template: `
            <div>Selected values: {{checklistFirstLevelValues.toString()}}</div>
            <div>Second level checklist selected values: {{checklistSecondLevelValues.toString()}}</div>
            <div>Third level checklist selected values: {{checklistThirdLevelValues.toString()}}</div>
            <sdc-checklist [checklistModel]="checklistModel"></sdc-checklist>
        `
    }
    ]);