Changed be able to edit names

This commit is contained in:
williamengbjerg committed 2021-06-06 23:00:54 +02:00
1 parent 072d54f46f
commit a9cd16d987
3 files changed
+18 -9

No files matched your search

+9 -4
View File
@@ -217,10 +217,10 @@ class Projected extends Component
})->where("id", $id)->first(); })->where("id", $id)->first();
if($post) { if($post) {
$this->rowPostID = $post->id; $this->rowPostID = $post->id;
$this->rowName = $post->name; $this->rowName = $post->name;
$this->rowTypeHTML = "<span class=\"".($post->is_expense ? "col-neg" : "col-pos")."\">".($post->is_expense ? "expense" : "income")."</span>"; $this->rowTypeHTML = "<span class=\"".($post->is_expense ? "col-neg" : "col-pos")."\">".($post->is_expense ? "expense" : "income")."</span>";
$this->modalRowUpdate = true; $this->modalRowUpdate = true;
$this->emit("focusField", "rowValue"); $this->emit("focusField", "rowValue");
} }
} }
@@ -230,6 +230,11 @@ class Projected extends Component
return $query->where('user_id', \Auth::user()->id); return $query->where('user_id', \Auth::user()->id);
})->where("id", $this->rowPostID)->first(); })->where("id", $this->rowPostID)->first();
if ($post->name !== $this->rowName) {
$post->update(['name' => $this->rowName]);
$post->save();
}
$value = null; $value = null;
if($this->rowValue != null && trim($this->rowValue) != "" && is_numeric(trim($this->rowValue))) { if($this->rowValue != null && trim($this->rowValue) != "" && is_numeric(trim($this->rowValue))) {
$value = floatval($this->rowValue); $value = floatval($this->rowValue);
+1
View File
@@ -10,6 +10,7 @@ class Post extends Model
use HasFactory; use HasFactory;
private $monthValueCache = null; private $monthValueCache = null;
private $monthActualValueCache = null; private $monthActualValueCache = null;
protected $guarded = [];
public function category() { public function category() {
return $this->belongsTo(\App\Models\Category::class); return $this->belongsTo(\App\Models\Category::class);
+8 -5
View File
@@ -185,14 +185,14 @@
<div class="fixed z-10 inset-0 overflow-y-auto" style="display:none" aria-labelledby="modal-title-1" role="dialog" aria-modal="true" x-show="modalFieldUpdate"> <div class="fixed z-10 inset-0 overflow-y-auto" style="display:none" aria-labelledby="modal-title-1" role="dialog" aria-modal="true" x-show="modalFieldUpdate">
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"> <div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div> <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span> <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
<div class="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full sm:p-6"> <div class="inline-block align-bottom bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-sm sm:w-full sm:p-6">
<div> <div>
<div class="mt-1 text-center sm:mt-1"> <div class="mt-1 text-center sm:mt-1">
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title-1"> <h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title-1">
{{$fieldName}} for ({{$fieldMonthName}}) {{$fieldName}} for ({{$fieldMonthName}}) <br>
</h3> </h3>
<div class="mt-2"> <div class="mt-2">
<p class="text-sm text-gray-500"> <p class="text-sm text-gray-500">
@@ -203,7 +203,7 @@
</div> </div>
</div> </div>
<div class="mt-5 sm:mt-6 text-center"> <div class="mt-5 sm:mt-6 text-center">
<button type="button" wire:click="updateField" class="inline-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-green-600 text-base font-medium text-white hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 sm:text-sm"> <button type="button" wire:click="updateField" class="inlin e-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-green-600 text-base font-medium text-white hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 sm:text-sm">
Update Update
</button> </button>
<button type="button" wire:click="closeFieldUpdate" class="inline-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:text-sm"> <button type="button" wire:click="closeFieldUpdate" class="inline-flex w-5/12 justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-gray-600 text-base font-medium text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 sm:text-sm">
@@ -224,7 +224,10 @@
<div> <div>
<div class="mt-1 text-center sm:mt-1"> <div class="mt-1 text-center sm:mt-1">
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title-2"> <h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title-2">
{{$rowName}} <label for="set-title">
{{$fieldName}} for ({{$fieldMonthName}}) <br>
<input id="set-title" name="title" type="text" wire:model.defer="rowName" class="form-input px-2 py-2 rounded-md w-10/12" />
</label>
</h3> </h3>
<div class="mt-2"> <div class="mt-2">
<p class="text-sm text-gray-500"> <p class="text-sm text-gray-500">