Skip to content

Commit 5277727

Browse files
author
yaroslav8765
committed
Revert "fix: don't validate optional empty fields as invalid"
This reverts commit d6dcd70.
1 parent d6dcd70 commit 5277727

File tree

8 files changed

+30
-188
lines changed

8 files changed

+30
-188
lines changed

adminforth/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ class AdminForth implements IAdminForth {
315315
return error;
316316
}
317317
} else {
318-
if (column.minValue !== undefined && record[column.name] && record[column.name] < column.minValue) {
318+
if (column.minValue !== undefined && record[column.name] < column.minValue) {
319319
return `Value in "${column.name}" must be greater than ${column.minValue}`;
320320
}
321-
if (column.maxValue !== undefined && record[column.name] && record[column.name] > column.maxValue) {
321+
if (column.maxValue !== undefined && record[column.name] > column.maxValue) {
322322
return `Value in "${column.name}" must be less than ${column.maxValue}`;
323323
}
324324
}

dev-demo/.env.sample

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
AWS_ACCESS_KEY_ID=
22
AWS_SECRET_ACCESS_KEY=
3+
ADMINFORTH_SECRET=123
4+
NODE_ENV=development
35
OPENAI_API_KEY=1
46
HEAVY_DEBUG=
5-
HEAVY_DEBUG_QUERY=
7+
HEAVY_DEBUG_QUERY=
8+
PORT=3000
9+
10+
DATABASE_FILE=./db.sqlite
11+
DATABASE_FILE_URL=file:${DATABASE_FILE}

dev-demo/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
22
*.sqlite
3-
*.sqlite-journal
43
.env
54
db

dev-demo/custom/GroupTable.vue

Lines changed: 0 additions & 116 deletions
This file was deleted.

dev-demo/index.ts

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,7 @@ export const admin = new AdminForth({
7878
loginBackgroundImage: 'https://images.unsplash.com/photo-1534239697798-120952b76f2b?q=80&w=3389&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
7979
loginBackgroundPosition: '1/2', // over, 3/4, 2/5, 3/5 (tailwind grid)
8080
demoCredentials: "adminforth:adminforth", // never use it for production
81-
// loginPromptHTML: async () => {
82-
// const adminforthUserExists = await admin.resource("users").count(Filters.EQ('email', 'adminforth')) > 0;
83-
// if (adminforthUserExists) {
84-
// return "Please use <b>adminforth</b> as username and <b>adminforth</b> as password"
85-
// }
86-
// return "";
87-
// },
88-
loginPromptHTML:"Nya without function",
81+
loginPromptHTML: "Use email <b>adminforth</b> and password <b>adminforth</b> to login",
8982
// loginBackgroundImage: '@@/pho.jpg',
9083
rememberMeDays: 30,
9184
beforeLoginConfirmation: [async ({adminUser, adminforth, extra}) => {
@@ -123,29 +116,6 @@ export const admin = new AdminForth({
123116
userMenu: '@@/login2.vue',
124117
// header: '@@/PropertyCost.vue',
125118
},
126-
customHeadItems: [
127-
{
128-
tagName: 'link',
129-
attributes: {
130-
rel: 'stylesheet',
131-
href: 'https://example.com/custom.css'
132-
}
133-
},
134-
{
135-
tagName: 'script',
136-
attributes: {
137-
src: 'https://example.com/custom.js',
138-
defer: true
139-
}
140-
},
141-
{
142-
tagName: 'meta',
143-
attributes: {
144-
name: 'theme-color',
145-
content: ' #000000'
146-
}
147-
}
148-
],
149119
customPages:[{
150120
path : '/login2',
151121
component: {
@@ -220,7 +190,7 @@ export const admin = new AdminForth({
220190
dataSources: [
221191
{
222192
id: 'maindb',
223-
url: process.env.DATABASE_URL as string,
193+
url: process.env.DATABASE_URL,
224194
},
225195
{
226196
id: 'pg',
@@ -232,7 +202,7 @@ export const admin = new AdminForth({
232202
},
233203
{
234204
id: 'ch',
235-
url: 'clickhouse://demo:demo@localhost:8124/demo',
205+
url: 'clickhouse://demo:demo@localhost:8125/demo',
236206
},
237207
{
238208
id: 'mysql',
@@ -255,13 +225,6 @@ export const admin = new AdminForth({
255225
translationsResource,
256226
],
257227
menu: [
258-
{
259-
label: 'TablesGroup',
260-
path: '/overview',
261-
homepage: true,
262-
icon: 'flowbite:chart-pie-solid',
263-
component: '@@/GroupTable.vue',
264-
},
265228
{
266229
label: 'Dashboard',
267230
icon: 'flowbite:chart-pie-solid',

dev-demo/package-lock.json

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-demo/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"author": "",
1616
"license": "ISC",
1717
"dependencies": {
18-
"@adminforth/foreign-inline-show": "^1.0.1",
1918
"@prisma/client": "^5.22.0",
2019
"better-sqlite3": "^10.1.0",
2120
"express": "^4.21.0",

dev-demo/resources/apartments.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import AdminForthAdapterLocal from "../../adapters/adminforth-storage-adapter-lo
2020
import AdminForthStorageAdapterLocalFilesystem from "../../adapters/adminforth-storage-adapter-local/index.js";
2121
import AdminForth from "../../adminforth";
2222
import { StorageAdapter } from "../../adminforth";
23-
import ForeignInlineShowPlugin from '@adminforth/foreign-inline-show';
23+
2424

2525
const demoChecker = async ({ record, adminUser, resource }) => {
2626
if (adminUser.dbUser.role !== "superadmin") {
@@ -143,7 +143,7 @@ export default {
143143
list: {
144144
file: "@/renderers/CountryFlag.vue",
145145
meta: {
146-
showCountryName: true,
146+
showCountryName: false,
147147
},
148148
},
149149
edit: {
@@ -245,7 +245,8 @@ export default {
245245
name: "square_meter",
246246
label: "Square",
247247
// allowMinMaxQuery: true,
248-
minValue: 2, // you can set min /max value for number fields
248+
minValue: 1, // you can set min /max value for number fields
249+
maxValue: 100000000,
249250
components: {
250251
list: {
251252
file: "@/renderers/HumanNumber.vue",
@@ -295,6 +296,18 @@ export default {
295296
showIn: {filter: true, show: true, edit: true, list: true, create: true},
296297
foreignResource: {
297298
resourceId: 'users',
299+
hooks: {
300+
dropdownList: {
301+
beforeDatasourceRequest: async ({ adminUser, query }: { adminUser: AdminUser, query: any }) => {
302+
if (adminUser.dbUser.role !== "superadmin") {
303+
query.filtersTools.replaceOrAddTopFilter(Filters.EQ("id", adminUser.dbUser.id));
304+
};
305+
return {
306+
"ok": true,
307+
};
308+
}
309+
},
310+
}
298311
}
299312
},
300313
{
@@ -318,11 +331,8 @@ export default {
318331
plugins: [
319332
...(process.env.AWS_ACCESS_KEY_ID
320333
? [
321-
new ForeignInlineShowPlugin({
322-
foreignResourceId: 'adminuser',
323-
}),
324-
new UploadPlugin({
325-
pathColumnName: "apartment_image",
334+
new UploadPlugin({
335+
pathColumnName: "apartment_image",
326336

327337
storageAdapter: new AdminForthAdapterS3Storage({
328338
region: "eu-central-1",

0 commit comments

Comments
 (0)