sprof 0.1.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.
- package/README.md +29 -0
- package/package.json +101 -0
- package/src/Hooks/Hooks.ts +75 -0
- package/src/assets/img/avatar.webp +0 -0
- package/src/assets/styles/borders.scss +11 -0
- package/src/assets/styles/brandbook.css +227 -0
- package/src/assets/styles/colors.scss +42 -0
- package/src/assets/styles/fonts.scss +15 -0
- package/src/assets/styles/index.css +15 -0
- package/src/assets/styles/index.scss +45 -0
- package/src/assets/styles/platform/android.css +53 -0
- package/src/assets/styles/platform/ios.css +53 -0
- package/src/assets/styles/platform/webdesktop.css +72 -0
- package/src/assets/styles/platform/webdesktop_old.css +65 -0
- package/src/assets/styles/platform/webmobile.css +53 -0
- package/src/assets/styles/platform/webtablet.css +53 -0
- package/src/assets/styles/reset.scss +28 -0
- package/src/assets/styles/shadow.scss +6 -0
- package/src/assets/styles/theme/aquaBlueLight.css +162 -0
- package/src/assets/styles/theme/blueLight.css +187 -0
- package/src/assets/styles/theme/blueLight_test.css +162 -0
- package/src/assets/styles/theme/dark.css +286 -0
- package/src/assets/styles/theme/light.css +151 -0
- package/src/assets/svg/ArrowLeft.svg +5 -0
- package/src/assets/svg/ArrowRight.svg +5 -0
- package/src/assets/svg/Close.svg +7 -0
- package/src/assets/svg/DoubleArrowLeft.svg +5 -0
- package/src/assets/svg/DoubleArrowRight.svg +5 -0
- package/src/assets/svg/Ellipsis.svg +7 -0
- package/src/assets/svg/Filter.svg +10 -0
- package/src/assets/svg/Menu.svg +5 -0
- package/src/assets/svg/Move.svg +5 -0
- package/src/assets/svg/Password.svg +5 -0
- package/src/assets/svg/RightMenu.svg +5 -0
- package/src/assets/svg/Settings.svg +6 -0
- package/src/assets/svg/User.svg +6 -0
- package/src/buildLibrary.ts +59 -0
- package/src/classes/Auth.ts +63 -0
- package/src/classes/AuthButton.ts +64 -0
- package/src/classes/AuthForm.ts +114 -0
- package/src/classes/AuthModal.ts +32 -0
- package/src/classes/AuthStatusesObjects.ts +37 -0
- package/src/classes/AuthTokens.ts +43 -0
- package/src/classes/AuthUser.ts +53 -0
- package/src/classes/CallbackRequest.ts +12 -0
- package/src/classes/Chat.ts +18 -0
- package/src/classes/ChatMessage.ts +48 -0
- package/src/classes/Contact.ts +96 -0
- package/src/classes/Cropper.ts +22 -0
- package/src/classes/DateHelper.ts +29 -0
- package/src/classes/Email.ts +18 -0
- package/src/classes/EmailField.ts +42 -0
- package/src/classes/EmailRules.ts +4 -0
- package/src/classes/FTSPPreset.ts +16 -0
- package/src/classes/FileInfo.ts +86 -0
- package/src/classes/HttpResponse.ts +22 -0
- package/src/classes/Human.ts +106 -0
- package/src/classes/LabelValue.ts +11 -0
- package/src/classes/LocalStore.ts +22 -0
- package/src/classes/M2M.ts +25 -0
- package/src/classes/Menu.ts +102 -0
- package/src/classes/PageSectionImage.ts +19 -0
- package/src/classes/PasswordField.ts +39 -0
- package/src/classes/PasswordRepeatField.ts +37 -0
- package/src/classes/Phone.ts +17 -0
- package/src/classes/PostAddress.ts +11 -0
- package/src/classes/PostAddressRules.ts +1 -0
- package/src/classes/Role.ts +13 -0
- package/src/classes/Schema.ts +13 -0
- package/src/classes/SchemaField.ts +10 -0
- package/src/classes/SearchElement.ts +18 -0
- package/src/classes/SearchElementMeta.ts +10 -0
- package/src/classes/SearchGroup.ts +25 -0
- package/src/classes/SearchGroupMetaColumn.ts +11 -0
- package/src/classes/SearchModel.ts +61 -0
- package/src/classes/SortModel.ts +57 -0
- package/src/classes/SubMenu.ts +56 -0
- package/src/classes/TelephoneNumberRules.ts +9 -0
- package/src/classes/User.ts +17 -0
- package/src/classes/UserAccount.ts +17 -0
- package/src/classes/UserService.ts +20 -0
- package/src/classes/ValidationRules.ts +15 -0
- package/src/classes/ValueType.ts +69 -0
- package/src/classes/Website.ts +11 -0
- package/src/classes/WebsiteRules.ts +4 -0
- package/src/classes/admin/AdminButtonParams.ts +27 -0
- package/src/classes/admin/AdminHeaderParams.ts +34 -0
- package/src/classes/calendar/Calendar.ts +168 -0
- package/src/classes/calendar/Day.ts +15 -0
- package/src/classes/calendar/Month.ts +144 -0
- package/src/classes/calendar/Week.ts +44 -0
- package/src/classes/calendar/Year.ts +130 -0
- package/src/classes/filters/Cursor.ts +43 -0
- package/src/classes/filters/FTSP.ts +99 -0
- package/src/classes/filters/FilterModel.ts +263 -0
- package/src/classes/filters/FilterQuery.ts +187 -0
- package/src/classes/filters/OperatorsOptions.ts +8 -0
- package/src/classes/filters/OperatorsTextOptions.ts +3 -0
- package/src/classes/filters/Pagination.ts +78 -0
- package/src/classes/filters/SelectFilter.ts +15 -0
- package/src/classes/filters/TreeModel.ts +14 -0
- package/src/classes/page/CustomSection.ts +24 -0
- package/src/classes/page/Page.ts +160 -0
- package/src/classes/page/PageDocument.ts +27 -0
- package/src/classes/page/PageImage.ts +15 -0
- package/src/classes/page/PageSection.ts +82 -0
- package/src/classes/page/PageSectionDocument.ts +56 -0
- package/src/classes/page/PageSideMenu.ts +74 -0
- package/src/components/AdaptiveContainer.vue +154 -0
- package/src/components/AdaptiveContainerHorizontal.vue +173 -0
- package/src/components/AdminGallery.vue +238 -0
- package/src/components/AuthModal.vue +16 -0
- package/src/components/CarouselImages.vue +434 -0
- package/src/components/ContactForm.vue +219 -0
- package/src/components/ContextWindow.vue +48 -0
- package/src/components/DateInputRange.vue +66 -0
- package/src/components/DateInputRange_v2.vue +25 -0
- package/src/components/DropList.vue +55 -0
- package/src/components/Edit.svg +10 -0
- package/src/components/EmailForm.vue +180 -0
- package/src/components/FTSPPanel.vue +379 -0
- package/src/components/FilterCheckbox.vue +73 -0
- package/src/components/FilterSelect.vue +104 -0
- package/src/components/FiltersButtonsSelect.vue +126 -0
- package/src/components/GeneralItem.vue +172 -0
- package/src/components/GridContainer.vue +66 -0
- package/src/components/Icons/Filter/IconDownload.vue +55 -0
- package/src/components/Icons/Filter/IconFilter.vue +55 -0
- package/src/components/Icons/IconArrowLeft.vue +36 -0
- package/src/components/Icons/IconCheckDefault.vue +41 -0
- package/src/components/Icons/IconClose.vue +37 -0
- package/src/components/Icons/IconEdit.vue +40 -0
- package/src/components/Icons/IconEmail.vue +36 -0
- package/src/components/Icons/IconMove.vue +53 -0
- package/src/components/Icons/IconPhone.vue +36 -0
- package/src/components/Icons/IconSearch.vue +47 -0
- package/src/components/Icons/IconSelectArrow.vue +41 -0
- package/src/components/Icons/Pagination/ArrowLeft.vue +52 -0
- package/src/components/Icons/Pagination/ArrowRight.vue +52 -0
- package/src/components/Icons/Pagination/DoubleArrowLeft.vue +52 -0
- package/src/components/Icons/Pagination/DoubleArrowRight.vue +52 -0
- package/src/components/Icons/Pagination/EllipsisSvg.vue +58 -0
- package/src/components/ImageCropper.vue +203 -0
- package/src/components/InfoItem.vue +294 -0
- package/src/components/InfoItemSelectButtons.vue +43 -0
- package/src/components/LeftRightContainer.vue +93 -0
- package/src/components/MessageBody.vue +45 -0
- package/src/components/PAutocomplete.vue +93 -0
- package/src/components/PDialog.vue +77 -0
- package/src/components/PLoader.vue +68 -0
- package/src/components/PNotification.vue +79 -0
- package/src/components/PPagination.vue +174 -0
- package/src/components/PhoneForm.vue +180 -0
- package/src/components/RSContainer.vue +262 -0
- package/src/components/RemoteSearch.vue +156 -0
- package/src/components/ResearcheContainer.vue +71 -0
- package/src/components/RightSliderContainer.vue +181 -0
- package/src/components/RightTabsContainer.vue +210 -0
- package/src/components/SelectValueType.vue +39 -0
- package/src/components/SingleNameToggleForm.vue +399 -0
- package/src/components/SortList.vue +101 -0
- package/src/components/SortSelect.vue +93 -0
- package/src/components/SvgIcon.vue +25 -0
- package/src/components/Switch3Pos.vue +173 -0
- package/src/components/ThemeWrapper.vue +19 -0
- package/src/components/ToggleInfoItem.vue +296 -0
- package/src/components/TopSliderContainer.vue +166 -0
- package/src/components/UploaderImage.vue +268 -0
- package/src/components/atoms/PButton/PButton.stories.ts +44 -0
- package/src/components/atoms/PButton/PButton.test.ts +66 -0
- package/src/components/atoms/PButton/PButton.vue +54 -0
- package/src/components/atoms/PButton/skins/p-button_base.css +131 -0
- package/src/components/atoms/PButton/skins/p-button_filter.scss +83 -0
- package/src/components/atoms/PButton/skins/p-button_icon.scss +78 -0
- package/src/components/atoms/PButton/skins/p-button_pag.css +44 -0
- package/src/components/atoms/PButton/skins/p-button_text.css +88 -0
- package/src/components/atoms/PButton/skins/p-button_text_ano.css +88 -0
- package/src/components/atoms/PCheckbox/PCheckBox.test.ts +107 -0
- package/src/components/atoms/PCheckbox/PCheckBox.vue +92 -0
- package/src/components/atoms/PDatePicker/PDatePicker.test.ts +63 -0
- package/src/components/atoms/PDatePicker/PDatePicker.vue +141 -0
- package/src/components/atoms/PFlex/PFlex.test.ts +41 -0
- package/src/components/atoms/PFlex/PFlex.vue +46 -0
- package/src/components/atoms/PInput/PInput.stories.ts +40 -0
- package/src/components/atoms/PInput/PInput.test.ts +92 -0
- package/src/components/atoms/PInput/PInput.vue +133 -0
- package/src/components/atoms/PInputDate/PInputDate.test.ts +55 -0
- package/src/components/atoms/PInputDate/PInputDate.vue +79 -0
- package/src/components/atoms/PInputNumber/PInputNumber.vue +175 -0
- package/src/components/atoms/PLeftSlider/PLeftSlider.test.ts +121 -0
- package/src/components/atoms/PLeftSlider/PLeftSlider.vue +139 -0
- package/src/components/atoms/PList/PList.test.ts +32 -0
- package/src/components/atoms/PList/PList.vue +27 -0
- package/src/components/atoms/PListItem/PListItem.test.ts +61 -0
- package/src/components/atoms/PListItem/PListItem.vue +51 -0
- package/src/components/atoms/PRadio/PRadio.test.ts +110 -0
- package/src/components/atoms/PRadio/PRadio.vue +97 -0
- package/src/components/atoms/PRightSlider/PRightSlider.test.ts +123 -0
- package/src/components/atoms/PRightSlider/PRightSlider.vue +149 -0
- package/src/components/atoms/PSelect/PSelect.test.ts +74 -0
- package/src/components/atoms/PSelect/PSelect.vue +192 -0
- package/src/components/atoms/PSelect/select-arrow-down.svg +4 -0
- package/src/components/atoms/PSticky/PSticky.test.ts +70 -0
- package/src/components/atoms/PSticky/PSticky.vue +37 -0
- package/src/components/atoms/PString/PString.test.ts +58 -0
- package/src/components/atoms/PString/PString.vue +58 -0
- package/src/components/atoms/PTextarea/PTextarea.stories.ts +40 -0
- package/src/components/atoms/PTextarea/PTextarea.test.ts +22 -0
- package/src/components/atoms/PTextarea/PTextarea.vue +123 -0
- package/src/components/atoms/PTopSlider/PTopSlider.test.ts +95 -0
- package/src/components/atoms/PTopSlider/PTopSlider.vue +164 -0
- package/src/components/molecules/Collapse/CollapseContainer.vue +36 -0
- package/src/components/molecules/Collapse/CollapseItem.vue +295 -0
- package/src/components/molecules/Collapse/VerticalCollapseContainer.vue +102 -0
- package/src/components/molecules/PAdd/PAdd.vue +65 -0
- package/src/components/molecules/PAdd/PContainer.vue +65 -0
- package/src/components/molecules/PAdd/PContainerStickyHead.vue +51 -0
- package/src/components/molecules/PDel/PDel.vue +74 -0
- package/src/components/organisms/AuthForm.vue +219 -0
- package/src/components/organisms/PModal.vue +113 -0
- package/src/components/organisms/PTabs/ITab.ts +5 -0
- package/src/components/organisms/PTabs/PTabs.vue +190 -0
- package/src/components/organisms/UploaderFile/UploaderFile.test.ts +23 -0
- package/src/components/organisms/UploaderFile/UploaderFile.vue +202 -0
- package/src/components/pages/AuthPage.vue +22 -0
- package/src/components/pages/PageNotFound.vue +7 -0
- package/src/index.ts +206 -0
- package/src/interfaces/AdminLayout.ts +4 -0
- package/src/interfaces/Animations.ts +5 -0
- package/src/interfaces/AuthStatuses.ts +8 -0
- package/src/interfaces/CalendarScale.ts +6 -0
- package/src/interfaces/Callback.ts +2 -0
- package/src/interfaces/Class.ts +3 -0
- package/src/interfaces/DataTypes.ts +8 -0
- package/src/interfaces/Filter.ts +3 -0
- package/src/interfaces/IAdminMenu.ts +9 -0
- package/src/interfaces/IAuthInfo.ts +0 -0
- package/src/interfaces/ICursor.ts +14 -0
- package/src/interfaces/IEmailPassword.ts +4 -0
- package/src/interfaces/IFIlesList.ts +4 -0
- package/src/interfaces/IFile.ts +7 -0
- package/src/interfaces/IFileAnchor.ts +4 -0
- package/src/interfaces/IFileInfo.ts +22 -0
- package/src/interfaces/IFileInfosGetter.ts +5 -0
- package/src/interfaces/IFiler.ts +7 -0
- package/src/interfaces/IFilter.ts +4 -0
- package/src/interfaces/IFilterQuery.ts +24 -0
- package/src/interfaces/IForm.ts +5 -0
- package/src/interfaces/IHTTPTypes.ts +19 -0
- package/src/interfaces/IMessage.ts +5 -0
- package/src/interfaces/IOption.ts +4 -0
- package/src/interfaces/IOrdered.ts +4 -0
- package/src/interfaces/IPagination.ts +15 -0
- package/src/interfaces/ISearchElement.ts +6 -0
- package/src/interfaces/ISearchObject.ts +6 -0
- package/src/interfaces/ISearchQuery.ts +4 -0
- package/src/interfaces/ISelectFilter.ts +6 -0
- package/src/interfaces/ISortModel.ts +18 -0
- package/src/interfaces/IStorePaginator.ts +4 -0
- package/src/interfaces/ISupposedTimePeriod.ts +4 -0
- package/src/interfaces/ITimePeriod.ts +4 -0
- package/src/interfaces/ITokens.ts +4 -0
- package/src/interfaces/IWithId.ts +3 -0
- package/src/interfaces/IWithImage.ts +9 -0
- package/src/interfaces/IWithName.ts +4 -0
- package/src/interfaces/IWithSupposedTimePeriod.ts +4 -0
- package/src/interfaces/ItemsWithCount.ts +4 -0
- package/src/interfaces/LocalStoreKeys.ts +7 -0
- package/src/interfaces/Operators.ts +11 -0
- package/src/interfaces/Orders.ts +4 -0
- package/src/interfaces/RoleName.ts +4 -0
- package/src/interfaces/SocialTypes.ts +6 -0
- package/src/interfaces/Sort.ts +9 -0
- package/src/interfaces/ValueRelation.ts +7 -0
- package/src/interfaces/canvas/ICanvas.ts +3 -0
- package/src/interfaces/canvas/ICanvasResult.ts +7 -0
- package/src/interfaces/canvas/ICoordinates.ts +6 -0
- package/src/interfaces/types.ts +3 -0
- package/src/services/AdminHead.ts +32 -0
- package/src/services/AdminSideMenu.ts +52 -0
- package/src/services/AdminUI.ts +9 -0
- package/src/services/Arrays.ts +65 -0
- package/src/services/Axios.ts +64 -0
- package/src/services/BaseRoutes.ts +21 -0
- package/src/services/BaseStore.ts +220 -0
- package/src/services/Button.ts +42 -0
- package/src/services/Cache.ts +44 -0
- package/src/services/CacheS.ts +44 -0
- package/src/services/CarouselSwipe.ts +14 -0
- package/src/services/ClassHelper.ts +101 -0
- package/src/services/Color.ts +8 -0
- package/src/services/CreateSortModels.ts +26 -0
- package/src/services/Cursor.ts +51 -0
- package/src/services/DateFormat.ts +102 -0
- package/src/services/DateMask.ts +69 -0
- package/src/services/Dates.ts +41 -0
- package/src/services/DatesFormatter.ts +45 -0
- package/src/services/Dialog.ts +70 -0
- package/src/services/Dragger.ts +22 -0
- package/src/services/Extension.ts +6 -0
- package/src/services/Favourite.ts +62 -0
- package/src/services/HttpClient.ts +199 -0
- package/src/services/HttpClientS.ts +188 -0
- package/src/services/HttpError.ts +58 -0
- package/src/services/Loading.ts +14 -0
- package/src/services/MakeCarousel.ts +10 -0
- package/src/services/Menu.ts +102 -0
- package/src/services/Message.ts +66 -0
- package/src/services/Notification.ts +37 -0
- package/src/services/PHelp.ts +20 -0
- package/src/services/Paginator.ts +22 -0
- package/src/services/Period.ts +29 -0
- package/src/services/PhoneService.ts +46 -0
- package/src/services/Router.ts +85 -0
- package/src/services/RouterGuard.ts +15 -0
- package/src/services/Scheduler.ts +66 -0
- package/src/services/Scroll.ts +19 -0
- package/src/services/SortList.ts +44 -0
- package/src/services/Sorter.ts +6 -0
- package/src/services/Strings.test.ts +30 -0
- package/src/services/Strings.ts +138 -0
- package/src/services/Time.ts +124 -0
- package/src/services/Timer.ts +13 -0
- package/src/services/Token.ts +71 -0
- package/src/services/Visible.ts +16 -0
- package/src/services/WaitElement.ts +19 -0
- package/src/services/WebSocketClient.ts +62 -0
- package/src/services/brandColors.ts +5 -0
- package/src/services/buildNameNumbers.ts +8 -0
- package/src/services/countRating.ts +12 -0
- package/src/services/index.ts +105 -0
- package/src/services/indexNames.ts +55 -0
- package/src/services/moves.ts +17 -0
- package/src/services/useConfirmLeavePage.ts +52 -0
- package/src/services/validate.ts +22 -0
- package/src/store/AuthStore.ts +58 -0
- package/src/store/ContactsStore.ts +11 -0
- package/src/store/CropperStore.ts +20 -0
- package/src/store/EmailsStore.ts +11 -0
- package/src/store/FTSPPresetsStore.ts +11 -0
- package/src/store/FileInfosStore.ts +11 -0
- package/src/store/HumansStore.ts +11 -0
- package/src/store/MenusStore.ts +11 -0
- package/src/store/PhonesStore.ts +11 -0
- package/src/store/SchemasStore.ts +11 -0
- package/src/store/SearchStore.ts +65 -0
- package/src/store/ServicesStores.ts +29 -0
- package/src/store/ServicesStoresNames.ts +17 -0
- package/src/store/UserAccountsStore.ts +11 -0
- package/src/store/ValueTypesStore.ts +11 -0
- package/src/tsconfig.build-lib.json +30 -0
- package/src/types/AuthInfo.ts +6 -0
- package/src/types/HttpHeaders.ts +12 -0
- package/src/types/HttpMethods.ts +6 -0
- package/src/types/Sizes.ts +7 -0
- package/src/types/Statuses.ts +9 -0
- package/src/types/ValueTypes.ts +16 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
import TokenService from '@/services/Token';
|
|
4
|
+
|
|
5
|
+
import ClassHelper from './ClassHelper';
|
|
6
|
+
import PHelp from './PHelp';
|
|
7
|
+
|
|
8
|
+
export default class HttpError {
|
|
9
|
+
private code = 400;
|
|
10
|
+
private err = '';
|
|
11
|
+
|
|
12
|
+
constructor(i?: HttpError) {
|
|
13
|
+
ClassHelper.BuildClass(this, i);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getErr(): string {
|
|
17
|
+
return this.capitalizedErr();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private capitalizedErr(): string {
|
|
21
|
+
return this.err.charAt(0).toUpperCase() + this.err.slice(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
static async Handle(error: any, axiosInstance: AxiosInstance) {
|
|
26
|
+
const originalRequest = error.config;
|
|
27
|
+
if (!error.response) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (error.response.status === 401 && !originalRequest._retry) {
|
|
31
|
+
originalRequest._retry = true;
|
|
32
|
+
try {
|
|
33
|
+
// await AuthStore.RefreshToken();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// await AuthStore.Logout();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
axiosInstance.defaults.headers.common['token'] = TokenService.getAccessToken();
|
|
39
|
+
error.config.headers['token'] = TokenService.getAccessToken();
|
|
40
|
+
error.config.baseURL = undefined;
|
|
41
|
+
return axiosInstance.request(originalRequest);
|
|
42
|
+
}
|
|
43
|
+
if (error.response.status >= 500) {
|
|
44
|
+
if (error.response.data === 'неверный логин или пароль') {
|
|
45
|
+
PHelp.Notification.Error('Неверный логин или пароль');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
PHelp.Notification.Error('Ошибка на сервере, попробуйте позже');
|
|
49
|
+
}
|
|
50
|
+
if (error.response.status >= 400 && error.response.status < 500) {
|
|
51
|
+
const err = new HttpError(error.response.data).getErr();
|
|
52
|
+
if (err) {
|
|
53
|
+
PHelp.Notification.Error(err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return Promise.reject(error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default function makeCarousel<ArrayType>(array: ArrayType[], size: number): ArrayType[][] {
|
|
2
|
+
// size - number of banners in el-carousel-item
|
|
3
|
+
const subarray = [];
|
|
4
|
+
if (array) {
|
|
5
|
+
for (let i = 0; i < Math.ceil(array.length / size); i++) {
|
|
6
|
+
subarray[i] = array.slice(i * size, i * size + size);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return subarray;
|
|
10
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
|
|
3
|
+
// import IElementPlusFile from '@/interfaces/files/IElementPlusFile';
|
|
4
|
+
import FileInfo from '@/services/classes/FileInfo';
|
|
5
|
+
import Page from '@/services/classes/page/Page';
|
|
6
|
+
import SubMenu from '@/services/classes/SubMenu';
|
|
7
|
+
import ClassHelper from '@/services/ClassHelper';
|
|
8
|
+
import IFile from '@/services/interfaces/IFile';
|
|
9
|
+
|
|
10
|
+
export default class Menu {
|
|
11
|
+
id?: string;
|
|
12
|
+
name = '';
|
|
13
|
+
link = '';
|
|
14
|
+
top = true;
|
|
15
|
+
side = true;
|
|
16
|
+
show = false;
|
|
17
|
+
hide = false;
|
|
18
|
+
active = false;
|
|
19
|
+
order = 0;
|
|
20
|
+
selected = false;
|
|
21
|
+
editMode = false;
|
|
22
|
+
|
|
23
|
+
page = new Page();
|
|
24
|
+
pageId?: string;
|
|
25
|
+
|
|
26
|
+
@ClassHelper.GetClassConstructor(SubMenu)
|
|
27
|
+
subMenus: SubMenu[] = [];
|
|
28
|
+
subMenusForDelete: string[] = [];
|
|
29
|
+
|
|
30
|
+
iconId?: string;
|
|
31
|
+
icon = new FileInfo();
|
|
32
|
+
|
|
33
|
+
constructor(i?: Menu) {
|
|
34
|
+
ClassHelper.BuildClass(this, i);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getLink(): string {
|
|
38
|
+
if (this.isLink() && !this.isPageLink()) {
|
|
39
|
+
return this.link;
|
|
40
|
+
}
|
|
41
|
+
if (!this.isLink() && this.isPageLink()) {
|
|
42
|
+
return this.page.getLink();
|
|
43
|
+
}
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
withoutChildren(): boolean {
|
|
48
|
+
return this.subMenus.length === 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
isLink(): boolean {
|
|
52
|
+
return this.link !== '';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
isPageLink(): boolean {
|
|
56
|
+
return !!this.pageId && this.pageId !== '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getFileInfos(): FileInfo[] {
|
|
60
|
+
const fileInfos: FileInfo[] = [];
|
|
61
|
+
fileInfos.push(this.icon);
|
|
62
|
+
this.subMenus.forEach((subMenu: SubMenu) => {
|
|
63
|
+
fileInfos.push(subMenu.icon);
|
|
64
|
+
});
|
|
65
|
+
return fileInfos;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
addFile(file: File & IFile): void {
|
|
69
|
+
if (!this.icon.id) {
|
|
70
|
+
this.icon.id = uuidv4();
|
|
71
|
+
}
|
|
72
|
+
this.icon.originalName = file.name;
|
|
73
|
+
this.icon.file = file.raw;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
addSubMenu(): void {
|
|
77
|
+
this.subMenus.push(new SubMenu());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
removeSubMenu(index: number): void {
|
|
81
|
+
const idForDelete = this.subMenus[index].id;
|
|
82
|
+
if (idForDelete) {
|
|
83
|
+
this.subMenusForDelete.push(idForDelete);
|
|
84
|
+
}
|
|
85
|
+
this.subMenus.splice(index, 1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setColorsForSubMenus(): void {
|
|
89
|
+
const colors: string[] = ['#00A248', '#E63021', '#006BB5', '#F3911F', '#6F6D6B'];
|
|
90
|
+
let i = 0;
|
|
91
|
+
this.subMenus.forEach((subMenu) => {
|
|
92
|
+
subMenu.color = colors[i];
|
|
93
|
+
i === colors.length - 1 ? (i = 0) : i++;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
containPath(path: string): boolean {
|
|
97
|
+
return this.getLink() === path || !!this.subMenus.find((subMenu: SubMenu) => subMenu.getLink() === path);
|
|
98
|
+
}
|
|
99
|
+
static GetClassName(): string {
|
|
100
|
+
return 'menu';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import Statuses from "../types/Statuses";
|
|
2
|
+
import Visible from "./Visible";
|
|
3
|
+
|
|
4
|
+
export type MessageOpts = {
|
|
5
|
+
text: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default class Message extends Visible {
|
|
10
|
+
private type: Statuses = Statuses.Success;
|
|
11
|
+
private text = "";
|
|
12
|
+
private title = "";
|
|
13
|
+
|
|
14
|
+
protected showMessage(m: string | MessageOpts, t: Statuses) {
|
|
15
|
+
this.hide();
|
|
16
|
+
this.type = t;
|
|
17
|
+
if (typeof m === "string") {
|
|
18
|
+
this.text = m;
|
|
19
|
+
} else {
|
|
20
|
+
this.text = m.text;
|
|
21
|
+
this.title = m.title ?? "";
|
|
22
|
+
}
|
|
23
|
+
super.show();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
GetText(): string {
|
|
27
|
+
return this.text;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
GetTitle(): string {
|
|
31
|
+
return this.title;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
GetType(): Statuses {
|
|
35
|
+
return this.type;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Info(m: string | MessageOpts): void {
|
|
39
|
+
this.showMessage(m, Statuses.Info);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Success(m: string | MessageOpts): void {
|
|
43
|
+
this.showMessage(m, Statuses.Success);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Error(m: string | MessageOpts): void {
|
|
47
|
+
this.showMessage(m, Statuses.Error);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Warning(m: string | MessageOpts): void {
|
|
51
|
+
this.showMessage(m, Statuses.Warning);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// eslint-disable-next-line
|
|
55
|
+
FormMessage(errorFields: any): string {
|
|
56
|
+
let errorMessage =
|
|
57
|
+
"<strong>Проверьте правильность введенных данных:</strong><ul>";
|
|
58
|
+
for (const item of Object.keys(errorFields)) {
|
|
59
|
+
if (errorFields[item][0] && errorFields[item][0].message) {
|
|
60
|
+
errorMessage += `<li>${errorFields[item][0].message}</li>`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
errorMessage += "</ul>";
|
|
64
|
+
return errorMessage;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Message, { MessageOpts } from "./Message";
|
|
2
|
+
import Time from "./Time";
|
|
3
|
+
import Timer from "./Timer";
|
|
4
|
+
import Statuses from "../types/Statuses";
|
|
5
|
+
|
|
6
|
+
type NotificationOpts = MessageOpts & {
|
|
7
|
+
duration: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
class NotificationConstructor extends Message {
|
|
11
|
+
private duration = Time.S(3);
|
|
12
|
+
|
|
13
|
+
protected showMessage(m: string | NotificationOpts, t: Statuses) {
|
|
14
|
+
super.showMessage(m, t);
|
|
15
|
+
if (typeof m !== "string") {
|
|
16
|
+
this.duration = m.duration ?? this.duration;
|
|
17
|
+
}
|
|
18
|
+
Timer.Wait(this.GetDuration()).then(() => super.hide());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private GetDuration(): number {
|
|
22
|
+
return this.duration;
|
|
23
|
+
}
|
|
24
|
+
Dev() {
|
|
25
|
+
const m = "В режиме разработки";
|
|
26
|
+
const t = Statuses.Warning;
|
|
27
|
+
super.showMessage(m, t);
|
|
28
|
+
}
|
|
29
|
+
Save() {
|
|
30
|
+
const m = "Изменения успешно сохранены";
|
|
31
|
+
const t = Statuses.Success;
|
|
32
|
+
super.showMessage(m, t);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const Notification: NotificationConstructor = new NotificationConstructor();
|
|
37
|
+
export default Notification;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import AdminUI from "./AdminUI";
|
|
2
|
+
import Auth from "../classes/Auth";
|
|
3
|
+
import AuthForm from "../classes/AuthForm";
|
|
4
|
+
import AuthModal from "../classes/AuthModal";
|
|
5
|
+
import Dialog from "./Dialog";
|
|
6
|
+
import Loading from "./Loading";
|
|
7
|
+
import Notification from "./Notification";
|
|
8
|
+
import Paginator from "./Paginator";
|
|
9
|
+
|
|
10
|
+
export default abstract class PHelp {
|
|
11
|
+
static Auth = reactive(Auth);
|
|
12
|
+
static AuthForm = reactive(AuthForm);
|
|
13
|
+
static AuthModal = reactive(AuthModal);
|
|
14
|
+
|
|
15
|
+
static AdminUI = reactive(AdminUI);
|
|
16
|
+
static Dialog = reactive(Dialog);
|
|
17
|
+
static Notification = reactive(Notification);
|
|
18
|
+
static Loading = reactive(Loading);
|
|
19
|
+
static Paginator = reactive(Paginator);
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class Paginator {
|
|
2
|
+
limit = 25;
|
|
3
|
+
|
|
4
|
+
count = 0;
|
|
5
|
+
curPage = 1;
|
|
6
|
+
storeModule? = '';
|
|
7
|
+
|
|
8
|
+
setCurPage(page: number): void {
|
|
9
|
+
this.curPage = page;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
pagesCount(): number {
|
|
13
|
+
return Math.ceil(this.count / this.limit) ?? 1;
|
|
14
|
+
}
|
|
15
|
+
reset(): void {
|
|
16
|
+
this.count = 0;
|
|
17
|
+
this.curPage = 1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const s = new Paginator();
|
|
22
|
+
export default s;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type Comparable = number | string | Date;
|
|
2
|
+
|
|
3
|
+
export default abstract class Period {
|
|
4
|
+
static Get(start: string, end: string, divider = '-'): string {
|
|
5
|
+
if (!start || !end) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
return `${start}${divider}${end}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static In(obj: Comparable, start: Comparable, end: Comparable): boolean {
|
|
12
|
+
return obj >= start && obj <= end;
|
|
13
|
+
}
|
|
14
|
+
static Intersects(p1Start: Comparable, p1End: Comparable, p2Start: Comparable, p2End: Comparable): boolean {
|
|
15
|
+
if (p1Start === p2Start || p1End === p2End) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (p1Start > p2Start && p1Start < p2End) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
if (p1End > p2Start && p1End < p2End) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (p1End > p2End && p1Start < p2Start) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default class PhoneService {
|
|
2
|
+
static Format(phone: string): string {
|
|
3
|
+
let value = phone;
|
|
4
|
+
if (!value) {
|
|
5
|
+
phone = value;
|
|
6
|
+
} else {
|
|
7
|
+
if ((value[0] === '7' || value[0] === '8') && value.length !== 1) value = value.slice(1);
|
|
8
|
+
const phoneNumber = value.replace(/\+7|[^\d]/g, '');
|
|
9
|
+
const phoneNumberLength = phoneNumber.length;
|
|
10
|
+
switch (true) {
|
|
11
|
+
case phoneNumberLength === 0:
|
|
12
|
+
phone = '';
|
|
13
|
+
break;
|
|
14
|
+
case phoneNumberLength === 1 && value.length === 1 && phoneNumber === '7':
|
|
15
|
+
case phoneNumberLength === 1 && value.length === 1 && phoneNumber === '8':
|
|
16
|
+
phone = '+7 (';
|
|
17
|
+
break;
|
|
18
|
+
case phoneNumberLength < 4:
|
|
19
|
+
phone = `+7 (${phoneNumber}`;
|
|
20
|
+
break;
|
|
21
|
+
case phoneNumberLength < 7:
|
|
22
|
+
phone = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3)}`;
|
|
23
|
+
break;
|
|
24
|
+
case phoneNumberLength < 9:
|
|
25
|
+
phone = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)}-${phoneNumber.slice(6, 8)}`;
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
phone = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)}-${phoneNumber.slice(6, 8)}-${phoneNumber.slice(8, 10)}`;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return phone;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private static getPhoneRegExp(): RegExp {
|
|
36
|
+
return /^(\s*)?(\+)?([- _():=+]?\d[- _():=+]?){10,14}(\s*)?$/;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static validatePhone = (_: unknown, value: string, callback: CallableFunction): void => {
|
|
40
|
+
if (PhoneService.getPhoneRegExp().test(value) || !value) {
|
|
41
|
+
callback();
|
|
42
|
+
} else {
|
|
43
|
+
callback(new Error('Пожалуйста, введите корректный номер телефона'));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RouteLocationNormalizedLoaded } from 'vue-router';
|
|
2
|
+
import { RouteLocation } from 'vue-router';
|
|
3
|
+
|
|
4
|
+
import router from '@/router';
|
|
5
|
+
|
|
6
|
+
import PHelp from './PHelp';
|
|
7
|
+
|
|
8
|
+
export default abstract class Router {
|
|
9
|
+
static async To(route: string) {
|
|
10
|
+
PHelp.Loading.Show();
|
|
11
|
+
await router.push(route);
|
|
12
|
+
PHelp.Loading.Hide();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static async ToHome() {
|
|
16
|
+
PHelp.Loading.Show();
|
|
17
|
+
const home = import.meta.env.VITE_HOME_PAGE;
|
|
18
|
+
await router.push(home);
|
|
19
|
+
PHelp.Loading.Hide();
|
|
20
|
+
}
|
|
21
|
+
static async Replace(route: string) {
|
|
22
|
+
await router.replace(route);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static Id(): string {
|
|
26
|
+
return Router.GetStringParam('id');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static Slug(): string {
|
|
30
|
+
return Router.GetStringParam('slug');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static async Back() {
|
|
34
|
+
PHelp.Loading.Show();
|
|
35
|
+
router.go(-1);
|
|
36
|
+
PHelp.Loading.Hide();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static GetQid() {
|
|
40
|
+
return Router.GetStringQueryParam('qid');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static Route(): RouteLocationNormalizedLoaded {
|
|
44
|
+
return router.currentRoute.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static RouterPushBlank(path: string): void {
|
|
48
|
+
const route = router.resolve({ path: path });
|
|
49
|
+
window.open(route.href, '_blank');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static GetPath(): string {
|
|
53
|
+
const arr = Router.Route().path.split('/');
|
|
54
|
+
return arr[arr.length - 1];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static async ToAdmin(path?: string): Promise<void> {
|
|
58
|
+
if (!path) {
|
|
59
|
+
await router.push(`/admin`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let safePath = path;
|
|
63
|
+
if (safePath[0] === '/') {
|
|
64
|
+
safePath = path.substring(1);
|
|
65
|
+
}
|
|
66
|
+
await Router.To(`/admin/${safePath}`);
|
|
67
|
+
}
|
|
68
|
+
static GetStringQueryParam(param: string): string {
|
|
69
|
+
return String(Router.Route().query[param]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static GetNumberQueryParam(param: string): number {
|
|
73
|
+
return Number(Router.Route().query[param] ?? 0);
|
|
74
|
+
}
|
|
75
|
+
static GetStringParam(param: string): string {
|
|
76
|
+
return Router.Route().params[param] as string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static Resolve(link: string): RouteLocation {
|
|
80
|
+
return router.resolve(link);
|
|
81
|
+
}
|
|
82
|
+
static GetRouter() {
|
|
83
|
+
return router;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NavigationGuardNext } from 'vue-router';
|
|
2
|
+
|
|
3
|
+
export default abstract class RouterGuard {
|
|
4
|
+
static async Auth(next?: NavigationGuardNext): Promise<void> {
|
|
5
|
+
if (next) {
|
|
6
|
+
next();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static Dev(): void {
|
|
11
|
+
// if (!UserService.isAdmin()) {
|
|
12
|
+
// router.push('/dev');
|
|
13
|
+
// }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import Time, { TimelineMinutes, TimelineSteps } from "@/services/Time";
|
|
2
|
+
|
|
3
|
+
import Arrays from "./Arrays";
|
|
4
|
+
import IWithId from "../interfaces/IWithId";
|
|
5
|
+
interface IWithTimePeriod {
|
|
6
|
+
startTime: string;
|
|
7
|
+
endTime: string;
|
|
8
|
+
}
|
|
9
|
+
export default class Scheduler {
|
|
10
|
+
startHour = 9;
|
|
11
|
+
startHM = `${this.startHour}:00`;
|
|
12
|
+
endHour = 19;
|
|
13
|
+
endHM = `${this.endHour}:00`;
|
|
14
|
+
|
|
15
|
+
timelinePxHeight = 50;
|
|
16
|
+
|
|
17
|
+
timelineStep: TimelineSteps = TimelineSteps.FiveMinutes;
|
|
18
|
+
|
|
19
|
+
timelines: string[] = TimelineMinutes[TimelineSteps.FiveMinutes];
|
|
20
|
+
|
|
21
|
+
periodIsCorrect(t1: string, t2: string): boolean {
|
|
22
|
+
return Time.GtOrEq(t1, this.startHM) && Time.GtOrEq(this.endHM, t2);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setTimelineStep(step: TimelineSteps): void {
|
|
26
|
+
this.timelineStep = step;
|
|
27
|
+
this.setTimelines();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setTimelines(): void {
|
|
31
|
+
this.timelines = TimelineMinutes[this.timelineStep];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getScheduleHeight() {
|
|
35
|
+
return this.getHourHeight() * this.getHoursArr().length;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getHourHeight() {
|
|
39
|
+
return this.timelinePxHeight * this.timelines.length;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getHoursArr(): number[] {
|
|
43
|
+
return Arrays.GenerateNumsRange(this.startHour, this.endHour);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
timeIsFree(
|
|
47
|
+
t1: string,
|
|
48
|
+
t2: string,
|
|
49
|
+
movedObjectId: string,
|
|
50
|
+
scheduleItems: (IWithTimePeriod & IWithId)[]
|
|
51
|
+
): boolean {
|
|
52
|
+
return scheduleItems
|
|
53
|
+
.filter((i: IWithId) => i.id !== movedObjectId)
|
|
54
|
+
.every(
|
|
55
|
+
(i: IWithTimePeriod) =>
|
|
56
|
+
!Time.PeriodsIntersects(t1, t2, i.startTime, i.endTime)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
sortByStartTime(scheduleItems: IWithTimePeriod[]): void {
|
|
61
|
+
scheduleItems.sort(
|
|
62
|
+
(s1: IWithTimePeriod, s2: IWithTimePeriod) =>
|
|
63
|
+
Time.HMtoM(s1.startTime) - Time.HMtoM(s2.startTime)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// height 58 - margin
|
|
2
|
+
const HeaderHeight = -58 - 10;
|
|
3
|
+
|
|
4
|
+
export default function scroll(query?: string, yOffset?: number): void {
|
|
5
|
+
if (!query) {
|
|
6
|
+
document.body.scrollTo({ top: 0, behavior: 'smooth' });
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const el = document.querySelector(query);
|
|
10
|
+
const offset = yOffset ?? HeaderHeight;
|
|
11
|
+
let y = 0;
|
|
12
|
+
if (el) {
|
|
13
|
+
const elRect = el.getBoundingClientRect();
|
|
14
|
+
y = elRect.top + offset + document.body.scrollTop;
|
|
15
|
+
}
|
|
16
|
+
if (y) {
|
|
17
|
+
document.body.scrollTo({ top: y, behavior: 'smooth' });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import createSortModels from "@/services/CreateSortModels";
|
|
2
|
+
import { SortModelBuildersLib } from "@/services/interfaces/Sort";
|
|
3
|
+
|
|
4
|
+
import SortModel from "../classes/SortModel";
|
|
5
|
+
|
|
6
|
+
class SortListC {
|
|
7
|
+
private list: SortModel[] = [];
|
|
8
|
+
private defaultSortModel: SortModel | undefined;
|
|
9
|
+
changeFlag = false;
|
|
10
|
+
|
|
11
|
+
Set(sorts?: SortModelBuildersLib | SortModel[]): void {
|
|
12
|
+
this.Reset();
|
|
13
|
+
if (!sorts) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(sorts)) {
|
|
17
|
+
this.list = sorts;
|
|
18
|
+
} else {
|
|
19
|
+
this.list = createSortModels(sorts);
|
|
20
|
+
}
|
|
21
|
+
this.SetDefault();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
SetDefault() {
|
|
25
|
+
this.defaultSortModel =
|
|
26
|
+
this.list.find((s: SortModel) => s.default) ?? this.list[0];
|
|
27
|
+
this.changeFlag = !this.changeFlag;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Get(): SortModel[] {
|
|
31
|
+
return this.list;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
GetDefault(): SortModel | undefined {
|
|
35
|
+
return this.defaultSortModel;
|
|
36
|
+
}
|
|
37
|
+
Reset(): void {
|
|
38
|
+
this.list = [];
|
|
39
|
+
this.defaultSortModel = undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SortList = new SortListC();
|
|
44
|
+
export default SortList;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
describe('Strings', () => {
|
|
2
|
+
test('CapitalizeFirstLetter', () => {
|
|
3
|
+
const str = 'str';
|
|
4
|
+
const res = Strings.Capitalize(str);
|
|
5
|
+
expect(res).toEqual('Str');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test('Capitalize empty string return empty string', () => {
|
|
9
|
+
const res = Strings.Capitalize('');
|
|
10
|
+
expect(res).toEqual('');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('JoinSnake', () => {
|
|
14
|
+
const res = Strings.JoinSnake('a', 'b');
|
|
15
|
+
expect(res).toEqual('a_b');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('ToCamelCase', () => {
|
|
19
|
+
const words: Record<string, string> = { a_b: 'aB', 'a b': 'aB', 'a-b': 'aB', а_я: 'аЯ', CAP: 'cap', АЯ: 'ая', 'а-Я': 'аЯ' };
|
|
20
|
+
|
|
21
|
+
for (const key in words) {
|
|
22
|
+
describe(`When given ${key}`, () => {
|
|
23
|
+
test(`Then given ${words[key]}`, () => {
|
|
24
|
+
const res = Strings.ToCamelCase(key);
|
|
25
|
+
expect(res).toEqual(words[key]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|