stash
This commit is contained in:
parent
751f3deaab
commit
7512ba76da
4 changed files with 43 additions and 11 deletions
|
@ -175,10 +175,6 @@ export default createStore({
|
|||
commit('setInventoryItems', {url: '/', items})
|
||||
return items
|
||||
},
|
||||
async searchInventories({state, dispatch, getters}, {query}) {
|
||||
const servers = await dispatch('getAllKnownServers')
|
||||
return await servers.get(getters.signAuth, '/api/inventory/search/?q=' + query)
|
||||
},
|
||||
async createInventoryItem({state, dispatch, getters}, item) {
|
||||
const servers = await dispatch('getHomeServers')
|
||||
const data = {availability_policy: 'private', ...item}
|
||||
|
@ -198,9 +194,12 @@ export default createStore({
|
|||
dispatch('fetchInventoryItems')
|
||||
return ret
|
||||
},
|
||||
async fetchSearchResults({state, dispatch, getters}, {query}) {
|
||||
async fetchSearchResults({state, commit, dispatch, getters}, {query}) {
|
||||
const servers = await dispatch('getAllKnownServers')
|
||||
return await servers.get(getters.signAuth, '/api/search/?query=' + query)
|
||||
const items = await servers.get(getters.signAuth, '/api/search/?query=' + query)
|
||||
items.map(item => item.files.map(file => file.owner = item.owner))
|
||||
commit('setInventoryItems', {url: '/search/' + query, items})
|
||||
return items
|
||||
},
|
||||
async fetchFriends({commit, dispatch, getters, state}) {
|
||||
const servers = await dispatch('getHomeServers')
|
||||
|
|
|
@ -45,6 +45,38 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card">
|
||||
<button class="btn" @click="fetchInventoryItems">Refresh</button>
|
||||
<router-link to="/inventory/new" class="btn btn-primary">Add</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-xl-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title">Friends' Inventory</h5>
|
||||
<h6 class="card-subtitle text-muted">Bar <code>baz</code>.</h6>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:40%;">Name</th>
|
||||
<th style="width:25%">Owner</th>
|
||||
<th style="width:25%">Availability Policy</th>
|
||||
<th class="d-none d-md-table-cell" style="width:25%">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in loaded_items.filter(item => item.owner !== user)" :key="item.id">
|
||||
<td>
|
||||
<router-link :to="`/inventory/${item.id}`">{{ item.name }}</router-link>
|
||||
</td>
|
||||
<td>{{ item.owner }}</td>
|
||||
<td class="d-none d-md-table-cell">{{ item.availability_policy }}</td>
|
||||
<td class="d-none d-md-table-cell">{{ item.owned_quantity }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-body" v-else>
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6 col-lg-4 col-xl-3" v-for="item in inventory_items"
|
||||
|
@ -104,7 +136,8 @@ export default {
|
|||
...BIcons
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["inventory_items"])
|
||||
...mapGetters(["inventory_items", "loaded_items"]),
|
||||
...mapState(["user"]),
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["fetchInventoryItems", "deleteInventoryItem"]),
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="image" class="form-label">Image</label>
|
||||
<combined-file-field :item_files="item.files" :item_id="item.id" @change="changeFiles"></combined-file-field>
|
||||
<combined-file-field :item_files="item.files" :item_id="item.id"
|
||||
@change="changeFiles"></combined-file-field>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%"
|
||||
|
@ -110,7 +111,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
...mapActions(["fetchInventoryItems", "updateInventoryItem", "fetchInfo"]),
|
||||
addFiles(files) {
|
||||
changeFiles(files) {
|
||||
this.inventory_items.find(item => item.id === parseInt(this.id)).files = files
|
||||
},
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<SearchBox @change="" />
|
||||
<SearchBox @change=""/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
|
@ -81,7 +81,6 @@ export default {
|
|||
},
|
||||
async mounted() {
|
||||
this.fetchSearchResults({query: this.query}).then((results) => {
|
||||
console.log(results);
|
||||
this.search_results = results;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue