Add tests for grouped stock list behavior and improve stock view mode UI and API enhancements
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
+37
-3
@@ -21,7 +21,24 @@ export async function searchItemDefinitions(store, query) {
|
||||
}
|
||||
|
||||
export async function listStockEntries(store, filters = {}) {
|
||||
const payload = await apiRequest(store, getPath('items'));
|
||||
const query = {};
|
||||
const searchName = filters.searchName || filters.search_name;
|
||||
if (searchName) {
|
||||
query.search_name = searchName;
|
||||
}
|
||||
if (filters.limit !== undefined && filters.limit !== null) {
|
||||
query.limit = filters.limit;
|
||||
}
|
||||
if (filters.offset !== undefined && filters.offset !== null) {
|
||||
query.offset = filters.offset;
|
||||
}
|
||||
if (filters.cursor) {
|
||||
query.cursor = filters.cursor;
|
||||
}
|
||||
|
||||
const payload = await apiRequest(store, getPath('items'), {
|
||||
query,
|
||||
});
|
||||
|
||||
if (Array.isArray(payload)) {
|
||||
return payload;
|
||||
@@ -30,9 +47,26 @@ export async function listStockEntries(store, filters = {}) {
|
||||
return payload?.data || payload?.entries || payload?.items || [];
|
||||
}
|
||||
|
||||
export async function listGroupedStockEntries(store) {
|
||||
export async function listGroupedStockEntries(store, options = {}) {
|
||||
const query = {};
|
||||
const expanded = options.expanded ?? 1;
|
||||
query.expanded = expanded;
|
||||
const searchName = options.searchName || options.search_name;
|
||||
if (searchName) {
|
||||
query.search_name = searchName;
|
||||
}
|
||||
if (options.limit !== undefined && options.limit !== null) {
|
||||
query.limit = options.limit;
|
||||
}
|
||||
if (options.offset !== undefined && options.offset !== null) {
|
||||
query.offset = options.offset;
|
||||
}
|
||||
if (options.cursor) {
|
||||
query.cursor = options.cursor;
|
||||
}
|
||||
|
||||
const payload = await apiRequest(store, `${getPath('items')}/grouped`, {
|
||||
query: { expanded: 1 },
|
||||
query,
|
||||
});
|
||||
|
||||
if (Array.isArray(payload)) {
|
||||
|
||||
Reference in New Issue
Block a user