mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-23 23:50:09 -06:00
Can edit and set location for accounts.
This commit is contained in:
parent
71f2cacdbd
commit
54b049e106
@ -79,6 +79,15 @@ class CreateController extends Controller
|
||||
$subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));
|
||||
$roles = $this->getRoles();
|
||||
$liabilityTypes = $this->getLiabilityTypes();
|
||||
$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,
|
||||
],
|
||||
];
|
||||
|
||||
// interest calculation periods:
|
||||
$interestPeriods = [
|
||||
@ -88,7 +97,6 @@ class CreateController extends Controller
|
||||
];
|
||||
|
||||
// pre fill some data
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$request->session()->flash(
|
||||
'preFilled', [
|
||||
'currency_id' => $defaultCurrency->id,
|
||||
@ -103,7 +111,7 @@ class CreateController extends Controller
|
||||
$request->session()->forget('accounts.create.fromStore');
|
||||
Log::channel('audit')->info('Creating new account.');
|
||||
|
||||
return view('accounts.create', compact('subTitleIcon', 'objectType', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
|
||||
return view('accounts.create', compact('subTitleIcon', 'locations', 'objectType', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +123,6 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function store(AccountFormRequest $request)
|
||||
{
|
||||
|
||||
$data = $request->getAccountData();
|
||||
$account = $this->repository->store($data);
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));
|
||||
|
@ -87,6 +87,19 @@ class EditController extends Controller
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));
|
||||
$roles = $this->getRoles();
|
||||
$liabilityTypes = $this->getLiabilityTypes();
|
||||
$location = $repository->getLocation($account);
|
||||
$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'),
|
||||
],
|
||||
];
|
||||
|
||||
// interest calculation periods:
|
||||
$interestPeriods = [
|
||||
@ -132,7 +145,9 @@ class EditController extends Controller
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
return view(
|
||||
'accounts.edit', compact('account', 'currency', 'subTitle', 'subTitleIcon', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods')
|
||||
'accounts.edit', compact(
|
||||
'account', 'currency', 'subTitle', 'subTitleIcon', 'locations', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,7 @@ class IndexController extends Controller
|
||||
$account->interest = round($this->repository->getMetaValue($account, 'interest'), 6);
|
||||
$account->interestPeriod = (string)trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->location = $this->repository->getLocation($account);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -99,7 +99,7 @@ class ShowController extends Controller
|
||||
if ($end < $start) {
|
||||
[$start, $end] = [$end, $start]; // @codeCoverageIgnore
|
||||
}
|
||||
$location = $account->locations()->first();
|
||||
$location = $this->repository->getLocation($account);
|
||||
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
||||
$today = new Carbon;
|
||||
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
|
||||
@ -147,6 +147,7 @@ class ShowController extends Controller
|
||||
return $this->redirectAccountToAccount($account); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$location = $this->repository->getLocation($account);
|
||||
$isLiability = $this->repository->isLiability($account);
|
||||
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
|
||||
$end = new Carbon;
|
||||
@ -168,8 +169,10 @@ class ShowController extends Controller
|
||||
|
||||
return view(
|
||||
'accounts.show',
|
||||
compact('account', 'showAll', 'objectType', 'isLiability', 'currency', 'today',
|
||||
'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end')
|
||||
compact(
|
||||
'account', 'showAll', 'location', 'objectType', 'isLiability', 'currency', 'today',
|
||||
'chartUri', 'periods', 'subTitleIcon', 'groups', 'subTitle', 'start', 'end'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,8 @@ class AccountFormRequest extends Request
|
||||
// new: location
|
||||
'longitude' => $this->float('location_longitude'),
|
||||
'latitude' => $this->float('location_latitude'),
|
||||
'zoom_level' => $this->integer('location_zoomlevel'),
|
||||
'has_location' => $this->boolean('location_has_tag'),
|
||||
'zoom_level' => $this->integer('location_zoom_level'),
|
||||
'has_location' => $this->boolean('location_has_location'),
|
||||
];
|
||||
if (false === $this->boolean('include_net_worth')) {
|
||||
$data['include_net_worth'] = '0';
|
||||
|
@ -27,6 +27,7 @@ use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@ -91,7 +92,18 @@ class Tag extends Model
|
||||
'longitude' => 'float',
|
||||
];
|
||||
/** @var array Fields that can be filled */
|
||||
protected $fillable = ['user_id', 'tag', 'date', 'description', 'latitude', 'longitude', 'zoomLevel', 'tagMode'];
|
||||
protected $fillable = ['user_id', 'tag', 'date', 'description'];
|
||||
|
||||
protected $hidden = ['zoomLevel', 'latitude', 'longitude'];
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function locations(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Location::class, 'locatable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Route binder. Converts the key in the URL to the specified object (or throw 404).
|
||||
|
@ -28,6 +28,7 @@ use FireflyIII\Factory\AccountFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@ -634,4 +635,12 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
return $query->get(['accounts.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLocation(Account $account): ?Location
|
||||
{
|
||||
return $account->locations()->first();
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Repositories\Account;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@ -46,6 +47,15 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function count(array $types): int;
|
||||
|
||||
/**
|
||||
* Get account location, if any.
|
||||
*
|
||||
* @param Account $account
|
||||
*
|
||||
* @return Location|null
|
||||
*/
|
||||
public function getLocation(Account $account): ?Location;
|
||||
|
||||
/**
|
||||
* Moved here from account CRUD.
|
||||
*
|
||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Location;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Support\AccountServiceTrait;
|
||||
use FireflyIII\User;
|
||||
@ -99,6 +100,23 @@ class AccountUpdateService
|
||||
// update all meta data:
|
||||
$this->updateMetaData($account, $data);
|
||||
|
||||
// update, delete or create location:
|
||||
$hasLocation = $data['has_location'] ?? false;
|
||||
if (false === $hasLocation) {
|
||||
$account->locations()->delete();
|
||||
}
|
||||
if (true === $hasLocation) {
|
||||
$location = $this->accountRepository->getLocation($account);
|
||||
if (null === $location) {
|
||||
$location = new Location;
|
||||
$location->locatable()->associate($account);
|
||||
}
|
||||
$location->latitude = $data['latitude'] ?? config('firefly.default_location.latitude');
|
||||
$location->longitude = $data['longitude'] ?? config('firefly.default_location.longitude');
|
||||
$location->zoom_level = $data['zoom_level'] ?? config('firefly.default_location.zoom_level');
|
||||
$location->save();
|
||||
}
|
||||
|
||||
// has valid initial balance (IB) data?
|
||||
$type = $account->accountType;
|
||||
// if it can have a virtual balance, it can also have an opening balance.
|
||||
|
@ -157,6 +157,11 @@ return [
|
||||
'login_provider' => envNonEmpty('LOGIN_PROVIDER', 'eloquent'),
|
||||
'cer_provider' => envNonEmpty('CER_PROVIDER', 'fixer'),
|
||||
'update_endpoint' => 'https://version.firefly-iii.org/index.json',
|
||||
'default_location' => [
|
||||
'longitude' => env('MAP_DEFAULT_LONG', '5.916667'),
|
||||
'latitude' => env('MAP_DEFAULT_LAT', '51.983333'),
|
||||
'zoom_level' => env('MAP_DEFAULT_ZOOM', '6'),
|
||||
],
|
||||
'allowedMimes' => [
|
||||
/* plain files */
|
||||
'text/plain',
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.4 KiB |
13986
public/v1/lib/leaflet/leaflet-src.esm.js
Normal file
13986
public/v1/lib/leaflet/leaflet-src.esm.js
Normal file
File diff suppressed because it is too large
Load Diff
1
public/v1/lib/leaflet/leaflet-src.esm.js.map
Normal file
1
public/v1/lib/leaflet/leaflet-src.esm.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -25,6 +25,10 @@
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
/* Prevents IE11 from highlighting tiles in blue */
|
||||
.leaflet-tile::selection {
|
||||
background: transparent;
|
||||
}
|
||||
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
|
||||
.leaflet-safari .leaflet-tile {
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
@ -45,8 +49,10 @@
|
||||
.leaflet-container .leaflet-marker-pane img,
|
||||
.leaflet-container .leaflet-shadow-pane img,
|
||||
.leaflet-container .leaflet-tile-pane img,
|
||||
.leaflet-container img.leaflet-image-layer {
|
||||
.leaflet-container img.leaflet-image-layer,
|
||||
.leaflet-container .leaflet-tile {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.leaflet-container.leaflet-touch-zoom {
|
||||
@ -55,7 +61,10 @@
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag {
|
||||
-ms-touch-action: pinch-zoom;
|
||||
}
|
||||
/* Fallback for FF which doesn't support pinch-zoom */
|
||||
touch-action: none;
|
||||
touch-action: pinch-zoom;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
@ -164,7 +173,6 @@
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
-o-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
@ -181,14 +189,12 @@
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
-o-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
@ -205,6 +211,7 @@
|
||||
.leaflet-grab {
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
.leaflet-crosshair,
|
||||
.leaflet-crosshair .leaflet-interactive {
|
||||
@ -220,6 +227,7 @@
|
||||
cursor: move;
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* marker & overlays interactivity */
|
||||
@ -233,7 +241,8 @@
|
||||
|
||||
.leaflet-marker-icon.leaflet-interactive,
|
||||
.leaflet-image-layer.leaflet-interactive,
|
||||
.leaflet-pane > svg path.leaflet-interactive {
|
||||
.leaflet-pane > svg path.leaflet-interactive,
|
||||
svg.leaflet-image-layer.leaflet-interactive path {
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
@ -490,7 +499,6 @@
|
||||
-webkit-transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
-o-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper,
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -503,7 +503,7 @@ return [
|
||||
'result' => 'Result',
|
||||
'sums_apply_to_range' => 'All sums apply to the selected range',
|
||||
'mapbox_api_key' => 'To use map, get an API key from <a href="https://www.mapbox.com/">Mapbox</a>. Open your <code>.env</code> file and enter this code after <code>MAPBOX_API_KEY=</code>.',
|
||||
'press_tag_location' => 'Right click or long press to set the tag\'s location.',
|
||||
'press_object_location' => 'Right click or long press to set the object\'s location.',
|
||||
'clear_location' => 'Clear location',
|
||||
'delete_all_selected_tags' => 'Delete all selected tags',
|
||||
'select_tags_to_delete' => 'Don\'t forget to select some tags.',
|
||||
|
@ -3,6 +3,11 @@
|
||||
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, objectType) }}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<!-- set location data high up -->
|
||||
<script type="text/javascript">
|
||||
var locations = {{ locations|json_encode|raw }};
|
||||
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
|
||||
</script>
|
||||
|
||||
<form action="{{ route('accounts.store') }}" method="post" id="store" class="form-horizontal">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||
@ -53,7 +58,7 @@
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
|
||||
{{ ExpandedForm.textarea('notes',null,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
{{ ExpandedForm.location('location') }}
|
||||
{{ ExpandedForm.location('location', null, {locations:locations}) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -77,43 +82,7 @@
|
||||
</form>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<!-- location script -->
|
||||
<script type="text/javascript">
|
||||
// pre-set latitude:
|
||||
{% if old('tag_position_latitude') %}
|
||||
var tag_position_latitude = "{{ old('tag_position_latitude') }}";
|
||||
{% else %}
|
||||
var tag_position_latitude = "52.3167";
|
||||
{% endif %}
|
||||
|
||||
// pre-set longitude
|
||||
{% if old('tag_position_longitude') %}
|
||||
var tag_position_longitude = "{{ old('tag_position_longitude') }}";
|
||||
{% else %}
|
||||
var tag_position_longitude = "5.5500";
|
||||
{% endif %}
|
||||
|
||||
// pre-set zoom level
|
||||
{% if old('tag_position_zoomlevel') %}
|
||||
var tag_position_zoomlevel = "{{ old('tag_position_zoomlevel') }}";
|
||||
{% else %}
|
||||
var tag_position_zoomlevel = "6";
|
||||
{% endif %}
|
||||
|
||||
// must draw a tag?
|
||||
{% if old('tag_position_latitude') and old('tag_position_longitude') and old('tag_position_zoomlevel') %}
|
||||
var tag_position_set_tag = true;
|
||||
{% else %}
|
||||
var tag_position_set_tag = false;
|
||||
{% endif %}
|
||||
|
||||
// token for Mapbox:
|
||||
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
|
||||
|
||||
</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 type="text/javascript" src="v1/js/ff/accounts/create.js?v={{ FF_VERSION }}"></script>
|
||||
|
@ -5,6 +5,12 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<!-- set location data high up -->
|
||||
<script type="text/javascript">
|
||||
var locations = {{ locations|json_encode|raw }};
|
||||
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
|
||||
</script>
|
||||
|
||||
{{ Form.model(account, {'class' : 'form-horizontal','id' : 'update','url' : route('accounts.update',account.id) } ) }}
|
||||
|
||||
<input type="hidden" name="id" value="{{ account.id }}"/>
|
||||
@ -57,14 +63,13 @@
|
||||
{{ ExpandedForm.amountNoCurrency('virtual_balance',null) }}
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
|
||||
{{ ExpandedForm.textarea('notes',preFilled.notes,{helpText: trans('firefly.field_supports_markdown')}) }}
|
||||
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('active', 1) }}
|
||||
{# only correct way to do active checkbox #}
|
||||
{{ ExpandedForm.checkbox('include_net_worth', 1) }}
|
||||
|
||||
{{ ExpandedForm.location('location', null, {locations: locations}) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -100,6 +105,7 @@
|
||||
{{ Form.close|raw }}
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<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 type="text/javascript" src="v1/js/ff/accounts/edit.js?v={{ FF_VERSION }}"></script>
|
||||
@ -108,4 +114,5 @@
|
||||
{% block styles %}
|
||||
<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">
|
||||
<link rel="stylesheet" href="v1/lib/leaflet/leaflet.css?v={{ FF_VERSION }}"/>
|
||||
{% endblock %}
|
||||
|
@ -156,13 +156,6 @@
|
||||
{% block scripts %}
|
||||
<script type="text/javascript">
|
||||
|
||||
var showAll = true;
|
||||
currencySymbol = "{{ currency.symbol }}";
|
||||
var accountID = {{ account.id }};
|
||||
var chartUri = '{{ chartUri }}';
|
||||
{% if not showAll %}
|
||||
showAll = false;
|
||||
|
||||
// location stuff
|
||||
{% if location %}
|
||||
var latitude = {{ location.latitude|default("52.3167") }};
|
||||
@ -173,6 +166,15 @@
|
||||
var mapboxToken = "{{ config('firefly.mapbox_api_key') }}";
|
||||
{% endif %}
|
||||
|
||||
var showAll = true;
|
||||
currencySymbol = "{{ currency.symbol }}";
|
||||
var accountID = {{ account.id }};
|
||||
var chartUri = '{{ chartUri }}';
|
||||
{% if not showAll %}
|
||||
showAll = false;
|
||||
|
||||
|
||||
|
||||
// uri's for charts:
|
||||
|
||||
var incomeCategoryUri = '{{ route('chart.account.income-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
|
@ -1,43 +1,45 @@
|
||||
<!--
|
||||
<pre>
|
||||
Some debug
|
||||
name: {{ name }}
|
||||
lat: {{ name~'_latitude' }}
|
||||
long: {{ name~'_longitude' }}
|
||||
zoom:{{ name~'_zoom_level' }}
|
||||
old lat: {{ old(name~'_latitude') }}
|
||||
old long: {{ old(name~'_longitude') }}
|
||||
old zoom: {{ old(name~'_zoom_level') }}
|
||||
default lat: {{ 'location.'~name~'.latitude' }}: {{ options.locations[name].latitude|default(config('firefly.default_location.latitude')) }} (with default)
|
||||
default long: {{ 'location.'~name~'.longitude' }}: {{ options.locations[name].longitude|default(config('firefly.default_location.longitude')) }} (with default)
|
||||
default zoom: {{ 'location.'~name~'.zoom_level' }}: {{ options.locations[name].zoom_level|default(config('firefly.default_location.zoom_level')) }} (with default)
|
||||
</pre>
|
||||
|
||||
-->
|
||||
<div class="{{ classes }}" id="{{ name }}_holder">
|
||||
<label for="{{ options.id }}" class="col-sm-4 control-label">{{ label }}</label>
|
||||
<div class="col-sm-8">
|
||||
{% if config('firefly.mapbox_api_key') == '' %}
|
||||
<p class="text-danger">
|
||||
{{ trans('firefly.mapbox_api_key')|raw }}
|
||||
</p>
|
||||
<p class="text-danger">
|
||||
{{ trans('firefly.mapbox_api_key')|raw }}
|
||||
</p>
|
||||
{% else %}
|
||||
<div id="{{ name }}_map" style="width:100%;height:300px;"></div>
|
||||
<div id="map-canvas"></div>
|
||||
<p class="help-block">
|
||||
{{ 'press_tag_location'|_ }}
|
||||
<a href="#" id="{{ name }}_clear_location">{{ 'clear_location'|_ }}</a>
|
||||
</p>
|
||||
{# latitude #}
|
||||
{% if old(name~'_latitude') %}
|
||||
<input type="hidden" name="{{ name }}_latitude" value="{{ old('tag_position_latitude') }}"/>
|
||||
{% else %}
|
||||
<input type="hidden" name="{{ name }}_latitude" value="{{ tag.latitude }}"/>
|
||||
{% endif %}
|
||||
<div id="{{ name }}_map" style="width:100%;height:300px;"></div>
|
||||
<div id="{{ name }}_map_canvas"></div>
|
||||
<p class="help-block">
|
||||
{{ 'press_object_location'|_ }}
|
||||
<button class="btn btn-default btn-xs" type="button" id="{{ name }}_clear_location">{{ 'clear_location'|_ }}</button>
|
||||
</p>
|
||||
{# latitude #}
|
||||
<input type="hidden" name="{{ name }}_latitude" value="{{ options.locations[name].latitude|default('52.3167') }}"/>
|
||||
|
||||
{# longitude #}
|
||||
{% if old('tag_position_longitude') %}
|
||||
<input type="hidden" name="{{ name }}_longitude" value="{{ old('tag_position_longitude') }}"/>
|
||||
{% else %}
|
||||
<input type="hidden" name="{{ name }}_longitude" value="{{ tag.longitude }}"/>
|
||||
{% endif %}
|
||||
{# longitude #}
|
||||
<input type="hidden" name="{{ name }}_longitude" value="{{ options.locations[name].longitude|default('5.5500') }}"/>
|
||||
|
||||
{# zoomlevel #}
|
||||
{% if old('tag_position_zoomlevel') %}
|
||||
<input type="hidden" name="{{ name }}_zoomlevel" value="{{ old('tag_position_zoomlevel') }}"/>
|
||||
{% else %}
|
||||
<input type="hidden" name="{{ name }}_zoomlevel" value="{{ tag.zoomLevel }}"/>
|
||||
{% endif %}
|
||||
{% if tag.zoomLevel and tag.longitude and tag.latitude %}
|
||||
<input type="hidden" name="{{ name }}_has_tag" value="true"/>
|
||||
{% else %}
|
||||
<input type="hidden" name="{{ name }}_has_tag" value="false"/>
|
||||
{% endif %}
|
||||
{% include 'form/feedback' %}
|
||||
{# zoomlevel #}
|
||||
<input type="hidden" name="{{ name }}_zoom_level" value="{{ options.locations[name].zoom_level|default('6') }}"/>
|
||||
|
||||
{# has location set? #}
|
||||
<input type="hidden" name="{{ name }}_has_location" value="{{ options.locations[name].has_location|default('false') }}"/>
|
||||
{% include 'form/feedback' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@ -45,62 +47,57 @@
|
||||
{% if config('firefly.mapbox_api_key') != '' %}
|
||||
{% set latitudevar = name~'_latitude' %}
|
||||
{% set longitudevar = name~'_longitude' %}
|
||||
{% set zoomlevelvar = name~'_zoomlevel' %}
|
||||
{% set hastagvar = name~'_has_tag' %}
|
||||
{% set settagvar = name~'_set_tag' %}
|
||||
{% set zoomlevelvar = name~'_zoom_level' %}
|
||||
{% set haslocationvar = name~'_has_location' %}
|
||||
{% set clearvar = name~'_clear_location' %}
|
||||
|
||||
<script type="text/javascript">
|
||||
var mymap;
|
||||
var marker;
|
||||
if (typeof {{ latitudevar }} === "undefined") {
|
||||
var {{ latitudevar }} =
|
||||
"52.3167";
|
||||
if (typeof locations.{{ name }}.latitude === 'undefined') {
|
||||
locations.{{ name }}.latitude = '52.3167';
|
||||
}
|
||||
if (typeof {{ longitudevar }} === "undefined") {
|
||||
var {{ longitudevar }} =
|
||||
"5.5500";
|
||||
if (typeof locations.{{ name }}.longitude === 'undefined') {
|
||||
locations.{{ name }}.longitude = '5.5500';
|
||||
}
|
||||
if (typeof {{ zoomlevelvar }} === "undefined") {
|
||||
var {{ zoomlevelvar }} =
|
||||
"6";
|
||||
if (typeof locations.{{ name }}.zoom_level === 'undefined') {
|
||||
locations.{{ name }}.zoom_level = '6';
|
||||
}
|
||||
|
||||
if (typeof mapboxToken === 'undefined') {
|
||||
var mapboxToken = 'invalid';
|
||||
}
|
||||
//
|
||||
document.getElementById('{{ clearvar }}').addEventListener('click', function () {
|
||||
if (typeof marker !== 'undefined') {
|
||||
marker.remove();
|
||||
$('input[name="{{ hastagvar }}"]').val('false');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
window.onload = function () {
|
||||
document.getElementById('{{ clearvar }}').addEventListener('click', function () {
|
||||
if (typeof marker !== 'undefined') {
|
||||
marker.remove();
|
||||
$('input[name="{{ haslocationvar }}"]').val('false');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// set location thing:
|
||||
function setTagLocation(e) {
|
||||
function setObjectLocation(e) {
|
||||
console.log('Set object location: lat(' + e.latlng.lat + '), long(' + e.latlng.lng + '), zoom (' + mymap.getZoom() + ')');
|
||||
$('input[name="{{ latitudevar }}"]').val(e.latlng.lat);
|
||||
$('input[name="{{ longitudevar }}"]').val(e.latlng.lng);
|
||||
$('input[name="{{ zoomlevelvar }}"]').val(mymap.getZoom());
|
||||
$('input[name="{{ hastagvar }}"]').val('true');
|
||||
$('input[name="{{ haslocationvar }}"]').val('true');
|
||||
|
||||
// remove existing marker:
|
||||
if (typeof marker !== 'undefined') {
|
||||
marker.remove();
|
||||
}
|
||||
// new marker
|
||||
marker = L.marker([e.latlng.lat, e.latlng.lng]).addTo(mymap);
|
||||
marker = L.marker({lat: e.latlng.lat, lng: e.latlng.lng}).addTo(mymap);
|
||||
}
|
||||
|
||||
|
||||
console.log({{ longitudevar }});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
"use strict";
|
||||
|
||||
// make map:
|
||||
mymap = L.map('{{ name }}_map').setView([{{ latitudevar }}, {{ longitudevar }}], {{ zoomlevelvar }});
|
||||
mymap = L.map('{{ name }}_map').setView({lat: locations.{{ name }}.latitude, lng: locations.{{ name }}.longitude}, locations.{{ name }}.zoom_level);
|
||||
|
||||
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
|
||||
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
|
||||
@ -109,13 +106,12 @@
|
||||
accessToken: mapboxToken
|
||||
}).addTo(mymap);
|
||||
|
||||
mymap.on('contextmenu', setTagLocation);
|
||||
mymap.on('contextmenu', setObjectLocation);
|
||||
|
||||
// add marker
|
||||
if (typeof {{ settagvar }} !== 'undefined' && {{ settagvar }} === true) {
|
||||
marker = L.marker([{{ latitudevar }}, {{ longitudevar }}]).addTo(mymap);
|
||||
if (typeof locations.{{ name }}.has_location !== 'undefined' && locations.{{ name }}.has_location === true) {
|
||||
marker = L.marker({lat: locations.{{ name }}.latitude, lng: locations.{{ name }}.longitude}).addTo(mymap);
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
|
@ -31,13 +31,18 @@
|
||||
<div class="btn-group btn-group-xs edit_tr_buttons"><a class="btn btn-default btn-xs" title="{{ 'edit'|_ }}"
|
||||
href="{{ route('accounts.edit',account.id) }}"><i
|
||||
class="fa fa-fw fa-pencil"></i></a>{% if objectType == 'asset' %}<a class="btn btn-default btn-xs"
|
||||
title="{{ 'reconcile_this_account'|_ }}"
|
||||
href="{{ route('accounts.reconcile',account.id) }}"><i
|
||||
title="{{ 'reconcile_this_account'|_ }}"
|
||||
href="{{ route('accounts.reconcile',account.id) }}"><i
|
||||
class="fa fa-fw fa-check"></i></a>{% endif %}<a class="btn btn-danger btn-xs" title="{{ 'delete'|_ }}"
|
||||
href="{{ route('accounts.delete',account.id) }}"><i
|
||||
class="fa fa-fw fa-trash-o"></i></a></div>
|
||||
</td>
|
||||
<td data-value="{{ account.name }}"><a href="{{ route('accounts.show',account.id) }}">{{ account.name }}</a></td>
|
||||
<td data-value="{{ account.name }}">
|
||||
<a href="{{ route('accounts.show',account.id) }}">{{ account.name }}</a>
|
||||
{% if account.location %}
|
||||
<i class="fa fa-fw fa-map-marker"></i>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if objectType == "asset" %}
|
||||
<td class="hidden-sm hidden-xs hidden-md">
|
||||
{% for entry in account.accountmeta %}
|
||||
|
Loading…
Reference in New Issue
Block a user