mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 00:15:48 +01:00
🐛 Fix categories and wrapper position issues
Co-authored-by: Bjorn Lammers <walkxnl@gmail.com>
This commit is contained in:
@@ -46,13 +46,13 @@ export const useCategoryActions = (configName: string | undefined, category: Cat
|
|||||||
...aboveCategories,
|
...aboveCategories,
|
||||||
category,
|
category,
|
||||||
// Move categories below down
|
// Move categories below down
|
||||||
...belowCategories.map((x) => ({ ...x, position: x.position + 2 })),
|
...belowCategories.map((x) => ({ ...x, position: x.position + 1 })),
|
||||||
],
|
],
|
||||||
wrappers: [
|
wrappers: [
|
||||||
...aboveWrappers,
|
...aboveWrappers,
|
||||||
newWrapper,
|
newWrapper,
|
||||||
// Move wrappers below down
|
// Move wrappers below down
|
||||||
...belowWrappers.map((x) => ({ ...x, position: x.position + 2 })),
|
...belowWrappers.map((x) => ({ ...x, position: x.position + 1 })),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -127,12 +127,12 @@ export const useCategoryActions = (configName: string | undefined, category: Cat
|
|||||||
const currentItem = previous.categories.find((x) => x.id === category.id);
|
const currentItem = previous.categories.find((x) => x.id === category.id);
|
||||||
if (!currentItem) return previous;
|
if (!currentItem) return previous;
|
||||||
|
|
||||||
const upperItem = previous.categories.find((x) => x.position === currentItem.position - 2);
|
const upperItem = previous.categories.find((x) => x.position === currentItem.position - 1);
|
||||||
|
|
||||||
if (!upperItem) return previous;
|
if (!upperItem) return previous;
|
||||||
|
|
||||||
currentItem.position -= 2;
|
currentItem.position -= 1;
|
||||||
upperItem.position += 2;
|
upperItem.position += 1;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...previous,
|
...previous,
|
||||||
@@ -156,12 +156,12 @@ export const useCategoryActions = (configName: string | undefined, category: Cat
|
|||||||
const currentItem = previous.categories.find((x) => x.id === category.id);
|
const currentItem = previous.categories.find((x) => x.id === category.id);
|
||||||
if (!currentItem) return previous;
|
if (!currentItem) return previous;
|
||||||
|
|
||||||
const belowItem = previous.categories.find((x) => x.position === currentItem.position + 2);
|
const belowItem = previous.categories.find((x) => x.position === currentItem.position + 1);
|
||||||
|
|
||||||
if (!belowItem) return previous;
|
if (!belowItem) return previous;
|
||||||
|
|
||||||
currentItem.position += 2;
|
currentItem.position += 1;
|
||||||
belowItem.position -= 2;
|
belowItem.position -= 1;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...previous,
|
...previous,
|
||||||
@@ -196,6 +196,15 @@ export const useCategoryActions = (configName: string | undefined, category: Cat
|
|||||||
x.area = { type: 'wrapper', properties: { id: mainWrapper?.id ?? 'default' } };
|
x.area = { type: 'wrapper', properties: { id: mainWrapper?.id ?? 'default' } };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const widgetsToMove = previous.widgets.filter(
|
||||||
|
(x) => x.area && x.area.type === 'category' && x.area.properties.id === currentItem.id
|
||||||
|
);
|
||||||
|
|
||||||
|
widgetsToMove.forEach((x) => {
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
x.area = { type: 'wrapper', properties: { id: mainWrapper?.id ?? 'default' } };
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...previous,
|
...previous,
|
||||||
apps: previous.apps,
|
apps: previous.apps,
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ const definition = defineWidget({
|
|||||||
options: {},
|
options: {},
|
||||||
|
|
||||||
gridstack: {
|
gridstack: {
|
||||||
minWidth: 6,
|
minWidth: 2,
|
||||||
minHeight: 6,
|
minHeight: 2,
|
||||||
maxWidth: 12,
|
maxWidth: 12,
|
||||||
maxHeight: 6,
|
maxHeight: 6,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user