Last active
June 1, 2021 14:55
-
-
Save mohamedali-s-4725/76a1c2e7dc71c91e4c9aa6627b3c2c32 to your computer and use it in GitHub Desktop.
Data-down component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
export default Component.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
export default Component.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
export default Component.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import object from "@ember/object"; | |
import { A } from '@ember/array'; | |
export default Controller.extend({ | |
routeList: A(), | |
isOfferEnabled: false, | |
init(){ | |
this._super(...arguments); | |
this.getUserWalletDetails(); | |
this.pushCollectionToStore(); | |
}, | |
getUserWalletDetails(){ | |
this.store.createRecord('wallet', {balance: 100}); | |
}, | |
pushCollectionToStore(){ | |
let mensWear = this.getCollectionList(); | |
// Pushing `Shirts` to Ember Store | |
mensWear.shirts.forEach(( collectionObj ) => { | |
this.store.createRecord('shirt', collectionObj); | |
}); | |
// Pushing `Foot Wears` to Ember Store | |
mensWear.footwears.forEach(( collectionObj ) => { | |
this.store.createRecord('footwear', collectionObj); | |
}); | |
// Pushing `Watches` to Ember Store | |
mensWear.watches.forEach(( collectionObj ) => { | |
this.store.createRecord('watch', collectionObj); | |
}); | |
}, | |
getCollectionList(){ | |
let mensWear = object.create({ | |
shirts: A([ | |
object.create({ | |
brand: 'OTTO', | |
availability: 2, | |
price: 5, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'Peter England', | |
availability: 8, | |
price: 7, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'Raymond', | |
availability: 20, | |
price: 10, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'POLO', | |
availability: 10, | |
price: 6, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'Allen Solly', | |
availability: 15, | |
price: 5, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'Levis', | |
availability: 8, | |
price: 4, | |
countInCart: 0 | |
}) | |
]), | |
footwears : A([ | |
object.create({ | |
brand: 'Nike shoes', | |
availability: 6, | |
price: 8, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'Brooks', | |
availability:11, | |
price: 7, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'topo', | |
availability: 3, | |
price: 10, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'Adidas', | |
availability: 30, | |
price: 12, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'PUMA', | |
availability: 12, | |
price: 16, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'Reebok', | |
availability: 4, | |
price: 6, | |
countInCart: 0 | |
}) | |
]), | |
watches : A([ | |
object.create({ | |
brand: 'TITAN', | |
availability: 6, | |
price: 18, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'EBEL', | |
availability:11, | |
price: 7, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'OMEGA', | |
availability: 3, | |
price: 10, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'ROLEX', | |
availability: 30, | |
price: 20, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'PUMA', | |
availability: 12, | |
price: 10, | |
countInCart: 0 | |
}), | |
object.create({ | |
brand: 'FASTRACK', | |
availability: 3, | |
price: 11, | |
countInCart: 0 | |
}) | |
]) | |
}); | |
return mensWear; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
export default Controller.extend({ | |
shopkeeper: service(), | |
canRemoveFromCart: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
export default Controller.extend({ | |
shopkeeper: service(), | |
canAddToCart: true, | |
canRemoveFromCart: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
export default Controller.extend({ | |
shopkeeper: service(), | |
canAddToCart: true, | |
canRemoveFromCart: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
export default Controller.extend({ | |
shopkeeper: service(), | |
canAddToCart: true, | |
canRemoveFromCart: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
import { inject as service } from '@ember/service'; | |
import { set } from "@ember/object"; | |
export default Controller.extend({ | |
shopkeeper: service(), | |
userNavigatedTo: '', | |
canAddToCart: false, | |
canRemoveFromCart: false, | |
showWalletBalance: true, | |
userWallet: null, | |
canCalculateBill: true, | |
showCartItems: false, | |
init() { | |
this._super(...arguments); | |
if (this.showWalletBalance) { | |
let userWallet = this.store.peekAll('wallet').firstObject; | |
set(this, 'userWallet', userWallet); | |
} | |
}, | |
actions: { | |
toggleCart(){ | |
this.toggleProperty('showCartItems'); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Controller from '@ember/controller'; | |
export default Controller.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
export default Model.extend({ | |
brand: attr('string'), | |
availability: attr('number'), | |
price: attr('number'), | |
countInCart: attr('number'), | |
type: attr('string') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CollectionModel from './collection'; | |
export default CollectionModel.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CollectionModel from './collection'; | |
export default CollectionModel.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from 'ember-data/model'; | |
import attr from 'ember-data/attr'; | |
export default Model.extend({ | |
balance: attr('number') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CollectionModel from './collection'; | |
export default CollectionModel.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import EmberRouter from '@ember/routing/router'; | |
import config from './config/environment'; | |
const Router = EmberRouter.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('userwallet', {path:'wallet'}); | |
this.route('menswear', function() { | |
this.route('shirts'); | |
this.route('footwears'); | |
this.route('accessories'); | |
}); | |
this.route('cart', function() { | |
this.route('billing'); | |
}); | |
this.route('offer'); | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
afterModel(){ | |
this.transitionTo('userwallet'); | |
// this.transitionTo('menswear.shirts'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
import object from "@ember/object"; | |
export default Route.extend({ | |
model(){ | |
return [ this.store.peekAll('shirt'), | |
this.store.peekAll('footwear'), | |
this.store.peekAll('watch') | |
]; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
model(){ | |
return this.store.peekAll('watch'); | |
}, | |
actions: { | |
didTransition(){ | |
this.send("navigateTo", 'Watches & Accessories'); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
model(){ | |
return this.store.peekAll('footwear'); | |
}, | |
actions: { | |
didTransition(){ | |
this.send("navigateTo", 'Foot wears'); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
model(){ | |
return this.store.peekAll('shirt'); | |
}, | |
actions: { | |
didTransition(){ | |
this.send("navigateTo", 'Shirts'); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
import object, { get, set } from "@ember/object"; | |
import { A } from '@ember/array'; | |
export default Route.extend({ | |
model(){ | |
return [ this.store.peekAll('shirt'), | |
this.store.peekAll('footwear'), | |
this.store.peekAll('watch') | |
]; | |
}, | |
actions: { | |
didTransition(){ | |
this.send('navigateTo', ''); | |
this.send('updateRouteList'); | |
}, | |
navigateTo( section ){ | |
set(this.controller, 'userNavigatedTo', section); | |
}, | |
updateRouteList(){ | |
let routeList = A([ | |
object.create({ | |
path: 'menswear.shirts', | |
name: 'Shirts' | |
}), | |
object.create({ | |
path: 'menswear.footwears', | |
name: 'Foot wears' | |
}), | |
object.create({ | |
path: 'menswear.accessories', | |
name: 'Watches & Accessories' | |
}) | |
]); | |
set(this.controllerFor('application'), 'routeList', routeList); | |
}, | |
willTransition(transition){ | |
if(transition.to.name.indexOf('menswear') === -1){ | |
A(get(this.controllerFor('application'), 'routeList')).clear(); | |
} | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Route from '@ember/routing/route'; | |
export default Route.extend({ | |
model(){ | |
return this.store.peekAll('wallet').firstObject; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Service from '@ember/service'; | |
import { action, set } from '@ember/object'; | |
import { inject as service } from '@ember/service'; | |
export default Service.extend({ | |
store: service(), | |
addItemToCart: action( function(selectedItem){ | |
if ( selectedItem.availability !== selectedItem.countInCart) { | |
set(selectedItem, 'countInCart', selectedItem.countInCart+1); | |
} | |
}), | |
removeItemFromCart: action( function(selectedItem) { | |
set(selectedItem, 'countInCart', selectedItem.countInCart-1); | |
}), | |
autoGenerateBill: action( function(){ | |
}), | |
getItemDetails: action( function(){ | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.parent-container { | |
display: flex; | |
} | |
h1 { | |
font-family: fantasy; | |
} | |
.p-10 { | |
padding: 10px; | |
} | |
.inline-block { | |
display: inline-block; | |
} | |
.font-grey { | |
color: grey; | |
} | |
li { | |
padding: 10px; | |
} | |
.left-panel { | |
border-right: 1px solid green; | |
height: 500px; | |
margin-left: 10px; | |
padding-right: 10px; | |
width: 20%; | |
} | |
.right-panel { | |
margin-left: 30px; | |
width: 75%; | |
} | |
.left-panel a { | |
color: #0060B6; | |
text-decoration: none; | |
} | |
.left-panel a:hover, .left-panel a.active { | |
font-size: 21px; | |
color:#00A0C6; | |
text-decoration:none; | |
cursor:pointer; | |
} | |
.show-cart-btn { | |
padding: 5px 8px; | |
border-radius: 6px; | |
font-size: 16px; | |
font-style: italic; | |
float: right; | |
cursor: pointer; | |
background: #fbfbfb; | |
} | |
.collection-container.adjust { | |
display: flex; | |
} | |
.collection-container { | |
height: 350px; | |
} | |
.collection-list-container.adjust { | |
width: 60%; | |
} | |
.side-pane { | |
width: 35%; | |
border: 1px solid #ececec; | |
margin-left: 30px; | |
background: #fbfbfb; | |
padding: 5px; | |
border-radius: 6px; | |
} | |
#menswear span a { | |
color: black; | |
text-decoration: none; | |
} | |
#menswear div li { | |
color: grey; | |
user-select: none; | |
display: inline-block; | |
} | |
#menswear div li b { | |
font-size: 15px; | |
margin-left: 20px; | |
} | |
#menswear div li .remove-icon { | |
font-size: 13px; | |
position: relative; | |
} | |
.hover-show { | |
display: none; | |
} | |
#menswear div li i { | |
color: red; | |
font-size: 14px; | |
} | |
#menswear div li:hover .hover-show{ | |
display: inline-block; | |
} | |
#menswear div li:hover { | |
color: black; | |
cursor:grab; | |
} | |
#menswear div li:hover .grey{ | |
color: grey; | |
} | |
#menswear div li.disabled:hover { | |
color: grey; | |
cursor:no-drop; | |
} | |
.right-panel a { | |
color: #0060B6; | |
text-decoration: none; | |
} | |
.right-panel a:hover, .right-panel a.active, #menswear span a:hover { | |
font-size: 18px; | |
color:#00A0C6; | |
text-decoration:none; | |
cursor:pointer; | |
} | |
.info { | |
padding: 10px; | |
font-size: 14px; | |
border-left: 4px solid #ccc!important; | |
border-color: #219cf3!important; | |
color: #000!important; | |
background-color: #ddefff!important; | |
border-radius: 6px; | |
box-shadow: 0 0 3px 1px rgb(0 0 0 / 10%); | |
} | |
#cart .info, .cart-list .info { | |
border-color: #f3cf21!important; | |
color: #000!important; | |
background-color: #ffeddd!important; | |
} | |
.cart-list { | |
height: calc(100vh - 350px)!important; | |
overflow: auto; | |
overflow-x: hidden; | |
} | |
.order-btn { | |
position: absolute; | |
right: 60px; | |
padding: 10px 25px 10px 25px; | |
background: #d6efe0; | |
border: 1px solid #70b58e; | |
font-family: serif; | |
font-size: 18px; | |
border-radius: 12px; | |
margin-top: 15px; | |
} | |
.order-btn a:hover { | |
font-size: 18px; | |
} | |
.footer { | |
position: sticky; | |
top: 85%; | |
width: 75%; | |
} | |
.cursor-pointer { | |
cursor: pointer; | |
} | |
.footer a:hover, .footer a.active { | |
color: #0060B6; | |
font-size: 16px; | |
text-decoration: none; | |
} | |
marquee { | |
color: brown; | |
margin: 18px 200px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.17.1", | |
"EmberENV": { | |
"FEATURES": {}, | |
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, | |
"_APPLICATION_TEMPLATE_WRAPPER": true, | |
"_JQUERY_INTEGRATION": true | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", | |
"ember": "3.11.1", | |
"ember-template-compiler": "3.11.1", | |
"ember-testing": "3.11.1" | |
}, | |
"addons": { | |
"@glimmer/component": "1.0.0", | |
"ember-truth-helpers": "2.0.0", | |
"ember-data": "3.11.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment