@tager/admin-banners 0.3.1 → 0.3.5

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/index.esm.js CHANGED
@@ -28,6 +28,7 @@ const EN = {
28
28
  remove: 'Remove',
29
29
  actions: 'actions',
30
30
  date: 'Date',
31
+ name: 'Name',
31
32
  success: 'Success',
32
33
  error: 'Error',
33
34
  statuses: {
@@ -67,6 +68,7 @@ const RU = {
67
68
  remove: 'Удалить',
68
69
  actions: 'Действия',
69
70
  date: 'Дата',
71
+ name: 'Название',
70
72
  success: 'Успех',
71
73
  error: 'Ошибка',
72
74
  statuses: {
@@ -102,7 +104,7 @@ function updateBanner(bannerId, payload) {
102
104
  });
103
105
  }
104
106
  function deleteBanner(bannerId) {
105
- return request.delete({ path: `/admin/banners/${bannerId}` });
107
+ return request.delete({ path: `/admin/adv/${bannerId}` });
106
108
  }
107
109
  function getBannerCount() {
108
110
  return request.get({ path: '/admin/adv/count' });
@@ -2748,12 +2750,13 @@ function getStatus(type, t) {
2748
2750
  return '';
2749
2751
  }
2750
2752
  }
2751
- function getColumnDefs$1(t) {
2753
+ function getColumnDefs$1(zoneList, t) {
2752
2754
  return [
2753
2755
  {
2754
2756
  id: 0,
2755
2757
  name: '#',
2756
2758
  field: 'id',
2759
+ format: ({ rowIndex }) => String(rowIndex + 1),
2757
2760
  style: { width: '50px', textAlign: 'center' },
2758
2761
  headStyle: { width: '50px', textAlign: 'center' },
2759
2762
  },
@@ -2761,7 +2764,12 @@ function getColumnDefs$1(t) {
2761
2764
  id: 1,
2762
2765
  name: t('banners:zone'),
2763
2766
  field: 'bannerZone',
2764
- format: ({ row }) => row.bannerZone ? row.bannerZone : t('banners:bannerZoneIsDeleted'),
2767
+ format: ({ row }) => {
2768
+ const foundBannerZone = zoneList.find((zone) => zone.id === row.bannerZone);
2769
+ return foundBannerZone
2770
+ ? foundBannerZone.name
2771
+ : t('banners:bannerZoneIsDeleted');
2772
+ },
2765
2773
  },
2766
2774
  {
2767
2775
  id: 2,
@@ -2803,6 +2811,9 @@ function getColumnDefs$1(t) {
2803
2811
  ],
2804
2812
  });
2805
2813
  },
2814
+ options: {
2815
+ shouldOpenNewTab: true,
2816
+ },
2806
2817
  },
2807
2818
  {
2808
2819
  id: 6,
@@ -2861,7 +2872,7 @@ function useAdvancedSearch({ context, t, zoneList }) {
2861
2872
  /** Params **/
2862
2873
  const filterParams = computed(() => getFilterParams({
2863
2874
  [FilterTypes.Zone]: zoneFilter.value.map(({ value }) => value),
2864
- [FilterTypes.Date]: dateFilter.value,
2875
+ [FilterTypes.Date]: dateFilter.value || [],
2865
2876
  [FilterTypes.Status]: statusFilter.value.map(({ value }) => value),
2866
2877
  }));
2867
2878
  /** Tag removal handler **/
@@ -2927,7 +2938,7 @@ var script$1 = defineComponent({
2927
2938
  const isBusy = (bannerId) => {
2928
2939
  return isDeleting(bannerId) || isBannersLoading.value;
2929
2940
  };
2930
- const columnDefs = computed(() => getColumnDefs$1(context.root.$t));
2941
+ const columnDefs = computed(() => getColumnDefs$1(zoneList.value, context.root.$t));
2931
2942
  const isRowDataLoading = computed(() => isBannersLoading.value || isZonesLoading.value);
2932
2943
  return {
2933
2944
  columnDefs,
@@ -3178,7 +3189,7 @@ __vue_render__$1._withStripped = true;
3178
3189
  /* style */
3179
3190
  const __vue_inject_styles__$1 = function (inject) {
3180
3191
  if (!inject) return
3181
- inject("data-v-92c7e846_0", { source: ".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerList/BannerList.vue","BannerList.vue"],"names":[],"mappings":"AA0NA;EACA,aAAA;EACA,eAAA;ACzNA;AD2NA;EACA,gBAAA;ACzNA;AD4NA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;AC1NA;;AAEA,yCAAyC","file":"BannerList.vue","sourcesContent":["<template>\n <page\n :title=\"$t('banners:banners')\"\n :header-buttons=\"[\n {\n text: $t('banners:createBanner'),\n href: getBannersBannerFormUrl({ bannerId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n data-table=\"banners\"\n :use-search=\"true\"\n :use-pagination=\"true\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"zoneFilter\"\n :options=\"zonesOptionList\"\n name=\"zoneFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:zone')\"\n class=\"filter\"\n />\n\n <form-field\n v-model=\"dateFilter\"\n :label=\"$t('banners:date')\"\n name=\"dateFilter\"\n type=\"date\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-model=\"statusFilter\"\n :options=\"statusesOptionList\"\n name=\"statusFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:status')\"\n class=\"filter\"\n />\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBannersBannerFormUrl({ bannerId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n SetupContext,\n watch,\n} from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport { useResourceDelete } from '@tager/admin-services';\n\nimport { deleteBanner, getBanners } from '../../../services/requests';\nimport { Banner } from '../../../typings/banners';\nimport { getBannersBannerFormUrl } from '../../../constants/paths';\nimport { useFetchZones } from '../../../hooks';\n\nimport { getColumnDefs } from './BannerList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'BannerList',\n setup(props, context: SetupContext) {\n const { t } = useTranslation(context);\n const { loading: isZonesLoading, data: zoneList } = useFetchZones({\n context,\n });\n\n const {\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n t,\n zoneList,\n });\n\n const {\n fetchEntityList: fetchBanners,\n isLoading: isBannersLoading,\n rowData,\n errorMessage,\n handleChange,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<Banner>({\n fetchEntityList: (params) =>\n getBanners({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Banners',\n });\n\n watch(filterParams, () => {\n if (isZonesLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchBanners();\n }\n });\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBanner,\n resourceName: 'Banner',\n onSuccess: fetchBanners,\n context,\n });\n\n const isBusy = (bannerId: number): boolean => {\n return isDeleting(bannerId) || isBannersLoading.value;\n };\n\n const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>\n getColumnDefs(context.root.$t)\n );\n\n const isRowDataLoading = computed<boolean>(\n () => isBannersLoading.value || isZonesLoading.value\n );\n\n return {\n columnDefs,\n isRowDataLoading,\n rowData,\n errorMessage,\n handleChange,\n getBannersBannerFormUrl,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n isBusy,\n handleResourceDelete,\n\n // Advanced search\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n tags,\n tagRemovalHandler,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */"]}, media: undefined });
3192
+ inject("data-v-23927d9c_0", { source: ".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerList/BannerList.vue","BannerList.vue"],"names":[],"mappings":"AA0NA;EACA,aAAA;EACA,eAAA;ACzNA;AD2NA;EACA,gBAAA;ACzNA;AD4NA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;AC1NA;;AAEA,yCAAyC","file":"BannerList.vue","sourcesContent":["<template>\n <page\n :title=\"$t('banners:banners')\"\n :header-buttons=\"[\n {\n text: $t('banners:createBanner'),\n href: getBannersBannerFormUrl({ bannerId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n data-table=\"banners\"\n :use-search=\"true\"\n :use-pagination=\"true\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"zoneFilter\"\n :options=\"zonesOptionList\"\n name=\"zoneFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:zone')\"\n class=\"filter\"\n />\n\n <form-field\n v-model=\"dateFilter\"\n :label=\"$t('banners:date')\"\n name=\"dateFilter\"\n type=\"date\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-model=\"statusFilter\"\n :options=\"statusesOptionList\"\n name=\"statusFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:status')\"\n class=\"filter\"\n />\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBannersBannerFormUrl({ bannerId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n SetupContext,\n watch,\n} from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport { useResourceDelete } from '@tager/admin-services';\n\nimport { deleteBanner, getBanners } from '../../../services/requests';\nimport { Banner } from '../../../typings/banners';\nimport { getBannersBannerFormUrl } from '../../../constants/paths';\nimport { useFetchZones } from '../../../hooks';\n\nimport { getColumnDefs } from './BannerList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'BannerList',\n setup(props, context: SetupContext) {\n const { t } = useTranslation(context);\n const { loading: isZonesLoading, data: zoneList } = useFetchZones({\n context,\n });\n\n const {\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n t,\n zoneList,\n });\n\n const {\n fetchEntityList: fetchBanners,\n isLoading: isBannersLoading,\n rowData,\n errorMessage,\n handleChange,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<Banner>({\n fetchEntityList: (params) =>\n getBanners({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Banners',\n });\n\n watch(filterParams, () => {\n if (isZonesLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchBanners();\n }\n });\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBanner,\n resourceName: 'Banner',\n onSuccess: fetchBanners,\n context,\n });\n\n const isBusy = (bannerId: number): boolean => {\n return isDeleting(bannerId) || isBannersLoading.value;\n };\n\n const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>\n getColumnDefs(zoneList.value, context.root.$t)\n );\n\n const isRowDataLoading = computed<boolean>(\n () => isBannersLoading.value || isZonesLoading.value\n );\n\n return {\n columnDefs,\n isRowDataLoading,\n rowData,\n errorMessage,\n handleChange,\n getBannersBannerFormUrl,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n isBusy,\n handleResourceDelete,\n\n // Advanced search\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n tags,\n tagRemovalHandler,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */"]}, media: undefined });
3182
3193
 
3183
3194
  };
3184
3195
  /* scoped */
@@ -3604,7 +3615,7 @@ function getBannersMenuItem(params) {
3604
3615
  };
3605
3616
  }
3606
3617
 
3607
- i18n.addTranslations('en', 'blog', EN);
3608
- i18n.addTranslations('ru', 'blog', RU);
3618
+ i18n.addTranslations('en', 'banners', EN);
3619
+ i18n.addTranslations('ru', 'banners', RU);
3609
3620
 
3610
3621
  export { BANNERS_BANNER_FORM_ROUTE, BANNERS_BANNER_LIST_ROUTE, BANNERS_ROUTE_PATHS, BANNERS_ZONE_LIST_ROUTE, createBanner, deleteBanner, getBanner, getBannerCount, getBanners, getBannersBannerFormUrl, getBannersBannerListUrl, getBannersMenuItem, getBannersZoneListUrl, getZones, updateBanner };
package/dist/index.umd.js CHANGED
@@ -29,6 +29,7 @@
29
29
  remove: 'Remove',
30
30
  actions: 'actions',
31
31
  date: 'Date',
32
+ name: 'Name',
32
33
  success: 'Success',
33
34
  error: 'Error',
34
35
  statuses: {
@@ -68,6 +69,7 @@
68
69
  remove: 'Удалить',
69
70
  actions: 'Действия',
70
71
  date: 'Дата',
72
+ name: 'Название',
71
73
  success: 'Успех',
72
74
  error: 'Ошибка',
73
75
  statuses: {
@@ -103,7 +105,7 @@
103
105
  });
104
106
  }
105
107
  function deleteBanner(bannerId) {
106
- return adminServices.request.delete({ path: `/admin/banners/${bannerId}` });
108
+ return adminServices.request.delete({ path: `/admin/adv/${bannerId}` });
107
109
  }
108
110
  function getBannerCount() {
109
111
  return adminServices.request.get({ path: '/admin/adv/count' });
@@ -2749,12 +2751,13 @@
2749
2751
  return '';
2750
2752
  }
2751
2753
  }
