/* * Copyright (c) 2016 VMware, Inc. All Rights Reserved. * This software is released under MIT license. * The full license information can be found in LICENSE in the root directory of this project. */ export const EXAMPLES = { stateInterface: ` interface State { page?: { from?: number; to?: number; size?: number; } sort?: { by: string | Comparator reverse: boolean; }; filters?: ({property: string, value: string} | Filter)[]; } `, serverDrivenTS: ` import {State} from "clarity-angular"; class MyComponent { users: User[]; total: number; loading: boolean = true; refresh(state: State) { this.loading = true; // We convert the filters from an array to a map, // because that's what our backend-calling service is expecting let filters:{[prop:string]: any[]} = {}; if (state.filters) { for (let filter of state.filters) { let {property, value} = <{property: string, value: string}>filter; filters[property] = [value]; } } this.inventory.filter(filters) .sort(<{by: string, reverse: boolean}>state.sort) .fetch(state.page.from, state.page.size) .then((result: FetchResult) => { this.users = result.users; this.total = result.length; this.loading = false; }); } } `, serverDrivenHTML: ` User ID Name Creation date Pokemon Favorite color {{user.id}} {{user.name}} {{user.creation | date}} {{user.pokemon.name}} {{pagination.firstItem + 1}} - {{pagination.lastItem + 1}} of {{total}} users ` };