Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat(composables): sorting, pagination and filtering the results with…
Browse files Browse the repository at this point in the history
… 6.2 API (#835)
  • Loading branch information
mkucmus authored Jun 30, 2020
1 parent 61af541 commit e571dec
Show file tree
Hide file tree
Showing 102 changed files with 2,179 additions and 250 deletions.
17 changes: 15 additions & 2 deletions api/composables.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { AddressType } from '@shopware-pwa/commons/interfaces/models/checkout/customer/CustomerAddress';
import { BillingAddress } from '@shopware-pwa/commons/interfaces/request/GuestOrderParams';
import { Cart } from '@shopware-pwa/commons/interfaces/models/checkout/cart/Cart';
import { ContainsFilter } from '@shopware-pwa/commons/interfaces/search/SearchFilter';
import { Country } from '@shopware-pwa/commons/interfaces/models/system/country/Country';
import { Currency } from '@shopware-pwa/commons/interfaces/models/system/currency/Currency';
import { Customer } from '@shopware-pwa/commons/interfaces/models/checkout/customer/Customer';
Expand All @@ -16,6 +17,8 @@ import { CustomerResetPasswordParam } from '@shopware-pwa/shopware-6-client';
import { CustomerUpdateEmailParam } from '@shopware-pwa/shopware-6-client';
import { CustomerUpdatePasswordParam } from '@shopware-pwa/shopware-6-client';
import { CustomerUpdateProfileParam } from '@shopware-pwa/shopware-6-client';
import { EqualsAnyFilter } from '@shopware-pwa/commons/interfaces/search/SearchFilter';
import { EqualsFilter } from '@shopware-pwa/commons/interfaces/search/SearchFilter';
import { GuestOrderParams } from '@shopware-pwa/commons/interfaces/request/GuestOrderParams';
import { LineItem } from '@shopware-pwa/commons/interfaces/models/checkout/cart/line-item/LineItem';
import { NavigationElement } from '@shopware-pwa/commons/interfaces/models/content/navigation/Navigation';
Expand All @@ -25,11 +28,11 @@ import { Product } from '@shopware-pwa/commons/interfaces/models/content/product
import { ProductListingResult } from '@shopware-pwa/commons/interfaces/response/ProductListingResult';
import { Ref } from '@vue/composition-api';
import { Salutation } from '@shopware-pwa/commons/interfaces/models/system/salutation/Salutation';
import { SearchCriteria } from '@shopware-pwa/commons/interfaces/search/SearchCriteria';
import { SessionContext } from '@shopware-pwa/commons/interfaces/response/SessionContext';
import { ShippingAddress } from '@shopware-pwa/commons/interfaces/request/GuestOrderParams';
import { ShippingMethod } from '@shopware-pwa/commons/interfaces/models/checkout/shipping/ShippingMethod';
import { ShopwareApiInstance } from '@shopware-pwa/shopware-6-client';
import { Sort } from '@shopware-pwa/commons/interfaces/search/SearchCriteria';
import { VueConstructor } from 'vue';

// @beta
Expand Down Expand Up @@ -348,9 +351,13 @@ export const useProductListing: (rootContext: ApplicationVueContext, initialList

// @alpha (undocumented)
export interface UseProductSearch {
// (undocumented)
availableFilters: Readonly<Ref<any>>;
// (undocumented)
changePage: (page: number) => Promise<void>;
// (undocumented)
changeSorting: (sorting: Sort) => void;
// (undocumented)
currentPagination: Ref<CurrentPagination | undefined>;
// (undocumented)
currentSearchTerm: Readonly<Ref<string>>;
Expand All @@ -359,13 +366,19 @@ export interface UseProductSearch {
// (undocumented)
loadingSuggestions: Readonly<Ref<boolean>>;
// (undocumented)
search: (term: string, searchCriteria?: SearchCriteria) => Promise<void>;
resetFilters: () => void;
// (undocumented)
search: (term: string) => Promise<void>;
// (undocumented)
searchResult: Readonly<Ref<ProductListingResult | null>>;
// (undocumented)
selectedFilters: Readonly<Ref<any>>;
// (undocumented)
suggestionsResult: Readonly<Ref<ProductListingResult | null>>;
// (undocumented)
suggestSearch: (term: string) => Promise<void>;
// (undocumented)
toggleFilter: (filter: EqualsFilter | EqualsAnyFilter | ContainsFilter, forceSave: boolean) => void;
}

// @alpha (undocumented)
Expand Down
12 changes: 8 additions & 4 deletions api/helpers.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
```ts

import { Aggregations } from '@shopware-pwa/commons/interfaces/search/Aggregations';
import { Category } from '@shopware-pwa/commons/interfaces/models/content/category/Category';
import { CmsPage } from '@shopware-pwa/commons/interfaces/models/content/cms/CmsPage';
import { CmsSection } from '@shopware-pwa/commons/interfaces/models/content/cms/CmsPage';
Expand Down Expand Up @@ -83,6 +84,9 @@ export function getCmsSections(content: CmsPage): CmsSection[];
// @alpha (undocumented)
export const getFilterSearchCriteria: (selectedFilters: any) => any[];

// @beta (undocumented)
export function getListingAvailableFilters(aggregations: Aggregations | undefined | null): UiCategoryFilter[];

// @alpha
export function getMessagesFromErrorsArray(errors: ShopwareError[]): string[];

Expand Down Expand Up @@ -242,7 +246,7 @@ export interface TierPrice {
unitPrice: number;
}

// @alpha (undocumented)
// @beta (undocumented)
export interface UiCategoryFilter {
// (undocumented)
name: string;
Expand All @@ -252,7 +256,7 @@ export interface UiCategoryFilter {
type: UiCategoryFilterType;
}

// @alpha (undocumented)
// @beta (undocumented)
export interface UiCategoryFilterOption {
// (undocumented)
color: boolean | string;
Expand All @@ -264,7 +268,7 @@ export interface UiCategoryFilterOption {
value: string;
}

// @alpha (undocumented)
// @beta (undocumented)
export enum UiCategoryFilterType {
// (undocumented)
entity = "entity",
Expand All @@ -276,7 +280,7 @@ export enum UiCategoryFilterType {
term = "term"
}

// @alpha (undocumented)
// @beta (undocumented)
export interface UiCategoryRangeFilterOption {
// (undocumented)
max: string;
Expand Down
7 changes: 5 additions & 2 deletions api/shopware-6-client.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,12 @@ export const getProducts: (searchCriteria?: SearchCriteria | undefined, contextI
// @alpha
export const getProductsIds: (options?: any, contextInstance?: ShopwareApiInstance) => Promise<SearchResult<string[]>>;

// @beta (undocumented)
// @beta @deprecated (undocumented)
export function getResults(term: string, searchCriteria?: SearchCriteria, contextInstance?: ShopwareApiInstance): Promise<ProductListingResult>;

// @beta (undocumented)
export function getSearchResults(term: string, searchCriteria?: SearchCriteria, contextInstance?: ShopwareApiInstance): Promise<ProductListingResult>;

// @alpha
export function getSessionContext(contextInstance?: ShopwareApiInstance): Promise<SessionContext>;

Expand Down Expand Up @@ -330,7 +333,7 @@ export interface ShopwareApiInstance {
update: (config?: ClientSettings) => void;
}

// @alpha (undocumented)
// @alpha @deprecated (undocumented)
export interface ShopwareParams {
// (undocumented)
associations?: ShopwareAssociation;
Expand Down
21 changes: 10 additions & 11 deletions docs/landing/resources/api/composables.applicationvuecontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ Applicatoin Context for Shopware PWA. It's an extended Vue instance.
```typescript
export interface ApplicationVueContext extends VueConstructor
```
<b>Extends:</b> VueConstructor
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [$cookies](./composables.applicationvuecontext._cookies.md) | any | <b><i>(BETA)</i></b> |
| [$i18n](./composables.applicationvuecontext._i18n.md) | any | <b><i>(BETA)</i></b> |
| [$router](./composables.applicationvuecontext._router.md) | any | <b><i>(BETA)</i></b> |
| [$shopwareApiInstance](./composables.applicationvuecontext._shopwareapiinstance.md) | ShopwareApiInstance | <b><i>(BETA)</i></b> |
| [$store](./composables.applicationvuecontext._store.md) | any | <b><i>(BETA)</i></b> |
| [cookies](./composables.applicationvuecontext.cookies.md) | any | <b><i>(BETA)</i></b> |
| [i18n](./composables.applicationvuecontext.i18n.md) | any | <b><i>(BETA)</i></b> |
| [router](./composables.applicationvuecontext.router.md) | any | <b><i>(BETA)</i></b> |
| [shopwareApiInstance](./composables.applicationvuecontext.shopwareapiinstance.md) | ShopwareApiInstance | <b><i>(BETA)</i></b> |
| [store](./composables.applicationvuecontext.store.md) | any | <b><i>(BETA)</i></b> |
| [$cookies](./composables.applicationvuecontext._cookies.md) | <code>any</code> | <b><i>(BETA)</i></b> |
| [$i18n](./composables.applicationvuecontext._i18n.md) | <code>any</code> | <b><i>(BETA)</i></b> |
| [$router](./composables.applicationvuecontext._router.md) | <code>any</code> | <b><i>(BETA)</i></b> |
| [$shopwareApiInstance](./composables.applicationvuecontext._shopwareapiinstance.md) | <code>ShopwareApiInstance</code> | <b><i>(BETA)</i></b> |
| [$store](./composables.applicationvuecontext._store.md) | <code>any</code> | <b><i>(BETA)</i></b> |
| [cookies](./composables.applicationvuecontext.cookies.md) | <code>any</code> | <b><i>(BETA)</i></b> |
| [i18n](./composables.applicationvuecontext.i18n.md) | <code>any</code> | <b><i>(BETA)</i></b> |
| [router](./composables.applicationvuecontext.router.md) | <code>any</code> | <b><i>(BETA)</i></b> |
| [shopwareApiInstance](./composables.applicationvuecontext.shopwareapiinstance.md) | <code>ShopwareApiInstance</code> | <b><i>(BETA)</i></b> |
| [store](./composables.applicationvuecontext.store.md) | <code>any</code> | <b><i>(BETA)</i></b> |
6 changes: 3 additions & 3 deletions docs/landing/resources/api/composables.currentpagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface CurrentPagination

| Property | Type | Description |
| --- | --- | --- |
| [currentPage](./composables.currentpagination.currentpage.md) | number \| undefined | <b><i>(BETA)</i></b> |
| [perPage](./composables.currentpagination.perpage.md) | number \| undefined | <b><i>(BETA)</i></b> |
| [total](./composables.currentpagination.total.md) | number \| undefined | <b><i>(BETA)</i></b> |
| [currentPage](./composables.currentpagination.currentpage.md) | <code>number &#124; undefined</code> | <b><i>(BETA)</i></b> |
| [perPage](./composables.currentpagination.perpage.md) | <code>number &#124; undefined</code> | <b><i>(BETA)</i></b> |
| [total](./composables.currentpagination.total.md) | <code>number &#124; undefined</code> | <b><i>(BETA)</i></b> |

12 changes: 9 additions & 3 deletions docs/landing/resources/api/composables.getapplicationcontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ export declare function getApplicationContext(rootContext: ApplicationVueContext

| Parameter | Type | Description |
| --- | --- | --- |
| rootContext | [ApplicationVueContext](./composables.applicationvuecontext.md) | |
| key | string | |
| rootContext | <code>ApplicationVueContext</code> | |
| key | <code>string</code> | |

<b>Returns:</b>

{ apiInstance: ShopwareApiInstance \| undefined; vuexStore: any; router: any; i18n: any; cookies: any; }
`{
apiInstance: ShopwareApiInstance | undefined;
vuexStore: any;
router: any;
i18n: any;
cookies: any;
}`

12 changes: 6 additions & 6 deletions docs/landing/resources/api/composables.iuseaddtocart.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export interface IUseAddToCart

| Property | Type | Description |
| --- | --- | --- |
| [addToCart](./composables.iuseaddtocart.addtocart.md) | () =&gt; Promise&lt;void&gt; | <b><i>(BETA)</i></b> Add to cart method |
| [error](./composables.iuseaddtocart.error.md) | Ref&lt;string&gt; | <b><i>(BETA)</i></b> Error message when adding to cart was not successful |
| [getStock](./composables.iuseaddtocart.getstock.md) | Ref&lt;number \| null&gt; | <b><i>(BETA)</i></b> Returns product count in stock |
| [isInCart](./composables.iuseaddtocart.isincart.md) | Ref&lt;boolean&gt; | <b><i>(BETA)</i></b> Flag if product is already in cart |
| [loading](./composables.iuseaddtocart.loading.md) | Ref&lt;boolean&gt; | <b><i>(BETA)</i></b> Adding to cart is in progress |
| [quantity](./composables.iuseaddtocart.quantity.md) | Ref&lt;number&gt; | <b><i>(BETA)</i></b> If you want to add more that 1 product set quantity before invoking <code>addToCart</code> |
| [addToCart](./composables.iuseaddtocart.addtocart.md) | <code>() =&gt; Promise&lt;void&gt;</code> | <b><i>(BETA)</i></b> Add to cart method |
| [error](./composables.iuseaddtocart.error.md) | <code>Ref&lt;string&gt;</code> | <b><i>(BETA)</i></b> Error message when adding to cart was not successful |
| [getStock](./composables.iuseaddtocart.getstock.md) | <code>Ref&lt;number &#124; null&gt;</code> | <b><i>(BETA)</i></b> Returns product count in stock |
| [isInCart](./composables.iuseaddtocart.isincart.md) | <code>Ref&lt;boolean&gt;</code> | <b><i>(BETA)</i></b> Flag if product is already in cart |
| [loading](./composables.iuseaddtocart.loading.md) | <code>Ref&lt;boolean&gt;</code> | <b><i>(BETA)</i></b> Adding to cart is in progress |
| [quantity](./composables.iuseaddtocart.quantity.md) | <code>Ref&lt;number&gt;</code> | <b><i>(BETA)</i></b> If you want to add more that 1 product set quantity before invoking <code>addToCart</code> |

22 changes: 11 additions & 11 deletions docs/landing/resources/api/composables.iusecart.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ export interface IUseCart

| Property | Type | Description |
| --- | --- | --- |
| [addProduct](./composables.iusecart.addproduct.md) | ({ id, quantity }: { id: string; quantity?: number; }) =&gt; void | <b><i>(BETA)</i></b> |
| [cart](./composables.iusecart.cart.md) | Readonly&lt;Ref&lt;Readonly&lt;Cart&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [cartItems](./composables.iusecart.cartitems.md) | Readonly&lt;Ref&lt;Readonly&lt;LineItem\[\]&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [changeProductQuantity](./composables.iusecart.changeproductquantity.md) | ({ id, quantity, }: { id: string; quantity: number; }) =&gt; void | <b><i>(BETA)</i></b> |
| [count](./composables.iusecart.count.md) | Readonly&lt;Ref&lt;Readonly&lt;number&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [error](./composables.iusecart.error.md) | Readonly&lt;Ref&lt;Readonly&lt;string&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [loading](./composables.iusecart.loading.md) | Readonly&lt;Ref&lt;Readonly&lt;boolean&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [refreshCart](./composables.iusecart.refreshcart.md) | () =&gt; void | <b><i>(BETA)</i></b> |
| [removeProduct](./composables.iusecart.removeproduct.md) | ({ id }: Partial&lt;Product&gt;) =&gt; void | <b><i>(BETA)</i></b> |
| [subtotal](./composables.iusecart.subtotal.md) | Readonly&lt;Ref&lt;Readonly&lt;number&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [totalPrice](./composables.iusecart.totalprice.md) | Readonly&lt;Ref&lt;Readonly&lt;number&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [addProduct](./composables.iusecart.addproduct.md) | <code>({ id, quantity }: {</code><br/><code> id: string;</code><br/><code> quantity?: number;</code><br/><code> }) =&gt; void</code> | <b><i>(BETA)</i></b> |
| [cart](./composables.iusecart.cart.md) | <code>Readonly&lt;Ref&lt;Readonly&lt;Cart&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [cartItems](./composables.iusecart.cartitems.md) | <code>Readonly&lt;Ref&lt;Readonly&lt;LineItem[]&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [changeProductQuantity](./composables.iusecart.changeproductquantity.md) | <code>({ id, quantity, }: {</code><br/><code> id: string;</code><br/><code> quantity: number;</code><br/><code> }) =&gt; void</code> | <b><i>(BETA)</i></b> |
| [count](./composables.iusecart.count.md) | <code>Readonly&lt;Ref&lt;Readonly&lt;number&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [error](./composables.iusecart.error.md) | <code>Readonly&lt;Ref&lt;Readonly&lt;string&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [loading](./composables.iusecart.loading.md) | <code>Readonly&lt;Ref&lt;Readonly&lt;boolean&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [refreshCart](./composables.iusecart.refreshcart.md) | <code>() =&gt; void</code> | <b><i>(BETA)</i></b> |
| [removeProduct](./composables.iusecart.removeproduct.md) | <code>({ id }: Partial&lt;Product&gt;) =&gt; void</code> | <b><i>(BETA)</i></b> |
| [subtotal](./composables.iusecart.subtotal.md) | <code>Readonly&lt;Ref&lt;Readonly&lt;number&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [totalPrice](./composables.iusecart.totalprice.md) | <code>Readonly&lt;Ref&lt;Readonly&lt;number&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |

20 changes: 10 additions & 10 deletions docs/landing/resources/api/composables.iusecheckout.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export interface IUseCheckout

| Property | Type | Description |
| --- | --- | --- |
| [billingAddress](./composables.iusecheckout.billingaddress.md) | Readonly&lt;Ref&lt;BillingAddress \| undefined&gt;&gt; | <b><i>(BETA)</i></b> |
| [createOrder](./composables.iusecheckout.createorder.md) | () =&gt; Promise&lt;Order&gt; | <b><i>(BETA)</i></b> |
| [getPaymentMethods](./composables.iusecheckout.getpaymentmethods.md) | (options?: { forceReload: boolean; }) =&gt; Promise&lt;Readonly&lt;Ref&lt;readonly PaymentMethod\[\]&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [getShippingMethods](./composables.iusecheckout.getshippingmethods.md) | (options?: { forceReload: boolean; }) =&gt; Promise&lt;Readonly&lt;Ref&lt;readonly ShippingMethod\[\]&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [guestOrderParams](./composables.iusecheckout.guestorderparams.md) | Ref&lt;Readonly&lt;Partial&lt;GuestOrderParams&gt;&gt;&gt; | <b><i>(BETA)</i></b> |
| [isGuestOrder](./composables.iusecheckout.isguestorder.md) | Readonly&lt;Ref&lt;boolean&gt;&gt; | <b><i>(BETA)</i></b> Flag isGuestOrder is true when user is not logged in |
| [paymentMethods](./composables.iusecheckout.paymentmethods.md) | Readonly&lt;Ref&lt;readonly PaymentMethod\[\]&gt;&gt; | <b><i>(BETA)</i></b> |
| [shippingAddress](./composables.iusecheckout.shippingaddress.md) | Readonly&lt;Ref&lt;ShippingAddress \| undefined&gt;&gt; | <b><i>(BETA)</i></b> |
| [shippingMethods](./composables.iusecheckout.shippingmethods.md) | Readonly&lt;Ref&lt;readonly ShippingMethod\[\]&gt;&gt; | <b><i>(BETA)</i></b> |
| [updateGuestOrderParams](./composables.iusecheckout.updateguestorderparams.md) | (params: Partial&lt;GuestOrderParams&gt;) =&gt; void | <b><i>(BETA)</i></b> |
| [billingAddress](./composables.iusecheckout.billingaddress.md) | <code>Readonly&lt;Ref&lt;BillingAddress &#124; undefined&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [createOrder](./composables.iusecheckout.createorder.md) | <code>() =&gt; Promise&lt;Order&gt;</code> | <b><i>(BETA)</i></b> |
| [getPaymentMethods](./composables.iusecheckout.getpaymentmethods.md) | <code>(options?: {</code><br/><code> forceReload: boolean;</code><br/><code> }) =&gt; Promise&lt;Readonly&lt;Ref&lt;readonly PaymentMethod[]&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [getShippingMethods](./composables.iusecheckout.getshippingmethods.md) | <code>(options?: {</code><br/><code> forceReload: boolean;</code><br/><code> }) =&gt; Promise&lt;Readonly&lt;Ref&lt;readonly ShippingMethod[]&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [guestOrderParams](./composables.iusecheckout.guestorderparams.md) | <code>Ref&lt;Readonly&lt;Partial&lt;GuestOrderParams&gt;&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [isGuestOrder](./composables.iusecheckout.isguestorder.md) | <code>Readonly&lt;Ref&lt;boolean&gt;&gt;</code> | <b><i>(BETA)</i></b> Flag isGuestOrder is true when user is not logged in |
| [paymentMethods](./composables.iusecheckout.paymentmethods.md) | <code>Readonly&lt;Ref&lt;readonly PaymentMethod[]&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [shippingAddress](./composables.iusecheckout.shippingaddress.md) | <code>Readonly&lt;Ref&lt;ShippingAddress &#124; undefined&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [shippingMethods](./composables.iusecheckout.shippingmethods.md) | <code>Readonly&lt;Ref&lt;readonly ShippingMethod[]&gt;&gt;</code> | <b><i>(BETA)</i></b> |
| [updateGuestOrderParams](./composables.iusecheckout.updateguestorderparams.md) | <code>(params: Partial&lt;GuestOrderParams&gt;) =&gt; void</code> | <b><i>(BETA)</i></b> |

Loading

1 comment on commit e571dec

@vercel
Copy link

@vercel vercel bot commented on e571dec Jun 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.