sprintify-ui 0.6.72 → 0.6.73

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.
@@ -0,0 +1,2 @@
1
+ import { Collection, PaginatedCollection, ResourceCollection } from "@/types";
2
+ export declare function getItems(data: Collection | PaginatedCollection | ResourceCollection | null): Collection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.6.72",
3
+ "version": "0.6.73",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -50,6 +50,7 @@ import { config } from '@/index';
50
50
  import { PropType } from 'vue';
51
51
  import BaseTagAutocompleteFetch from './BaseTagAutocompleteFetch.vue';
52
52
  import { AxiosResponse } from 'axios';
53
+ import { getItems } from '@/utils/getApiData';
53
54
 
54
55
  const props = defineProps({
55
56
  modelValue: {
@@ -128,34 +129,25 @@ watch(
128
129
 
129
130
  watch(
130
131
  () => props.modelValue,
131
- debounce(() => fetchModels(), 300),
132
+ debounce(() => fetchModels(), 200),
132
133
  { immediate: true }
133
134
  );
134
135
 
135
136
  function fetchModels() {
136
137
 
137
- console.log('check if currentModels is undefined');
138
-
139
138
  if (props.currentModels !== undefined) {
140
139
  return;
141
140
  }
142
141
 
143
- console.log('check if showRouteUrl is empty');
144
-
145
- if (props.showRouteUrl == null) {
142
+ if (props.showRouteUrl == undefined) {
146
143
  return;
147
144
  }
148
145
 
149
- console.log('check if modelValue is empty');
150
-
151
146
  if (!props.modelValue) {
152
147
  models.value = [];
153
148
  return;
154
149
  }
155
150
 
156
- console.log('check models');
157
-
158
-
159
151
  // Do not fetch if the modelValue is the same as the local models
160
152
 
161
153
  const ids = props.modelValue.map((id: number | string) => id.toString());
@@ -166,12 +158,13 @@ function fetchModels() {
166
158
  return;
167
159
  }
168
160
 
169
- console.log('fetch models');
170
-
171
161
  http
172
162
  .get(props.showRouteUrl(ids))
173
163
  .then((response: AxiosResponse) => {
174
- models.value = response.data.data.filter((i: any) => {
164
+
165
+ const items = getItems(response.data);
166
+
167
+ models.value = items.filter((i: any) => {
175
168
  return ids.includes(i[props.primaryKey]);
176
169
  });
177
170
  })
@@ -6,18 +6,13 @@ import {
6
6
  PaginationMetadata,
7
7
  } from '@/types';
8
8
  import { isArray } from 'lodash';
9
+ import { getItems } from '@/utils/getApiData';
9
10
 
10
11
  export function useHasPaginatedData(
11
12
  data: Ref<Collection | PaginatedCollection | ResourceCollection | null>
12
13
  ) {
13
14
  const items = computed(() => {
14
- if (!data.value) {
15
- return [];
16
- }
17
- if (isArray(data.value)) {
18
- return data.value;
19
- }
20
- return data.value.data;
15
+ return getItems(data.value);
21
16
  });
22
17
 
23
18
  const paginationMetadata = computed<PaginationMetadata | null>(() => {
@@ -0,0 +1,12 @@
1
+ import { Collection, PaginatedCollection, ResourceCollection } from "@/types";
2
+ import { isArray } from "lodash";
3
+
4
+ export function getItems(data: Collection | PaginatedCollection | ResourceCollection | null) {
5
+ if (!data) {
6
+ return [];
7
+ }
8
+ if (isArray(data)) {
9
+ return data;
10
+ }
11
+ return data.data;
12
+ }