adminforth 1.1.42 → 1.1.43

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.
@@ -75,9 +75,17 @@ class MongoConnector {
75
75
  } else {
76
76
  throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps)`);
77
77
  }
78
+
79
+ } else if (field.type == AdminForthDataTypes.DATE) {
80
+ if (!value) {
81
+ return null;
82
+ }
83
+ return dayjs(value).toISOString().split('T')[0];
84
+
78
85
  } else if (field.type == AdminForthDataTypes.BOOLEAN) {
79
86
  return !!value;
80
87
  }
88
+
81
89
  return value;
82
90
  }
83
91
 
@@ -109,7 +109,11 @@ class PostgresConnector {
109
109
  field.type = AdminForthDataTypes.FLOAT;
110
110
  field._underlineType = 'real';
111
111
 
112
- } else if (baseType.includes('date') || baseType.includes('time')) {
112
+ } else if (baseType == 'date') {
113
+ field.type = AdminForthDataTypes.DATE;
114
+ field._underlineType = 'timestamp';
115
+
116
+ } else if (baseType.includes('date') || baseType.includes('time')) {
113
117
  field.type = AdminForthDataTypes.DATETIME;
114
118
  field._underlineType = 'timestamp';
115
119
 
@@ -127,16 +131,23 @@ class PostgresConnector {
127
131
 
128
132
  getFieldValue(field, value) {
129
133
  if (field.type == AdminForthDataTypes.DATETIME) {
130
- if (!value) {
131
- return null;
132
- }
133
- if (field._underlineType == 'timestamp' || field._underlineType == 'int') {
134
- return dayjs(value).toISOString();
135
- } else if (field._underlineType == 'varchar') {
136
- return dayjs(value).toISOString();
137
- } else {
138
- throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps)`);
139
- }
134
+ if (!value) {
135
+ return null;
136
+ }
137
+ if (field._underlineType == 'timestamp' || field._underlineType == 'int') {
138
+ return dayjs(value).toISOString();
139
+ } else if (field._underlineType == 'varchar') {
140
+ return dayjs(value).toISOString();
141
+ } else {
142
+ throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps)`);
143
+ }
144
+ }
145
+
146
+ if (field.type == AdminForthDataTypes.DATE) {
147
+ if (!value) {
148
+ return null;
149
+ }
150
+ return dayjs(value).toISOString().split('T')[0];
140
151
  }
141
152
 
142
153
  return value;
@@ -79,9 +79,17 @@ class SQLiteConnector {
79
79
  } else {
80
80
  throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps). Issue in field "${field.name}"`);
81
81
  }
82
+
83
+ } else if (field.type == AdminForthDataTypes.DATE) {
84
+ if (!value) {
85
+ return null;
86
+ }
87
+ return dayjs(value).toISOString().split('T')[0];
88
+
82
89
  } else if (field.type == AdminForthDataTypes.BOOLEAN) {
83
90
  return !!value;
84
91
  }
92
+
85
93
  return value;
86
94
  }
87
95
 
@@ -81,6 +81,12 @@ class MongoConnector {
81
81
  throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps)`);
82
82
  }
83
83
  }
84
+ else if (field.type == AdminForthDataTypes.DATE) {
85
+ if (!value) {
86
+ return null;
87
+ }
88
+ return dayjs(value).toISOString().split('T')[0];
89
+ }
84
90
  else if (field.type == AdminForthDataTypes.BOOLEAN) {
85
91
  return !!value;
86
92
  }
@@ -109,6 +109,10 @@ class PostgresConnector {
109
109
  field.type = AdminForthDataTypes.FLOAT;
110
110
  field._underlineType = 'real';
111
111
  }
112
+ else if (baseType == 'date') {
113
+ field.type = AdminForthDataTypes.DATE;
114
+ field._underlineType = 'timestamp';
115
+ }
112
116
  else if (baseType.includes('date') || baseType.includes('time')) {
113
117
  field.type = AdminForthDataTypes.DATETIME;
114
118
  field._underlineType = 'timestamp';
@@ -140,6 +144,12 @@ class PostgresConnector {
140
144
  throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps)`);
141
145
  }
142
146
  }
147
+ if (field.type == AdminForthDataTypes.DATE) {
148
+ if (!value) {
149
+ return null;
150
+ }
151
+ return dayjs(value).toISOString().split('T')[0];
152
+ }
143
153
  return value;
144
154
  }
145
155
  getPrimaryKey(resource) {
@@ -107,6 +107,12 @@ class SQLiteConnector {
107
107
  throw new Error(`AdminForth does not support row type: ${field._underlineType} for timestamps, use VARCHAR (with iso strings) or TIMESTAMP/INT (with unix timestamps). Issue in field "${field.name}"`);
108
108
  }
109
109
  }
110
+ else if (field.type == AdminForthDataTypes.DATE) {
111
+ if (!value) {
112
+ return null;
113
+ }
114
+ return dayjs(value).toISOString().split('T')[0];
115
+ }
110
116
  else if (field.type == AdminForthDataTypes.BOOLEAN) {
111
117
  return !!value;
112
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.1.42",
3
+ "version": "1.1.43",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -799,7 +799,7 @@ export type AdminForthConfig = {
799
799
  * import HighchartsVue from 'highcharts-vue';
800
800
  * // import '@@/custom.scss'; // here is how you can import custom styles
801
801
  *
802
- * export default function (app) {
802
+ * export default function (app) {
803
803
  * app.use(HighchartsVue);
804
804
  * }
805
805
  * ```
@@ -831,7 +831,10 @@ export type AdminForthConfig = {
831
831
  baseUrl?: string,
832
832
 
833
833
  deleteConfirmation?: boolean,
834
-
834
+
835
+ /**
836
+ * Object to redefine default styles for AdminForth components. Use this file as reference for all possible adjustments https://github.com/devforth/adminforth/blob/main/adminforth/modules/styles.ts
837
+ */
835
838
  styles?: Object,
836
839
  }
837
840