live charts update added

This commit is contained in:
Anatoliy Poloz
2022-06-02 12:02:58 +00:00
parent 3cd66a54e5
commit 12e42ddddd
61 changed files with 1881 additions and 546 deletions

View File

@@ -29,6 +29,8 @@ class MealForm extends Component
'portion' => 'required|min:1'
];
protected $listeners = ['food-intake-updated' => '$refresh'];
public function mount()
{
$this->diary = Diary::find($this->diaryId);
@@ -63,7 +65,23 @@ class MealForm extends Component
public function render()
{
return view('livewire.meal-form');
$types = [0, 1, 2, 3, 4];
$typeNames = ['Завтрак', 'Обед', 'Ужин', 'Ланч', 'Перекусы'];
$typeCssIds = ['breakfast', 'dinner', 'supper', 'lunch', 'snacks'];
return view(
'livewire.meal-form',
[
'types' => $types,
'typeNames' => $typeNames,
'typeCssIds' => $typeCssIds,
'curMeal' => $this
->diary
->meals
->where('type', $this->type)
->first(),
]
);
}
public function setType(int $type): void
@@ -113,6 +131,8 @@ class MealForm extends Component
}
}
}
/* $this->emit('food-intake-updated'); */
$this->emitSelf('food-intake-updated');
}
public function addPortion()
@@ -142,12 +162,14 @@ class MealForm extends Component
$this->delPortion($key, $item);
$this->fill($filed);
}
private function addPortionIfItFilled()
{
if (mb_strlen($this->product_name) && $this->quantity && mb_strlen($this->portion)) {
$this->addPortion();
}
}
public function delPortion($key, $item)
{
if (isset($item['id'])) {