@intellias/menu 1.0.0 → 1.0.4

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 (170) hide show
  1. package/README.md +40 -11
  2. package/dist/css/1.css +20 -5
  3. package/dist/css/main.css +20 -2
  4. package/dist/index.html +9 -0
  5. package/dist/js/0.js +27 -27
  6. package/dist/js/1.js +27 -27
  7. package/dist/js/2.js +19 -19
  8. package/dist/js/3.js +16 -16
  9. package/dist/js/4.js +16 -16
  10. package/dist/js/5.js +16 -16
  11. package/dist/js/6.js +5 -5
  12. package/dist/js/main.js +653 -642
  13. package/dist/js/vue.js +2 -2
  14. package/package.json +99 -112
  15. package/Menu.ts +0 -625
  16. package/assets/icons/arrow-down.svg +0 -13
  17. package/assets/icons/arrow-left.svg +0 -3
  18. package/assets/icons/arrow-submenu.svg +0 -8
  19. package/assets/icons/close.svg +0 -3
  20. package/assets/icons/delete.svg +0 -13
  21. package/assets/icons/faq-new.svg +0 -4
  22. package/assets/icons/kudos.svg +0 -14
  23. package/assets/icons/loading-spinner.svg +0 -40
  24. package/assets/icons/notification.svg +0 -11
  25. package/assets/icons/notifications/assessment.svg +0 -10
  26. package/assets/icons/notifications/buddy_program.svg +0 -8
  27. package/assets/icons/notifications/compensation_packages.svg +0 -10
  28. package/assets/icons/notifications/dsat.svg +0 -8
  29. package/assets/icons/notifications/feedback.svg +0 -7
  30. package/assets/icons/notifications/kudos.svg +0 -4
  31. package/assets/icons/notifications/overtime_requests.svg +0 -15
  32. package/assets/icons/notifications/pdu_program.svg +0 -4
  33. package/assets/icons/notifications/profile_update.svg +0 -6
  34. package/assets/icons/notifications/recommendation_program.svg +0 -7
  35. package/assets/icons/notifications/reminders.svg +0 -4
  36. package/assets/icons/notifications/sick_leaves.svg +0 -5
  37. package/assets/icons/notifications/smarts.svg +0 -4
  38. package/assets/icons/notifications/survey.svg +0 -8
  39. package/assets/icons/notifications/unpaid_leave.svg +0 -4
  40. package/assets/icons/notifications/vacations.svg +0 -4
  41. package/assets/icons/pause.svg +0 -13
  42. package/assets/icons/play.svg +0 -13
  43. package/assets/icons/smart.svg +0 -14
  44. package/assets/icons/smarts-kudos.svg +0 -11
  45. package/assets/icons/spinner-solid.svg +0 -1
  46. package/assets/icons/vacation.svg +0 -14
  47. package/assets/icons/visibility.svg +0 -1
  48. package/assets/intems-logo.svg +0 -3
  49. package/babel.config.js +0 -6
  50. package/buses/eventBus.ts +0 -19
  51. package/buses/events/GiveKudosEvent.ts +0 -7
  52. package/components/buttons/action-button/ActionButton.scss +0 -133
  53. package/components/buttons/action-button/ActionButton.ts +0 -57
  54. package/components/buttons/action-button/ActionButton.vue +0 -50
  55. package/components/buttons/secondary-button/SecondaryButton.scss +0 -48
  56. package/components/buttons/secondary-button/SecondaryButton.ts +0 -28
  57. package/components/buttons/secondary-button/SecondaryButton.vue +0 -27
  58. package/components/confirm/Confirm.scss +0 -44
  59. package/components/confirm/Confirm.ts +0 -82
  60. package/components/confirm/Confirm.vue +0 -64
  61. package/components/give-kudos-form/GiveKudosForm.scss +0 -114
  62. package/components/give-kudos-form/GiveKudosForm.ts +0 -159
  63. package/components/give-kudos-form/GiveKudosForm.vue +0 -131
  64. package/components/give-kudos-form/mixins/UserSelectMixin.ts +0 -57
  65. package/components/give-kudos-form/models/KudosShareModel.ts +0 -6
  66. package/components/give-kudos-form/models/UserListModel.ts +0 -5
  67. package/components/give-kudos-form/validators/InEnglishValidatorRegex.ts +0 -17
  68. package/components/give-kudos-form/validators/KudosBalance.ts +0 -10
  69. package/components/modal/Modal.scss +0 -53
  70. package/components/modal/Modal.ts +0 -70
  71. package/components/modal/Modal.vue +0 -28
  72. package/components/notifications-sidebar/NotificationsSidebar.scss +0 -665
  73. package/components/notifications-sidebar/NotificationsSidebar.ts +0 -203
  74. package/components/notifications-sidebar/NotificationsSidebar.vue +0 -171
  75. package/components/notifications-sidebar/models/BroadcastNotificationPayload.ts +0 -8
  76. package/components/notifications-sidebar/models/TotalCounter.ts +0 -50
  77. package/components/notifications-sidebar/notification/Notification.ts +0 -17
  78. package/components/notifications-sidebar/notification/Notification.vue +0 -87
  79. package/components/play-pause/PlayPause.scss +0 -33
  80. package/components/play-pause/PlayPause.ts +0 -156
  81. package/components/play-pause/PlayPause.vue +0 -36
  82. package/components/play-pause/PlayPauseStatus.ts +0 -4
  83. package/components/play-pause/helpers/LatestTrackedTimeDurationHelper.ts +0 -55
  84. package/components/play-pause/helpers/PauseHelper.ts +0 -55
  85. package/components/play-pause/helpers/TrackedTimeHelper.ts +0 -80
  86. package/components/preloader/Preloader.vue +0 -34
  87. package/components/request-loader/RequestLoader.scss +0 -20
  88. package/components/request-loader/RequestLoader.ts +0 -80
  89. package/components/request-loader/RequestLoader.vue +0 -15
  90. package/components/sub-menu/SubMenu.scss +0 -33
  91. package/components/sub-menu/SubMenu.ts +0 -38
  92. package/components/sub-menu/SubMenu.vue +0 -21
  93. package/components/time-ago/TimeAgo.ts +0 -34
  94. package/components/time-ago/TimeAgo.vue +0 -9
  95. package/components/user-picture/UserPicture.scss +0 -62
  96. package/components/user-picture/UserPicture.ts +0 -105
  97. package/components/user-picture/UserPicture.vue +0 -23
  98. package/components/v-select-intems/VSelectIntems.ts +0 -112
  99. package/components/v-select-intems/VSelectIntems.vue +0 -68
  100. package/components/v-select-intems/open-indicator/OpenIndicator.vue +0 -3
  101. package/dist/html/app.html +0 -19
  102. package/dist/html/styles.html +0 -1
  103. package/helpers/GeneralHelper.ts +0 -61
  104. package/helpers/PublisherSubscriber.ts +0 -34
  105. package/helpers/QueryFilter.ts +0 -204
  106. package/helpers/TimeHelper.ts +0 -54
  107. package/helpers/Validations.ts +0 -7
  108. package/helpers/model/ModelHelper.ts +0 -155
  109. package/helpers/model/decorators/AsCollection.ts +0 -26
  110. package/helpers/model/decorators/AsModel.ts +0 -25
  111. package/helpers/model/decorators/DateTime.ts +0 -26
  112. package/helpers/model/decorators/TimeDuration.ts +0 -33
  113. package/helpers/moment/Duration.ts +0 -64
  114. package/helpers/moment/Moment.ts +0 -17
  115. package/helpers/moment/index.d.ts +0 -20
  116. package/helpers/response/AxiosProxy.ts +0 -72
  117. package/helpers/response/ErrorsToToastHelper.ts +0 -42
  118. package/helpers/response/ResponseCode.ts +0 -16
  119. package/helpers/response/ResponseHelper.ts +0 -42
  120. package/helpers/response/ResponseInterface.ts +0 -34
  121. package/helpers/response/ResponseState.ts +0 -6
  122. package/jsconfig.json +0 -19
  123. package/mixins/IntemsMath.ts +0 -29
  124. package/mixins/notifications/ActionProcessing.ts +0 -134
  125. package/mixins/notifications/confirms/AssetRejectionConfirm.vue +0 -59
  126. package/mixins/notifications/confirms/SickLeaveRejectionConfirm.vue +0 -31
  127. package/mixins/notifications/confirms/UnpaidLeaveRejectionConfirm.vue +0 -31
  128. package/mixins/notifications/confirms/VacationRejectionConfirm.vue +0 -31
  129. package/models/AssetModel.ts +0 -80
  130. package/models/AssetRequestModel.ts +0 -25
  131. package/models/ConfigModel.ts +0 -20
  132. package/models/EmployeeStartEndDateModel.ts +0 -16
  133. package/models/EmploymentTypeModel.ts +0 -95
  134. package/models/LogoutModel.ts +0 -3
  135. package/models/Model.ts +0 -12
  136. package/models/ModuleOptions.ts +0 -24
  137. package/models/PublicInfoModel.ts +0 -38
  138. package/models/PublicLocationModel.ts +0 -36
  139. package/models/StatusModel.ts +0 -8
  140. package/models/TrackedTimeModel.ts +0 -32
  141. package/models/location/PublicLocationModel.ts +0 -36
  142. package/models/timezones/LocalTimezoneHistoryModel.ts +0 -8
  143. package/models/timezones/TimezoneModel.ts +0 -9
  144. package/models/user/ExtendedInfoModel.ts +0 -37
  145. package/models/user/NotificationActionModel.ts +0 -53
  146. package/models/user/NotificationModel.ts +0 -84
  147. package/models/user/PublicInfoModel.ts +0 -38
  148. package/models/user/WelcomeProgram.ts +0 -4
  149. package/repositories/BaseRepository.ts +0 -42
  150. package/repositories/BaseUrl.ts +0 -107
  151. package/repositories/Repository.ts +0 -291
  152. package/repositories/ResourceRepository.ts +0 -99
  153. package/repositories/TrackedTimeRepository.ts +0 -43
  154. package/repositories/UserRepository.ts +0 -75
  155. package/repositories/subscribers/CreateSubscribers.ts +0 -28
  156. package/repositories/subscribers/DefaultSubscribers.ts +0 -82
  157. package/repositories/subscribers/DeleteSubscribers.ts +0 -28
  158. package/repositories/subscribers/DownloadSubscribers.ts +0 -28
  159. package/repositories/subscribers/Subscribers.ts +0 -13
  160. package/repositories/subscribers/UpdateSubscribers.ts +0 -32
  161. package/scss/components/_global.scss +0 -66
  162. package/scss/components/_mixins.scss +0 -31
  163. package/scss/components/_tooltip.scss +0 -45
  164. package/scss/components/_utils.scss +0 -26
  165. package/scss/components/_variables.scss +0 -103
  166. package/scss/main.scss +0 -7
  167. package/shims-vue.d.ts +0 -9
  168. package/tsconfig.json +0 -31
  169. package/webpack.config.js +0 -126
  170. package/wrapper.ts +0 -51
