@tager/admin-banners 0.3.5 → 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.
- package/dist/constants/paths.d.ts +5 -10
- package/dist/constants/routes.d.ts +4 -4
- package/dist/dev/App.vue.d.ts +5 -0
- package/dist/dev/config.d.ts +2 -0
- package/dist/dev/env.d.ts +1 -0
- package/dist/dev/main.d.ts +3 -0
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/useFetchBanner.d.ts +7 -8
- package/dist/hooks/useFetchBanners.d.ts +3 -6
- package/dist/hooks/useFetchZoneFields.d.ts +7 -0
- package/dist/hooks/useFetchZones.d.ts +3 -6
- package/dist/index.mjs +993 -0
- package/dist/locales/apply.d.ts +1 -0
- package/dist/locales/en.d.ts +41 -40
- package/dist/locales/ru.d.ts +2 -3
- package/dist/main.d.ts +3 -4
- package/dist/services/requests.d.ts +25 -24
- package/dist/style.css +1 -0
- package/dist/typings/banners.d.ts +47 -40
- package/dist/typings/common.d.ts +1 -1
- package/dist/typings/model.d.ts +104 -104
- package/dist/typings/zones.d.ts +9 -5
- package/dist/utils/common.d.ts +2 -2
- package/dist/utils/paths.d.ts +5 -0
- package/dist/views/Banners/BannerForm/BannerForm.helpers.d.ts +5 -5
- package/dist/views/Banners/BannerForm/BannerForm.vue.d.ts +2694 -81
- package/dist/views/Banners/BannerForm/index.d.ts +1 -1
- package/dist/views/Banners/BannerList/BannerList.helpers.d.ts +6 -6
- package/dist/views/Banners/BannerList/BannerList.vue.d.ts +25 -55
- package/dist/views/Banners/BannerList/hooks/index.d.ts +1 -1
- package/dist/views/Banners/BannerList/hooks/useAdvancedSearch.d.ts +23 -21
- package/dist/views/Banners/BannerList/index.d.ts +1 -1
- package/dist/views/Zones/ZoneList/ZoneList.helpers.d.ts +5 -5
- package/dist/views/Zones/ZoneList/ZoneList.vue.d.ts +11 -28
- package/dist/views/Zones/ZoneList/index.d.ts +1 -1
- package/package.json +51 -49
- package/src/constants/paths.ts +1 -15
- package/src/constants/routes.ts +7 -7
- package/src/dev/App.vue +46 -0
- package/src/dev/config.ts +23 -0
- package/src/dev/env.ts +17 -0
- package/src/dev/main.ts +47 -0
- package/src/hooks/useFetchBanner.ts +3 -6
- package/src/hooks/useFetchBanners.ts +2 -5
- package/src/hooks/useFetchZoneFields.ts +39 -0
- package/src/hooks/useFetchZones.ts +2 -5
- package/src/locales/apply.ts +9 -0
- package/src/locales/en.ts +2 -1
- package/src/locales/ru.ts +40 -41
- package/src/main.ts +3 -8
- package/src/services/requests.ts +7 -1
- package/src/typings/banners.ts +14 -2
- package/src/typings/zones.ts +6 -0
- package/src/utils/paths.ts +15 -0
- package/src/views/Banners/BannerForm/BannerForm.helpers.ts +10 -0
- package/src/views/Banners/BannerForm/BannerForm.vue +168 -83
- package/src/views/Banners/BannerList/BannerList.helpers.ts +11 -4
- package/src/views/Banners/BannerList/BannerList.vue +60 -47
- package/src/views/Banners/BannerList/hooks/useAdvancedSearch.ts +14 -14
- package/src/views/Zones/ZoneList/ZoneList.helpers.ts +1 -1
- package/src/views/Zones/ZoneList/ZoneList.vue +18 -19
- package/CHANGELOG.md +0 -13
- package/dist/constants/menu.d.ts +0 -5
- package/dist/dev.d.ts +0 -1
- package/dist/index.esm.js +0 -3621
- package/dist/index.umd.js +0 -3640
- package/dist/router/index.d.ts +0 -4
- package/src/constants/menu.ts +0 -26
- package/src/dev.ts +0 -34
- package/src/router/index.ts +0 -38
- package/src/typings/sfc.d.ts +0 -12
- package/src/typings/shims-tsx.d.ts +0 -13
- package/src/typings/shims-vue.d.ts +0 -11
- package/src/views/App.vue +0 -22
- package/src/views/Home.vue +0 -37
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { computed, onMounted, Ref, SetupContext, watch } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { Nullable, ResourceRef, useResource } from '@tager/admin-services';
|
|
4
|
+
|
|
5
|
+
import { getZoneFields } from '../services/requests';
|
|
6
|
+
import { ZoneFields } from '../typings/zones';
|
|
7
|
+
import { BannerFormValues } from '../typings/banners';
|
|
8
|
+
|
|
9
|
+
export function useFetchZoneFields({
|
|
10
|
+
values,
|
|
11
|
+
}: {
|
|
12
|
+
values: Ref<BannerFormValues>;
|
|
13
|
+
}): ResourceRef<Nullable<ZoneFields>> {
|
|
14
|
+
const zoneId = computed(() => values.value.bannerZone?.value ?? '');
|
|
15
|
+
|
|
16
|
+
const [fetchZoneFields, resource] = useResource<Nullable<ZoneFields>>({
|
|
17
|
+
fetchResource: () => getZoneFields(zoneId.value),
|
|
18
|
+
initialValue: null,
|
|
19
|
+
resourceName: 'Zone Fields',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
onMounted(() => {
|
|
23
|
+
if (!zoneId.value) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fetchZoneFields();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
watch(zoneId, () => {
|
|
31
|
+
if (!zoneId.value) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fetchZoneFields();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return resource;
|
|
39
|
+
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { onMounted
|
|
1
|
+
import { onMounted } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { ResourceRef, useResource } from '@tager/admin-services';
|
|
4
4
|
|
|
5
5
|
import { getZones } from '../services/requests';
|
|
6
6
|
import { Zone } from '../typings/zones';
|
|
7
7
|
|
|
8
|
-
export function useFetchZones(
|
|
9
|
-
context: SetupContext;
|
|
10
|
-
}): ResourceRef<Zone[]> {
|
|
8
|
+
export function useFetchZones(): ResourceRef<Zone[]> {
|
|
11
9
|
const [fetchZones, resource] = useResource<Zone[]>({
|
|
12
10
|
fetchResource: getZones,
|
|
13
11
|
initialValue: [],
|
|
14
|
-
context: params.context,
|
|
15
12
|
resourceName: 'Banner zones',
|
|
16
13
|
});
|
|
17
14
|
|
package/src/locales/en.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const EN = {
|
|
1
|
+
export const EN = {
|
|
2
2
|
home: 'Home',
|
|
3
3
|
zone: 'Banner zone',
|
|
4
4
|
zones: 'Banner zones',
|
|
@@ -24,6 +24,7 @@ const EN = {
|
|
|
24
24
|
actions: 'actions',
|
|
25
25
|
date: 'Date',
|
|
26
26
|
name: 'Name',
|
|
27
|
+
priority: 'Priority',
|
|
27
28
|
|
|
28
29
|
success: 'Success',
|
|
29
30
|
error: 'Error',
|
package/src/locales/ru.ts
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
import EN from './en';
|
|
1
|
+
import {EN} from './en';
|
|
2
2
|
|
|
3
|
-
const RU: typeof EN = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
export const RU: typeof EN = {
|
|
4
|
+
home: 'Главная',
|
|
5
|
+
zone: 'Баннерная зона',
|
|
6
|
+
zones: 'Баннерные зоны',
|
|
7
|
+
banners: 'Баннеры',
|
|
8
|
+
bannerForm: 'Форма баннера',
|
|
9
|
+
createBanner: 'Добавить баннер',
|
|
10
|
+
updateBanner: 'Редактировать баннер',
|
|
11
|
+
link: 'Ссылка',
|
|
12
|
+
image: 'Картинка',
|
|
13
|
+
openNewTab: 'Открывать в новой вкладке',
|
|
14
|
+
period: 'Срок действия',
|
|
15
|
+
from: 'От',
|
|
16
|
+
to: 'До',
|
|
17
|
+
disabled: 'Выключен',
|
|
18
|
+
comment: 'Комментарий',
|
|
19
|
+
status: 'Статус',
|
|
20
|
+
bannerZoneIsDeleted: 'Баннерная зона удалена',
|
|
21
|
+
newTab: 'Новая вкладка',
|
|
22
|
+
yes: 'Да',
|
|
23
|
+
no: 'Нет',
|
|
24
|
+
edit: 'Редактировать',
|
|
25
|
+
remove: 'Удалить',
|
|
26
|
+
actions: 'Действия',
|
|
27
|
+
date: 'Дата',
|
|
28
|
+
name: 'Название',
|
|
29
|
+
priority: 'Приоритет',
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
success: 'Успех',
|
|
32
|
+
error: 'Ошибка',
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
statuses: {
|
|
35
|
+
waiting: 'В ожидании',
|
|
36
|
+
archived: 'Архивный',
|
|
37
|
+
active: 'Активный',
|
|
38
|
+
disabled: 'Отключен',
|
|
39
|
+
},
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
bannerWasSuccessfullyCreated: 'Баннер успешно создан',
|
|
42
|
+
bannerWasSuccessfullyUpdated: 'Баннер успешно обновлен',
|
|
43
|
+
bannerCreationWasFailed: 'Не удалось создать баннер',
|
|
44
|
+
bannerUpdateWasFailed: 'Не удалось обновить баннер',
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
-
export default RU;
|
package/src/main.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyTranslations } from './locales/apply';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import RU from './locales/ru';
|
|
5
|
-
|
|
6
|
-
i18n.addTranslations('en', 'banners', EN);
|
|
7
|
-
i18n.addTranslations('ru', 'banners', RU);
|
|
3
|
+
applyTranslations();
|
|
8
4
|
|
|
9
5
|
export * from './constants/routes';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './constants/paths';
|
|
6
|
+
export * from './utils/paths';
|
|
12
7
|
export * from './services/requests';
|
package/src/services/requests.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { request, ResponseBody } from '@tager/admin-services';
|
|
2
2
|
|
|
3
|
-
import { Zone } from '../typings/zones';
|
|
3
|
+
import { Zone, ZoneFields } from '../typings/zones';
|
|
4
4
|
import { Banner, BannerPayload } from '../typings/banners';
|
|
5
5
|
|
|
6
6
|
/** Zones **/
|
|
@@ -13,6 +13,12 @@ export function getZones(params?: {
|
|
|
13
13
|
return request.get({ path: '/admin/adv/zones', params });
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export function getZoneFields(
|
|
17
|
+
zoneId: string
|
|
18
|
+
): Promise<ResponseBody<ZoneFields>> {
|
|
19
|
+
return request.get({ path: `/admin/adv/zones/${zoneId}` });
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
/** Banners **/
|
|
17
23
|
|
|
18
24
|
export function getBanners(params?: {
|
package/src/typings/banners.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { FileType, Nullable } from '@tager/admin-services';
|
|
2
2
|
import { OptionType, SingleFileInputValueType } from '@tager/admin-ui';
|
|
3
|
+
import {
|
|
4
|
+
FieldShortType,
|
|
5
|
+
FieldUnion,
|
|
6
|
+
IncomingValueUnion,
|
|
7
|
+
OutgoingValueUnion,
|
|
8
|
+
} from '@tager/admin-dynamic-field';
|
|
3
9
|
|
|
4
10
|
export enum Status {
|
|
5
11
|
Waiting = 'WAITING',
|
|
@@ -11,6 +17,7 @@ export enum Status {
|
|
|
11
17
|
export interface Banner {
|
|
12
18
|
id: number;
|
|
13
19
|
status: Status;
|
|
20
|
+
priority: number;
|
|
14
21
|
link: Nullable<string>;
|
|
15
22
|
image: Nullable<FileType>;
|
|
16
23
|
bannerZone: Nullable<string>;
|
|
@@ -19,26 +26,31 @@ export interface Banner {
|
|
|
19
26
|
dateEnd: Nullable<string>;
|
|
20
27
|
disabled: boolean;
|
|
21
28
|
comment: Nullable<string>;
|
|
29
|
+
fields: FieldShortType<IncomingValueUnion>[];
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
export interface BannerFormValues {
|
|
25
33
|
link: Nullable<string>;
|
|
26
34
|
image: Nullable<SingleFileInputValueType>;
|
|
27
35
|
bannerZone: Nullable<OptionType>;
|
|
36
|
+
priority: string;
|
|
28
37
|
openNewTab: boolean;
|
|
29
38
|
dateStart: string;
|
|
30
39
|
dateEnd: string;
|
|
31
40
|
disabled: boolean;
|
|
32
41
|
comment: string;
|
|
42
|
+
fields: FieldUnion[];
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
export interface BannerPayload {
|
|
36
46
|
link: Nullable<string>;
|
|
37
47
|
image: Nullable<string>;
|
|
48
|
+
priority: number;
|
|
38
49
|
bannerZone: string;
|
|
39
50
|
openNewTab: boolean;
|
|
40
|
-
dateStart: string
|
|
41
|
-
dateEnd: string
|
|
51
|
+
dateStart: Nullable<string>;
|
|
52
|
+
dateEnd: Nullable<string>;
|
|
42
53
|
disabled: boolean;
|
|
43
54
|
comment: string;
|
|
55
|
+
fields: FieldShortType<OutgoingValueUnion>[];
|
|
44
56
|
}
|
package/src/typings/zones.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {compile} from 'path-to-regexp';
|
|
2
|
+
|
|
3
|
+
import {BANNERS_ROUTE_PATHS} from '../constants/paths';
|
|
4
|
+
|
|
5
|
+
export function getBannersZoneListUrl() {
|
|
6
|
+
return BANNERS_ROUTE_PATHS.ZONE_LIST;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getBannersBannerListUrl() {
|
|
10
|
+
return BANNERS_ROUTE_PATHS.BANNER_LIST;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getBannersBannerFormUrl(params: { bannerId: number | string }) {
|
|
14
|
+
return compile(BANNERS_ROUTE_PATHS.BANNER_FORM)(params);
|
|
15
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OptionType } from '@tager/admin-ui';
|
|
2
2
|
import { createId, Nullable } from '@tager/admin-services';
|
|
3
|
+
import { universalFieldUtils } from '@tager/admin-dynamic-field';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
Banner,
|
|
@@ -16,6 +17,7 @@ export function convertBannerToFormValues(
|
|
|
16
17
|
);
|
|
17
18
|
|
|
18
19
|
return {
|
|
20
|
+
priority: String(banner?.priority ?? 1),
|
|
19
21
|
link: banner?.link ?? '',
|
|
20
22
|
image: banner?.image ? { id: createId(), file: banner.image } : null,
|
|
21
23
|
bannerZone: foundZone ?? null,
|
|
@@ -24,6 +26,7 @@ export function convertBannerToFormValues(
|
|
|
24
26
|
dateEnd: banner?.dateEnd ?? '',
|
|
25
27
|
disabled: banner?.disabled ?? false,
|
|
26
28
|
comment: banner?.comment ?? '',
|
|
29
|
+
fields: [],
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -32,7 +35,14 @@ export function convertBannerFormValuesToPayload(
|
|
|
32
35
|
): BannerPayload {
|
|
33
36
|
return {
|
|
34
37
|
...values,
|
|
38
|
+
priority: values.priority ? Number(values.priority) : 1,
|
|
39
|
+
dateStart: values.dateStart ? values.dateStart : null,
|
|
40
|
+
dateEnd: values.dateEnd ? values.dateEnd : null,
|
|
35
41
|
image: values.image?.file.id ?? null,
|
|
36
42
|
bannerZone: values.bannerZone?.value ?? '',
|
|
43
|
+
fields: values.fields.map((field) => ({
|
|
44
|
+
name: field.config.name,
|
|
45
|
+
value: universalFieldUtils.getOutgoingValue(field),
|
|
46
|
+
})),
|
|
37
47
|
};
|
|
38
48
|
}
|