Commits
lotte authored cd5c7b72c2e
3 3 | import { type } from '../../shared/ngrx/type'; |
4 4 | |
5 5 | /** |
6 6 | * For each action type in an action group, make a simple |
7 7 | * enum object for all of this group's action types. |
8 8 | * |
9 9 | * The 'type' utility function coerces strings into string |
10 10 | * literal types and runs a simple check to guarantee all |
11 11 | * action types in the application are unique. |
12 12 | */ |
13 - | export const AdminSidebarSectionActionTypes = { |
14 - | COLLAPSE: type('dspace/admin-sidebar-section/COLLAPSE'), |
15 - | EXPAND: type('dspace/admin-sidebar-sectio/EXPAND'), |
16 - | TOGGLE: type('dspace/admin-sidebar-sectio/TOGGLE'), |
13 + | export const AdminSidebarActionTypes = { |
14 + | SECTION_COLLAPSE: type('dspace/admin-sidebar/SECTION_COLLAPSE'), |
15 + | SECTION_EXPAND: type('dspace/admin-sidebar/SECTION_EXPAND'), |
16 + | SECTION_TOGGLE: type('dspace/admin-sidebar/SECTION_TOGGLE'), |
17 + | COLLAPSE: type('dspace/admin-sidebar/COLLAPSE'), |
18 + | EXPAND: type('dspace/admin-sidebar/EXPAND'), |
19 + | TOGGLE: type('dspace/admin-sidebar/TOGGLE'), |
17 20 | }; |
18 21 | |
19 - | export class AdminSidebarSectionAction implements Action { |
20 - | /** |
21 - | * Name of the section the action is performed on, used to identify the section |
22 - | */ |
23 - | sectionName: string; |
22 + | /* tslint:disable:max-classes-per-file */ |
23 + | export class AdminSidebarAction implements Action { |
24 24 | |
25 25 | /** |
26 26 | * Type of action that will be performed |
27 27 | */ |
28 28 | type; |
29 + | } |
30 + | |
31 + | export class AdminSidebarSectionAction extends AdminSidebarAction { |
32 + | /** |
33 + | * Name of the section the action is performed on, used to identify the section |
34 + | */ |
35 + | sectionName: string; |
29 36 | |
30 37 | /** |
31 38 | * Initialize with the section's name |
32 39 | * @param {string} name of the section |
33 40 | */ |
34 41 | constructor(name: string) { |
42 + | super(); |
35 43 | this.sectionName = name; |
36 44 | } |
37 45 | } |
38 46 | |
39 47 | /* tslint:disable:max-classes-per-file */ |
48 + | /** |
49 + | * Used to collapse the sidebar |
50 + | */ |
51 + | export class AdminSidebarCollapseAction extends AdminSidebarAction { |
52 + | type = AdminSidebarActionTypes.COLLAPSE; |
53 + | } |
54 + | |
55 + | /** |
56 + | * Used to expand the sidebar |
57 + | */ |
58 + | export class AdminSidebarExpandAction extends AdminSidebarAction { |
59 + | type = AdminSidebarActionTypes.EXPAND; |
60 + | } |
61 + | |
62 + | /** |
63 + | * Used to collapse the sidebar when it's expanded and expand it when it's collapsed |
64 + | */ |
65 + | export class AdminSidebarToggleAction extends AdminSidebarAction { |
66 + | type = AdminSidebarActionTypes.TOGGLE; |
67 + | } |
68 + | |
40 69 | /** |
41 70 | * Used to collapse a section |
42 71 | */ |
43 72 | export class AdminSidebarSectionCollapseAction extends AdminSidebarSectionAction { |
44 - | type = AdminSidebarSectionActionTypes.COLLAPSE; |
73 + | type = AdminSidebarActionTypes.SECTION_COLLAPSE; |
45 74 | } |
46 75 | |
47 76 | /** |
48 77 | * Used to expand a section |
49 78 | */ |
50 79 | export class AdminSidebarSectionExpandAction extends AdminSidebarSectionAction { |
51 - | type = AdminSidebarSectionActionTypes.EXPAND; |
80 + | type = AdminSidebarActionTypes.SECTION_EXPAND; |
52 81 | } |
53 82 | |
54 83 | /** |
55 84 | * Used to collapse a section when it's expanded and expand it when it's collapsed |
56 85 | */ |
57 86 | export class AdminSidebarSectionToggleAction extends AdminSidebarSectionAction { |
58 - | type = AdminSidebarSectionActionTypes.TOGGLE; |
87 + | type = AdminSidebarActionTypes.SECTION_TOGGLE; |
59 88 | } |
60 89 | |
61 90 | /* tslint:enable:max-classes-per-file */ |