This commit is contained in:
James Cole 2019-01-27 17:02:45 +01:00
parent 74ff17da7e
commit e6ff895eff
8 changed files with 30 additions and 26 deletions

View File

@ -58,20 +58,19 @@ class TagFactory
{
$zoomLevel = 0 === (int)$data['zoom_level'] ? null : (int)$data['zoom_level'];
$latitude = 0.0 === (float)$data['latitude'] ? null : (float)$data['latitude'];
$longitude = 0.0 === (float)$data['longitude'] ? null : (int)$data['longitude'];
$longitude = 0.0 === (float)$data['longitude'] ? null : (float)$data['longitude'];
$array = [
'user_id' => $this->user->id,
'tag' => trim($data['tag']),
'tagMode' => 'nothing',
'date' => $data['date'],
'description' => $data['description'],
'latitude' => $latitude,
'longitude' => $longitude,
'zoomLevel' => $zoomLevel,
];
return Tag::create(
[
'user_id' => $this->user->id,
'tag' => trim($data['tag']),
'tagMode' => 'nothing',
'date' => $data['date'],
'description' => $data['description'],
'latitude' => $latitude,
'longitude ' => $longitude,
'zoomLevel' => $zoomLevel,
]
);
return Tag::create($array);
}
/**

View File

@ -33,6 +33,7 @@ use FireflyIII\Support\Http\Controllers\PeriodOverview;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Log;
/**
* Class TagController.
@ -250,7 +251,10 @@ class TagController extends Controller
public function store(TagFormRequest $request): RedirectResponse
{
$data = $request->collectTagData();
$this->repository->store($data);
Log::debug('Data from request', $data);
$result = $this->repository->store($data);
Log::debug('Data after storage', $result->toArray());
session()->flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']]));
app('preferences')->mark();

View File

@ -40,8 +40,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $id
* @property \Carbon\Carbon $date
* @property int zoomLevel
* @property float longitude
* @property float latitude
* @property float longitude
* @property string description
* @property string amount_sum
* @property string tagMode
@ -64,9 +64,11 @@ class Tag extends Model
'deleted_at' => 'datetime',
'date' => 'date',
'zoomLevel' => 'int',
'latitude' => 'float',
'longitude' => 'float',
];
/** @var array Fields that can be filled */
protected $fillable = ['user_id', 'tag', 'date', 'description', 'longitude', 'latitude', 'zoomLevel', 'tagMode'];
protected $fillable = ['user_id', 'tag', 'date', 'description', 'latitude', 'longitude', 'zoomLevel', 'tagMode'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).

View File

@ -253,10 +253,9 @@ class TagRepository implements TagRepositoryInterface
public function store(array $data): Tag
{
/** @var TagFactory $factory */
$factory = new TagFactory;
$factory = app(TagFactory::class);
$factory->setUser($this->user);
return $factory->create($data);
}
/**

View File

@ -1,7 +1,7 @@
<div class="{{ classes }}" id="{{ name }}_holder">
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
<div class="col-sm-8">
{% if env('MAPBOX_API_KEY','') == '' %}
{% if config('firefly.mapbox_api_key') == '' %}
<p class="text-danger">
{{ trans('firefly.mapbox_api_key')|raw }}
</p>
@ -42,7 +42,7 @@
</div>
</div>
{% if env('MAPBOX_API_KEY','') != '' %}
{% if config('firefly.mapbox_api_key') != '' %}
{% set latitudevar = name~'_latitude' %}
{% set longitudevar = name~'_longitude' %}
{% set zoomlevelvar = name~'_zoomlevel' %}

View File

@ -85,13 +85,13 @@
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
</script>
<script src="lib/leaflet/leaflet.js?v={{ FF_VERSION }}"></script>
<script src="v1/lib/leaflet/leaflet.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script>
<script src="v1/js/ff/tags/create-edit.js?v={{ FF_VERSION }}"></script>
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
<link rel="stylesheet" href="v1/lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
{% endblock %}

View File

@ -89,13 +89,13 @@
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
</script>
<script src="lib/leaflet/leaflet.js?v={{ FF_VERSION }}"></script>
<script src="v1/lib/leaflet/leaflet.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script>
<script src="v1/js/ff/tags/create-edit.js?v={{ FF_VERSION }}"></script>
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
<link rel="stylesheet" href="v1/lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
<link href="v1/css/jquery-ui/jquery-ui.structure.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
<link href="v1/css/jquery-ui/jquery-ui.theme.min.css?v={{ FF_VERSION }}" type="text/css" rel="stylesheet" media="all">
{% endblock %}

View File

@ -168,7 +168,7 @@
{% endblock %}
{% block styles %}
<link rel="stylesheet" href="lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
<link rel="stylesheet" href="v1/lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
{% endblock %}
{% block scripts %}
<script type="text/javascript">
@ -186,7 +186,7 @@
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
</script>
<script src="lib/leaflet/leaflet.js?v={{ FF_VERSION }}"></script>
<script src="v1/lib/leaflet/leaflet.js?v={{ FF_VERSION }}"></script>
<script src="v1/js/ff/tags/show.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/ff/transactions/list.js?v={{ FF_VERSION }}"></script>
{% endblock %}