Skip to content

Commit 6c1fde0

Browse files
committed
Merge branch 'develop'
2 parents bddd321 + 0016267 commit 6c1fde0

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

admin/components/generic/InputSelect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function remoteSearch(query) {
124124
ref = true
125125
}
126126
if (ref) {
127-
itemsStore.retrieveItems($axios, url, {search: query, limit: 0, offset: 0, ordering: undefined}).then((items) => {
127+
itemsStore.retrieveItems($axios, url, {search: query, limit: 0, offset: 0, ordering: undefined}, false).then((items) => {
128128
items = JSON.parse(JSON.stringify(items))
129129
items.results = items.results.map((item) => {
130130
return {

admin/store/items.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@ export const useItemsStore = defineStore('items', {
2828
ordering: undefined,
2929
}),
3030
actions: {
31-
async retrieveItems($axios, apiUrl = undefined, params = {}) {
31+
async retrieveItems($axios, apiUrl = undefined, params = {}, cache= true) {
3232
const cacheName = apiCacheName(apiUrl, params)
3333
// Would be nice to amke ordering dynamic as a parameter, perhaps one day
34-
// let ordering = "-updated_date"
35-
// if (apiUrl.indexOf("/people/") !== -1)
36-
// ordering = "first_name"
37-
// check if params has "limit", "order" or "offset" and use them instead of the default ones
3834
if (!("limit" in params))
3935
params.limit = this.pageSize
4036
if (!("offset" in params))
@@ -49,10 +45,14 @@ export const useItemsStore = defineStore('items', {
4945
}
5046
apiUrl += "?" + new URLSearchParams(params).toString()
5147

52-
this.items[cacheName] = (await $axios.get(apiUrl, {'headers': authHeaders()})).data
53-
if (Array.isArray(this.items[cacheName])) { // When the endpoint is not paginated
54-
this.items[cacheName] = {results: this.items[cacheName]}
48+
let res = (await $axios.get(apiUrl, {'headers': authHeaders()})).data
49+
if (Array.isArray(res)) { // When the endpoint is not paginated
50+
res = {results: res}
5551
}
52+
if (!cache)
53+
return res
54+
55+
this.items[cacheName] = res
5656
return this.items[cacheName]
5757
},
5858
async deleteItem($axios, apiUrl, id) {

0 commit comments

Comments
 (0)