quasar-ui-danx 0.4.33 → 0.4.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.4.33",
3
+ "version": "0.4.36",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -154,7 +154,7 @@ const selectedValue = computed(() => {
154
154
  } else {
155
155
  if (props.modelValue === null) return "__null__";
156
156
 
157
- if (props.selectByObject) return props.modelValue.value || props.modelValue.id;
157
+ if (props.selectByObject) return props.modelValue?.value || props.modelValue?.id;
158
158
 
159
159
  return props.modelValue;
160
160
  }
@@ -73,7 +73,7 @@ export function useControls(name: string, options: ListControlsOptions): ListCon
73
73
 
74
74
  async function loadList() {
75
75
  if (!isInitialized || options.isListEnabled === false) return;
76
- // isLoadingList.value = true;
76
+ isLoadingList.value = true;
77
77
  try {
78
78
  setPagedItems(await options.routes.list(pager.value));
79
79
  } catch (e) {
@@ -29,40 +29,6 @@ export function remoteDateTime(dateTimeString: string) {
29
29
  return DateTime.fromSQL(dateTimeString, { zone: "local" }).setZone(SERVER_TZ);
30
30
  }
31
31
 
32
- /**
33
- * Parses a date string into a Luxon DateTime object
34
- */
35
- export function parseDateTime(dateTime: string | DateTime | null): DateTime<boolean> | null {
36
- if (typeof dateTime === "string") {
37
- return parseSqlDateTime(dateTime) || parseQDate(dateTime) || parseQDateTime(dateTime);
38
- }
39
- return dateTime || DateTime.fromSQL("0000-00-00 00:00:00");
40
- }
41
-
42
- /**
43
- * Parses a SQL formatted date string into a Luxon DateTime object
44
- */
45
- export function parseSqlDateTime(dateTime: string) {
46
- const parsed = DateTime.fromSQL(dateTime.replace("T", " ").replace(/\//g, "-"));
47
- return parsed.isValid ? parsed : null;
48
- }
49
-
50
- /**
51
- * Parses a Quasar formatted date string into a Luxon DateTime object
52
- */
53
- export function parseQDate(date: string, format = "yyyy/MM/dd"): DateTime<boolean> | null {
54
- const parsed = DateTime.fromFormat(date, format);
55
- return parsed.isValid ? parsed : null;
56
- }
57
-
58
- /**
59
- * Parses a Quasar formatted date/time string into a Luxon DateTime object
60
- */
61
- export function parseQDateTime(date: string, format = "yyyy/MM/dd HH:mm:ss"): DateTime<boolean> | null {
62
- const parsed = DateTime.fromFormat(date, format);
63
- return parsed.isValid ? parsed : null;
64
- }
65
-
66
32
  /**
67
33
  * Formats a Luxon DateTime object into a Quasar formatted date string
68
34
  * @param date
@@ -119,6 +85,89 @@ export function fDate(dateTime: string | DateTime | null, { empty = "--", format
119
85
  return formatted || empty;
120
86
  }
121
87
 
88
+
89
+ /**
90
+ * Parses a date string into a Luxon DateTime object
91
+ */
92
+ export function parseDateTime(dateTime: string | DateTime | null): DateTime<boolean> | null {
93
+ if (typeof dateTime === "string") {
94
+ return parseGenericDateTime(dateTime);
95
+ }
96
+ return dateTime || DateTime.fromSQL("0000-00-00 00:00:00");
97
+ }
98
+
99
+ /**
100
+ * Parses a SQL formatted date string into a Luxon DateTime object
101
+ */
102
+ export function parseSqlDateTime(dateTime: string) {
103
+ const parsed = DateTime.fromSQL(dateTime.replace("T", " ").replace(/\//g, "-"));
104
+ return parsed.isValid ? parsed : null;
105
+ }
106
+
107
+ /**
108
+ * Parses a Quasar formatted date string into a Luxon DateTime object
109
+ */
110
+ export function parseQDate(date: string, format = "yyyy/MM/dd"): DateTime<boolean> | null {
111
+ const parsed = DateTime.fromFormat(date, format);
112
+ return parsed.isValid ? parsed : null;
113
+ }
114
+
115
+ /**
116
+ * Parses a Quasar formatted date/time string into a Luxon DateTime object
117
+ */
118
+ export function parseQDateTime(date: string, format = "yyyy/MM/dd HH:mm:ss"): DateTime<boolean> | null {
119
+ const parsed = DateTime.fromFormat(date, format);
120
+ return parsed.isValid ? parsed : null;
121
+ }
122
+
123
+ /**
124
+ * Parses a date string in various formats into a Luxon DateTime object.
125
+ * Tries a list of common formats until one works.
126
+ *
127
+ * @param {string} dateTimeString - The date string to parse.
128
+ * @param {string} [defaultZone="local"] - The default time zone to use if not specified.
129
+ * @returns {DateTime | null} - A Luxon DateTime object if parsing succeeds, otherwise null.
130
+ */
131
+ export function parseGenericDateTime(dateTimeString: string, defaultZone = "local"): DateTime | null {
132
+ if (!dateTimeString) return null;
133
+
134
+ const formats = [
135
+ "yyyy-MM-dd", // ISO date
136
+ "yyyy-MM-dd HH:mm:ss", // ISO date with time
137
+ "MM/dd/yyyy", // US-style date
138
+ "dd/MM/yyyy", // European-style date
139
+ "MM/dd/yy", // US short date
140
+ "dd/MM/yy", // European short date
141
+ "yyyy/MM/dd", // Alternative ISO
142
+ "MM-dd-yyyy", // US with dashes
143
+ "dd-MM-yyyy", // European with dashes
144
+ "M/d/yyyy", // US date without leading zeros
145
+ "d/M/yyyy", // European date without leading zeros
146
+ "yyyyMMdd" // Compact ISO
147
+ ];
148
+
149
+ for (const format of formats) {
150
+ const parsed = DateTime.fromFormat(dateTimeString, format, { zone: defaultZone });
151
+ if (parsed.isValid) {
152
+ return parsed;
153
+ }
154
+ }
155
+
156
+ // Fallback to ISO parsing for strings like "2022-11-18T10:10:10Z"
157
+ const isoParsed = DateTime.fromISO(dateTimeString, { zone: defaultZone });
158
+ if (isoParsed.isValid) {
159
+ return isoParsed;
160
+ }
161
+
162
+ // Fallback to SQL parsing for strings like "2022-11-18 10:10:10"
163
+ const sqlParsed = DateTime.fromSQL(dateTimeString, { zone: defaultZone });
164
+ if (sqlParsed.isValid) {
165
+ return sqlParsed;
166
+ }
167
+
168
+ return null;
169
+ }
170
+
122
171
  /**
123
172
  * Formats a number of seconds into Hours / Minutes / Seconds or just Minutes and Seconds
124
173
  *
@@ -11,15 +11,11 @@ export function useActionRoutes(baseUrl: string, extend?: object): ListControlsR
11
11
  summary(filter) {
12
12
  return request.post(`${baseUrl}/summary`, { filter });
13
13
  },
14
- details(target) {
15
- return request.get(`${baseUrl}/${target.id}/details`);
14
+ details(target, fields) {
15
+ return request.get(`${baseUrl}/${target.id}/details`, { params: { fields } });
16
16
  },
17
- async detailsAndStore(target) {
18
- const item = await request.get(`${baseUrl}/${target.id}/details`);
19
- return storeObject(item);
20
- },
21
- async relation(target, relation) {
22
- const item = await request.get(`${baseUrl}/${target.id}/relation/${relation}`);
17
+ async detailsAndStore(target, fields) {
18
+ const item = await request.get(`${baseUrl}/${target.id}/details`, { params: { fields } });
23
19
  return storeObject(item);
24
20
  },
25
21
  fieldOptions() {
@@ -24,11 +24,9 @@ export interface ListControlsRoutes<T = ActionTargetItem> {
24
24
 
25
25
  summary?(filter?: ListControlsFilter): Promise<AnyObject>;
26
26
 
27
- details?(target: T): Promise<T>;
27
+ details?(target: T, fields: ControlsFieldsList): Promise<T>;
28
28
 
29
- detailsAndStore?(target: T): Promise<T>;
30
-
31
- relation?(target: T, relation: string): Promise<T>;
29
+ detailsAndStore?(target: T, fields: ControlsFieldsList): Promise<T>;
32
30
 
33
31
  more?(pager: ListControlsPagination): Promise<T[]>;
34
32
 
@@ -62,6 +60,11 @@ export interface ListControlsPagination {
62
60
  rowsPerPage?: number;
63
61
  perPage?: number;
64
62
  filter?: ListControlsFilter;
63
+ fields?: ControlsFieldsList;
64
+ }
65
+
66
+ export interface ControlsFieldsList {
67
+ [key: string]: boolean | ControlsFieldsList;
65
68
  }
66
69
 
67
70
  export interface PagedItems<T = ActionTargetItem> {