@intellias/menu 1.0.0

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 (174) hide show
  1. package/Menu.ts +625 -0
  2. package/README.md +121 -0
  3. package/assets/icons/arrow-down.svg +13 -0
  4. package/assets/icons/arrow-left.svg +3 -0
  5. package/assets/icons/arrow-submenu.svg +8 -0
  6. package/assets/icons/close.svg +3 -0
  7. package/assets/icons/delete.svg +13 -0
  8. package/assets/icons/faq-new.svg +4 -0
  9. package/assets/icons/kudos.svg +14 -0
  10. package/assets/icons/loading-spinner.svg +40 -0
  11. package/assets/icons/notification.svg +11 -0
  12. package/assets/icons/notifications/assessment.svg +10 -0
  13. package/assets/icons/notifications/buddy_program.svg +8 -0
  14. package/assets/icons/notifications/compensation_packages.svg +10 -0
  15. package/assets/icons/notifications/dsat.svg +8 -0
  16. package/assets/icons/notifications/feedback.svg +7 -0
  17. package/assets/icons/notifications/kudos.svg +4 -0
  18. package/assets/icons/notifications/overtime_requests.svg +15 -0
  19. package/assets/icons/notifications/pdu_program.svg +4 -0
  20. package/assets/icons/notifications/profile_update.svg +6 -0
  21. package/assets/icons/notifications/recommendation_program.svg +7 -0
  22. package/assets/icons/notifications/reminders.svg +4 -0
  23. package/assets/icons/notifications/sick_leaves.svg +5 -0
  24. package/assets/icons/notifications/smarts.svg +4 -0
  25. package/assets/icons/notifications/survey.svg +8 -0
  26. package/assets/icons/notifications/unpaid_leave.svg +4 -0
  27. package/assets/icons/notifications/vacations.svg +4 -0
  28. package/assets/icons/pause.svg +13 -0
  29. package/assets/icons/play.svg +13 -0
  30. package/assets/icons/smart.svg +14 -0
  31. package/assets/icons/smarts-kudos.svg +11 -0
  32. package/assets/icons/spinner-solid.svg +1 -0
  33. package/assets/icons/vacation.svg +14 -0
  34. package/assets/icons/visibility.svg +1 -0
  35. package/assets/intems-logo.svg +3 -0
  36. package/babel.config.js +6 -0
  37. package/buses/eventBus.ts +19 -0
  38. package/buses/events/GiveKudosEvent.ts +7 -0
  39. package/components/buttons/action-button/ActionButton.scss +133 -0
  40. package/components/buttons/action-button/ActionButton.ts +57 -0
  41. package/components/buttons/action-button/ActionButton.vue +50 -0
  42. package/components/buttons/secondary-button/SecondaryButton.scss +48 -0
  43. package/components/buttons/secondary-button/SecondaryButton.ts +28 -0
  44. package/components/buttons/secondary-button/SecondaryButton.vue +27 -0
  45. package/components/confirm/Confirm.scss +44 -0
  46. package/components/confirm/Confirm.ts +82 -0
  47. package/components/confirm/Confirm.vue +64 -0
  48. package/components/give-kudos-form/GiveKudosForm.scss +114 -0
  49. package/components/give-kudos-form/GiveKudosForm.ts +159 -0
  50. package/components/give-kudos-form/GiveKudosForm.vue +131 -0
  51. package/components/give-kudos-form/mixins/UserSelectMixin.ts +57 -0
  52. package/components/give-kudos-form/models/KudosShareModel.ts +6 -0
  53. package/components/give-kudos-form/models/UserListModel.ts +5 -0
  54. package/components/give-kudos-form/validators/InEnglishValidatorRegex.ts +17 -0
  55. package/components/give-kudos-form/validators/KudosBalance.ts +10 -0
  56. package/components/modal/Modal.scss +53 -0
  57. package/components/modal/Modal.ts +70 -0
  58. package/components/modal/Modal.vue +28 -0
  59. package/components/notifications-sidebar/NotificationsSidebar.scss +665 -0
  60. package/components/notifications-sidebar/NotificationsSidebar.ts +203 -0
  61. package/components/notifications-sidebar/NotificationsSidebar.vue +171 -0
  62. package/components/notifications-sidebar/models/BroadcastNotificationPayload.ts +8 -0
  63. package/components/notifications-sidebar/models/TotalCounter.ts +50 -0
  64. package/components/notifications-sidebar/notification/Notification.ts +17 -0
  65. package/components/notifications-sidebar/notification/Notification.vue +87 -0
  66. package/components/play-pause/PlayPause.scss +33 -0
  67. package/components/play-pause/PlayPause.ts +156 -0
  68. package/components/play-pause/PlayPause.vue +36 -0
  69. package/components/play-pause/PlayPauseStatus.ts +4 -0
  70. package/components/play-pause/helpers/LatestTrackedTimeDurationHelper.ts +55 -0
  71. package/components/play-pause/helpers/PauseHelper.ts +55 -0
  72. package/components/play-pause/helpers/TrackedTimeHelper.ts +80 -0
  73. package/components/preloader/Preloader.vue +34 -0
  74. package/components/request-loader/RequestLoader.scss +20 -0
  75. package/components/request-loader/RequestLoader.ts +80 -0
  76. package/components/request-loader/RequestLoader.vue +15 -0
  77. package/components/sub-menu/SubMenu.scss +33 -0
  78. package/components/sub-menu/SubMenu.ts +38 -0
  79. package/components/sub-menu/SubMenu.vue +21 -0
  80. package/components/time-ago/TimeAgo.ts +34 -0
  81. package/components/time-ago/TimeAgo.vue +9 -0
  82. package/components/user-picture/UserPicture.scss +62 -0
  83. package/components/user-picture/UserPicture.ts +105 -0
  84. package/components/user-picture/UserPicture.vue +23 -0
  85. package/components/v-select-intems/VSelectIntems.ts +112 -0
  86. package/components/v-select-intems/VSelectIntems.vue +68 -0
  87. package/components/v-select-intems/open-indicator/OpenIndicator.vue +3 -0
  88. package/dist/css/1.css +85 -0
  89. package/dist/css/2.css +34 -0
  90. package/dist/css/3.css +34 -0
  91. package/dist/css/4.css +34 -0
  92. package/dist/css/5.css +34 -0
  93. package/dist/css/main.css +1564 -0
  94. package/dist/html/app.html +19 -0
  95. package/dist/html/styles.html +1 -0
  96. package/dist/images/intems-logo.svg +3 -0
  97. package/dist/js/0.js +315 -0
  98. package/dist/js/1.js +313 -0
  99. package/dist/js/2.js +217 -0
  100. package/dist/js/3.js +181 -0
  101. package/dist/js/4.js +181 -0
  102. package/dist/js/5.js +181 -0
  103. package/dist/js/6.js +47 -0
  104. package/dist/js/main.js +7465 -0
  105. package/dist/js/vue.js +15 -0
  106. package/helpers/GeneralHelper.ts +61 -0
  107. package/helpers/PublisherSubscriber.ts +34 -0
  108. package/helpers/QueryFilter.ts +204 -0
  109. package/helpers/TimeHelper.ts +54 -0
  110. package/helpers/Validations.ts +7 -0
  111. package/helpers/model/ModelHelper.ts +155 -0
  112. package/helpers/model/decorators/AsCollection.ts +26 -0
  113. package/helpers/model/decorators/AsModel.ts +25 -0
  114. package/helpers/model/decorators/DateTime.ts +26 -0
  115. package/helpers/model/decorators/TimeDuration.ts +33 -0
  116. package/helpers/moment/Duration.ts +64 -0
  117. package/helpers/moment/Moment.ts +17 -0
  118. package/helpers/moment/index.d.ts +20 -0
  119. package/helpers/response/AxiosProxy.ts +72 -0
  120. package/helpers/response/ErrorsToToastHelper.ts +42 -0
  121. package/helpers/response/ResponseCode.ts +16 -0
  122. package/helpers/response/ResponseHelper.ts +42 -0
  123. package/helpers/response/ResponseInterface.ts +34 -0
  124. package/helpers/response/ResponseState.ts +6 -0
  125. package/jsconfig.json +19 -0
  126. package/mixins/IntemsMath.ts +29 -0
  127. package/mixins/notifications/ActionProcessing.ts +134 -0
  128. package/mixins/notifications/confirms/AssetRejectionConfirm.vue +59 -0
  129. package/mixins/notifications/confirms/SickLeaveRejectionConfirm.vue +31 -0
  130. package/mixins/notifications/confirms/UnpaidLeaveRejectionConfirm.vue +31 -0
  131. package/mixins/notifications/confirms/VacationRejectionConfirm.vue +31 -0
  132. package/models/AssetModel.ts +80 -0
  133. package/models/AssetRequestModel.ts +25 -0
  134. package/models/ConfigModel.ts +20 -0
  135. package/models/EmployeeStartEndDateModel.ts +16 -0
  136. package/models/EmploymentTypeModel.ts +95 -0
  137. package/models/LogoutModel.ts +3 -0
  138. package/models/Model.ts +12 -0
  139. package/models/ModuleOptions.ts +24 -0
  140. package/models/PublicInfoModel.ts +38 -0
  141. package/models/PublicLocationModel.ts +36 -0
  142. package/models/StatusModel.ts +8 -0
  143. package/models/TrackedTimeModel.ts +32 -0
  144. package/models/location/PublicLocationModel.ts +36 -0
  145. package/models/timezones/LocalTimezoneHistoryModel.ts +8 -0
  146. package/models/timezones/TimezoneModel.ts +9 -0
  147. package/models/user/ExtendedInfoModel.ts +37 -0
  148. package/models/user/NotificationActionModel.ts +53 -0
  149. package/models/user/NotificationModel.ts +84 -0
  150. package/models/user/PublicInfoModel.ts +38 -0
  151. package/models/user/WelcomeProgram.ts +4 -0
  152. package/package.json +117 -0
  153. package/repositories/BaseRepository.ts +42 -0
  154. package/repositories/BaseUrl.ts +107 -0
  155. package/repositories/Repository.ts +291 -0
  156. package/repositories/ResourceRepository.ts +99 -0
  157. package/repositories/TrackedTimeRepository.ts +43 -0
  158. package/repositories/UserRepository.ts +75 -0
  159. package/repositories/subscribers/CreateSubscribers.ts +28 -0
  160. package/repositories/subscribers/DefaultSubscribers.ts +82 -0
  161. package/repositories/subscribers/DeleteSubscribers.ts +28 -0
  162. package/repositories/subscribers/DownloadSubscribers.ts +28 -0
  163. package/repositories/subscribers/Subscribers.ts +13 -0
  164. package/repositories/subscribers/UpdateSubscribers.ts +32 -0
  165. package/scss/components/_global.scss +66 -0
  166. package/scss/components/_mixins.scss +31 -0
  167. package/scss/components/_tooltip.scss +45 -0
  168. package/scss/components/_utils.scss +26 -0
  169. package/scss/components/_variables.scss +103 -0
  170. package/scss/main.scss +7 -0
  171. package/shims-vue.d.ts +9 -0
  172. package/tsconfig.json +31 -0
  173. package/webpack.config.js +126 -0
  174. package/wrapper.ts +51 -0
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,20 @@
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;
@@ -0,0 +1,72 @@
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
+ }
@@ -0,0 +1,42 @@
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
+ }
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,42 @@
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
+ }
@@ -0,0 +1,34 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ export enum ResponseState {
2
+ Pending = "Pending",
3
+ Resolved = "Resolved",
4
+ Rejected = "Rejected",
5
+ Done = "Done",
6
+ }
package/jsconfig.json ADDED
@@ -0,0 +1,19 @@
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
+ }
@@ -0,0 +1,29 @@
1
+ export default {
2
+ methods: {
3
+ round(value: number | string, precision?: number): number {
4
+ let num: number;
5
+ if (typeof value !== "number") {
6
+ num = parseFloat(value);
7
+ } else {
8
+ num = value;
9
+ }
10
+ return Number(num.toFixed(precision !== undefined ? precision : 2));
11
+ },
12
+ numberFormat(num: number): string {
13
+ return (Math.round(num * 100) / 100)
14
+ .toFixed(2)
15
+ .toString()
16
+ .replace(/\B(?=(\d{3})+(?!\d))/g, ",");
17
+ },
18
+ bytesToSize(bytes: number): string {
19
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
20
+ if (bytes === 0) {
21
+ return "0 Byte";
22
+ }
23
+
24
+ const i = Number(Math.floor(Math.log(bytes) / Math.log(1024)));
25
+
26
+ return `${(bytes / 1024 ** i).toFixed(1)} ${sizes[i]}`;
27
+ },
28
+ },
29
+ };
@@ -0,0 +1,134 @@
1
+ import { mapActions, mapGetters } from "vuex";
2
+ import moment from "moment";
3
+ import BaseRepository from "../../repositories/BaseRepository";
4
+ import { ResponseState } from "../../helpers/response/ResponseState";
5
+ import { DefaultContext } from "../../helpers/response/ResponseHelper";
6
+ import NotificationActionModel, {
7
+ ActionType,
8
+ ProceedTo,
9
+ RequestMethod,
10
+ } from "../../models/user/NotificationActionModel";
11
+ import {
12
+ confirmRejections,
13
+ NotificationCategory,
14
+ } from "../../models/user/NotificationModel";
15
+ import UserRepository from "../../repositories/UserRepository";
16
+ import { myOptions } from "../../wrapper";
17
+
18
+ const titlesMap = new Map([
19
+ [ActionType.reject, "Reject"],
20
+ [ActionType.confirm, "Confirm"],
21
+ [ActionType.view, "View"],
22
+ ]);
23
+ export default {
24
+ mounted(): void {
25
+ this.baseRepository
26
+ .getResponseHelper()
27
+ .subscribe(ResponseState.Resolved, this.handleSuccess, DefaultContext);
28
+ this.baseRepository
29
+ .getResponseHelper()
30
+ .subscribe(ResponseState.Rejected, this.handleError, DefaultContext);
31
+ },
32
+ computed: {
33
+ ...mapGetters("Config", ["config"]),
34
+ },
35
+ methods: {
36
+ ...mapActions("User/Notifications", [
37
+ "read",
38
+ "markAsRead",
39
+ "process",
40
+ "markAsProcessed",
41
+ ]),
42
+ submitAction(action: NotificationActionModel): Promise<void> {
43
+ if (
44
+ action.type === ActionType.reject &&
45
+ confirmRejections.includes(this.notification.category)
46
+ ) {
47
+ this.actionProcessing = true;
48
+ const rejectionComponent = this.rejectionComponent();
49
+
50
+ this.$emit("rejection-component", {
51
+ rejectionComponent,
52
+ notification: this.notification,
53
+ });
54
+ return;
55
+ }
56
+ this.request(action);
57
+ },
58
+ async request(action: NotificationActionModel): Promise<void> {
59
+ this.actionProcessing = true;
60
+ this.markAsRead(this.notification);
61
+ await this.baseRepository.request(
62
+ action.action,
63
+ action.method ? action.method : RequestMethod.put,
64
+ action.body
65
+ );
66
+ },
67
+ // eslint-disable-next-line complexity
68
+ async proceedToView(view: NotificationActionModel): Promise<void> {
69
+ if (this.notification.isNew) {
70
+ await this.read(this.notification);
71
+ }
72
+ const action = view.action ? view.action : view.url;
73
+ if (view.proceedTo === ProceedTo.remote) {
74
+ window.open(action, "_blank");
75
+ } else if (view.proceedTo === ProceedTo.career) {
76
+ window.location.href = `${this.config.careerSiteUrl}${action}`;
77
+ } else if (view.proceedTo === ProceedTo.old) {
78
+ window.location.href = `${this.config.oldSiteUrl}${action}`;
79
+ } else if (this.$router.currentRoute.path !== action) {
80
+ await this.$router.push(action.replace("api/", ""));
81
+ }
82
+ },
83
+ async handleSuccess(): Promise<void> {
84
+ myOptions.storeAdapter.Toasts.mutations.addMessage(
85
+ "The request has been processed."
86
+ );
87
+ myOptions.storeAdapter.Toasts.mutations.showAll();
88
+ this.markAsProcessed(this.notification);
89
+ this.actionProcessing = false;
90
+ },
91
+ async handleError(): Promise<void> {
92
+ myOptions.storeAdapter.Toasts.mutations.addWarning(
93
+ "Action failed. The request had been already processed."
94
+ );
95
+ myOptions.storeAdapter.Toasts.mutations.showAll();
96
+
97
+ await this.process(this.notification);
98
+
99
+ if (typeof this.errorAction === "function") {
100
+ this.errorAction();
101
+ }
102
+ this.actionProcessing = false;
103
+ },
104
+ rejectionComponent() {
105
+ if (this.notification.category === NotificationCategory.vacations) {
106
+ return () => import("./confirms/VacationRejectionConfirm.vue");
107
+ }
108
+ if (this.notification.category === NotificationCategory.unpaid_leave) {
109
+ return () => import("./confirms/UnpaidLeaveRejectionConfirm.vue");
110
+ }
111
+ if (this.notification.category === NotificationCategory.profile_update) {
112
+ return () => import("./confirms/AssetRejectionConfirm.vue");
113
+ }
114
+ if (this.notification.category === NotificationCategory.sick_leaves) {
115
+ return () => import("./confirms/SickLeaveRejectionConfirm.vue");
116
+ }
117
+
118
+ return null;
119
+ },
120
+ isExpired(action: NotificationActionModel): boolean {
121
+ return action.expired_at && action.expired_at.isBefore(moment());
122
+ },
123
+ title(action: NotificationActionModel): string {
124
+ return action.title ? action.title : titlesMap.get(action.type);
125
+ },
126
+ },
127
+ data(): Record<string, unknown> {
128
+ return {
129
+ actionProcessing: false,
130
+ userRepository: new UserRepository(),
131
+ baseRepository: new BaseRepository(),
132
+ };
133
+ },
134
+ };
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <confirm
3
+ ref="rejectConfirm"
4
+ :title="'Rejection reason'"
5
+ :submit-btn="'Send'"
6
+ :reject-btn="'Cancel'"
7
+ @confirmed="confirmed"
8
+ @rejected="$emit('unsetRejection')"
9
+ >
10
+ <template #confirm-content>
11
+ <p>Please specify why you want to reject the item.</p>
12
+ <p
13
+ v-for="option in rejectOptions"
14
+ :key="option.value"
15
+ class="margin-bottom-5"
16
+ >
17
+ <label class="reject-reasons">
18
+ <input
19
+ class="with-gap"
20
+ v-model="rejectReason"
21
+ :value="option.value"
22
+ type="radio"
23
+ />
24
+ <span>{{ option.title }}</span>
25
+ </label>
26
+ </p>
27
+ </template>
28
+ </confirm>
29
+ </template>
30
+
31
+ <script lang="ts">
32
+ import Confirm from "../../../components/confirm/Confirm.vue";
33
+ import {
34
+ RejectAssetOptions,
35
+ RejectAssetReason,
36
+ } from "../../../models/AssetModel";
37
+
38
+ export default {
39
+ components: { Confirm },
40
+ mounted(): void {
41
+ this.$refs.rejectConfirm.open();
42
+ },
43
+ computed: {
44
+ rejectOptions(): Set<{ value: RejectAssetReason; title: string }> {
45
+ return RejectAssetOptions;
46
+ },
47
+ },
48
+ methods: {
49
+ confirmed(): void {
50
+ this.$emit("confirmed", this.rejectReason);
51
+ },
52
+ },
53
+ data(): Record<string, unknown> {
54
+ return {
55
+ rejectReason: RejectAssetReason.dont_need,
56
+ };
57
+ },
58
+ };
59
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <confirm
3
+ ref="rejectConfirm"
4
+ :title="'Sick leave rejection reason'"
5
+ :submit-btn="'Reject'"
6
+ :reject-btn="'Cancel'"
7
+ :comment="{
8
+ placeholder: 'Add comment (required)',
9
+ required: true
10
+ }"
11
+ @confirmed="confirmed"
12
+ @rejected="$emit('unsetRejection')"
13
+ ><template #footer-description><div v-html="description" class="margin-top-10"></div></template></confirm>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ import Confirm from '../../../components/confirm/Confirm.vue';
18
+
19
+ export default {
20
+ components: { Confirm },
21
+ props: { description: String },
22
+ mounted(): void {
23
+ this.$refs.rejectConfirm.open();
24
+ },
25
+ methods: {
26
+ confirmed(payload: { comment: string }): void {
27
+ this.$emit('confirmed', payload);
28
+ }
29
+ }
30
+ };
31
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <confirm
3
+ ref="rejectConfirm"
4
+ :title="'Unpaid leave rejection reason'"
5
+ :submit-btn="'Reject'"
6
+ :reject-btn="'Cancel'"
7
+ :comment="{
8
+ placeholder: 'Add comment (required)',
9
+ required: true
10
+ }"
11
+ @confirmed="confirmed"
12
+ @rejected="$emit('unsetRejection')"
13
+ ><template #footer-description><div v-html="description" class="margin-top-10"></div></template></confirm>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ import Confirm from '../../../components/confirm/Confirm.vue';
18
+
19
+ export default {
20
+ components: { Confirm },
21
+ props: { description: String },
22
+ mounted(): void {
23
+ this.$refs.rejectConfirm.open();
24
+ },
25
+ methods: {
26
+ confirmed(payload: { comment: string }): void {
27
+ this.$emit('confirmed', payload);
28
+ }
29
+ }
30
+ };
31
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <confirm
3
+ ref="rejectConfirm"
4
+ :title="'Vacation rejection reason'"
5
+ :submit-btn="'Reject'"
6
+ :reject-btn="'Cancel'"
7
+ :comment="{
8
+ placeholder: 'Add comment (required)',
9
+ required: true
10
+ }"
11
+ @confirmed="confirmed"
12
+ @rejected="$emit('unsetRejection')"
13
+ ><template #footer-description><div v-html="description" class="margin-top-10"></div></template></confirm>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ import Confirm from '../../../components/confirm/Confirm.vue';
18
+
19
+ export default {
20
+ components: { Confirm },
21
+ props: { description: String },
22
+ mounted(): void {
23
+ this.$refs.rejectConfirm.open();
24
+ },
25
+ methods: {
26
+ confirmed(payload: { comment: string }): void {
27
+ this.$emit('confirmed', payload);
28
+ }
29
+ }
30
+ };
31
+ </script>
@@ -0,0 +1,80 @@
1
+ import PublicInfoModel from "../models/user/PublicInfoModel";
2
+ import AsModel from "../helpers/model/decorators/AsModel";
3
+ import AssetRequestModel from "./AssetRequestModel";
4
+ import { Statuses } from "./StatusModel";
5
+
6
+ export enum AssetStatus {
7
+ waiting_for_confirmation = "waiting_for_confirmation",
8
+ confirmed = "confirmed",
9
+ return_is_expected = "return_is_expected",
10
+ processing = "processing",
11
+ }
12
+ export enum RejectAssetReason {
13
+ dont_need = "dont_need",
14
+ dont_have = "dont_have",
15
+ }
16
+ export const AssetStatusLabels = new Map([
17
+ [AssetStatus.waiting_for_confirmation, "Waiting for confirmation"],
18
+ [AssetStatus.confirmed, "Confirmed"],
19
+ [AssetStatus.return_is_expected, "Return is expected"],
20
+ [AssetStatus.processing, "Processing"],
21
+ ]);
22
+
23
+ export const AssetStatusTypes = new Map([
24
+ [AssetStatus.waiting_for_confirmation, Statuses.danger],
25
+ [AssetStatus.confirmed, Statuses.success],
26
+ [AssetStatus.return_is_expected, Statuses.inactive],
27
+ [AssetStatus.processing, Statuses.warning],
28
+ ]);
29
+
30
+ export const RejectAssetOptions = new Set([
31
+ { value: RejectAssetReason.dont_need, title: "I don’t need it anymore." },
32
+ { value: RejectAssetReason.dont_have, title: "I don’t have it." },
33
+ ]);
34
+ @AsModel("employee", PublicInfoModel)
35
+ @AsModel("request", AssetRequestModel)
36
+ export default class AssetModel {
37
+ id = undefined as number;
38
+ employee = undefined as PublicInfoModel;
39
+ name = undefined as string;
40
+ inventory_number = undefined as number;
41
+ owner = undefined as string;
42
+ type = undefined as string;
43
+ status = undefined as AssetStatus;
44
+ request = undefined as AssetRequestModel;
45
+ selected = false as boolean;
46
+
47
+ get statusLabel(): string {
48
+ return AssetStatusLabels.has(this.status)
49
+ ? AssetStatusLabels.get(this.status)
50
+ : "";
51
+ }
52
+
53
+ get statusType(): Statuses {
54
+ return AssetStatusTypes.has(this.status)
55
+ ? AssetStatusTypes.get(this.status)
56
+ : Statuses.inactive;
57
+ }
58
+
59
+ get isConfirmed(): boolean {
60
+ return (
61
+ this.status === AssetStatus.confirmed ||
62
+ this.status === AssetStatus.return_is_expected
63
+ );
64
+ }
65
+
66
+ get confirmed(): boolean {
67
+ return this.status === AssetStatus.confirmed;
68
+ }
69
+
70
+ get isUnconfirmed(): boolean {
71
+ return (
72
+ this.status === AssetStatus.waiting_for_confirmation ||
73
+ this.status === AssetStatus.processing
74
+ );
75
+ }
76
+
77
+ get processing(): boolean {
78
+ return this.status === AssetStatus.processing;
79
+ }
80
+ }