Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/common-brooms-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@o2s/blocks.notification-list': minor
'@o2s/integrations.strapi-cms': minor
'@o2s/blocks.invoice-list': minor
'@o2s/integrations.mocked': minor
'@o2s/blocks.ticket-list': minor
'@o2s/blocks.order-list': minor
'@o2s/framework': minor
---

adding initial filters support to list blocks
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const mapInvoiceList = (
},
downloadFileName: cms.downloadFileName,
downloadButtonAriaDescription: cms.downloadButtonAriaDescription,
initialFilters: cms.initialFilters,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class InvoiceListBlock extends ApiModels.Block.Block {
};
downloadFileName?: string;
downloadButtonAriaDescription?: string;
initialFilters?: Partial<Invoices.Model.Invoice & { sort?: string }>;
}

export class Invoice {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ export class InvoiceListService {
concatMap(([cms]) => {
return this.invoiceService
.getInvoiceList({
...(cms.initialFilters || {}),
...query,
limit: cms.pagination?.limit || query.limit,
limit: query.limit || cms.pagination?.limit || 1,
offset: query.offset || 0,
locale: headers['x-locale'],
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
.pipe(
map((invoices) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const mapNotificationList = (
total: notifications.total,
data: notifications.data.map((notification) => mapNotification(notification, cms, locale, timezone)),
},
initialFilters: cms.initialFilters,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class NotificationListBlock extends ApiModels.Block.Block {
data: Notification[];
total: Notifications.Model.Notifications['total'];
};
initialFilters?: Partial<Notifications.Model.Notification & { sort?: string }>;
}

export class Notification {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class NotificationListService {
concatMap(([cms]) => {
return this.notificationService
.getNotificationList({
...(cms.initialFilters || {}),
...query,
limit: query.limit || cms.pagination?.limit || 1,
offset: query.offset || 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const mapOrderList = (
pagination: cms.pagination,
labels: cms.labels,
reorderLabel: cms.reorderLabel,
initialFilters: cms.initialFilters,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class OrderListBlock extends ApiModels.Block.Block {
clickToSelect: string;
};
reorderLabel?: string;
initialFilters?: Partial<Orders.Model.Order & { sort?: string }>;
}

export class Order {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class OrderListService {
return this.orderService
.getOrderList(
{
...(cms.initialFilters || {}),
...query,
limit: query.limit || cms.pagination?.limit || 1,
offset: query.offset || 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const mapTicketList = (
},
forms: cms.forms,
labels: cms.labels,
initialFilters: cms.initialFilters,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class TicketListBlock extends ApiModels.Block.Block {
showMore: string;
clickToSelect: string;
};
initialFilters?: Partial<Tickets.Model.Ticket & { sort?: string }>;
}

export class Ticket {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class TicketListService {
concatMap(([cms]) => {
return this.ticketService
.getTicketList({
...(cms.initialFilters || {}),
...query,
limit: query.limit || cms.pagination?.limit || 1,
offset: query.offset || 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export class InvoiceListBlock extends Block.Block {
clickToSelect: string;
};
downloadButtonAriaDescription?: string;
initialFilters?: Partial<Invoice & { sort?: string }>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export class NotificationListBlock extends Block.Block {
clickToSelect: string;
};
detailsUrl!: string;
initialFilters?: Partial<Notification & { sort?: string }>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export class OrderListBlock extends Block.Block {
};
reorderLabel?: string;
detailsUrl!: string;
initialFilters?: Partial<Order & { sort?: string }>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export class TicketListBlock extends Block.Block {
};
detailsUrl!: string;
forms?: Link[];
initialFilters?: Partial<Ticket & { sort?: string }>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export class GetInvoiceListQuery extends PaginationQuery {
dateTo?: Date;
sort?: string;
search?: string;
locale?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ const MOCK_NOTIFICATION_LIST_BLOCK_EN: CMS.Model.NotificationListBlock.Notificat
label: 'Priority',
allowMultiple: true,
options: [
{ label: 'Low Priority', value: 'low' },
{ label: 'Medium Priority', value: 'medium' },
{ label: 'High Priority', value: 'high' },
{ label: 'Critical Priority', value: 'critical' },
{ label: 'Low Priority', value: 'LOW' },
{ label: 'Medium Priority', value: 'MEDIUM' },
{ label: 'High Priority', value: 'HIGH' },
{ label: 'Critical Priority', value: 'CRITICAL' },
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const mapInvoiceListBlock = (data: GetComponentQuery): CMS.Model.InvoiceL
table: mapTable(component.table),
downloadFileName: component.downloadFileName,
downloadButtonAriaDescription: component.downloadButtonAriaDescription,
initialFilters: undefined, // TODO: add initial filters field in CMS
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const mapNotificationListBlock = (
clickToSelect: configurableTexts.actions.clickToSelect,
},
detailsUrl: component.detailsURL as string,
initialFilters: undefined, // TODO: add initial filters field in CMS
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const mapOrderListBlock = (data: GetComponentQuery): CMS.Model.OrderListB
},
reorderLabel: component.reorderLabel,
detailsUrl: component.detailsURL as string,
initialFilters: undefined, // TODO: add initial filters field in CMS
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const mapTicketListBlock = (data: GetComponentQuery): CMS.Model.TicketLis
clickToSelect: configurableTexts.actions.clickToSelect,
},
detailsUrl: component.detailsURL as string,
initialFilters: undefined, // TODO: add initial filters field in CMS
};
}

Expand Down