mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-10 12:24:50 +00:00
Fix drag/drop + sort
This commit is contained in:
@@ -71,6 +71,7 @@ class EditController extends Controller
|
||||
'targetamount' => $piggyBank->targetamount,
|
||||
'targetdate' => $targetDate,
|
||||
'startdate' => $startDate,
|
||||
'object_group' => $piggyBank->objectGroups->first() ? $piggyBank->objectGroups->first()->title : '',
|
||||
'notes' => null === $note ? '' : $note->text,
|
||||
];
|
||||
session()->flash('preFilled', $preFilled);
|
||||
|
||||
@@ -132,8 +132,15 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse
|
||||
{
|
||||
$newOrder = (int) $request->get('order');
|
||||
$objectGroupTitle = $request->get('objectGroupTitle');
|
||||
$newOrder = (int) $request->get('order');
|
||||
$this->piggyRepos->setOrder($piggyBank, $newOrder);
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);
|
||||
}
|
||||
if ('' === $objectGroupTitle) {
|
||||
$this->piggyRepos->removeObjectGroup($piggyBank);
|
||||
}
|
||||
|
||||
return response()->json(['data' => 'OK']);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,17 @@ trait ModifiesPiggyBanks
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeObjectGroup(PiggyBank $piggyBank): PiggyBank
|
||||
{
|
||||
$piggyBank->objectGroups()->sync([]);
|
||||
|
||||
return $piggyBank;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param PiggyBankRepetition $repetition
|
||||
* @param string $amount
|
||||
@@ -250,6 +261,22 @@ trait ModifiesPiggyBanks
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setObjectGroup(PiggyBank $piggyBank, string $objectGroupTitle): PiggyBank
|
||||
{
|
||||
$objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);
|
||||
if (null !== $objectGroup) {
|
||||
$piggyBank->objectGroups()->sync([$objectGroup->id]);
|
||||
}
|
||||
|
||||
return $piggyBank;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
|
||||
@@ -393,4 +393,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,21 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface PiggyBankRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param string $objectGroupTitle
|
||||
*
|
||||
* @return PiggyBank
|
||||
*/
|
||||
public function setObjectGroup(PiggyBank $piggyBank, string $objectGroupTitle): PiggyBank;
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return PiggyBank
|
||||
*/
|
||||
public function removeObjectGroup(PiggyBank $piggyBank): PiggyBank;
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param string $amount
|
||||
|
||||
Reference in New Issue
Block a user