@tager/admin-blog 0.3.37 → 0.3.41

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.
@@ -23,6 +23,7 @@ interface Params {
23
23
  context: SetupContext;
24
24
  categoryList: ComputedRef<Category[]>;
25
25
  languageList: ComputedRef<Language[]>;
26
+ statusOptionList: ComputedRef<OptionType[]>;
26
27
  }
27
28
 
28
29
  interface State {
@@ -32,6 +33,7 @@ interface State {
32
33
  languageOptionList: ComputedRef<OptionType[]>;
33
34
  fromDateFilter: Ref<string>;
34
35
  toDateFilter: Ref<string>;
36
+ statusFilter: Ref<OptionType[]>;
35
37
  filterParams: ComputedRef<Record<string, string | string[]>>;
36
38
  tags: ComputedRef<FilterTagType[]>;
37
39
  tagRemovalHandler(event: FilterTagType): void;
@@ -42,6 +44,7 @@ enum FilterTypes {
42
44
  LANGUAGE = 'language',
43
45
  FROM_DATE = 'from-date',
44
46
  TO_DATE = 'to-date',
47
+ STATUS = 'status',
45
48
  }
46
49
 
47
50
  export const dateFormat = (date: string) => date.split('-').reverse().join('.');
@@ -50,6 +53,7 @@ export function useAdvancedSearch({
50
53
  context,
51
54
  categoryList,
52
55
  languageList,
56
+ statusOptionList,
53
57
  }: Params): State {
54
58
  /** Category **/
55
59
 
@@ -161,12 +165,31 @@ export function useAdvancedSearch({
161
165
  };
162
166
  });
163
167
 
168
+ /** Status **/
169
+
170
+ const initialStatusFilter = computed<OptionType[]>(() => {
171
+ const queryValue = getFilterParamAsStringArray(
172
+ context.root.$route.query,
173
+ FilterTypes.STATUS
174
+ );
175
+ return statusOptionList.value.filter(({ value }) =>
176
+ queryValue.some((selected) => selected === value)
177
+ );
178
+ });
179
+
180
+ const statusFilter = ref<OptionType[]>(initialStatusFilter.value);
181
+
182
+ watch(initialStatusFilter, () => {
183
+ statusFilter.value = initialStatusFilter.value;
184
+ });
185
+
164
186
  /** Params **/
165
187
 
166
188
  const filterParams = computed(() => {
167
189
  const filters: Record<string, string | string[]> = {
168
190
  [FilterTypes.CATEGORY]: categoryFilter.value.map(({ value }) => value),
169
191
  [FilterTypes.LANGUAGE]: languageFilter.value.map(({ value }) => value),
192
+ [FilterTypes.STATUS]: statusFilter.value.map(({ value }) => value),
170
193
  };
171
194
 
172
195
  if (fromDateFilter.value) {
@@ -197,6 +220,11 @@ export function useAdvancedSearch({
197
220
  fromDateFilter.value = '';
198
221
  toDateFilter.value = '';
199
222
  }
223
+ if (event.name === FilterTypes.STATUS) {
224
+ statusFilter.value = statusFilter.value.filter(
225
+ ({ value }) => value !== event.value
226
+ );
227
+ }
200
228
  }
201
229
 
202
230
  /** Tags **/
@@ -216,6 +244,12 @@ export function useAdvancedSearch({
216
244
  title: context.root.$t('blog:language'),
217
245
  })),
218
246
  date.value,
247
+ ...statusFilter.value.map(({ value, label }) => ({
248
+ value,
249
+ label,
250
+ name: FilterTypes.STATUS,
251
+ title: context.root.$t('blog:status'),
252
+ })),
219
253
  ].filter(isNotNullish)
220
254
  );
221
255
 
@@ -243,6 +277,7 @@ export function useAdvancedSearch({
243
277
  languageOptionList,
244
278
  fromDateFilter,
245
279
  toDateFilter,
280
+ statusFilter,
246
281
  tagRemovalHandler,
247
282
  tags: tags,
248
283
  filterParams,