@@ -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;
@@ -1,72 +0,0 @@
1
- import axios, { AxiosPromise, AxiosRequestConfig, AxiosResponse } from "axios";
2
- import ResponseHelper, { DefaultContext } from "./ResponseHelper";
3
-
4
- export default class AxiosProxy {
5
- protected responseHelper: ResponseHelper;
6
-
7
- constructor(responseHelper: ResponseHelper) {
8
- this.responseHelper = responseHelper;
9
- }
10
-
11
- async get<TResponse>(
12
- url: string,
13
- config?: AxiosRequestConfig,
14
- context: string = DefaultContext
15
- ): Promise<AxiosResponse<TResponse>> {
16
- return this.request(axios.get<TResponse>(url, config), context);
17
- }
18
-
19
- async post<TResponse>(
20
- url: string,
21
- data?: unknown,
22
- config?: AxiosRequestConfig,
23
- context: string = DefaultContext
24
- ): Promise<AxiosResponse<TResponse>> {
25
- return this.request(axios.post<TResponse>(url, data, config), context);
26
- }
27
-
28
- async put<TResponse>(
29
- url: string,
30
- data?: unknown,
31
- config?: AxiosRequestConfig,
32
- context: string = DefaultContext
33
- ): Promise<AxiosResponse<TResponse>> {
34
- return this.request(axios.put<TResponse>(url, data, config), context);
35
- }
36
-
37
- async delete(
38
- url: string,
39
- config?: AxiosRequestConfig,
40
- context: string = DefaultContext
41
- ): Promise<AxiosResponse<void>> {
42
- return this.request(axios.delete(url, config), context);
43
- }
44
-
45
- async patch<TResponse>(
46
- url: string,
47
- config?: AxiosRequestConfig,
48
- context: string = DefaultContext
49
- ): Promise<AxiosResponse<TResponse>> {
50
- return this.request(axios.patch<TResponse>(url, config), context);
51
- }
52
-
53
- async head(
54
- url: string,
55
- config?: AxiosRequestConfig,
56
- context: string = DefaultContext
57
- ): Promise<AxiosResponse<void>> {
58
- return this.request(axios.head(url, config), context);
59
- }
60
-
61
- protected async request<TResponse>(
62
- axiosPromise: AxiosPromise<TResponse>,
63
- context: string
64
- ): Promise<AxiosResponse<TResponse>> {
65
- try {
66
- this.responseHelper.handle<TResponse>(axiosPromise, context);
67
- return await axiosPromise;
68
- } catch (error) {
69
- return error.response;
70
- }
71
- }
72
- }
@@ -1,42 +0,0 @@
1
- import { AxiosError } from "axios";
2
- import { ResponseCode } from "./ResponseCode";
3
- import { UnprocessableEntity } from "./ResponseInterface";
4
- import { myOptions } from "../../wrapper";
5
-
6
- export default class ErrorsToToastHelper {
7
- public static showErrors(axiosError: AxiosError): void {
8
- if (axiosError.response.status !== ResponseCode.UnprocessableEntity) {
9
- return;
10
- }
11
-
12
- const renderError = (data) => {
13
- const errors = Object.values(data.errors);
14
- errors.forEach((error) => {
15
- if (error instanceof Array) {
16
- error.forEach((item) =>
17
- myOptions.storeAdapter.Toasts.mutations.addError(String(item))
18
- );
19
- } else {
20
- myOptions.storeAdapter.Toasts.mutations.addError(String(error));
21
- }
22
- });
23
- myOptions.storeAdapter.Toasts.mutations.showAll();
24
- };
25
-
26
- if (
27
- axiosError.request.responseType === "blob" &&
28
- axiosError.response.data instanceof Blob
29
- ) {
30
- axiosError.response.data.text().then((err) => {
31
- renderError(JSON.parse(err));
32
- });
33
- } else {
34
- renderError(<UnprocessableEntity>axiosError.response.data);
35
- }
36
- }
37
-
38
- public static error(message: string): void {
39
- myOptions.storeAdapter.Toasts.mutations.addError(message);
40
- myOptions.storeAdapter.Toasts.mutations.showAll();
41
- }
42
- }
@@ -1,16 +0,0 @@
1
- export enum ResponseCode {
2
- Ok = 200,
3
- Created = 201,
4
- Accepted = 202,
5
- NoContent = 204,
6
-
7
- BadRequest = 400,
8
- Unauthorized = 401,
9
- Forbidden = 403,
10
- NotFound = 404,
11
- PageExpired = 419,
12
- UnprocessableEntity = 422,
13
-
14
- ServerError = 500,
15
- ServiceUnavailable = 503,
16
- }
@@ -1,42 +0,0 @@
1
- import { AxiosError, AxiosPromise, AxiosResponse } from "axios";
2
- import { Subscribers } from "../../repositories/subscribers/Subscribers";
3
- import { ResponseState } from "./ResponseState";
4
- import PublisherSubscriber from "../PublisherSubscriber";
5
-
6
- export const DefaultContext = "default";
7
-
8
- export default class ResponseHelper extends PublisherSubscriber<ResponseState> {
9
- applySubscribers(subscribers: Subscribers, context: string): this {
10
- for (const [responseState, callback] of Object.entries(
11
- subscribers.generate()
12
- )) {
13
- const responseStateEnum = ResponseState[responseState];
14
- this.subscribe(responseStateEnum, callback, context);
15
- }
16
- return this;
17
- }
18
-
19
- handle<TResponse>(
20
- axiosPromise: AxiosPromise<TResponse>,
21
- context: string
22
- ): void {
23
- if (context !== DefaultContext) {
24
- this.handleResponse(axiosPromise, DefaultContext);
25
- }
26
- this.handleResponse(axiosPromise, context);
27
- }
28
-
29
- protected handleResponse(axiosPromise: AxiosPromise, context: string): void {
30
- this.publish(ResponseState.Pending, undefined, context);
31
- axiosPromise
32
- .then((axiosResponse: AxiosResponse) => {
33
- this.publish(ResponseState.Resolved, axiosResponse, context);
34
- })
35
- .catch((error: AxiosError) => {
36
- this.publish(ResponseState.Rejected, error, context);
37
- })
38
- .finally(() => {
39
- this.publish(ResponseState.Done, undefined, context);
40
- });
41
- }
42
- }
@@ -1,34 +0,0 @@
1
- import { AxiosResponse } from "axios";
2
-
3
- export interface Meta {
4
- current_page: number;
5
- from: number;
6
- last_page: number;
7
- path: string;
8
- per_page: number;
9
- to: number;
10
- total: number;
11
- }
12
-
13
- // This type of response we get if we use Laravel Eloquent: API Resources
14
- // TODO RENAME FILE TO RESPONSE AND MOVE TO HELPERS???
15
- // TODO RENAME TO MORE CORRECT NAMES (READ AND CREATE)
16
- export interface Read<T> {
17
- data: T;
18
- links?: {
19
- first: string;
20
- last: string;
21
- prev: string | null;
22
- next: string | null;
23
- };
24
- meta?: Meta;
25
- }
26
-
27
- interface UnprocessableEntityErrors {
28
- [key: string]: Array<string>;
29
- }
30
-
31
- export interface UnprocessableEntity extends AxiosResponse {
32
- message: string;
33
- errors?: UnprocessableEntityErrors;
34
- }
@@ -1,6 +0,0 @@
1
- export enum ResponseState {
2
- Pending = "Pending",
3
- Resolved = "Resolved",
4
- Rejected = "Rejected",
5
- Done = "Done",
6
- }
package/jsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es5",
4
- "module": "esnext",
5
- "baseUrl": "./",
6
- "moduleResolution": "node",
7
- "paths": {
8
- "@/*": [
9
- "src/*"
10
- ]
11
- },
12
- "lib": [
13
- "esnext",
14
- "dom",
15
- "dom.iterable",
16
- "scripthost"
17
- ]
18
- }
19
- }