@tager/admin-banners 1.0.0 → 1.0.1

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i18n, request, useI18n, useResource, useResourceDelete, createId, useToast, navigateBack, convertRequestErrorToMap } from "@tager/admin-services";
1
+ import { i18n, request, useI18n, useResource, isNotNullish, useResourceDelete, createId, useToast, navigateBack, convertRequestErrorToMap } from "@tager/admin-services";
2
2
  import { defineComponent, onMounted, computed, resolveComponent, openBlock, createBlock, withCtx, createVNode, createTextVNode, toDisplayString, ref, watch, createElementVNode, withModifiers, createElementBlock, Fragment, renderList } from "vue";
3
3
  import { CountButton, DataTable, useDataTable, getFilterParamAsStringArray, getFilterParamAsString, getFilterParams, DeleteIcon, EditIcon, BaseButton, FormField, FormFieldMultiSelect, AdvancedSearch, FormFieldFileInput, FormFieldCheckbox, InputLabel, FormFieldSelect, FormFooter } from "@tager/admin-ui";
4
4
  import { Page } from "@tager/admin-layout";
@@ -351,12 +351,7 @@ function getColumnDefs(zoneList, t) {
351
351
  }
352
352
  ];
353
353
  }
354
- function useAdvancedSearch({
355
- context,
356
- t,
357
- zoneList,
358
- route
359
- }) {
354
+ function useAdvancedSearch({ t, zoneList, route }) {
360
355
  const zonesOptionList = computed(
361
356
  () => zoneList.value.map(({ id, name }) => ({
362
357
  value: id,
@@ -427,7 +422,28 @@ function useAdvancedSearch({
427
422
  );
428
423
  }
429
424
  };
430
- const tags = computed(() => []);
425
+ const tags = computed(
426
+ () => [
427
+ ...zoneFilter.value.map(({ value, label }) => ({
428
+ value,
429
+ label,
430
+ name: "zone",
431
+ title: t("banners:zone")
432
+ })),
433
+ ...statusFilter.value.map(({ value, label }) => ({
434
+ value,
435
+ label,
436
+ name: "status",
437
+ title: t("banners:status")
438
+ })),
439
+ dateFilter.value ? {
440
+ value: dateFilter.value,
441
+ label: dateFilter.value,
442
+ name: "date",
443
+ title: t("banners:date")
444
+ } : null
445
+ ].filter(isNotNullish)
446
+ );
431
447
  return {
432
448
  zoneFilter,
433
449
  zonesOptionList,
@@ -452,7 +468,7 @@ const _sfc_main$1 = defineComponent({
452
468
  Page,
453
469
  DataTable
454
470
  },
455
- setup(props, context) {
471
+ setup() {
456
472
  const route = useRoute();
457
473
  const router = useRouter();
458
474
  const { t } = useI18n();
@@ -467,7 +483,6 @@ const _sfc_main$1 = defineComponent({
467
483
  tags,
468
484
  tagRemovalHandler
469
485
  } = useAdvancedSearch({
470
- context,
471
486
  t,
472
487
  zoneList,
473
488
  route
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .filters{display:flex;margin:0 -10px}.filters:not(:first-child){margin-top:10px}.filters .filter{padding:10px 10px 0;width:50%;margin:0}.date{display:grid;grid-template-columns:repeat(2,1fr);column-gap:10px}.zone{display:flex}.zone>*:first-child{flex:1 1 1px}.zone>*:last-child{flex-basis:30%;margin-left:20px}.link{display:flex;align-items:flex-end}.link>*:first-child{flex:1 1 1px}.link>*:last-child{flex-basis:30%;margin-left:20px;padding-bottom:8px}
1
+ .filters{display:grid;gap:1rem;grid-template-columns:1fr 1fr 1fr}.date{display:grid;grid-template-columns:repeat(2,1fr);column-gap:10px}.zone{display:flex}.zone>*:first-child{flex:1 1 1px}.zone>*:last-child{flex-basis:30%;margin-left:20px}.link{display:flex;align-items:flex-end}.link>*:first-child{flex:1 1 1px}.link>*:last-child{flex-basis:30%;margin-left:20px;padding-bottom:8px}
@@ -1,10 +1,9 @@
1
- import { ComputedRef, Ref, SetupContext } from 'vue';
1
+ import { ComputedRef, Ref } from 'vue';
2
2
  import { TFunction } from 'i18next';
3
3
  import { RouteLocationNormalizedLoaded } from 'vue-router';
4
4
  import { FilterTagType, OptionType } from '@tager/admin-ui';
5
5
  import { Zone } from '../../../../typings/zones';
6
6
  interface Params {
7
- context: SetupContext;
8
7
  t: TFunction;
9
8
  zoneList: Ref<Zone[]>;
10
9
  route: RouteLocationNormalizedLoaded;
@@ -19,5 +18,5 @@ interface State {
19
18
  tags: ComputedRef<FilterTagType[]>;
20
19
  tagRemovalHandler(event: FilterTagType): void;
21
20
  }
22
- export declare function useAdvancedSearch({ context, t, zoneList, route, }: Params): State;
21
+ export declare function useAdvancedSearch({ t, zoneList, route }: Params): State;
23
22
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tager/admin-banners",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,15 +1,15 @@
1
- import {compile} from 'path-to-regexp';
1
+ import { compile } from 'path-to-regexp';
2
2
 
3
- import {BANNERS_ROUTE_PATHS} from '../constants/paths';
3
+ import { BANNERS_ROUTE_PATHS } from '../constants/paths';
4
4
 
5
5
  export function getBannersZoneListUrl() {
6
- return BANNERS_ROUTE_PATHS.ZONE_LIST;
6
+ return BANNERS_ROUTE_PATHS.ZONE_LIST;
7
7
  }
8
8
 
9
9
  export function getBannersBannerListUrl() {
10
- return BANNERS_ROUTE_PATHS.BANNER_LIST;
10
+ return BANNERS_ROUTE_PATHS.BANNER_LIST;
11
11
  }
12
12
 
13
13
  export function getBannersBannerFormUrl(params: { bannerId: number | string }) {
14
- return compile(BANNERS_ROUTE_PATHS.BANNER_FORM)(params);
14
+ return compile(BANNERS_ROUTE_PATHS.BANNER_FORM)(params);
15
15
  }
@@ -122,7 +122,7 @@ export default defineComponent({
122
122
  Page,
123
123
  DataTable,
124
124
  },
125
- setup(props, context: SetupContext) {
125
+ setup() {
126
126
  const route = useRoute();
127
127
  const router = useRouter();
128
128
  const { t } = useI18n();
@@ -139,7 +139,6 @@ export default defineComponent({
139
139
  tags,
140
140
  tagRemovalHandler,
141
141
  } = useAdvancedSearch({
142
- context,
143
142
  t,
144
143
  zoneList,
145
144
  route,
@@ -230,17 +229,8 @@ export default defineComponent({
230
229
 
231
230
  <style lang="scss">
232
231
  .filters {
233
- display: flex;
234
- margin: 0 -10px;
235
-
236
- &:not(:first-child) {
237
- margin-top: 10px;
238
- }
239
-
240
- .filter {
241
- padding: 10px 10px 0;
242
- width: 50%;
243
- margin: 0;
244
- }
232
+ display: grid;
233
+ gap: 1rem;
234
+ grid-template-columns: 1fr 1fr 1fr;
245
235
  }
246
236
  </style>
@@ -9,13 +9,13 @@ import {
9
9
  getFilterParams,
10
10
  OptionType,
11
11
  } from '@tager/admin-ui';
12
+ import { isNotNullish } from '@tager/admin-services';
12
13
 
13
14
  import { Zone } from '../../../../typings/zones';
14
15
  import { Status } from '../../../../typings/banners';
15
16
  import { getStatus } from '../BannerList.helpers';
16
17
 
17
18
  interface Params {
18
- context: SetupContext;
19
19
  t: TFunction;
20
20
  zoneList: Ref<Zone[]>;
21
21
  route: RouteLocationNormalizedLoaded;
@@ -39,12 +39,7 @@ enum FilterTypes {
39
39
  Status = 'status',
40
40
  }
41
41
 
42
- export function useAdvancedSearch({
43
- context,
44
- t,
45
- zoneList,
46
- route,
47
- }: Params): State {
42
+ export function useAdvancedSearch({ t, zoneList, route }: Params): State {
48
43
  /** Zone **/
49
44
 
50
45
  const zonesOptionList = computed<OptionType[]>(() =>
@@ -137,7 +132,32 @@ export function useAdvancedSearch({
137
132
 
138
133
  /** Tags **/
139
134
 
140
- const tags = computed<FilterTagType[]>(() => []);
135
+ const tags = computed<FilterTagType[]>(() =>
136
+ [
137
+ ...zoneFilter.value.map(({ value, label }) => ({
138
+ value,
139
+ label,
140
+ name: FilterTypes.Zone,
141
+ title: t('banners:zone'),
142
+ })),
143
+
144
+ ...statusFilter.value.map(({ value, label }) => ({
145
+ value,
146
+ label,
147
+ name: FilterTypes.Status,
148
+ title: t('banners:status'),
149
+ })),
150
+
151
+ dateFilter.value
152
+ ? {
153
+ value: dateFilter.value,
154
+ label: dateFilter.value,
155
+ name: FilterTypes.Date,
156
+ title: t('banners:date'),
157
+ }
158
+ : null,
159
+ ].filter(isNotNullish)
160
+ );
141
161
 
142
162
  return {
143
163
  zoneFilter,