Remove code no longer used.

This commit is contained in:
James Cole 2016-10-21 21:43:12 +02:00
parent 0dc188b083
commit 0dd7ecbfbe
10 changed files with 0 additions and 332 deletions

View File

@ -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');

View File

@ -1,188 +0,0 @@
<?php
/**
* ExpandedMultiForm.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Support;
use Amount as Amt;
use Carbon\Carbon;
use Illuminate\Support\MessageBag;
use Input;
use RuntimeException;
use Session;
/**
* Class ExpandedMultiForm
*
* @package FireflyIII\Support
*/
class ExpandedMultiForm
{
/**
* @param string $name
* @param int $index
* @param null $value
* @param array $options
*
* @return string
*/
public function amount(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);
$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));
}
}

View File

@ -1,35 +0,0 @@
<?php
/**
* ExpandedMultiForm.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Support\Facades;
use Illuminate\Support\Facades\Facade;
/**
* Class Amount
*
* @package FireflyIII\Support\Facades
*/
class ExpandedMultiForm extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor(): string
{
return 'expandedmultiform';
}
}

View File

@ -267,7 +267,6 @@ return [
'Amount' => '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',

View File

@ -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',

View File

@ -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 <A> 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

View File

@ -1,30 +0,0 @@
<div class="{{ classes }}" id="{{ name }}_{{ index }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
<div class="input-group">
<div class="input-group-btn">
<button type="button"
class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}_{{ index }}" data-toggle="dropdown"
aria-expanded="false">
<span id="currency_select_symbol_{{ name }}_{{ index }}">{{ defaultCurrency.symbol|raw }}</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu currency-dropdown-menu" role="menu">
{% for currency in currencies %}
<li>
<a href="#"
class="multi-currency-option"
data-id="{{ currency.id }}"
data-name="{{ name }}"
data-index="{{ index }}"
data-currency="{{ currency.code }}"
data-symbol="{{ currency.symbol|raw }}">{{ currency.name }}</a></li>
{% endfor %}
</ul>
</div>
{{ Form.input('number', name~'['~index~']', value, options) }}
</div>
{% include 'form.multi.feedback.twig' %}
</div>
<input type="hidden" name="amount_currency_id_{{ name }}_{{ index }}" value="{{ defaultCurrency.id }}"/>
</div>

View File

@ -1,4 +0,0 @@
{% if errors.has(name~'.'~index) %}
<span class="form-control-feedback"><i class="fa fa-fw fa-remove"></i></span>
<p class="text-danger">{{ errors.first(name~'.'~index) }}</p>
{% endif %}

View File

@ -1,10 +0,0 @@
<div class="{{ classes }}" id="{{ name }}_{{ index }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.select(name~'['~index~']', list, selected , options ) }}
{% include 'form.help.twig' %}
{% include 'form.multi.feedback.twig' %}
</div>
</div>

View File

@ -1,9 +0,0 @@
<div class="{{ classes }}" id="{{ name }}_{{ index }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{{ Form.input('text', name~'['~index~']', value, options) }}
{% include 'form/help.twig' %}
{% include 'form.multi.feedback.twig' %}
</div>
</div>