2752
- function getColumnDefs$1(t) {
2754
+ function getColumnDefs$1(zoneList, t) {
2753
2755
  return [
2754
2756
  {
2755
2757
  id: 0,
2756
2758
  name: '#',
2757
2759
  field: 'id',
2760
+ format: ({ rowIndex }) => String(rowIndex + 1),
2758
2761
  style: { width: '50px', textAlign: 'center' },
2759
2762
  headStyle: { width: '50px', textAlign: 'center' },
2760
2763
  },
@@ -2762,7 +2765,12 @@
2762
2765
  id: 1,
2763
2766
  name: t('banners:zone'),
2764
2767
  field: 'bannerZone',
2765
- format: ({ row }) => row.bannerZone ? row.bannerZone : t('banners:bannerZoneIsDeleted'),
2768
+ format: ({ row }) => {
2769
+ const foundBannerZone = zoneList.find((zone) => zone.id === row.bannerZone);
2770
+ return foundBannerZone
2771
+ ? foundBannerZone.name
2772
+ : t('banners:bannerZoneIsDeleted');
2773
+ },
2766
2774
  },
2767
2775
  {
2768
2776
  id: 2,
@@ -2804,6 +2812,9 @@
2804
2812
  ],
2805
2813
  });
2806
2814
  },
