quasar-ui-danx 0.2.22 → 0.2.24

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.
@@ -1,6 +1,30 @@
1
+ import { ref, Ref, UnwrapRef } from "vue";
2
+
3
+ interface RequestOptions {
4
+ baseUrl: string;
5
+ }
6
+
7
+ const requestOptions: Ref<UnwrapRef<RequestOptions>> = ref({
8
+ baseUrl: ""
9
+ });
10
+ /**
11
+ * A simple request helper that wraps the fetch API
12
+ * to make GET and POST requests easier w/ JSON payloads
13
+ */
1
14
  export const request = {
2
- async get(url, options = {}) {
3
- return fetch(url, {
15
+ configure(options: RequestOptions) {
16
+ requestOptions.value = options;
17
+ },
18
+
19
+ url(url: string) {
20
+ if (url.startsWith("http")) {
21
+ return url;
22
+ }
23
+ return requestOptions.value.baseUrl + url;
24
+ },
25
+
26
+ async get(url: string, options = {}): Promise<object> {
27
+ return fetch(request.url(url), {
4
28
  method: "get",
5
29
  headers: {
6
30
  Accept: "application/json",
@@ -10,8 +34,8 @@ export const request = {
10
34
  }).then((r) => r.json());
11
35
  },
12
36
 
13
- async post(url, data = {}, options = {}) {
14
- return fetch(url, {
37
+ async post(url: string, data = {}, options = {}) {
38
+ return fetch(request.url(url), {
15
39
  method: "post",
16
40
  body: JSON.stringify(data),
17
41
  headers: {
@@ -29,34 +53,27 @@ export const request = {
29
53
  * also fetches that resource record from the endpoint, then adds it to the list if it
30
54
  * does not exist in the filtered list
31
55
  *
32
- * @param fetchFn
33
- * @param list
34
- * @param id
35
- * @param filter
36
- * @returns {Promise<void>}
37
56
  */
38
- export async function fetchResourceListWithSelected(fetchFn, list, id, filter) {
57
+ export async function fetchResourceListWithSelected(fetchFn: (filter: object) => Promise<any[]>, list: Ref, id: string, filter: object): Promise<void> {
39
58
  // First make sure we have the selected record, so we can always add it to the list
40
59
  let selectedResource;
41
60
  if (id) {
42
- selectedResource = list.value.find((c) => c.id === id) || (await fetchFn({ id }))[0];
61
+ selectedResource = list.value.find((c: { id: string }) => c.id === id) || (await fetchFn({ id }))[0];
43
62
  }
44
63
 
45
64
  // Get the filtered campaign list
46
65
  list.value = await fetchFn(filter);
47
66
 
48
67
  // If our selected campaign is not in the filtered list, add it
49
- if (selectedResource && !list.value.find((c) => c.id === id)) {
68
+ if (selectedResource && !list.value.find((c: { id: string }) => c.id === id)) {
50
69
  list.value.push(selectedResource);
51
70
  }
52
71
  }
53
72
 
54
73
  /**
55
74
  * Returns the value of the URL parameter (if it is set)
56
- * @param key
57
- * @param url
58
75
  */
59
- export function getUrlParam(key, url = undefined) {
76
+ export function getUrlParam(key: string, url?: string) {
60
77
  const params = new URLSearchParams(url?.replace(/.*\?/, "") || window.location.search);
61
78
  return params.get(key);
62
79
  }
@@ -1,3 +1,5 @@
1
1
  @tailwind base;
2
2
  @tailwind components;
3
3
  @tailwind utilities;
4
+
5
+ @import 'quasar-reset';
@@ -0,0 +1,28 @@
1
+ .q-tab-panels {
2
+ overflow: visible;
3
+
4
+ .q-panel {
5
+ overflow: visible;
6
+
7
+ &.scroll {
8
+ overflow: auto;
9
+ }
10
+
11
+ .q-tab-panel {
12
+ padding: 0;
13
+ }
14
+ }
15
+
16
+ &.overflow-y-auto {
17
+ overflow-y: auto;
18
+ }
19
+ }
20
+
21
+ .q-toolbar {
22
+ min-height: 0;
23
+ padding: 0;
24
+ }
25
+
26
+ .q-notification__actions {
27
+ color: inherit;
28
+ }