@intellias/menu 1.0.2 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +44 -9
  2. package/dist/css/main.css +155 -2
  3. package/dist/index.html +9 -0
  4. package/dist/js/{1.js → kudosForm.js} +24 -58
  5. package/dist/js/main.js +654 -689
  6. package/dist/js/rejectComponent.js +363 -0
  7. package/dist/js/{6.js → vendors~kudosForm.js} +5 -5
  8. package/dist/js/{0.js → vendors~kudosForm~rejectComponent.js} +27 -27
  9. package/dist/js/vue.js +2 -2
  10. package/package.json +100 -112
  11. package/Menu.ts +0 -625
  12. package/assets/icons/arrow-down.svg +0 -13
  13. package/assets/icons/arrow-left.svg +0 -3
  14. package/assets/icons/arrow-submenu.svg +0 -8
  15. package/assets/icons/close.svg +0 -3
  16. package/assets/icons/delete.svg +0 -13
  17. package/assets/icons/faq-new.svg +0 -4
  18. package/assets/icons/kudos.svg +0 -14
  19. package/assets/icons/loading-spinner.svg +0 -40
  20. package/assets/icons/notification.svg +0 -11
  21. package/assets/icons/notifications/assessment.svg +0 -10
  22. package/assets/icons/notifications/buddy_program.svg +0 -8
  23. package/assets/icons/notifications/compensation_packages.svg +0 -10
  24. package/assets/icons/notifications/dsat.svg +0 -8
  25. package/assets/icons/notifications/feedback.svg +0 -7
  26. package/assets/icons/notifications/kudos.svg +0 -4
  27. package/assets/icons/notifications/overtime_requests.svg +0 -15
  28. package/assets/icons/notifications/pdu_program.svg +0 -4
  29. package/assets/icons/notifications/profile_update.svg +0 -6
  30. package/assets/icons/notifications/recommendation_program.svg +0 -7
  31. package/assets/icons/notifications/reminders.svg +0 -4
  32. package/assets/icons/notifications/sick_leaves.svg +0 -5
  33. package/assets/icons/notifications/smarts.svg +0 -4
  34. package/assets/icons/notifications/survey.svg +0 -8
  35. package/assets/icons/notifications/unpaid_leave.svg +0 -4
  36. package/assets/icons/notifications/vacations.svg +0 -4
  37. package/assets/icons/pause.svg +0 -13
  38. package/assets/icons/play.svg +0 -13
  39. package/assets/icons/smart.svg +0 -14
  40. package/assets/icons/smarts-kudos.svg +0 -11
  41. package/assets/icons/spinner-solid.svg +0 -1
  42. package/assets/icons/vacation.svg +0 -14
  43. package/assets/icons/visibility.svg +0 -1
  44. package/assets/intems-logo.svg +0 -3
  45. package/babel.config.js +0 -6
  46. package/buses/eventBus.ts +0 -19
  47. package/buses/events/GiveKudosEvent.ts +0 -7
  48. package/components/buttons/action-button/ActionButton.scss +0 -133
  49. package/components/buttons/action-button/ActionButton.ts +0 -57
  50. package/components/buttons/action-button/ActionButton.vue +0 -50
  51. package/components/buttons/secondary-button/SecondaryButton.scss +0 -48
  52. package/components/buttons/secondary-button/SecondaryButton.ts +0 -28
  53. package/components/buttons/secondary-button/SecondaryButton.vue +0 -27
  54. package/components/confirm/Confirm.scss +0 -44
  55. package/components/confirm/Confirm.ts +0 -82
  56. package/components/confirm/Confirm.vue +0 -64
  57. package/components/give-kudos-form/GiveKudosForm.scss +0 -114
  58. package/components/give-kudos-form/GiveKudosForm.ts +0 -159
  59. package/components/give-kudos-form/GiveKudosForm.vue +0 -131
  60. package/components/give-kudos-form/mixins/UserSelectMixin.ts +0 -57
  61. package/components/give-kudos-form/models/KudosShareModel.ts +0 -6
  62. package/components/give-kudos-form/models/UserListModel.ts +0 -5
  63. package/components/give-kudos-form/validators/InEnglishValidatorRegex.ts +0 -17
  64. package/components/give-kudos-form/validators/KudosBalance.ts +0 -10
  65. package/components/modal/Modal.scss +0 -53
  66. package/components/modal/Modal.ts +0 -70
  67. package/components/modal/Modal.vue +0 -28
  68. package/components/notifications-sidebar/NotificationsSidebar.scss +0 -665
  69. package/components/notifications-sidebar/NotificationsSidebar.ts +0 -203
  70. package/components/notifications-sidebar/NotificationsSidebar.vue +0 -171
  71. package/components/notifications-sidebar/models/BroadcastNotificationPayload.ts +0 -8
  72. package/components/notifications-sidebar/models/TotalCounter.ts +0 -50
  73. package/components/notifications-sidebar/notification/Notification.ts +0 -17
  74. package/components/notifications-sidebar/notification/Notification.vue +0 -87
  75. package/components/play-pause/PlayPause.scss +0 -33
  76. package/components/play-pause/PlayPause.ts +0 -156
  77. package/components/play-pause/PlayPause.vue +0 -36
  78. package/components/play-pause/PlayPauseStatus.ts +0 -4
  79. package/components/play-pause/helpers/LatestTrackedTimeDurationHelper.ts +0 -55
  80. package/components/play-pause/helpers/PauseHelper.ts +0 -55
  81. package/components/play-pause/helpers/TrackedTimeHelper.ts +0 -80
  82. package/components/preloader/Preloader.vue +0 -34
  83. package/components/request-loader/RequestLoader.scss +0 -20
  84. package/components/request-loader/RequestLoader.ts +0 -80
  85. package/components/request-loader/RequestLoader.vue +0 -15
  86. package/components/sub-menu/SubMenu.scss +0 -33
  87. package/components/sub-menu/SubMenu.ts +0 -38
  88. package/components/sub-menu/SubMenu.vue +0 -21
  89. package/components/time-ago/TimeAgo.ts +0 -34
  90. package/components/time-ago/TimeAgo.vue +0 -9
  91. package/components/user-picture/UserPicture.scss +0 -62
  92. package/components/user-picture/UserPicture.ts +0 -105
  93. package/components/user-picture/UserPicture.vue +0 -23
  94. package/components/v-select-intems/VSelectIntems.ts +0 -112
  95. package/components/v-select-intems/VSelectIntems.vue +0 -68
  96. package/components/v-select-intems/open-indicator/OpenIndicator.vue +0 -3
  97. package/dist/css/1.css +0 -85
  98. package/dist/css/2.css +0 -34
  99. package/dist/css/3.css +0 -34
  100. package/dist/css/4.css +0 -34
  101. package/dist/css/5.css +0 -34
  102. package/dist/html/app.html +0 -19
  103. package/dist/html/styles.html +0 -1
  104. package/dist/js/2.js +0 -217
  105. package/dist/js/3.js +0 -181
  106. package/dist/js/4.js +0 -181
  107. package/dist/js/5.js +0 -181
  108. package/helpers/GeneralHelper.ts +0 -61
  109. package/helpers/PublisherSubscriber.ts +0 -34
  110. package/helpers/QueryFilter.ts +0 -204
  111. package/helpers/TimeHelper.ts +0 -54
  112. package/helpers/Validations.ts +0 -7
  113. package/helpers/model/ModelHelper.ts +0 -155
  114. package/helpers/model/decorators/AsCollection.ts +0 -26
  115. package/helpers/model/decorators/AsModel.ts +0 -25
  116. package/helpers/model/decorators/DateTime.ts +0 -26
  117. package/helpers/model/decorators/TimeDuration.ts +0 -33
  118. package/helpers/moment/Duration.ts +0 -64
  119. package/helpers/moment/Moment.ts +0 -17
  120. package/helpers/moment/index.d.ts +0 -20
  121. package/helpers/response/AxiosProxy.ts +0 -72
  122. package/helpers/response/ErrorsToToastHelper.ts +0 -42
  123. package/helpers/response/ResponseCode.ts +0 -16
  124. package/helpers/response/ResponseHelper.ts +0 -42
  125. package/helpers/response/ResponseInterface.ts +0 -34
  126. package/helpers/response/ResponseState.ts +0 -6
  127. package/jsconfig.json +0 -19
  128. package/mixins/IntemsMath.ts +0 -29
  129. package/mixins/notifications/ActionProcessing.ts +0 -134
  130. package/mixins/notifications/confirms/AssetRejectionConfirm.vue +0 -59
  131. package/mixins/notifications/confirms/SickLeaveRejectionConfirm.vue +0 -31
  132. package/mixins/notifications/confirms/UnpaidLeaveRejectionConfirm.vue +0 -31
  133. package/mixins/notifications/confirms/VacationRejectionConfirm.vue +0 -31
  134. package/models/AssetModel.ts +0 -80
  135. package/models/AssetRequestModel.ts +0 -25
  136. package/models/ConfigModel.ts +0 -20
  137. package/models/EmployeeStartEndDateModel.ts +0 -16
  138. package/models/EmploymentTypeModel.ts +0 -95
  139. package/models/LogoutModel.ts +0 -3
  140. package/models/Model.ts +0 -12
  141. package/models/ModuleOptions.ts +0 -24
  142. package/models/PublicInfoModel.ts +0 -38
  143. package/models/PublicLocationModel.ts +0 -36
  144. package/models/StatusModel.ts +0 -8
  145. package/models/TrackedTimeModel.ts +0 -32
  146. package/models/location/PublicLocationModel.ts +0 -36
  147. package/models/timezones/LocalTimezoneHistoryModel.ts +0 -8
  148. package/models/timezones/TimezoneModel.ts +0 -9
  149. package/models/user/ExtendedInfoModel.ts +0 -37
  150. package/models/user/NotificationActionModel.ts +0 -53
  151. package/models/user/NotificationModel.ts +0 -84
  152. package/models/user/PublicInfoModel.ts +0 -38
  153. package/models/user/WelcomeProgram.ts +0 -4
  154. package/repositories/BaseRepository.ts +0 -42
  155. package/repositories/BaseUrl.ts +0 -107
  156. package/repositories/Repository.ts +0 -291
  157. package/repositories/ResourceRepository.ts +0 -99
  158. package/repositories/TrackedTimeRepository.ts +0 -43
  159. package/repositories/UserRepository.ts +0 -75
  160. package/repositories/subscribers/CreateSubscribers.ts +0 -28
  161. package/repositories/subscribers/DefaultSubscribers.ts +0 -82
  162. package/repositories/subscribers/DeleteSubscribers.ts +0 -28
  163. package/repositories/subscribers/DownloadSubscribers.ts +0 -28
  164. package/repositories/subscribers/Subscribers.ts +0 -13
  165. package/repositories/subscribers/UpdateSubscribers.ts +0 -32
  166. package/scss/components/_global.scss +0 -66
  167. package/scss/components/_mixins.scss +0 -31
  168. package/scss/components/_tooltip.scss +0 -45
  169. package/scss/components/_utils.scss +0 -26
  170. package/scss/components/_variables.scss +0 -103
  171. package/scss/main.scss +0 -7
  172. package/shims-vue.d.ts +0 -9
  173. package/tsconfig.json +0 -31
  174. package/webpack.config.js +0 -126
  175. package/wrapper.ts +0 -51
