mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-20 08:30:06 +00:00
Various code cleanup.
This commit is contained in:
@@ -20,31 +20,6 @@ use Session;
|
||||
class ExpandedForm
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function amountSmall(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$options['min'] = '0.01';
|
||||
$defaultCurrency = isset($options['currency']) ? $options['currency'] : Amt::getDefaultCurrency();
|
||||
$currencies = Amt::getAllCurrencies();
|
||||
unset($options['currency']);
|
||||
unset($options['placeholder']);
|
||||
$html = view('form.amount-small', compact('defaultCurrency', 'currencies', 'classes', 'name', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
@@ -70,6 +45,31 @@ class ExpandedForm
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function amountSmall(string $name, $value = null, array $options = []): string
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$options['min'] = '0.01';
|
||||
$defaultCurrency = isset($options['currency']) ? $options['currency'] : Amt::getDefaultCurrency();
|
||||
$currencies = Amt::getAllCurrencies();
|
||||
unset($options['currency']);
|
||||
unset($options['placeholder']);
|
||||
$html = view('form.amount-small', compact('defaultCurrency', 'currencies', 'classes', 'name', 'value', 'options'))->render();
|
||||
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $value
|
||||
@@ -196,17 +196,38 @@ class ExpandedForm
|
||||
* Takes any collection and tries to make a sensible select list compatible array of it.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $set
|
||||
* @param bool $addEmpty
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function makeSelectList(Collection $set, bool $addEmpty = false): array
|
||||
public function makeSelectList(Collection $set): array
|
||||
{
|
||||
$selectList = [];
|
||||
if ($addEmpty) {
|
||||
$selectList[0] = '(none)';
|
||||
$fields = ['title', 'name', 'description'];
|
||||
/** @var Eloquent $entry */
|
||||
foreach ($set as $entry) {
|
||||
$entryId = intval($entry->id);
|
||||
$title = null;
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if (isset($entry->$field) && is_null($title)) {
|
||||
$title = $entry->$field;
|
||||
}
|
||||
}
|
||||
$selectList[$entryId] = $title;
|
||||
}
|
||||
$fields = ['title', 'name', 'description'];
|
||||
|
||||
return $selectList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $set
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function makeSelectListWithEmpty(Collection $set): array
|
||||
{
|
||||
$selectList[0] = '(none)';
|
||||
$fields = ['title', 'name', 'description'];
|
||||
/** @var Eloquent $entry */
|
||||
foreach ($set as $entry) {
|
||||
$entryId = intval($entry->id);
|
||||
|
||||
Reference in New Issue
Block a user