Skip to content

Instantly share code, notes, and snippets.

@SiddiqueAhmad
Last active February 8, 2021 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiddiqueAhmad/4c3d1c4c88222edd3d22 to your computer and use it in GitHub Desktop.
Save SiddiqueAhmad/4c3d1c4c88222edd3d22 to your computer and use it in GitHub Desktop.
[{"name":" Schweppes Soft Drink (Ginger Ale,Tonic Water,300ml) ","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/5/4/5472.jpg","price":80,"lastpurchased":38},{"name":"Heinz Beans (Baked Beanz,415g)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/0/0/003181_1.jpg","price":110,"lastpurchased":84},{"name":"Bounty Chocolate (Bar) 57g","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/b/o/bounty_chocolate_coconut_85_g__1.jpg","price":60,"lastpurchased":47.9166},{"name":"Old Elpaso Tortila 8 Flour Wraps 8 inch 311g","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/4/6/46000273426.jpg","price":350,"lastpurchased":295},{"name":"Mirinda Soft Drink (150ml)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/0/2/020310090758_untitled-1_20copy.jpg","price":60,"lastpurchased":29.45},{"name":"McCain Frozen Food (Smiles,450g)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/o/r/original1.993423.2.jpg","price":250,"lastpurchased":225},{"name":" Hersheys Syrup (680g,Chocolate) ","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/s/y/syrup.jpg","price":310,"lastpurchased":270},{"name":" Nestle Yogurt (Natural) ","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/n/e/nestle-yogurt-detail.jpg","price":90,"lastpurchased":77.25},{"name":"Pringles Chips (Original,40g)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/p/r/pringles_original_40g.jpg","price":70,"lastpurchased":60},{"name":"Rafhan Baking Jelly (Strawberry,80g)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/8/9/8961014189513_1.jpg","price":55,"lastpurchased":50.84},{"name":"CADBURY D/M 49G FRUIT&NUT","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/7/1/71_5jdhd1vl._sl1500_.jpg","price":95,"lastpurchased":81.25},{"name":"Betty Crocker Cake Mixes (French Vanilla,432g)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/b/e/betty-crocker-cake-mix-_sup.jpg","price":250,"lastpurchased":205},{"name":"Cakes (C5,Caramel,150g) Galaxy","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/i/m/image_11_18.jpg","price":690,"lastpurchased":209},{"name":"PINAR LABANEH 200G","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/p/i/pinar_laban_labne_200_g_.jpg","price":430,"lastpurchased":8.5},{"name":"Chips (311.8g,Spicy Sweet Chilli) Doritos","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/b/u/bugles_spicy_sweet_chili.jpg","price":530,"lastpurchased":500},{"name":"Gerber Baby Juice (Pear,118ml)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/g/e/gerber-baby-juice-_100_-pea.jpg","price":160,"lastpurchased":56.23},{"name":"Kettle Chips (Sour Cream,Sweet Onion,40g)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df…ab33525d08d6e5fb8d27136e95/k/e/kettle_chips_sour_cream_sweet_onion_40g.jpg","price":210,"lastpurchased":140},{"name":"Cadbury Chocolate (Dairy Milk,Whole Nut,200g)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/1/2/12756_4.1405593347.jpg","price":310,"lastpurchased":245},{"name":"Lurpak Fresh Butter (250g,Spreadable,Unsalted )","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/5/7/5740900806405.jpg","price":360,"lastpurchased":325},{"name":"Lurpak Fresh Butter (Spreadable,Salted ) 250g","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/8/8/8847415115806.jpg","price":360,"lastpurchased":325},{"name":"Mac Biscuits Marie Finge 200g","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/m/c/mcvities_biscuit_marie_finger_200_g_.png","price":190,"lastpurchased":165},{"name":" Maltesers Thick Shake 300ml","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/5/0/5060122037082.jpg","price":350,"lastpurchased":190},{"name":"Elle & Vire Whipping Cream (Liquide,198ml)","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df…b33525d08d6e5fb8d27136e95/e/l/elle_vire_whipping_cream_excellence_1_l_.jpg","price":390,"lastpurchased":264.99},{"name":"Chips (Crunchy Cheese ,30g) Cheetos","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/c/h/cheetos_crunchy_cheese_snacks.jpg","price":50,"lastpurchased":45.08},{"name":"MENTOS GUM SPEARMI 15'30G","image":"http://localhost/media/catalog/product/cache/1/thumbnail/9df78eab33525d08d6e5fb8d27136e95/m/e/mentos.jpg","price":140,"lastpurchased":130}]
<template>
<section class="au-animate">
<h2>${heading}</h2>
<label for="search">Search Items:</label>
<input id="search" type="text" value.bind="searchText" />
<div class="dropdown" align="right">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Sort
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu1">
<li><a href="#">Price High to Low</a></li>
<li><a href="#">Price Low to High</a></li>
<li><a href="#">Latest</a></li>
</ul>
</div>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="checkbox" checked.bind="higestSold"> Highest Sold
</label>
<label class="btn btn-default">
<input type="checkbox" checked.bind="deadItems"> Dead Items
</label>
<label class="btn btn-default">
<input type="checkbox" checked.bind="lowestSold"> Lowest Sold
</label>
<label class="btn btn-default">
<input type="checkbox" checked.bind="adjusted"> Adjusted
</label>
<label class="btn btn-default ${notAdjusted ? 'active' : ''}">
<input type="checkbox" checked.bind="notAdjusted"> Not Adjusted
</label>
<label class="btn btn-default ${activeItems ? 'active' : ''}" click.delegate="filterItems()" >
<input type="checkbox" checked.bind="activeItems" > Active
</label>
<label class="btn btn-default">
<input type="checkbox" checked.bind="inActive"> In Active
</label>
</div>
<div class="row au-stagger">
<div class="col-sm-6 col-md-3 flickr-img au-animate" repeat.for="item of items">
<a class="thumbnail">
<img src.bind="item.image"/>
</a>
<div class="caption">
<h3>${item.name}</h3>
<p>Retail: ${item.price}</p>
</div>
</div>
</div>
</section>
</template>
import {inject} from 'aurelia-framework';
import {ItemService} from './item-service';
@inject(ItemService)
export class Search{
heading = 'Search';
searchText = '';
higestSold = false;
deadItems = false;
lowestSold = false;
adjusted = false;
notAdjusted = false;
activeItems = true;
inActive = false;
items = [];
constructor(ItemService){
this.ItemService = ItemService;
}
activate(params){
return this.ItemService.getItems(params).then(response => {
this.items = response.content.data;
});
}
filterItems() {
this.items = [];
let filters = {};
filters.activeItems = this.activeItems
filters.inActive = this.inActive
this.ItemService.getItems(filters).then(response => {
this.items = [];
this.items = response.content.data;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment