@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,62 +0,0 @@
1
- @use "sass:map";
2
- @import "../../scss/components/variables";
3
-
4
- .image-wrapper {
5
- &.sm {
6
- width: 35px;
7
- height: 35px;
8
- .user-image {
9
- border: 1px solid map.get($intems-colors, "border");
10
- &.anonymous {
11
- font-size: $font-size-12;
12
- }
13
- }
14
- }
15
- &.md {
16
- height: 44px;
17
- width: 44px;
18
- .user-image {
19
- border: 1px solid map.get($intems-colors, "border");
20
- &.anonymous {
21
- font-size: $font-size-16;
22
- color: map.get($intems-colors, "text-disable");
23
- }
24
- }
25
- }
26
- &.lg {
27
- height: 96px;
28
- width: 96px;
29
- }
30
- &.xl {
31
- height: 128px;
32
- width: 128px;
33
- .user-image.anonymous {
34
- font-size: $font-size-50;
35
- color: map.get($intems-colors, "text-disable");
36
- }
37
- }
38
- .user-image {
39
- border: 2px solid map.get($intems-colors, "border");
40
- border-radius: 50%;
41
- overflow: hidden;
42
- width: inherit;
43
- height: inherit;
44
-
45
- &img {
46
- object-fit: cover;
47
- }
48
- &.anonymous {
49
- background-color: map.get($intems-colors, "background");
50
- font-size: $font-size-40;
51
- color: map.get($intems-colors, "text-disable");
52
- font-weight: 600;
53
- text-transform: uppercase;
54
- display: inline-flex;
55
- justify-content: center;
56
- align-items: center;
57
- }
58
- }
59
- &.no-border .user-image {
60
- border: none;
61
- }
62
- }
@@ -1,105 +0,0 @@
1
- import { PropType } from "vue";
2
- import { VueLazyloadImage } from "vue-lazyload";
3
- import PublicInfoModel from "../../models/PublicInfoModel";
4
-
5
- enum Size {
6
- sm = "sm",
7
- md = "md",
8
- lg = "lg",
9
- xl = "xl",
10
- full = "full",
11
- }
12
-
13
- interface IPictureOptions {
14
- size: Size;
15
- noBorder: boolean;
16
- }
17
-
18
- const OPTIONS: IPictureOptions = {
19
- size: Size.md,
20
- noBorder: false,
21
- };
22
-
23
- export interface IPictureModel {
24
- avatar_url: string;
25
- thumbnail_url: string;
26
- first_name: string;
27
- last_name: string;
28
- }
29
- const EMPTY_MODEL: IPictureModel = {
30
- avatar_url: "",
31
- first_name: "",
32
- last_name: "",
33
- thumbnail_url: "",
34
- };
35
- export default {
36
- props: {
37
- employee: {} as PublicInfoModel | IPictureModel,
38
- options: {} as PropType<IPictureOptions>,
39
- },
40
- mounted(): void {
41
- this.cOptions = { ...OPTIONS, ...this.options };
42
- this.pictureModel = this.toPictureModel();
43
- },
44
- watch: {
45
- employee: {
46
- deep: true,
47
- handler(newVal: IPictureModel, oldVal: IPictureModel): void {
48
- if (newVal.avatar_url && newVal.avatar_url !== oldVal.avatar_url) {
49
- this.anonymous = false;
50
- }
51
- this.pictureModel = this.toPictureModel();
52
- },
53
- },
54
- },
55
- computed: {
56
- image(): VueLazyloadImage {
57
- return {
58
- src: this.imageUrl,
59
- error: `not-image`,
60
- } as VueLazyloadImage;
61
- },
62
- imageUrl(): string {
63
- return [Size.sm, Size.md].includes(this.cOptions.size) &&
64
- this.pictureModel.thumbnail_url
65
- ? this.pictureModel.thumbnail_url
66
- : this.pictureModel.avatar_url;
67
- },
68
- imageAlt(): string {
69
- return `${this.pictureModel.first_name} ${this.pictureModel.last_name} avatar`;
70
- },
71
- employeeInitials(): string {
72
- return `${
73
- typeof this.pictureModel.first_name === "string"
74
- ? this.pictureModel.first_name.substring(0, 1)
75
- : ""
76
- }${
77
- typeof this.pictureModel.last_name === "string"
78
- ? this.pictureModel.last_name.substring(0, 1)
79
- : ""
80
- }`;
81
- },
82
- border(): string {
83
- return this.cOptions.noBorder ? "no-border" : "";
84
- },
85
- },
86
- methods: {
87
- replaceByAnonymous(): void {
88
- this.anonymous = true;
89
- },
90
- toPictureModel(): IPictureModel {
91
- if (this.employee === undefined) {
92
- return EMPTY_MODEL as IPictureModel;
93
- }
94
-
95
- return { ...EMPTY_MODEL, ...this.employee };
96
- },
97
- },
98
- data(): Record<string, unknown> {
99
- return {
100
- anonymous: false,
101
- cOptions: {} as IPictureOptions,
102
- pictureModel: {} as IPictureModel,
103
- };
104
- },
105
- };
@@ -1,23 +0,0 @@
1
- <template>
2
- <div class="image-wrapper" :class="[cOptions.size, border]">
3
- <img
4
- v-if="imageUrl && !anonymous"
5
- class="user-image"
6
- v-lazy="image"
7
- :alt="imageAlt"
8
- @error="replaceByAnonymous"
9
- />
10
- <div v-else class="user-image anonymous" :title="imageAlt">
11
- <span>{{ employeeInitials }}</span>
12
- </div>
13
- </div>
14
- </template>
15
-
16
- <script>
17
- import UserPicture from "./UserPicture";
18
-
19
- export default UserPicture;
20
- </script>
21
- <style lang="scss">
22
- @import "UserPicture";
23
- </style>
@@ -1,112 +0,0 @@
1
- import vSelect from "vue-select";
2
- import debounce from "lodash.debounce";
3
- import UserPicture from "../user-picture/UserPicture.vue";
4
- import UserListModel from "../give-kudos-form/models/UserListModel";
5
- import OpenIndicator from "./open-indicator/OpenIndicator.vue";
6
-
7
- export default {
8
- components: { UserPicture, vSelect },
9
- props: ["data", "value"],
10
- methods: {
11
- onInput(val): void {
12
- this.$emit("input", val);
13
- },
14
- handlers(map, vm) {
15
- const choose = (e) => {
16
- e.preventDefault();
17
-
18
- if (
19
- vm.filteredOptions.length === 1 &&
20
- vm.filteredOptions[0] instanceof UserListModel &&
21
- vm.filteredOptions[0].disabled_option
22
- ) {
23
- return false;
24
- }
25
- vm.typeAheadSelect();
26
- };
27
-
28
- return {
29
- ...map,
30
- 13: choose,
31
- };
32
- },
33
- opened(): void {
34
- this.$emit("open");
35
-
36
- const comboboxEl = this.toggleElement;
37
- const selectedEl = this.$el.getElementsByClassName("vs__selected")[0];
38
- if (this.data.multiple || !comboboxEl || !selectedEl) {
39
- return;
40
- }
41
-
42
- comboboxEl.style.height = `${selectedEl.offsetHeight + 9}px`;
43
- },
44
- search: debounce(function (val) {
45
- if (val) {
46
- this.$emit("search", val);
47
- }
48
- }, 500),
49
- selected(val): void {
50
- this.$emit("selected", val);
51
- },
52
- deselected(val): void {
53
- this.$emit("deselected", val);
54
- },
55
- selecting(val): void {
56
- this.$emit("selecting", val);
57
- },
58
- deselecting(val): void {
59
- this.$emit("deselecting", val);
60
- },
61
- closed(): void {
62
- this.$emit("close");
63
-
64
- const comboboxEl = this.toggleElement;
65
- if (this.data.multiple && !comboboxEl) {
66
- return;
67
- }
68
-
69
- comboboxEl.style.height = null;
70
- },
71
- },
72
- computed: {
73
- toggleElement(): Element {
74
- return this.$el.getElementsByClassName("vs__dropdown-toggle")[0];
75
- },
76
- filterBy() {
77
- return this.data.filterBy
78
- ? (
79
- option: Record<string, unknown>,
80
- label: string,
81
- search: string
82
- ): boolean => {
83
- let searchString = "";
84
- this.data.filterBy.forEach((field) => {
85
- searchString +=
86
- option[field] !== undefined ? ` ${option[field]}` : "";
87
- });
88
-
89
- return (
90
- searchString.toLowerCase().indexOf(search.toLowerCase()) > -1
91
- );
92
- }
93
- : undefined;
94
- },
95
- showOptionsWithAvatars(): boolean {
96
- return this.data.class && this.data.class["select-with-avatars"];
97
- },
98
- customOption(): boolean {
99
- return this.showOptionsWithAvatars;
100
- },
101
- },
102
- data(): Record<string, unknown> {
103
- return {
104
- Deselect,
105
- OpenIndicator,
106
- attributes: {
107
- ref: "openIndicator",
108
- role: "presentation",
109
- },
110
- };
111
- },
112
- };
@@ -1,68 +0,0 @@
1
- <template>
2
- <v-select
3
- :selectable="(item) => !item.disabled_option"
4
- :value="value"
5
- @input="onInput"
6
- v-bind="data"
7
- :components="{ OpenIndicator }"
8
- v-bind:filterBy="filterBy"
9
- :map-keydown="handlers"
10
- @open="opened"
11
- @close="closed"
12
- @search="search"
13
- @option:selected="selected"
14
- @option:deselected="deselected"
15
- @option:selecting="selecting"
16
- @option:deselecting="deselecting"
17
- >
18
- <template
19
- slot="selected-option"
20
- v-if="showOptionsWithAvatars"
21
- slot-scope="option"
22
- >
23
- <div class="option-with-image">
24
- <user-picture
25
- :employee="option"
26
- :options="{ size: 'sm' }"
27
- ></user-picture>
28
- <div class="option-value">
29
- <div class="label">{{ option[data.label] }}</div>
30
- <div class="position">
31
- {{ option.position }}
32
- </div>
33
- </div>
34
- </div>
35
- </template>
36
- <template slot="option" slot-scope="option">
37
- <div>
38
- <user-picture
39
- :employee="option"
40
- :options="{ size: 'sm' }"
41
- ></user-picture>
42
- <span class="text-wrapper"> {{ option[data.label] }}</span>
43
- </div>
44
- </template>
45
- <template slot="option" v-if="customOption" slot-scope="option">
46
- <div class="option-with-image" v-if="showOptionsWithAvatars">
47
- <user-picture
48
- :employee="option"
49
- :options="{ size: 'sm' }"
50
- ></user-picture>
51
- <div class="text-block">
52
- <span class="text-name"> {{ option[data.label] }}</span>
53
- <br />
54
- <span class="text-position"> {{ option.position }}</span>
55
- </div>
56
- </div>
57
- </template>
58
-
59
- <template #list-footer>
60
- <slot name="list-footer"></slot>
61
- </template>
62
- </v-select>
63
- </template>
64
- <script>
65
- import VSelectIntems from "./VSelectIntems";
66
-
67
- export default VSelectIntems;
68
- </script>
@@ -1,3 +0,0 @@
1
- <template>
2
- <i class="icon icon-small arrow-down"></i>
3
- </template>
@@ -1,19 +0,0 @@
1
- Html Webpack Plugin:
2
- <pre>
3
- TypeError: Cannot read properties of undefined (reading 'entry')
4
-
5
- - loader.js:4 eval
6
- [app.html?.]/[html-webpack-plugin]/lib/loader.js:4:45
7
-
8
- - loader.js:9 module.exports
9
- [app.html?.]/[html-webpack-plugin]/lib/loader.js:9:3
10
-
11
- - index.js:284
12
- [intems-menu]/[html-webpack-plugin]/index.js:284:18
13
-
14
- - runMicrotasks
15
-
16
- - task_queues:96 processTicksAndRejections
17
- node:internal/process/task_queues:96:5
18
-
19
- </pre>
@@ -1 +0,0 @@
1
- <link href="/css/main.css" rel="stylesheet">
@@ -1,61 +0,0 @@
1
- import axios from "axios";
2
- import { Collection } from "collect.js";
3
-
4
- export function getRandomIntegerBetween(min: number, max: number): number {
5
- const randomBuffer = new Uint32Array(1);
6
-
7
- window.crypto.getRandomValues(randomBuffer);
8
-
9
- const randomNumber = randomBuffer[0] / (0xffffffff + 1);
10
-
11
- return Math.floor(randomNumber * (max - min + 1)) + min;
12
- }
13
-
14
- export function sortObjectByKeysCaseInsensitive(
15
- object: unknown
16
- ): Record<string, unknown> {
17
- return (object instanceof Collection ? object : Object.keys(object))
18
- .sort((a, b) => a.localeCompare(b))
19
- .reduce((sorted, key) => {
20
- sorted[key] = object[key];
21
- return sorted;
22
- }, {});
23
- }
24
-
25
- export function downloadFile(filePath: string, fileName?: string): void {
26
- axios({
27
- url: filePath,
28
- method: "GET",
29
- responseType: "blob",
30
- }).then((response) => {
31
- const fileURL = window.URL.createObjectURL(new Blob([response.data]));
32
- const fileLink = document.createElement("a");
33
-
34
- fileLink.href = fileURL;
35
- fileLink.setAttribute(
36
- "download",
37
- fileName || filePath.replace(/^.*[\\\/]/, "")
38
- );
39
- document.body.appendChild(fileLink);
40
-
41
- fileLink.click();
42
- });
43
- }
44
-
45
- export function postForm(url: string, data?: Record<string, string>): void {
46
- const form = document.createElement("form");
47
- form.method = "POST";
48
- form.action = url;
49
-
50
- Object.entries(data).forEach(([key, value]: [key: string, value: string]) => {
51
- const input = document.createElement("input");
52
- input.type = "hidden";
53
- input.name = key;
54
- input.value = value;
55
- form.append(input);
56
- });
57
-
58
- document.body.appendChild(form);
59
-
60
- form.submit();
61
- }
@@ -1,34 +0,0 @@
1
- // Publisher-Subscriber pattern interface
2
- type Callback = (data: unknown) => void;
3
- type Subscriber<Event> = Map<Event, Set<Callback>>;
4
-
5
- export default abstract class PublisherSubscriber<Event> {
6
- protected subscribers: Map<string, Subscriber<Event>> = new Map();
7
-
8
- subscribe(event: Event, callback: Callback, context = ""): void {
9
- if (!this.subscribers.has(context)) {
10
- this.createSubscriber(context);
11
- }
12
- if (!this.subscribers.get(context).has(event)) {
13
- this.createEvent(context, event);
14
- }
15
- this.subscribers.get(context).get(event).add(callback);
16
- }
17
-
18
- protected createSubscriber(context: string): void {
19
- this.subscribers.set(context, new Map());
20
- }
21
-
22
- protected createEvent(context: string, event: Event): void {
23
- this.subscribers.get(context).set(event, new Set());
24
- }
25
-
26
- protected publish(event: Event, data: unknown, context = ""): void {
27
- const subscriber = this.subscribers.get(context);
28
- if (subscriber && subscriber.has(event)) {
29
- subscriber.get(event).forEach((callback) => {
30
- callback(data);
31
- });
32
- }
33
- }
34
- }
@@ -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
- }