Skip to content

Commit

Permalink
feat(Places): fixes for review
Browse files Browse the repository at this point in the history
- Fixed bug when editing
- Added text

issue: #494
  • Loading branch information
rebeccadjim committed Jul 11, 2024
1 parent 26d88e8 commit 413df75
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/app/Http/Livewire/Forms/Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public static function rules($fieldname = null): array

public static function decode($previous)
{
if (is_array($previous)) {
return $previous;
}
return json_decode($previous, true);
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/lang/en/livewire/forms/form-area.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
return [
"latitude" => "Latitude",
"longitude" => "Longitude",
'polygon' => 'Polygon',
];
1 change: 1 addition & 0 deletions src/resources/lang/en/place/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'lat' => 'Latitude',
'lon' => 'Longitude',
'actions' => 'Actions',
'area' => 'Polygons',
],
'delete_confirm' => 'Are you sure you want to delete this place?',
];
10 changes: 7 additions & 3 deletions src/resources/views/livewire/forms/form-area.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<label for="{{ $form_elem }}" class="block font-medium text-md text-gray-700">{{ $title }}</label>
@for($row_index = 0; $row_index < $fieldCount; $row_index++)
<br>
<div>{{__("livewire/forms/form-area.polygon")}} {{$row_index + 1}}</div>
<jet-div wire:key="div-{{ $row_index }}" class="mt-4">
@for($column_index = 0; $column_index < 4; $column_index++)
<div class="flex">
Expand All @@ -10,7 +11,7 @@
<input type="text" name="{{ $form_elem }}[polygons][{{ $row_index }}][{{ $column_index }}][lat]"
id="lat{{ $row_index }}{{ $column_index }}"
class="form-input rounded-md shadow-sm mt-1 block w-full"
value="{{ old($form_elem.'.polygons.'.$row_index.'.'.$column_index.'.long',
value="{{ old($form_elem.'.polygons.'.$row_index.'.'.$column_index.'.lat',
$previous['polygons'][$row_index][$column_index]['lat'] ?? '') }}"
placeholder="{{ $placeHolder }}"/>
</div>
Expand All @@ -27,11 +28,14 @@ class="form-input rounded-md shadow-sm mt-1 block w-full"
</div>
@endfor
@error($form_elem.'.polygons.*.*.lat')
<p class="text-sm text-red-600">{{ Str::replace($form_elem.'.polygons.0.0.lat', $this->title.' (latitudes)', $message) }}</p>
<p class="text-sm text-red-600">{{ Str::replace($form_elem.'.polygons.', $this->title.' (latitudes)', $message) }}</p>
@enderror
@error($form_elem.'.polygons.*.*.long')
<p class="text-sm text-red-600">{{ Str::replace($form_elem.'.polygons.0.0.long', $this->title.' (longitudes)', $message) }}</p>
<p class="text-sm text-red-600">{{ Str::replace($form_elem.'.polygons.', $this->title.' (longitudes)', $message) }}</p>
@enderror
@error($form_elem.'.polygons.*.*.')
<p class="text-sm text-red-600">{{ Str::replace($form_elem.'.polygons.', $this->title.' (latitudes)', $message) }}</p>
@enderror
</jet-div>
@endfor

Expand Down
2 changes: 2 additions & 0 deletions src/resources/views/place/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">
<th class="toFilter">{{__('place/index.fields.lat')}}</th>
<th class="toFilter">{{__('place/index.fields.lon')}}</th>
<th class="toFilter">{{__('place/index.fields.description')}}</th>
<th class="toFilter">{{__('place/index.fields.area')}}</th>
@can('update', $places->first())
<th></th>
@endcan
Expand All @@ -43,6 +44,7 @@ class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">
<td>{{ json_decode($place->coordinates, true)['lat'] }}</td>
<td>{{ json_decode($place->coordinates, true)['long'] }}</td>
<td>{{ $place->description }}</td>
<td>{{ count(json_decode($place->area, true)['polygons']) }}</td>
@can('update', $place)
<td><a href="{{ route('place.edit', $place->id) }}">{{__('common.edit')}}</a></td>
@endcan
Expand Down

0 comments on commit 413df75

Please sign in to comment.