mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-17 23:28:20 +00:00
Make sure that accounts and tags both can handle locations.
This commit is contained in:
@@ -92,18 +92,29 @@ class TagController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.new_tag');
|
||||
$subTitleIcon = 'fa-tag';
|
||||
|
||||
// location info:
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$locations = [
|
||||
'location' => [
|
||||
'latitude' => $hasOldInput ? old('location_latitude') : config('firefly.default_location.latitude'),
|
||||
'longitude' => $hasOldInput ? old('location_longitude') : config('firefly.default_location.longitude'),
|
||||
'zoom_level' => $hasOldInput ? old('location_zoom_level') : config('firefly.default_location.zoom_level'),
|
||||
'has_location' => $hasOldInput ? 'true' === old('location_has_location') : false,
|
||||
],
|
||||
];
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (true !== session('tags.create.fromStore')) {
|
||||
$this->rememberPreviousUri('tags.create.uri');
|
||||
}
|
||||
session()->forget('tags.create.fromStore');
|
||||
|
||||
return view('tags.create', compact('subTitle', 'subTitleIcon'));
|
||||
return view('tags.create', compact('subTitle', 'subTitleIcon', 'locations'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,13 +164,27 @@ class TagController extends Controller
|
||||
$subTitle = (string)trans('firefly.edit_tag', ['tag' => $tag->tag]);
|
||||
$subTitleIcon = 'fa-tag';
|
||||
|
||||
$location = $this->repository->getLocation($tag);
|
||||
$latitude = $location ? $location->latitude : config('firefly.default_location.latitude');
|
||||
$longitude = $location ? $location->longitude : config('firefly.default_location.longitude');
|
||||
$zoomLevel = $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
||||
$hasLocation = null !== $location;
|
||||
$locations = [
|
||||
'location' => [
|
||||
'latitude' => old('location_latitude') ?? $latitude,
|
||||
'longitude' => old('location_longitude') ?? $longitude,
|
||||
'zoom_level' => old('location_zoom_level') ?? $zoomLevel,
|
||||
'has_location' => $hasLocation || 'true' === old('location_has_location'),
|
||||
],
|
||||
];
|
||||
|
||||
// put previous url in session if not redirect from store (not "return_to_edit").
|
||||
if (true !== session('tags.edit.fromUpdate')) {
|
||||
$this->rememberPreviousUri('tags.edit.uri');
|
||||
}
|
||||
session()->forget('tags.edit.fromUpdate');
|
||||
|
||||
return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon'));
|
||||
return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon','locations'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,6 +234,7 @@ class TagController extends Controller
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$start = $start ?? session('start');
|
||||
$end = $end ?? session('end');
|
||||
$location = $this->repository->getLocation($tag);
|
||||
$subTitle = trans(
|
||||
'firefly.journals_in_period_for_tag', ['tag' => $tag->tag, 'start' => $start->formatLocalized($this->monthAndDayFormat),
|
||||
'end' => $end->formatLocalized($this->monthAndDayFormat),]
|
||||
@@ -229,7 +255,7 @@ class TagController extends Controller
|
||||
$groups->setPath($path);
|
||||
$sums = $this->repository->sumsOfTag($tag, $start, $end);
|
||||
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end'));
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end', 'location'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,6 +278,7 @@ class TagController extends Controller
|
||||
$start = $this->repository->firstUseDate($tag) ?? new Carbon;
|
||||
$end = new Carbon;
|
||||
$path = route('tags.show', [$tag->id, 'all']);
|
||||
$location = $this->repository->getLocation($tag);
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setLimit($pageSize)->setPage($page)->withAccountInformation()
|
||||
@@ -260,7 +287,7 @@ class TagController extends Controller
|
||||
$groups->setPath($path);
|
||||
$sums = $this->repository->sumsOfTag($tag, $start, $end);
|
||||
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end'));
|
||||
return view('tags.show', compact('tag', 'sums', 'periods', 'subTitle', 'subTitleIcon', 'groups', 'start', 'end', 'location'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user