mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
🐛 Automatic positions for wrappers and categories
This commit is contained in:
@@ -38,29 +38,27 @@ export const AvailableElementTypes = ({
|
||||
category: {
|
||||
id: uuidv4(),
|
||||
name: 'New category',
|
||||
position: 0,
|
||||
position: 0, // doesn't matter, is being overwritten
|
||||
},
|
||||
onSuccess: async (category) => {
|
||||
if (!configName) return;
|
||||
|
||||
await updateConfig(configName, (previousConfig) => ({
|
||||
...previousConfig,
|
||||
wrappers:
|
||||
previousConfig.wrappers.length <= previousConfig.categories.length
|
||||
? [
|
||||
wrappers: [
|
||||
...previousConfig.wrappers,
|
||||
{
|
||||
id: uuidv4(),
|
||||
position: previousConfig.categories.length,
|
||||
// Thank you ChatGPT ;)
|
||||
position: previousConfig.categories.length + 1,
|
||||
},
|
||||
]
|
||||
: previousConfig.wrappers,
|
||||
],
|
||||
categories: [
|
||||
...previousConfig.categories,
|
||||
{
|
||||
id: uuidv4(),
|
||||
name: category.name,
|
||||
position: previousConfig.categories.length,
|
||||
position: previousConfig.categories.length + 1,
|
||||
},
|
||||
],
|
||||
})).then(() => {
|
||||
|
||||
Reference in New Issue
Block a user