-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
323 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ref } from 'vue' | ||
|
||
export function useUnits() { | ||
|
||
const units = ref([ | ||
{ | ||
'name':'ounces', | ||
'displayName': 'Ounces (dry)', | ||
}, | ||
{ | ||
'name': 'ounces-liquid', | ||
'displayName': 'Ounces (liquid)', | ||
}, | ||
{ | ||
'name': 'pounds', | ||
'displayName': 'Pounds', | ||
} | ||
]) | ||
|
||
return { | ||
units | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,65 @@ | ||
<script setup> | ||
import { ref } from 'vue' | ||
import { ref, onBeforeMount } from 'vue' | ||
import OrdersTabs from '@/components/OrdersTabs.vue' | ||
import { collection, getFirestore, query, where, doc, getDocs, addDoc, updateDoc, orderBy } from 'firebase/firestore' | ||
import SortableTableHeader from '@/components/SortableTableHeader.vue' | ||
const db = getFirestore() | ||
const items = ref() | ||
const sortBy = ref("name") | ||
const sortAsc = ref(true) | ||
const refreshList = async () => { | ||
const q = query(collection(db, "item"), orderBy(sortBy.value, sortAsc.value ? "asc" : "desc")) | ||
const itemRef = await getDocs(q) | ||
const itemarray = [] | ||
itemRef.forEach((item)=> { | ||
itemarray.push({id:item.id,...item.data()}) | ||
}) | ||
items.value = itemarray | ||
} | ||
const sortList = param => { | ||
sortAsc.value = sortBy.value === param ? !sortAsc.value : true | ||
sortBy.value = param | ||
refreshList() | ||
} | ||
onBeforeMount( async () => { | ||
await refreshList() | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="container"> | ||
<OrdersTabs activeTab="Items" /> | ||
|
||
<div class="mt-3"> | ||
<router-link class="btn btn-primary" :to="{'name':'OrderItemPage'}">New Item</router-link> | ||
</div> | ||
|
||
<div class="table-responsive-md"> | ||
<table class="table table-striped table-hover"> | ||
<thead> | ||
<tr> | ||
<SortableTableHeader heading="Name" sortKey="name" :sortBy="sortBy" :sortAsc="sortAsc" @sort-list="sortList" /> | ||
<th scope="col">Inventory</th> | ||
<th scope="col">Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="item in items" :key="item.id"> | ||
<td>{{item.name}}</td> | ||
<td>{{item.numInventory}}</td> | ||
<td> | ||
<router-link class="btn btn-sm btn-primary" :to="{name:'OrderItemPage', params:{id:item.id} }">Edit</router-link> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
</div> | ||
</template> |
Oops, something went wrong.