Hi Jargonuat,
I assume at this stage you have a working solution but for anyone else looking for a solution I have devised a neater solution
As we are either moving one position up or one position down, I'm using variables to store the current and new position, then patch the 2 items to be switched with the other items position. Here is the full solution
Gallery Items
Sort(
[YourSource],
[YourOrderColumn]
)
Up Arrow - OnSelect
UpdateContext(
{
varCurrentOrderPos: ThisItem.[YourOrderColumn],
varNewOrderPos: ThisItem.[YourOrderColumn]-1 //current position - 1
}
);
//Increase Order of Previous item by 1
Patch(
[YourSource],
LookUp(
[YourSource],
[YourOrderColumn] = locNumberNewOrderPos
),
{
[YourOrderColumn]: locNumberCurrentOrderPos,
}
);
//Decrease Order of Current Item by 1
Patch(
[YourSource],
ThisItem,
{
[YourOrderColumn]: locNumberNewOrderPos
}
);
Up Arrow - Visible
ThisItem.[YourOrderColumn] > 1 //hide if item is first
Down Arrow - On Select
UpdateContext(
{
varCurrentOrderPos: ThisItem.[YourOrderColumn],
varNewOrderPos: ThisItem.[YourOrderColumn]+1 //current position + 1
}
);
//Decrease Order of Next Item by 1
Patch(
[YourSource],
LookUp(
[YourSource],
[YourOrderColumn] = locNumberNewOrderPos
),
{
[YourOrderColumn]: locNumberCurrentOrderPos,
}
);
//Increase Order of Current Item by 1
Patch(
[YourSource],
ThisItem,
{
[YourOrderColumn]: locNumberNewOrderPos
}
);
Down Arrow - Visible
ThisItem.[YourOrderColumn] < [YourSource].AllItemsCount //Use variable to store total rows to avoid delegation warning