diff --git a/app/config/app.php b/app/config/app.php index 85182e8c8e..87816af984 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -37,8 +37,8 @@ return [ 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Illuminate\Workbench\WorkbenchServiceProvider', - 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', - 'Barryvdh\Debugbar\ServiceProvider', + # 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', + # 'Barryvdh\Debugbar\ServiceProvider', 'Firefly\Storage\StorageServiceProvider', 'Firefly\Helper\HelperServiceProvider', 'Firefly\Validation\ValidationServiceProvider', diff --git a/app/controllers/RecurringController.php b/app/controllers/RecurringController.php index 146a52d77c..599c7563a6 100644 --- a/app/controllers/RecurringController.php +++ b/app/controllers/RecurringController.php @@ -19,8 +19,8 @@ class RecurringController extends BaseController { $this->_repository = $repository; - View::share('title','Recurring transactions'); - View::share('mainTitleIcon','fa-rotate-right'); + View::share('title', 'Recurring transactions'); + View::share('mainTitleIcon', 'fa-rotate-right'); } /** @@ -28,7 +28,7 @@ class RecurringController extends BaseController */ public function create() { - View::share('subTitle','Create new'); + View::share('subTitle', 'Create new'); $periods = \Config::get('firefly.periods_to_text'); return View::make('recurring.create')->with('periods', $periods); @@ -41,7 +41,7 @@ class RecurringController extends BaseController */ public function delete(RecurringTransaction $recurringTransaction) { - View::share('subTitle','Delete "' .$recurringTransaction->name.'"'); + View::share('subTitle', 'Delete "' . $recurringTransaction->name . '"'); return View::make('recurring.delete')->with('recurringTransaction', $recurringTransaction); } @@ -73,7 +73,7 @@ class RecurringController extends BaseController { $periods = \Config::get('firefly.periods_to_text'); - View::share('subTitle','Edit "' .$recurringTransaction->name.'"'); + View::share('subTitle', 'Edit "' . $recurringTransaction->name . '"'); return View::make('recurring.edit')->with('periods', $periods)->with( 'recurringTransaction', $recurringTransaction @@ -93,14 +93,11 @@ class RecurringController extends BaseController */ public function show(RecurringTransaction $recurringTransaction) { - View::share('subTitle',$recurringTransaction->name); + View::share('subTitle', $recurringTransaction->name); return View::make('recurring.show')->with('recurring', $recurringTransaction); } - /** - * @return $this|\Illuminate\Http\RedirectResponse - */ public function store() { @@ -108,25 +105,54 @@ class RecurringController extends BaseController default: throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.'); break; + case 'store': + case 'create_another': + /* + * Try to store: + */ + $messageBag = $this->_repository->store(Input::all()); + + /* + * Failure! + */ + if ($messageBag->count() > 0) { + Session::flash('error', 'Could not save recurring transaction: ' . $messageBag->first()); + return Redirect::route('recurring.create')->withInput()->withErrors($messageBag); + } + + /* + * Success! + */ + Session::flash('success', 'Recurring transaction "' . e(Input::get('name')) . '" saved!'); + + /* + * Redirect to original location or back to the form. + */ + if (Input::get('post_submit_action') == 'create_another') { + return Redirect::route('recurring.create')->withInput(); + } else { + return Redirect::route('recurring.index'); + } + break; } - $recurringTransaction = $this->_repository->store(Input::all()); - - if ($recurringTransaction->errors()->count() == 0) { - Session::flash('success', 'Recurring transaction "' . $recurringTransaction->name . '" saved!'); - //Event::fire('recurring.store', [$recurringTransaction]); - if (Input::get('create') == '1') { - return Redirect::route('recurring.create')->withInput(); - } else { - return Redirect::route('recurring.index'); - } - } else { - Session::flash( - 'error', 'Could not save the recurring transaction: ' . $recurringTransaction->errors()->first() - ); - - return Redirect::route('recurring.create')->withInput()->withErrors($recurringTransaction->errors()); - } +// +// +// if ($recurringTransaction->errors()->count() == 0) { +// Session::flash('success', 'Recurring transaction "' . $recurringTransaction->name . '" saved!'); +// //Event::fire('recurring.store', [$recurringTransaction]); +// if (Input::get('create') == '1') { +// return Redirect::route('recurring.create')->withInput(); +// } else { +// return Redirect::route('recurring.index'); +// } +// } else { +// Session::flash( +// 'error', 'Could not save the recurring transaction: ' . $recurringTransaction->errors()->first() +// ); +// +// return Redirect::route('recurring.create')->withInput()->withErrors($recurringTransaction->errors()); +// } } /** diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php index 53d7546c85..cbe56bd115 100644 --- a/app/controllers/TransactionController.php +++ b/app/controllers/TransactionController.php @@ -67,19 +67,9 @@ class TransactionController extends BaseController $piggies = $toolkit->makeSelectList($piggyRepository->get()); $piggies[0] = '(no piggy bank)'; - /* - * Catch messages from validation round: - */ - if (Session::has('messages')) { - $messages = Session::get('messages'); - Session::forget('messages'); - } else { - $messages = new MessageBag; - } - return View::make('transactions.create')->with('accounts', $assetAccounts)->with('budgets', $budgets)->with( 'what', $what - )->with('piggies', $piggies)->with('subTitle', 'Add a new ' . $what)->with('messages', $messages); + )->with('piggies', $piggies)->with('subTitle', 'Add a new ' . $what); } /** diff --git a/app/lib/Firefly/Form/Form.php b/app/lib/Firefly/Form/Form.php index bbe8f3f4b4..5def4eaaf1 100644 --- a/app/lib/Firefly/Form/Form.php +++ b/app/lib/Firefly/Form/Form.php @@ -16,19 +16,52 @@ class Form * @return string * @throws FireflyException */ - public static function ffNumber($name, $value = null, array $options = []) + public static function ffInteger($name, $value = null, array $options = []) { - $options['step'] = 'any'; - $options['min'] = '0.01'; + $options['step'] = '1'; return self::ffInput('number', $name, $value, $options); } + public static function ffCheckbox($name, $value = 1, $checked = null, $options = []) + { + $options['checked'] = $checked ? true : null; + return self::ffInput('checkbox', $name, $value, $options); + } + + public static function ffAmount($name, $value = null, array $options = []) + { + $options['step'] = 'any'; + $options['min'] = '0.01'; + return self::ffInput('amount', $name, $value, $options); + + } + + /** + * @param $name + * @param null $value + * @param array $options + * @return string + * @throws FireflyException + */ public static function ffDate($name, $value = null, array $options = []) { return self::ffInput('date', $name, $value, $options); } + /** + * @param $name + * @param null $value + * @param array $options + * @return string + * @throws FireflyException + */ + public static function ffTags($name, $value = null, array $options = []) + { + $options['data-role'] = 'tagsinput'; + return self::ffInput('text', $name, $value, $options); + } + /** * @param $name * @param array $list @@ -55,6 +88,22 @@ class Form } + public static function label($name) + { + $labels = [ + 'amount_min' => 'Amount (min)', + 'amount_max' => 'Amount (max)', + 'match' => 'Matches on', + 'repeat_freq' => 'Repetition', + 'account_from_id' => 'Account from', + 'account_to_id' => 'Account to', + 'account_id' => 'Asset account' + ]; + + return isset($labels[$name]) ? $labels[$name] : str_replace('_',' ',ucfirst($name)); + + } + /** * @param $type * @param $name @@ -72,18 +121,11 @@ class Form $options['class'] = 'form-control'; $options['id'] = 'ffInput_' . $name; $options['autocomplete'] = 'off'; - $options['type'] = 'text'; - + $label = self::label($name); /* * Make label and placeholder look nice. */ - $options['placeholder'] = isset($options['label']) ? $options['label'] : ucfirst($name); - $options['label'] = isset($options['label']) ? $options['label'] : ucfirst($name); - if ($name == 'account_id') { - $options['label'] = 'Asset account'; - } - $options['label'] = str_replace(['_'], [' '], $options['label']); - $options['placeholder'] = str_replace(['_'], [' '], $options['placeholder']); + $options['placeholder'] = ucfirst($name); /* * Get the value. @@ -129,7 +171,6 @@ class Form /* * Add some HTML. */ - $label = isset($options['label']) ? $options['label'] : ucfirst($name); $html = '
{{$errors->first('name')}}
- @endif -{{$errors->first('match')}}
- @endif -{{$errors->first('amount_min')}}
- @endif -{{$errors->first('amount_max')}}
- @endif -{{$errors->first('date')}}
- @endif -{{$errors->first('repeat_freq')}}
- @endif -@@ -93,43 +31,9 @@ Optional fields
{{$errors->first('skip')}}
- @else - Make Firefly skip every n times. Fill in2
, and Firefly
- will match, skip, skip and match a transaction.
- @endif
-