@@ -1,204 +0,0 @@
1
- import { Moment } from "moment";
2
-
3
- enum SortDirection {
4
- asc = "asc",
5
- desc = "desc",
6
- }
7
- const MAX_ITEMS_ON_PAGE = 25;
8
- export default class QueryFilter {
9
- private query = {};
10
- max_on_page = MAX_ITEMS_ON_PAGE as number;
11
- total = undefined as number;
12
- end_reached = false as boolean;
13
- loading = false as boolean;
14
-
15
- equal(key: string, value: string | number | Moment): this {
16
- if (value) {
17
- this.query[`${key}$eq`] = value;
18
- }
19
-
20
- return this;
21
- }
22
-
23
- custom(
24
- key: string,
25
- value: string | number | boolean | Moment | string[]
26
- ): this {
27
- if (value !== null) {
28
- this.query[key] = value;
29
- }
30
-
31
- return this;
32
- }
33
-
34
- scope(key: string, value: string | number | Moment): this {
35
- if (value) {
36
- this.query[`${key}$scope`] = value;
37
- }
38
-
39
- return this;
40
- }
41
-
42
- jsonContains(key: string, value: string | number | Moment): this {
43
- if (value) {
44
- this.query[`${key}$jc`] = value;
45
- }
46
-
47
- return this;
48
- }
49
-
50
- notEqual(key: string, value: string | number | Moment): this {
51
- if (value) {
52
- this.query[`${key}$neq`] = value;
53
- }
54
-
55
- return this;
56
- }
57
-
58
- gte(key: string, value: string | number | Moment): this {
59
- if (value) {
60
- this.query[`${key}$gte`] = value;
61
- }
62
-
63
- return this;
64
- }
65
-
66
- lte(key: string, value: string | number | Moment): this {
67
- if (value) {
68
- this.query[`${key}$lte`] = value;
69
- }
70
-
71
- return this;
72
- }
73
-
74
- gt(key: string, value: string | number | Moment): this {
75
- if (value) {
76
- this.query[`${key}$gt`] = value;
77
- }
78
-
79
- return this;
80
- }
81
-
82
- lt(key: string, value: string | number | Moment): this {
83
- if (value) {
84
- this.query[`${key}$lt`] = value;
85
- }
86
-
87
- return this;
88
- }
89
-
90
- like(key: string, value: string | number | Moment): this {
91
- if (value) {
92
- this.query[`${key}$like`] = value;
93
- }
94
-
95
- return this;
96
- }
97
-
98
- offset(offset: number): this {
99
- this.query[`@offset`] = offset;
100
-
101
- return this;
102
- }
103
-
104
- take(take: number = this.max_on_page): this {
105
- this.query[`@take`] = take;
106
-
107
- return this;
108
- }
109
-
110
- page(page: number | null, max_on_page = this.max_on_page): this {
111
- if (page) {
112
- this.offset(page * max_on_page - max_on_page);
113
- this.take(max_on_page);
114
- this.custom("page", page);
115
- }
116
-
117
- return this;
118
- }
119
-
120
- firstPage(): this {
121
- this.end_reached = false;
122
- this.page(1);
123
-
124
- return this;
125
- }
126
-
127
- unsetPagination(): this {
128
- this.end_reached = false;
129
- this.offset(undefined);
130
-
131
- return this;
132
- }
133
-
134
- nextPage(): this {
135
- if (this.query[`@offset`] !== undefined) {
136
- this.offset(this.query[`@offset`] + this.max_on_page);
137
- } else {
138
- this.offset(0);
139
- }
140
- this.take(this.max_on_page);
141
-
142
- return this;
143
- }
144
-
145
- unlimited(): this {
146
- this.take(null);
147
- this.offset(null);
148
- this.page(null);
149
-
150
- return this;
151
- }
152
-
153
- sort(key: number, direction: SortDirection = SortDirection.asc): this {
154
- this.query[`@sort,${direction}`] = key;
155
-
156
- return this;
157
- }
158
-
159
- in(key: string, values: Array<string | number | Moment>): this {
160
- if (values) {
161
- this.query[`${key}$in`] = values.join(",");
162
- }
163
-
164
- return this;
165
- }
166
-
167
- notIn(key: string, values: Array<string | number | Moment>): this {
168
- if (values) {
169
- this.query[`${key}$nin`] = values.join(",");
170
- }
171
-
172
- return this;
173
- }
174
-
175
- endList(): void {
176
- this.end_reached = true;
177
- }
178
-
179
- startLoading(): void {
180
- this.loading = true;
181
- }
182
-
183
- endLoading(): void {
184
- this.loading = false;
185
- }
186
-
187
- maxOnPage(max_on_page: number): this {
188
- this.max_on_page = max_on_page;
189
-
190
- return this;
191
- }
192
-
193
- getKey(key: string): unknown {
194
- return this.query[key];
195
- }
196
-
197
- clone(): QueryFilter {
198
- return Object.assign(Object.create(Object.getPrototypeOf(this)), this);
199
- }
200
-
201
- toObject(): Record<string, unknown> {
202
- return this.query;
203
- }
204
- }
@@ -1,54 +0,0 @@
1
- import { Moment } from "moment";
2
- import moment from "./moment/Moment";
3
-
4
- const workingHours = 8;
5
-
6
- const formatDuration = (duration: number) => {
7
- const hours = Math.trunc(duration / 60);
8
- const minutes = `0${duration % 60}`.slice(-2);
9
- return `${hours}:${minutes}`;
10
- };
11
-
12
- const fiveMinutesRound = (minutes: number) => {
13
- return Math.round(minutes / 5) * 5;
14
- };
15
-
16
- /**
17
- * Returns difference between two dates rounded using 5 minutes grid
18
- * @param from
19
- * @param to
20
- */
21
- const diffMinutes = (from: Moment, to: Moment) => {
22
- const minutes = to.diff(from, "minutes", true);
23
- return fiveMinutesRound(minutes);
24
- };
25
-
26
- /**
27
- * Example 1: start = 16:03:00, to: 16:04:30 (can be current time), return = 16:05:30
28
- * Example 2: start = 16:03:00, to: 16:05:30, return = 16:10:30 (not 16:08:00 because now 5 minutes round is 5 minutes
29
- * and next change (10 minutes) will appear in 16:10:30)
30
- * Example 3: start = 16:03:00, to: 16:07:00, return = 16:10:30
31
- * Example 4: start = 16:03:00, to: 16:10:00 (can be current time), return = 16:10:30
32
- * Example 5: start = 16:10:35, to: 16:10:00 (can be current time), return = 16:15:30
33
- *
34
- * @todo write tests!!!
35
- * @param {Moment} from
36
- * @param {Moment} to
37
- */
38
- const nextTimeFiveMinutesWillRound = (from: Moment, to: Moment) => {
39
- const minutesDiff = to.diff(from, "minutes", true);
40
- const roundedTo5Minutes = fiveMinutesRound(minutesDiff);
41
- const timeElapsed = minutesDiff - roundedTo5Minutes;
42
- const leftToHalfOf5Minutes = 2.5 - timeElapsed;
43
-
44
- return to.clone().add(leftToHalfOf5Minutes, "minutes");
45
- };
46
-
47
- export {
48
- workingHours,
49
- formatDuration,
50
- diffMinutes,
51
- fiveMinutesRound,
52
- nextTimeFiveMinutesWillRound,
53
- moment,
54
- };
@@ -1,7 +0,0 @@
1
- const onlyLatin = (value: string): boolean => !/[^\u0020-\u007e\u00a0-\u00ff]/g.test(value);
2
-
3
- const onlyCyrillic = (value: string): boolean => /^[^A-Za-z]*$/g.test(value);
4
-
5
- const monthReportingLimit = (value: number): boolean => value >= 1 && value <= 300;
6
-
7
- export { onlyLatin, onlyCyrillic, monthReportingLimit };
@@ -1,155 +0,0 @@
1
- import { collect, Collection as BaseCollection } from "collect.js";
2
- import * as moment from "moment";
3
-
4
- /**
5
- * Map resource to model
6
- * @param target model class
7
- * @param source resource that we get from api
8
- */
9
- const map = (target, source) => {
10
- if (Array.isArray(source)) {
11
- return mapCollection(source, target);
12
- }
13
-
14
- if (!target) {
15
- return;
16
- }
17
- const model = new target();
18
- for (const key of Object.keys(model)) {
19
- model[key] = getModelPropertyValue(source[key], model[key]);
20
- }
21
-
22
- return model;
23
- };
24
-
25
- const tree = (collection) => {
26
- return collection
27
- .filter((item) => !item.parent)
28
- .map((parent) => {
29
- parent.children = collection.where("parent.id", parent.id);
30
-
31
- return parent;
32
- });
33
- };
34
-
35
- const arrayTree = (collection) => {
36
- return collection
37
- .filter((item) => !item.parent)
38
- .map((parent) => {
39
- parent.children = [];
40
- collection
41
- .where("parent.id", parent.id)
42
- .each((child) => parent.children.push(child));
43
- return parent;
44
- })
45
- .all();
46
- };
47
-
48
- /**
49
- * Get value for model object property using source property (api resource property)
50
- * @param sourceProperty
51
- * @param modelProperty
52
- */
53
- const getModelPropertyValue = (sourceProperty, modelProperty) => {
54
- // Todo: Maybe all of this move to fabric with polymorph classes (move to decorators, then this method will not be needed
55
- if (sourceProperty === undefined) {
56
- return undefined;
57
- }
58
- if (sourceProperty === null) {
59
- return null;
60
- }
61
-
62
- if (modelProperty instanceof TypeModel) {
63
- return map(modelProperty.getModel(), sourceProperty);
64
- }
65
-
66
- if (modelProperty instanceof TypeCollection) {
67
- return mapCollection(sourceProperty, modelProperty.getModel());
68
- }
69
-
70
- return sourceProperty;
71
- };
72
-
73
- /**
74
- * Map array to Collection with models
75
- * @param collection
76
- * @param model
77
- */
78
- const mapCollection = <TModel>(
79
- collection: Array<Partial<TModel>>,
80
- model: TModel
81
- ) => {
82
- return collect(collection.map((source) => map(model, source)));
83
- };
84
-
85
- /**
86
- * Special type that express that we expect get model from resource(api)
87
- * @deprecated Use @AsModel decorator instead (example in ExtendedInfoModel)
88
- * @param model
89
- */
90
- const asModel = <TModel>(model: TModel) => {
91
- return new TypeModel(model);
92
- };
93
-
94
- /**
95
- * Special type that express that we expect get collection(array) from resource(api)
96
- * @deprecated Use @AsCollection decorator instead (example in ExtendedInfoModel)
97
- * @param model
98
- */
99
-
100
- const asCollection = <TModel extends new (...args: any) => any>(
101
- model: TModel
102
- ): TypeCollection<TModel> | TypeCollection<InstanceType<TModel>> => {
103
- return new TypeCollection(model);
104
- };
105
-
106
- // TODO: Move somewhere
107
- const updateProperties = <T, U extends Partial<T>>(target: T, source: U): T => {
108
- for (const key of Object.keys(source)) {
109
- target[key] = cloneValue(source[key]);
110
- }
111
- return target;
112
- };
113
-
114
- const Moment = moment().constructor;
115
- const cloneValue = (value) => {
116
- const isMomentInstance = value instanceof Moment;
117
- return isMomentInstance ? moment(value) : value;
118
- };
119
-
120
- abstract class Type<TModel> {
121
- private readonly model: TModel;
122
-
123
- public constructor(model: TModel) {
124
- this.model = model;
125
- }
126
-
127
- getModel() {
128
- return this.model;
129
- }
130
- }
131
-
132
- /** This is helper class to specify type collection with some model for mapping */
133
- class TypeCollection<TModel> extends Type<TModel> {}
134
- /** This is helper class to specify type model for mapping */
135
- class TypeModel<TModel> extends Type<TModel> {}
136
-
137
- // Todo: maybe do same as we do with Moment class, just moment().constructor is class
138
- // This code (class Collection) gives us possibility to check instanceof Collection (collect.js).
139
- // Default Collection from collect.js causes an error: "TypeError: Right-hand side of 'instanceof' is not an object",
140
- // because it is just a declaration
141
- class Collection {}
142
- Object.assign(Collection, collect().__proto__);
143
-
144
- // type Collection<Item> = BaseCollection<Item>;
145
-
146
- export {
147
- asModel,
148
- asCollection,
149
- TypeCollection,
150
- map,
151
- Collection,
152
- updateProperties,
153
- tree,
154
- arrayTree,
155
- };
@@ -1,26 +0,0 @@
1
- import { collect } from "collect.js";
2
- import { map } from "../ModelHelper";
3
-
4
- export default (property: string, instance: Object) => {
5
- return function <T extends { new (...args: any[]): {} }>(constructor: T) {
6
- return class extends constructor {
7
- constructor(...args: any[]) {
8
- super(...args);
9
-
10
- let value;
11
- Object.defineProperty(this, property, {
12
- enumerable: true,
13
- get: () => {
14
- return value;
15
- },
16
- set: (newValue: Array<any> | undefined) => {
17
- value =
18
- newValue !== undefined
19
- ? collect(newValue.map((source) => map(instance, source)))
20
- : newValue;
21
- },
22
- });
23
- }
24
- };
25
- };
26
- };
@@ -1,25 +0,0 @@
1
- import { map } from "../ModelHelper";
2
-
3
- export default (property: string, instance: Object) => {
4
- return function <T extends { new (...args: any[]): {} }>(constructor: T) {
5
- return class extends constructor {
6
- constructor(...args: any[]) {
7
- super(...args);
8
-
9
- let value;
10
- Object.defineProperty(this, property, {
11
- enumerable: true,
12
- get: () => {
13
- return value;
14
- },
15
- set: (newValue: Object | undefined) => {
16
- value =
17
- newValue !== undefined && newValue !== null
18
- ? map(instance, newValue)
19
- : newValue;
20
- },
21
- });
22
- }
23
- };
24
- };
25
- };
@@ -1,26 +0,0 @@
1
- import { Moment } from "moment";
2
- import { moment } from "../../TimeHelper";
3
-
4
- export default (property) => {
5
- return function <T extends { new (...args: any[]): {} }>(constructor: T) {
6
- return class extends constructor {
7
- constructor(...args: any[]) {
8
- super(...args);
9
-
10
- let value;
11
- Object.defineProperty(this, property, {
12
- enumerable: true,
13
- get: () => {
14
- return value;
15
- },
16
- set: (newValue: Moment | undefined | null) => {
17
- value =
18
- newValue !== undefined && newValue !== null
19
- ? moment(newValue)
20
- : newValue;
21
- },
22
- });
23
- }
24
- };
25
- };
26
- };
@@ -1,33 +0,0 @@
1
- import { Duration as DurationType } from "moment";
2
- import { moment } from "../../TimeHelper";
3
-
4
- const Duration = moment.duration().constructor;
5
-
6
- export default (property) => {
7
- return function <T extends { new (...args: any[]): {} }>(constructor: T) {
8
- return class extends constructor {
9
- constructor(...args: any[]) {
10
- super(...args);
11
-
12
- let value = moment.duration(0);
13
- Object.defineProperty(this, property, {
14
- enumerable: true,
15
- get: () => {
16
- return value;
17
- },
18
- set: (newValue: DurationType | number) => {
19
- if (!(newValue instanceof Duration)) {
20
- let minutes = Number(newValue);
21
- if (Number.isNaN(minutes)) {
22
- minutes = 0;
23
- }
24
- newValue = moment.duration(minutes, "minutes");
25
- }
26
-
27
- value = moment.duration(newValue);
28
- },
29
- });
30
- }
31
- };
32
- };
33
- };
@@ -1,64 +0,0 @@
1
- import { DurationInputArg1, DurationInputArg2 } from "moment";
2
- import * as moment from "moment";
3
- import { Duration } from "./index";
4
- import { workingHours } from "../TimeHelper";
5
-
6
- const duration = (
7
- inp?: DurationInputArg1,
8
- unit?: DurationInputArg2
9
- ): Duration => {
10
- const momentDurationPrototype = moment.duration(inp, unit);
11
- const intemsDuration: Duration = Object.create(momentDurationPrototype);
12
-
13
- // Is used when we do some primitive manipulations with class (eg. Duration + 5, will transform Duration into minutes and add 5)
14
- intemsDuration.valueOf = () => {
15
- return intemsDuration.asMinutes();
16
- };
17
-
18
- intemsDuration.clone = () => {
19
- return duration(intemsDuration);
20
- };
21
-
22
- intemsDuration.minutesWithLeadingZeroes = () => {
23
- return intemsDuration.minutes().toString().padStart(2, "0");
24
- };
25
-
26
- intemsDuration.hoursAsNumber = () => {
27
- return Math.floor(intemsDuration.asHours());
28
- };
29
-
30
- intemsDuration.humanizedHours = () => {
31
- return intemsDuration.hoursAsNumber() === 1 ? "hour" : "hours";
32
- };
33
-
34
- intemsDuration.humanizedMinutes = () => {
35
- return intemsDuration.minutes() === 1 ? "minute" : "minutes";
36
- };
37
-
38
- intemsDuration.formatted = () => {
39
- return `${intemsDuration.hoursAsNumber()}:${intemsDuration.minutesWithLeadingZeroes()}`;
40
- };
41
-
42
- intemsDuration.formattedInLongForm = () => {
43
- const formattedHours = `${intemsDuration.hoursAsNumber()} ${intemsDuration.humanizedHours()}`;
44
- const formattedMinutes = `${intemsDuration.minutes()} ${intemsDuration.humanizedMinutes()}`;
45
-
46
- if (intemsDuration.hoursAsNumber() === 0) {
47
- return formattedMinutes;
48
- }
49
-
50
- return intemsDuration.minutes() === 0
51
- ? formattedHours
52
- : `${formattedHours} ${formattedMinutes}`;
53
- };
54
-
55
- intemsDuration.formattedInWorkingDays = () => {
56
- const workingDays = Math.floor(intemsDuration.asHours() / workingHours);
57
- const humanizedDays = workingDays === 1 ? "day" : "days";
58
- return `${workingDays} ${humanizedDays}`;
59
- };
60
-
61
- return intemsDuration;
62
- };
63
-
64
- export default duration;
@@ -1,17 +0,0 @@
1
- import * as baseMoment from "moment";
2
- import { Duration, Moment } from "./index";
3
- import momentDuration from "./Duration";
4
-
5
- const moment = (inp?, format?, strict?: boolean): Moment => {
6
- const momentPrototype = baseMoment(inp, format, strict);
7
- const intemsMoment: Moment = Object.create(momentPrototype);
8
- // Is used when object is serialized to JSON string (eg. in our case date should be in MySQL DB format)
9
- intemsMoment.toJSON = () => {
10
- return intemsMoment.format("YYYY-MM-DD HH:mm:ss");
11
- };
12
-
13
- return intemsMoment;
14
- };
15
- moment.duration = momentDuration;
16
-
17
- export default moment;
@@ -1,20 +0,0 @@
1
- import * as moment from "moment";
2
- import { DurationInputArg1, DurationInputArg2 } from "moment";
3
-
4
- export type Duration = {
5
- add(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration;
6
- subtract(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration;
7
- clone(): Duration;
8
- minutesWithLeadingZeroes(): string;
9
- hoursAsNumber(): number;
10
- humanizedHours(): string;
11
- humanizedMinutes(): string;
12
- humanizedDays(): string;
13
- formatted(): string;
14
- formattedInLongForm(): string;
15
- formattedInWorkingDays(): string;
16
- } & moment.Duration;
17
-
18
- export type Moment = {
19
- duration: Duration;
20
- } & moment.Moment;