Skip to content

Commit

Permalink
Merge pull request #267 from tobiasKaminsky/improvements
Browse files Browse the repository at this point in the history
Whitespaces / Sort
  • Loading branch information
tobiasKaminsky committed Sep 23, 2024
2 parents 1496332 + 5fb15e0 commit d5d420a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Controller/GroceryListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ public function addItem(string $name, string $quantity, int $category, int $list
public function updateItem(int $id, string $name, string $quantity, int $category)
{
$item = $this->itemMapper->find($id);
$item->setName($name);
$item->setQuantity($quantity);
$item->setName(trim($name));
$item->setQuantity(trim($quantity));
$item->setCategory($category);

return new DataResponse($this->itemMapper->update($item));
Expand Down
7 changes: 6 additions & 1 deletion src/views/GroceryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<div>
<div v-if="hideCategory">
<ul class="list-item">
<ListItem v-for="item in allItems"
<ListItem v-for="item in sortedItems"
:key="item.id"
:item="item"
@edit="() => editItem(item)"
Expand Down Expand Up @@ -197,6 +197,11 @@ export default {
allItems() {
return this.items
},
sortedItems() {
return this.items.sort((a, b) => {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase())
})
},
filteredCategories() {
if (this.categories == null) {
return
Expand Down

0 comments on commit d5d420a

Please sign in to comment.