2815
+ options: {
2816
+ shouldOpenNewTab: true,
2817
+ },
2807
2818
  },
2808
2819
  {
2809
2820
  id: 6,
@@ -2862,7 +2873,7 @@
2862
2873
  /** Params **/
2863
2874
  const filterParams = compositionApi.computed(() => adminUi.getFilterParams({
2864
2875
  [FilterTypes.Zone]: zoneFilter.value.map(({ value }) => value),
2865
- [FilterTypes.Date]: dateFilter.value,
2876
+ [FilterTypes.Date]: dateFilter.value || [],
2866
2877
  [FilterTypes.Status]: statusFilter.value.map(({ value }) => value),
2867
2878
  }));
2868
2879
  /** Tag removal handler **/
@@ -2928,7 +2939,7 @@
2928
2939
  const isBusy = (bannerId) => {
2929
2940
  return isDeleting(bannerId) || isBannersLoading.value;
2930
2941
  };
2931
- const columnDefs = compositionApi.computed(() => getColumnDefs$1(context.root.$t));
2942
+ const columnDefs = compositionApi.computed(() => getColumnDefs$1(zoneList.value, context.root.$t));
2932
2943
  const isRowDataLoading = compositionApi.computed(() => isBannersLoading.value || isZonesLoading.value);
2933
2944
  return {
2934
2945
  columnDefs,
@@ -3179,7 +3190,7 @@
3179
3190
  /* style */
3180
3191
  const __vue_inject_styles__$1 = function (inject) {
3181
3192
  if (!inject) return
3182
- inject("data-v-92c7e846_0", { source: ".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerList/BannerList.vue","BannerList.vue"],"names":[],"mappings":"AA0NA;EACA,aAAA;EACA,eAAA;ACzNA;AD2NA;EACA,gBAAA;ACzNA;AD4NA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;AC1NA;;AAEA,yCAAyC","file":"BannerList.vue","sourcesContent":["<template>\n <page\n :title=\"$t('banners:banners')\"\n :header-buttons=\"[\n {\n text: $t('banners:createBanner'),\n href: getBannersBannerFormUrl({ bannerId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n data-table=\"banners\"\n :use-search=\"true\"\n :use-pagination=\"true\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"zoneFilter\"\n :options=\"zonesOptionList\"\n name=\"zoneFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:zone')\"\n class=\"filter\"\n />\n\n <form-field\n v-model=\"dateFilter\"\n :label=\"$t('banners:date')\"\n name=\"dateFilter\"\n type=\"date\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-model=\"statusFilter\"\n :options=\"statusesOptionList\"\n name=\"statusFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:status')\"\n class=\"filter\"\n />\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBannersBannerFormUrl({ bannerId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n SetupContext,\n watch,\n} from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport { useResourceDelete } from '@tager/admin-services';\n\nimport { deleteBanner, getBanners } from '../../../services/requests';\nimport { Banner } from '../../../typings/banners';\nimport { getBannersBannerFormUrl } from '../../../constants/paths';\nimport { useFetchZones } from '../../../hooks';\n\nimport { getColumnDefs } from './BannerList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'BannerList',\n setup(props, context: SetupContext) {\n const { t } = useTranslation(context);\n const { loading: isZonesLoading, data: zoneList } = useFetchZones({\n context,\n });\n\n const {\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n t,\n zoneList,\n });\n\n const {\n fetchEntityList: fetchBanners,\n isLoading: isBannersLoading,\n rowData,\n errorMessage,\n handleChange,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<Banner>({\n fetchEntityList: (params) =>\n getBanners({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Banners',\n });\n\n watch(filterParams, () => {\n if (isZonesLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchBanners();\n }\n });\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBanner,\n resourceName: 'Banner',\n onSuccess: fetchBanners,\n context,\n });\n\n const isBusy = (bannerId: number): boolean => {\n return isDeleting(bannerId) || isBannersLoading.value;\n };\n\n const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>\n getColumnDefs(context.root.$t)\n );\n\n const isRowDataLoading = computed<boolean>(\n () => isBannersLoading.value || isZonesLoading.value\n );\n\n return {\n columnDefs,\n isRowDataLoading,\n rowData,\n errorMessage,\n handleChange,\n getBannersBannerFormUrl,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n isBusy,\n handleResourceDelete,\n\n // Advanced search\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n tags,\n tagRemovalHandler,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */"]}, media: undefined });
3193
+ inject("data-v-23927d9c_0", { source: ".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerList/BannerList.vue","BannerList.vue"],"names":[],"mappings":"AA0NA;EACA,aAAA;EACA,eAAA;ACzNA;AD2NA;EACA,gBAAA;ACzNA;AD4NA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;AC1NA;;AAEA,yCAAyC","file":"BannerList.vue","sourcesContent":["<template>\n <page\n :title=\"$t('banners:banners')\"\n :header-buttons=\"[\n {\n text: $t('banners:createBanner'),\n href: getBannersBannerFormUrl({ bannerId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n data-table=\"banners\"\n :use-search=\"true\"\n :use-pagination=\"true\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"zoneFilter\"\n :options=\"zonesOptionList\"\n name=\"zoneFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:zone')\"\n class=\"filter\"\n />\n\n <form-field\n v-model=\"dateFilter\"\n :label=\"$t('banners:date')\"\n name=\"dateFilter\"\n type=\"date\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-model=\"statusFilter\"\n :options=\"statusesOptionList\"\n name=\"statusFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:status')\"\n class=\"filter\"\n />\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBannersBannerFormUrl({ bannerId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n SetupContext,\n watch,\n} from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport { useResourceDelete } from '@tager/admin-services';\n\nimport { deleteBanner, getBanners } from '../../../services/requests';\nimport { Banner } from '../../../typings/banners';\nimport { getBannersBannerFormUrl } from '../../../constants/paths';\nimport { useFetchZones } from '../../../hooks';\n\nimport { getColumnDefs } from './BannerList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'BannerList',\n setup(props, context: SetupContext) {\n const { t } = useTranslation(context);\n const { loading: isZonesLoading, data: zoneList } = useFetchZones({\n context,\n });\n\n const {\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n t,\n zoneList,\n });\n\n const {\n fetchEntityList: fetchBanners,\n isLoading: isBannersLoading,\n rowData,\n errorMessage,\n handleChange,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<Banner>({\n fetchEntityList: (params) =>\n getBanners({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Banners',\n });\n\n watch(filterParams, () => {\n if (isZonesLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchBanners();\n }\n });\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBanner,\n resourceName: 'Banner',\n onSuccess: fetchBanners,\n context,\n });\n\n const isBusy = (bannerId: number): boolean => {\n return isDeleting(bannerId) || isBannersLoading.value;\n };\n\n const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>\n getColumnDefs(zoneList.value, context.root.$t)\n );\n\n const isRowDataLoading = computed<boolean>(\n () => isBannersLoading.value || isZonesLoading.value\n );\n\n return {\n columnDefs,\n isRowDataLoading,\n rowData,\n errorMessage,\n handleChange,\n getBannersBannerFormUrl,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n isBusy,\n handleResourceDelete,\n\n // Advanced search\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n tags,\n tagRemovalHandler,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */"]}, media: undefined });
3183
3194
 
