diff options
Diffstat (limited to 'src/models/News.ts')
-rw-r--r-- | src/models/News.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/models/News.ts b/src/models/News.ts new file mode 100644 index 000000000..3db812937 --- /dev/null +++ b/src/models/News.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | // @flow | ||
2 | |||
3 | interface INews { | ||
4 | id: string; | ||
5 | message: string; | ||
6 | type: string; | ||
7 | sticky: boolean | undefined; | ||
8 | } | ||
9 | |||
10 | export default class News { | ||
11 | id: string = ''; | ||
12 | |||
13 | message: string = ''; | ||
14 | |||
15 | type: string = 'primary'; | ||
16 | |||
17 | sticky: boolean = false; | ||
18 | |||
19 | constructor(data: INews) { | ||
20 | if (!data.id) { | ||
21 | throw Error('News requires Id'); | ||
22 | } | ||
23 | |||
24 | this.id = data.id; | ||
25 | this.message = data.message || this.message; | ||
26 | this.type = data.type || this.type; | ||
27 | this.sticky = data.sticky !== undefined ? data.sticky : this.sticky; | ||
28 | } | ||
29 | } | ||