This commit is contained in:
James Cole 2017-11-22 21:41:48 +01:00
parent 24b63abf2f
commit 8f80ee25c2
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 13 additions and 2 deletions

View File

@ -170,16 +170,21 @@ class PiggyBankController extends Controller
$subTitle = trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);
$subTitleIcon = 'fa-pencil';
$targetDate = null;
$startDate = null;
$note = $piggyBank->notes()->first();
// Flash some data to fill the form.
if (null !== $piggyBank->targetdate) {
$targetDate = $piggyBank->targetdate->format('Y-m-d');
}
if (null !== $piggyBank->startdate) {
$startDate = $piggyBank->startdate->format('Y-m-d');
}
$preFilled = ['name' => $piggyBank->name,
'account_id' => $piggyBank->account_id,
'targetamount' => $piggyBank->targetamount,
'targetdate' => $targetDate,
'startdate' => $startDate,
'note' => null === $note ? '' : $note->text,
];
Session::flash('preFilled', $preFilled);
@ -390,9 +395,13 @@ class PiggyBankController extends Controller
*/
public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository)
{
$data = $request->getPiggyBankData();
$data = $request->getPiggyBankData();
if (null === $data['startdate']) {
$data['startdate'] = new Carbon;
}
$piggyBank = $repository->store($data);
Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => $piggyBank->name])));
Preferences::mark();

View File

@ -45,7 +45,7 @@ class PiggyBankFormRequest extends Request
{
return [
'name' => $this->string('name'),
'startdate' => new Carbon,
'startdate' => $this->date('startdate'),
'account_id' => $this->integer('account_id'),
'targetamount' => $this->string('targetamount'),
'targetdate' => $this->date('targetdate'),

View File

@ -91,6 +91,7 @@ return [
'deletePermanently' => 'Delete permanently',
'cancel' => 'Cancel',
'targetdate' => 'Target date',
'startdate' => 'Start date',
'tag' => 'Tag',
'under' => 'Under',
'symbol' => 'Symbol',

View File

@ -32,6 +32,7 @@
<h3 class="box-title">{{ 'optionalFields'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.date('startdate') }}
{{ ExpandedForm.date('targetdate') }}
{{ ExpandedForm.textarea('note', null, {helpText: trans('firefly.field_supports_markdown')}) }}
</div>