From 0dd7ecbfbe45c926081e33da6ba6e7d195d5c3be Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 21 Oct 2016 21:43:12 +0200 Subject: [PATCH] Remove code no longer used. --- app/Providers/FireflyServiceProvider.php | 6 - app/Support/ExpandedMultiForm.php | 188 ---------------------- app/Support/Facades/ExpandedMultiForm.php | 35 ---- config/app.php | 1 - config/twigbridge.php | 5 - public/js/ff/firefly.js | 44 ----- resources/views/form/multi/amount.twig | 30 ---- resources/views/form/multi/feedback.twig | 4 - resources/views/form/multi/select.twig | 10 -- resources/views/form/multi/text.twig | 9 -- 10 files changed, 332 deletions(-) delete mode 100644 app/Support/ExpandedMultiForm.php delete mode 100644 app/Support/Facades/ExpandedMultiForm.php delete mode 100644 resources/views/form/multi/amount.twig delete mode 100644 resources/views/form/multi/feedback.twig delete mode 100644 resources/views/form/multi/select.twig delete mode 100644 resources/views/form/multi/text.twig diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index e8a9d8c592..b1530b08ca 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -15,7 +15,6 @@ namespace FireflyIII\Providers; use FireflyIII\Support\Amount; use FireflyIII\Support\ExpandedForm; -use FireflyIII\Support\ExpandedMultiForm; use FireflyIII\Support\FireflyConfig; use FireflyIII\Support\Navigation; use FireflyIII\Support\Preferences; @@ -93,11 +92,6 @@ class FireflyServiceProvider extends ServiceProvider return new ExpandedForm; } ); - $this->app->bind( - 'expandedmultiform', function () { - return new ExpandedMultiForm; - } - ); $this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository'); $this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search'); diff --git a/app/Support/ExpandedMultiForm.php b/app/Support/ExpandedMultiForm.php deleted file mode 100644 index e8340c7b9b..0000000000 --- a/app/Support/ExpandedMultiForm.php +++ /dev/null @@ -1,188 +0,0 @@ -label($name, $options); - $options = $this->expandOptionArray($name, $index, $label, $options); - $classes = $this->getHolderClasses($name, $index); - $value = $this->fillFieldValue($name, $index, $value); - $options['step'] = 'any'; - $options['min'] = '0.01'; - $defaultCurrency = isset($options['currency']) ? $options['currency'] : Amt::getDefaultCurrency(); - $currencies = Amt::getAllCurrencies(); - $options['data-hiddenfield'] = 'amount_currency_id_' . $name . '_' . $index; - unset($options['currency']); - unset($options['placeholder']); - $html = view('form.multi.amount', compact('defaultCurrency', 'index', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render(); - - return $html; - - } - - /** - * @param string $name - * @param int $index - * @param array $list - * @param null $selected - * @param array $options - * - * @return string - */ - public function select(string $name, int $index, array $list = [], $selected = null, array $options = []): string - { - $label = $this->label($name, $options); - $options = $this->expandOptionArray($name, $index, $label, $options); - $classes = $this->getHolderClasses($name, $index); - $selected = $this->fillFieldValue($name, $index, $selected); - unset($options['autocomplete']); - unset($options['placeholder']); - $html = view('form.multi.select', compact('classes', 'index', 'name', 'label', 'selected', 'options', 'list'))->render(); - - return $html; - } - - /** - * @param string $name - * @param int $index - * @param null $value - * @param array $options - * - * @return string - */ - public function text(string $name, int $index, $value = null, array $options = []): string - { - $label = $this->label($name, $options); - $options = $this->expandOptionArray($name, $index, $label, $options); - $classes = $this->getHolderClasses($name, $index); - $value = $this->fillFieldValue($name, $index, $value); - $html = view('form.multi.text', compact('classes', 'name', 'index', 'label', 'value', 'options'))->render(); - - return $html; - - } - - /** - * @param string $name - * @param int $index - * @param string $label - * @param array $options - * - * @return array - */ - protected function expandOptionArray(string $name, int $index, string $label, array $options): array - { - $options['class'] = 'form-control'; - $options['id'] = 'ffInput_' . $name . '_' . $index; - $options['autocomplete'] = 'off'; - $options['placeholder'] = ucfirst($label); - - return $options; - } - - /** - * @param string $name - * @param int $index - * @param $value - * - * @return mixed - */ - protected function fillFieldValue(string $name, int $index, $value) - { - if (Session::has('preFilled')) { - $preFilled = session('preFilled'); - $value = isset($preFilled[$name][$index]) && is_null($value) ? $preFilled[$name][$index] : $value; - } - try { - if (!is_null(Input::old($name)[$index])) { - $value = Input::old($name)[$index]; - } - } catch (RuntimeException $e) { - // don't care about session errors. - } - if ($value instanceof Carbon) { - $value = $value->format('Y-m-d'); - } - - - return $value; - } - - /** - * @param string $name - * @param int $index - * - * @return string - */ - protected function getHolderClasses(string $name, int $index): string - { - /* - * Get errors from session: - */ - /** @var MessageBag $errors */ - $errors = session('errors'); - $classes = 'form-group'; - $set = []; - - if (!is_null($errors)) { - $set = $errors->get($name . '.' . $index); - } - - if (!is_null($errors) && count($set) > 0) { - $classes = 'form-group has-error has-feedback'; - } - - return $classes; - } - - /** - * @param string $name - * @param array $options - * - * @return string - */ - protected function label(string $name, array $options): string - { - if (isset($options['label'])) { - return $options['label']; - } - - return strval(trans('form.' . $name)); - - } -} \ No newline at end of file diff --git a/app/Support/Facades/ExpandedMultiForm.php b/app/Support/Facades/ExpandedMultiForm.php deleted file mode 100644 index 064f3bb305..0000000000 --- a/app/Support/Facades/ExpandedMultiForm.php +++ /dev/null @@ -1,35 +0,0 @@ - 'FireflyIII\Support\Facades\Amount', 'Steam' => 'FireflyIII\Support\Facades\Steam', 'ExpandedForm' => 'FireflyIII\Support\Facades\ExpandedForm', - 'ExpandedMultiForm' => 'FireflyIII\Support\Facades\ExpandedMultiForm', 'Entrust' => 'Zizaco\Entrust\EntrustFacade', 'Input' => 'Illuminate\Support\Facades\Input', 'Google2FA' => 'PragmaRX\Google2FA\Vendor\Laravel\Facade', diff --git a/config/twigbridge.php b/config/twigbridge.php index 5a4822e22f..886f44d6e1 100644 --- a/config/twigbridge.php +++ b/config/twigbridge.php @@ -162,11 +162,6 @@ return [ 'multiRadio', 'file', 'multiCheckbox', 'staticText', 'amountSmall', ], ], - 'ExpandedMultiForm' => [ - 'is_safe' => [ - 'text','select','amount' - ], - ], 'Form' => [ 'is_safe' => [ 'input', 'select', 'checkbox', 'model', 'open', 'radio', 'textarea', 'file', diff --git a/public/js/ff/firefly.js b/public/js/ff/firefly.js index b3e4b7bf93..d63eddbcc3 100644 --- a/public/js/ff/firefly.js +++ b/public/js/ff/firefly.js @@ -5,9 +5,6 @@ $(function () { // when you click on a currency, this happens: $('.currency-option').click(currencySelect); - // when you click on a multi currency, this happens: - $('.multi-currency-option').click(multiCurrencySelect); - var ranges = {}; ranges[dateRangeConfig.currentPeriod] = [moment(dateRangeConfig.ranges.current[0]), moment(dateRangeConfig.ranges.current[1])]; ranges[dateRangeConfig.previousPeriod] = [moment(dateRangeConfig.ranges.previous[0]), moment(dateRangeConfig.ranges.previous[1])]; @@ -60,47 +57,6 @@ $(function () { }); -function multiCurrencySelect(e) { - "use strict"; - // clicked on - var target = $(e.target); // target is the tag. - - // name of the field in question: - var name = target.data('name'); - - // index of the field in question: - var index = target.data('index'); - console.log('name is ' + name + ':' + index); - - // id of menu button (used later on): - var menuID = 'currency_dropdown_' + name + '_' + index; - - // the hidden input with the actual value of the selected currency: - var hiddenInputName = 'amount_currency_id_' + name + '_' + index; - console.log('Looking for hidden input: ' + hiddenInputName); - - // span with the current selection (next to the caret): - var spanId = 'currency_select_symbol_' + name + '_' + index; - - // the selected currency symbol: - var symbol = target.data('symbol'); - - // id of the selected currency. - var id = target.data('id'); - - // update the hidden input: - $('input[name="' + hiddenInputName + '"]').val(id); - - // update the symbol: - $('#' + spanId).text(symbol); - - // close the menu (hack hack) - $('#' + menuID).click(); - - - return false; -} - function currencySelect(e) { "use strict"; // clicked on diff --git a/resources/views/form/multi/amount.twig b/resources/views/form/multi/amount.twig deleted file mode 100644 index 4e6fc1590f..0000000000 --- a/resources/views/form/multi/amount.twig +++ /dev/null @@ -1,30 +0,0 @@ -
- -
-
- - {{ Form.input('number', name~'['~index~']', value, options) }} -
- {% include 'form.multi.feedback.twig' %} -
- - -
diff --git a/resources/views/form/multi/feedback.twig b/resources/views/form/multi/feedback.twig deleted file mode 100644 index 92c00d26d9..0000000000 --- a/resources/views/form/multi/feedback.twig +++ /dev/null @@ -1,4 +0,0 @@ -{% if errors.has(name~'.'~index) %} - -

{{ errors.first(name~'.'~index) }}

-{% endif %} diff --git a/resources/views/form/multi/select.twig b/resources/views/form/multi/select.twig deleted file mode 100644 index 1c6d81b31a..0000000000 --- a/resources/views/form/multi/select.twig +++ /dev/null @@ -1,10 +0,0 @@ -
- - -
- {{ Form.select(name~'['~index~']', list, selected , options ) }} - {% include 'form.help.twig' %} - {% include 'form.multi.feedback.twig' %} - -
-
diff --git a/resources/views/form/multi/text.twig b/resources/views/form/multi/text.twig deleted file mode 100644 index 5f0b154fbd..0000000000 --- a/resources/views/form/multi/text.twig +++ /dev/null @@ -1,9 +0,0 @@ -
- - -
- {{ Form.input('text', name~'['~index~']', value, options) }} - {% include 'form/help.twig' %} - {% include 'form.multi.feedback.twig' %} -
-