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})
|
commit('setInventoryItems', {url: '/', items})
|
||||||
return 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) {
|
async createInventoryItem({state, dispatch, getters}, item) {
|
||||||
const servers = await dispatch('getHomeServers')
|
const servers = await dispatch('getHomeServers')
|
||||||
const data = {availability_policy: 'private', ...item}
|
const data = {availability_policy: 'private', ...item}
|
||||||
|
@ -198,9 +194,12 @@ export default createStore({
|
||||||
dispatch('fetchInventoryItems')
|
dispatch('fetchInventoryItems')
|
||||||
return ret
|
return ret
|
||||||
},
|
},
|
||||||
async fetchSearchResults({state, dispatch, getters}, {query}) {
|
async fetchSearchResults({state, commit, dispatch, getters}, {query}) {
|
||||||
const servers = await dispatch('getAllKnownServers')
|
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}) {
|
async fetchFriends({commit, dispatch, getters, state}) {
|
||||||
const servers = await dispatch('getHomeServers')
|
const servers = await dispatch('getHomeServers')
|
||||||
|
|
|
@ -45,6 +45,38 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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="card-body" v-else>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-md-6 col-lg-4 col-xl-3" v-for="item in inventory_items"
|
<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
|
...BIcons
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(["inventory_items"])
|
...mapGetters(["inventory_items", "loaded_items"]),
|
||||||
|
...mapState(["user"]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["fetchInventoryItems", "deleteInventoryItem"]),
|
...mapActions(["fetchInventoryItems", "deleteInventoryItem"]),
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="image" class="form-label">Image</label>
|
<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>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<button type="submit" class="btn btn-primary" style="width: 100%"
|
<button type="submit" class="btn btn-primary" style="width: 100%"
|
||||||
|
@ -110,7 +111,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["fetchInventoryItems", "updateInventoryItem", "fetchInfo"]),
|
...mapActions(["fetchInventoryItems", "updateInventoryItem", "fetchInfo"]),
|
||||||
addFiles(files) {
|
changeFiles(files) {
|
||||||
this.inventory_items.find(item => item.id === parseInt(this.id)).files = files
|
this.inventory_items.find(item => item.id === parseInt(this.id)).files = files
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -81,7 +81,6 @@ export default {
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.fetchSearchResults({query: this.query}).then((results) => {
|
this.fetchSearchResults({query: this.query}).then((results) => {
|
||||||
console.log(results);
|
|
||||||
this.search_results = results;
|
this.search_results = results;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue