mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 04:16:16 +02:00
Add location support to equipment
This commit is contained in:
parent
68b4abfac4
commit
8d07311ae5
|
|
@ -15,7 +15,8 @@ class EquipmentController extends BaseController
|
||||||
{
|
{
|
||||||
return $this->renderPage($response, 'equipmentform', [
|
return $this->renderPage($response, 'equipmentform', [
|
||||||
'mode' => 'create',
|
'mode' => 'create',
|
||||||
'userfields' => $this->getUserfieldsService()->GetFields('equipment')
|
'userfields' => $this->getUserfieldsService()->GetFields('equipment'),
|
||||||
|
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -23,7 +24,8 @@ class EquipmentController extends BaseController
|
||||||
return $this->renderPage($response, 'equipmentform', [
|
return $this->renderPage($response, 'equipmentform', [
|
||||||
'equipment' => $this->getDatabase()->equipment($args['equipmentId']),
|
'equipment' => $this->getDatabase()->equipment($args['equipmentId']),
|
||||||
'mode' => 'edit',
|
'mode' => 'edit',
|
||||||
'userfields' => $this->getUserfieldsService()->GetFields('equipment')
|
'userfields' => $this->getUserfieldsService()->GetFields('equipment'),
|
||||||
|
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +35,8 @@ class EquipmentController extends BaseController
|
||||||
return $this->renderPage($response, 'equipment', [
|
return $this->renderPage($response, 'equipment', [
|
||||||
'equipment' => $this->getDatabase()->equipment()->orderBy('name', 'COLLATE NOCASE'),
|
'equipment' => $this->getDatabase()->equipment()->orderBy('name', 'COLLATE NOCASE'),
|
||||||
'userfields' => $this->getUserfieldsService()->GetFields('equipment'),
|
'userfields' => $this->getUserfieldsService()->GetFields('equipment'),
|
||||||
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('equipment')
|
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('equipment'),
|
||||||
|
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
migrations/0255.sql
Normal file
1
migrations/0255.sql
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE equipment ADD location_id INTEGER;
|
||||||
|
|
@ -35,6 +35,18 @@ function DisplayEquipment(id)
|
||||||
$("#description-tab-content").html(equipmentItem.description);
|
$("#description-tab-content").html(equipmentItem.description);
|
||||||
$(".equipment-edit-button").attr("href", U("/equipment/" + equipmentItem.id.toString()));
|
$(".equipment-edit-button").attr("href", U("/equipment/" + equipmentItem.id.toString()));
|
||||||
|
|
||||||
|
var equipmentLocation = FindObjectInArrayByPropertyValue(Grocy.Locations, 'id', equipmentItem.location_id);
|
||||||
|
if (equipmentLocation)
|
||||||
|
{
|
||||||
|
$("#selected-equipment-location-name").text(equipmentLocation.name);
|
||||||
|
$("#selected-equipment-location").removeClass("d-none");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#selected-equipment-location-name").text("");
|
||||||
|
$("#selected-equipment-location").addClass("d-none");
|
||||||
|
}
|
||||||
|
|
||||||
if (equipmentItem.instruction_manual_file_name)
|
if (equipmentItem.instruction_manual_file_name)
|
||||||
{
|
{
|
||||||
var pdfUrl = U('/api/files/equipmentmanuals/' + btoa(equipmentItem.instruction_manual_file_name));
|
var pdfUrl = U('/api/files/equipmentmanuals/' + btoa(equipmentItem.instruction_manual_file_name));
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = $('#equipment-form').serializeJSON();
|
var jsonData = $('#equipment-form').serializeJSON();
|
||||||
|
if (jsonData.location_id == "")
|
||||||
|
{
|
||||||
|
jsonData.location_id = null;
|
||||||
|
}
|
||||||
Grocy.FrontendHelpers.BeginUiBusy("equipment-form");
|
Grocy.FrontendHelpers.BeginUiBusy("equipment-form");
|
||||||
|
|
||||||
if ($("#instruction-manual")[0].files.length > 0)
|
if ($("#instruction-manual")[0].files.length > 0)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@
|
||||||
@section('title', $__t('Equipment'))
|
@section('title', $__t('Equipment'))
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
<script>
|
||||||
|
Grocy.Locations = @json($locations);
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-md-4 pb-3">
|
<div class="col-12 col-md-4 pb-3">
|
||||||
<div class="title-related-links border-bottom mb-2 py-1">
|
<div class="title-related-links border-bottom mb-2 py-1">
|
||||||
|
|
@ -68,6 +72,7 @@
|
||||||
href="#"><i class="fa-solid fa-eye"></i></a>
|
href="#"><i class="fa-solid fa-eye"></i></a>
|
||||||
</th>
|
</th>
|
||||||
<th>{{ $__t('Name') }}</th>
|
<th>{{ $__t('Name') }}</th>
|
||||||
|
<th>{{ $__t('Location') }}</th>
|
||||||
|
|
||||||
@include('components.userfields_thead', array(
|
@include('components.userfields_thead', array(
|
||||||
'userfields' => $userfields,
|
'userfields' => $userfields,
|
||||||
|
|
@ -106,6 +111,12 @@
|
||||||
<td>
|
<td>
|
||||||
{{ $equipmentItem->name }}
|
{{ $equipmentItem->name }}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
@php $location = FindObjectInArrayByPropertyValue($locations, 'id', $equipmentItem->location_id); @endphp
|
||||||
|
@if(!empty($location))
|
||||||
|
{{ $location->name }}
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
|
||||||
@include('components.userfields_tbody', array(
|
@include('components.userfields_tbody', array(
|
||||||
'userfields' => $userfields,
|
'userfields' => $userfields,
|
||||||
|
|
@ -120,6 +131,11 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-md-8">
|
<div class="col-12 col-md-8">
|
||||||
|
<p id="selected-equipment-location"
|
||||||
|
class="text-muted d-none">
|
||||||
|
<i class="fa-solid fa-location-dot"></i>
|
||||||
|
<span id="selected-equipment-location-name"></span>
|
||||||
|
</p>
|
||||||
<ul class="nav nav-tabs grocy-tabs mb-1">
|
<ul class="nav nav-tabs grocy-tabs mb-1">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active"
|
<a class="nav-link active"
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@
|
||||||
<div class="invalid-feedback">{{ $__t('A name is required') }}</div>
|
<div class="invalid-feedback">{{ $__t('A name is required') }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@include('components.locationpicker', array(
|
||||||
|
'locations' => $locations,
|
||||||
|
'isRequired' => false,
|
||||||
|
'prefillById' => $mode == 'edit' ? $equipment->location_id : ''
|
||||||
|
))
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="description">{{ $__t('Notes') }}</label>
|
<label for="description">{{ $__t('Notes') }}</label>
|
||||||
<textarea class="form-control wysiwyg-editor"
|
<textarea class="form-control wysiwyg-editor"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user