Skip to content

Commit 51fdc09

Browse files
committed
Various fixes
1 parent 4abba72 commit 51fdc09

File tree

2 files changed

+607
-682
lines changed

2 files changed

+607
-682
lines changed

src/lib/diagram.ts

+28-17
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ const viewSystemAttributes = [
4545
{ name: 'id', type: 'string', required: false, isRelation: false, options: {} }
4646
];
4747

48+
const viewSystemAttributeNames = viewSystemAttributes.map((attr) => attr.name);
49+
4850
const collectionSystemAttributes = viewSystemAttributes.concat([
49-
{ name: 'created', type: 'date', required: false, isRelation: false, options: {} },
50-
{ name: 'updated', type: 'date', required: false, isRelation: false, options: {} }
51+
{ name: 'created', type: 'autodate', required: false, isRelation: false, options: {} },
52+
{ name: 'updated', type: 'autodate', required: false, isRelation: false, options: {} }
5153
]);
5254

55+
const collectionSystemAttributeNames = collectionSystemAttributes.map((attr) => attr.name);
56+
5357
export async function loadPocketbaseCollections(connection: Connection | undefined) {
5458
if (!connection) throw new Error('Missing connection parameters');
5559
const { url, email, password } = connection;
@@ -87,21 +91,28 @@ export function generateMarkup(
8791
: [])
8892
];
8993
attributes = attributes.concat(
90-
fields.map((field) => ({
91-
name: field.name,
92-
type: field.type,
93-
options: {
94-
min: field.min,
95-
max: field.max,
96-
minSelect: field.minSelect,
97-
maxSelect: field.maxSelect,
98-
cascadeDelete: field.cascadeDelete,
99-
collectionId: field.collectionId,
100-
values: field.values
101-
} as AttributeOptions,
102-
required: field.required,
103-
isRelation: field.type === 'relation'
104-
}))
94+
fields
95+
.filter(
96+
({ name }) =>
97+
!($isView
98+
? viewSystemAttributeNames.includes(name)
99+
: collectionSystemAttributeNames.includes(name))
100+
)
101+
.map((field) => ({
102+
name: field.name,
103+
type: field.type,
104+
options: {
105+
min: field.min,
106+
max: field.max,
107+
minSelect: field.minSelect,
108+
maxSelect: field.maxSelect,
109+
cascadeDelete: field.cascadeDelete,
110+
collectionId: field.collectionId,
111+
values: field.values
112+
} as AttributeOptions,
113+
required: field.required,
114+
isRelation: field.type === 'relation'
115+
}))
105116
);
106117

107118
return [id, { id: sanitizeId(id), name, attributes, isView: $isView }];

0 commit comments

Comments
 (0)