3184
3195
  };
3185
3196
  /* scoped */
@@ -3605,8 +3616,8 @@
3605
3616
  };
3606
3617
  }
3607
3618
 
3608
- adminServices.i18n.addTranslations('en', 'blog', EN);
3609
- adminServices.i18n.addTranslations('ru', 'blog', RU);
3619
+ adminServices.i18n.addTranslations('en', 'banners', EN);
3620
+ adminServices.i18n.addTranslations('ru', 'banners', RU);
3610
3621
 
3611
3622
  exports.BANNERS_BANNER_FORM_ROUTE = BANNERS_BANNER_FORM_ROUTE;
3612
3623
  exports.BANNERS_BANNER_LIST_ROUTE = BANNERS_BANNER_LIST_ROUTE;
@@ -23,6 +23,7 @@ declare const EN: {
23
23
  remove: string;
24
24
  actions: string;
25
25
  date: string;
26
+ name: string;
26
27
  success: string;
27
28
  error: string;
28
29
  statuses: {
@@ -1,5 +1,6 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { ColumnDefinition } from '@tager/admin-ui';
3
3
  import { Banner, Status } from '../../../typings/banners';
4
+ import { Zone } from '../../../typings/zones';
4
5
  export declare function getStatus(type: Status, t: TFunction): string;
5
- export declare function getColumnDefs(t: TFunction): ColumnDefinition<Banner>[];
6
+ export declare function getColumnDefs(zoneList: Zone[], t: TFunction): ColumnDefinition<Banner>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tager/admin-banners",
3
- "version": "0.3.1",
3
+ "version": "0.3.5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
@@ -27,9 +27,9 @@
27
27
  "@rollup/plugin-commonjs": "^15.0.0",
28
28
  "@rollup/plugin-node-resolve": "^9.0.0",
29
29
  "@tager/admin-dynamic-field": "^0.1.18",
30
- "@tager/admin-layout": "^0.5.3",
30
+ "@tager/admin-layout": "^0.5.4",
31
31
  "@tager/admin-services": "^0.2.26",
32
- "@tager/admin-ui": "^0.8.85",
32
+ "@tager/admin-ui": "^0.8.96",
33
33
  "@types/lodash.isequal": "^4.5.5",
34
34
  "@types/lodash.pick": "^4.4.6",
35
35
  "@types/node": "12.x",
package/src/locales/en.ts CHANGED
@@ -23,6 +23,7 @@ const EN = {
23
23
  remove: 'Remove',
24
24
  actions: 'actions',
25
25
  date: 'Date',
26
+ name: 'Name',
26
27
 
27
28
  success: 'Success',
28
29
  error: 'Error',
package/src/locales/ru.ts CHANGED
@@ -25,6 +25,7 @@ const RU: typeof EN = {
25
25
  remove: 'Удалить',
26
26
  actions: 'Действия',
27
27
  date: 'Дата',
28
+ name: 'Название',
28
29
 
29
30
  success: 'Успех',
30
31
  error: 'Ошибка',
package/src/main.ts CHANGED
@@ -3,8 +3,8 @@ import { i18n } from '@tager/admin-services';
3
3
  import EN from './locales/en';
4
4
  import RU from './locales/ru';
5
5
 
6
- i18n.addTranslations('en', 'blog', EN);
7
- i18n.addTranslations('ru', 'blog', RU);
6
+ i18n.addTranslations('en', 'banners', EN);
7
+ i18n.addTranslations('ru', 'banners', RU);
8
8
 
9
9
  export * from './constants/routes';
10
10
  export * from './constants/menu';
@@ -48,7 +48,7 @@ export function updateBanner(
48
48
  export function deleteBanner(
49
49
  bannerId: number | string
50
50
  ): Promise<{ success: boolean }> {
51
- return request.delete({ path: `/admin/banners/${bannerId}` });
51
+ return request.delete({ path: `/admin/adv/${bannerId}` });
52
52
  }
53
53
 
54
54
  export function getBannerCount(): Promise<ResponseBody<{ count: number }>> {
@@ -3,6 +3,7 @@ import { TFunction } from 'i18next';
3
3
  import { ColumnDefinition } from '@tager/admin-ui';
4
4
 
5
5
  import { Banner, Status } from '../../../typings/banners';
6
+ import { Zone } from '../../../typings/zones';
6
7
 
7
8
  export function getStatus(type: Status, t: TFunction) {
8
9
  switch (type) {
@@ -20,12 +21,16 @@ export function getStatus(type: Status, t: TFunction) {
20
21
  }
21
22
  }
22
23
 
23
- export function getColumnDefs(t: TFunction): ColumnDefinition<Banner>[] {
24
+ export function getColumnDefs(
25
+ zoneList: Zone[],
26
+ t: TFunction
27
+ ): ColumnDefinition<Banner>[] {
24
28
  return [
25
29
  {
26
30
  id: 0,
27
31
  name: '#',
28
32
  field: 'id',
33
+ format: ({ rowIndex }) => String(rowIndex + 1),
29
34
  style: { width: '50px', textAlign: 'center' },
30
35
  headStyle: { width: '50px', textAlign: 'center' },
31
36
  },
@@ -33,8 +38,14 @@ export function getColumnDefs(t: TFunction): ColumnDefinition<Banner>[] {
33
38
  id: 1,
34
39
  name: t('banners:zone'),
35
40
  field: 'bannerZone',
36
- format: ({ row }) =>
37
- row.bannerZone ? row.bannerZone : t('banners:bannerZoneIsDeleted'),
41
+ format: ({ row }) => {
42
+ const foundBannerZone = zoneList.find(
43
+ (zone) => zone.id === row.bannerZone
44
+ );
45
+ return foundBannerZone
46
+ ? foundBannerZone.name
47
+ : t('banners:bannerZoneIsDeleted');
48
+ },
38
49
  },
39
50
  {
40
51
  id: 2,
@@ -76,6 +87,9 @@ export function getColumnDefs(t: TFunction): ColumnDefinition<Banner>[] {
76
87
  },
77
88
  ],
78
89
  }),
90
+ options: {
91
+ shouldOpenNewTab: true,
92
+ },
79
93
  },
80
94
  {
81
95
  id: 6,
@@ -181,7 +181,7 @@ export default defineComponent({
181
181
  };
182
182
 
183
183
  const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>
184
- getColumnDefs(context.root.$t)
184
+ getColumnDefs(zoneList.value, context.root.$t)
185
185
  );
186
186
 
187
187
  const isRowDataLoading = computed<boolean>(
@@ -112,7 +112,7 @@ export function useAdvancedSearch({ context, t, zoneList }: Params): State {
112
112
  const filterParams = computed(() =>
113
113
  getFilterParams({
114
114
  [FilterTypes.Zone]: zoneFilter.value.map(({ value }) => value),
115
- [FilterTypes.Date]: dateFilter.value,
115
+ [FilterTypes.Date]: dateFilter.value || [],
116
116
  [FilterTypes.Status]: statusFilter.value.map(({ value }) => value),
117
117
  })
118
118
  );