Skip to content

Commit

Permalink
Merge branch 'cmsSafe' of github.com:atelier-saulx/based-boilerplate …
Browse files Browse the repository at this point in the history
…into cmsSafe
  • Loading branch information
kylemarch513 committed Dec 14, 2023
2 parents 84ac27f + 02d34e5 commit cf7422c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
5 changes: 1 addition & 4 deletions cms/Schema/SchemaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const SchemaField = ({
setOpenDeleteModal,
setItemToEdit,
id,
metaIndex,
}) => {
const { attributes, listeners, setNodeRef, transform, transition } =
useSortable({ id: id })
Expand Down Expand Up @@ -100,7 +99,7 @@ export const SchemaField = ({
<Badge color={ALL_FIELDS[index]?.color as any} light>
{item.type}
</Badge>
meta index: {metaIndex} --
{/* meta index: {metaIndex} -- */}
{item?.meta?.format && <Badge light>{item.meta.format}</Badge>}
{item?.meta?.contentMediaEncoding && (
<Badge light color="blue">
Expand Down Expand Up @@ -155,8 +154,6 @@ export const SchemaField = ({
{item.type === 'object' &&
!collapsed &&
Object.keys(item.properties).map((key) => {
// console.log('🚒', item.properties[key])

let objItem = item.properties[key]

return (
Expand Down
27 changes: 19 additions & 8 deletions cms/Schema/SchemaFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,46 @@ const parseSchema = (schema, routeType) => {
const indexedArray = [] as SchemaItem[]
const array = [] as unindexedSchemaItem[]
const type = schema.types[routeType as string]?.fields

console.log('indexed array ---->', indexedArray)
console.log('unindex', array)

for (const i in type) {
console.log('🔫 meta', type[i].meta, 'index', type[i].index)
if (type[i].index || type[i].meta.index) {
// console.log('🔫 meta', type[i]?.meta, 'index', type[i]?.index, type[i])
if (type[i].hasOwnProperty('meta')) {
// console.log('REACh 🔥')
indexedArray.push({
name: i,
meta: type[i].meta,
id: i,
type: type[i].type,
label: i,
// index: +type[i].index || type[i].meta.index,
index: type[i].meta.index,
index: type[i]?.meta.index || +i,
// index: type[i].meta.index,
properties: type[i].properties,
})
} else {
} else if (!type[i].index) {
console.log('REACh 🐧')
array.push({
name: i,
meta: type[i].meta,
id: i,
type: type[i].type,
label: i,
// index: +type[i].index || i,
// index: i,
properties: type[i].properties,
})
}
// else {
// console.log('REACH THIS>>> 🫔')
// array.push({ ...type })
// }
}

indexedArray.sort((a, b) => a.meta.index - b.meta.index)

console.log('indexed array ---->', indexedArray)
console.log('unindex', array)

return [...indexedArray, ...array]
}
Expand All @@ -102,7 +114,7 @@ const parseItems = (items, schema, routeType) => {
const type = items[i]
object[type.name] = {
...schemaType[type.name],
// index: +i, // TODO yves: if index works on all fields turn on
index: +i, // TODO yves: if index works on all fields turn on
meta: { ...type.meta, index: +i },
}
}
Expand Down Expand Up @@ -180,7 +192,6 @@ export const SchemaFields = () => {
setOpenEditModal={setOpenEditModal}
setOpenDeleteModal={setOpenDeleteModal}
key={item.id}
metaIndex={item.meta.index}
/>
)
})}
Expand Down

0 comments on commit cf7422c

Please sign in to comment.