Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
0.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemanja Popovic committed Nov 6, 2015
1 parent f2a6afd commit e92bcb7
Show file tree
Hide file tree
Showing 12 changed files with 458 additions and 49 deletions.
1 change: 1 addition & 0 deletions config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = function(config){

'public/js/app/home/home-index.js',
'public/js/app/home/controllers/home-ctrl.js',
'public/js/app/home/services/home-svc.js',

'public/js/app/search/search-index.js',
'public/js/app/search/controllers/search-list-ctrl.js',
Expand Down
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
<script src="js/app/orders/services/orders-rest.js"></script>
<script src="js/app/home/home-index.js"></script>
<script src="js/app/home/controllers/home-ctrl.js"></script>
<script src="js/app/home/directives/site-content-image-directive.js"></script>
<script src="js/app/home/services/home-svc.js"></script>
<script src="js/app/products/products-index.js"></script>
<script src="js/app/products/controllers/browse-products-ctrl.js"></script>
<script src="js/app/products/controllers/product-detail-ctrl.js"></script>
Expand Down
46 changes: 27 additions & 19 deletions public/js/app/home/controllers/home-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@
* license agreement you entered into with hybris.
*/

'use strict';
(function () {
'use strict';

angular.module('ds.home')
angular.module('ds.home')
.controller('HomeCtrl', ['$scope', 'HomeSvc',
function ($scope, HomeSvc) {

.controller('HomeCtrl', ['$scope',
function ($scope) {
$scope.carouselInterval = 5000;
$scope.slidesLarge = [];
$scope.slidesSmall = [];
$scope.banner1 = {};
$scope.banner2 = {};

$scope.carouselInterval = 5000;
//Get site content data from service
$scope.getSiteContent = function getSiteContent() {
var siteContent = HomeSvc.init();

$scope.slides = [
{
id: 'audioBanner',
image: './img/homePg-hero-audio.jpg',
state: 'base.category'
},
{
id: 'officeBanner',
image: './img/homePg-hero-office.jpg',
state: 'base.category'
}
];
$scope.slidesLarge = siteContent.slidesLarge;
$scope.slidesSmall = siteContent.slidesSmall;
$scope.banner1 = siteContent.banner1;
$scope.banner2 = siteContent.banner2;
};

//Init site content data
$scope.getSiteContent();

}]
);
//Listen for site change event
$scope.$on('site:updated', function siteUpdated() {
$scope.getSiteContent();
});

}]);
})();
27 changes: 27 additions & 0 deletions public/js/app/home/directives/site-content-image-directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* [y] hybris Platform
*
* Copyright (c) 2000-2015 hybris AG
* All rights reserved.
*
* This software is the confidential and proprietary information of hybris
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with hybris.
*/

(function () {
'use strict';

angular.module('ds.home')
.directive('siteContentImage', function () {
return {
restrict: 'E',
scope: {
image: '=',
id: '@imageId'
},
templateUrl: 'js/app/home/templates/site-content-image.html'
};
});
})();
108 changes: 108 additions & 0 deletions public/js/app/home/services/home-svc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* [y] hybris Platform
*
* Copyright (c) 2000-2015 hybris AG
* All rights reserved.
*
* This software is the confidential and proprietary information of hybris
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with hybris.
*/

(function () {
'use strict';

angular.module('ds.home')
.service('HomeSvc', ['GlobalData', 'settings', '$state',
function (GlobalData, settings, $state) {

var homeBannerId = 'homeBanner';

/**
* Initializes all site content in objects that can be used in UI
* @return object that contains carousel images and banners
*/
var init = function init() {
var self = this;
var slidesLarge = [];
var slidesSmall = [];
var banner1 = {};
var banner2 = {};
var siteContent = GlobalData.getSiteBanners();

if (self.siteContentExists(siteContent)) {
if (!!siteContent.topImages && siteContent.topImages.length > 0) {

for (var i = 0; i < siteContent.topImages.length; i++) {
if (!!siteContent.topImages[i].large && siteContent.topImages[i].large.imageUrl !== '') {
slidesLarge.push({ id: homeBannerId, image: siteContent.topImages[i].large });
}

if (!!siteContent.topImages[i].small && siteContent.topImages[i].small.imageUrl !== '') {
slidesSmall.push({ id: homeBannerId, image: siteContent.topImages[i].small });
}
}
}
banner1 = siteContent.banner1;
banner2 = siteContent.banner2;
}
else {
//Redirect to all products page
$state.go(settings.allProductsState);
}

return {
slidesLarge: slidesLarge,
slidesSmall: slidesSmall,
banner1: banner1,
banner2: banner2
};
};

/**
* Checks if there is any site content defined for selected site
* @param siteContent - current site content
* @return true/false value that shows if there is site content for provided site
*/
var siteContentExists = function siteContentExists(siteContent) {
if (!siteContent) {
return false;
}

if (!!siteContent.topImages) {
for (var i = 0; i < siteContent.topImages.length; i++) {
if (!!siteContent.topImages[i] &&
!!siteContent.topImages[i].large &&
(siteContent.topImages[i].large.imageUrl !== '' ||
siteContent.topImages[i].small.imageUrl !== '')) {
return true;
}
}
}

if (!!siteContent.banner1 &&
!!siteContent.banner1.large &&
(siteContent.banner1.large.imageUrl !== '' ||
siteContent.banner1.small.imageUrl !== '')) {
return true;
}

if (!!siteContent.banner2 && !!
!!siteContent.banner2.large &&
(siteContent.banner2.large.imageUrl !== '' ||
siteContent.banner2.small.imageUrl !== '')) {
return true;
}

return false;
};

return {
init: init,
siteContentExists: siteContentExists
};

}]);

})();
35 changes: 26 additions & 9 deletions public/js/app/home/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
<div class="homepageContainer" match-background>
<div class="homepageCarouselContainer">
<carousel interval="carouselInterval">
<slide ng-repeat="slide in slides" active="slide.active">
<a data-ui-sref="{{slide.state}}">
<img ng-src="{{slide.image}}" id="{{slide.id}}" class="banner">
</a>
<!-- Top Images Carousel - Large -->
<carousel interval="carouselInterval" class="visible-lg">
<slide ng-repeat="slide in slidesLarge" active="slide.active">
<site-content-image image="slide.image" image-id="{{slide.id}}"></site-content-image>
</slide>
</carousel>

<!-- Top Images Carousel - Small -->
<carousel interval="carouselInterval" class="hidden-lg">
<slide ng-repeat="slide in slidesSmall" active="slide.active">
<site-content-image image="slide.image" image-id="{{slide.id}}"></site-content-image>
</slide>
</carousel>
<div class="carouselImages">
<div class="content-container clearfix">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<img src="./img/homePg-banner3.jpg" alt="free gift" />

<!-- Banner 1 -->
<div class="hidden-xs col-sm-6 col-md-6 col-lg-6">
<site-content-image image="banner1.large" image-id="banner1"></site-content-image>
</div>
<div class="hidden-xs col-sm-6 col-md-6 col-lg-6">
<site-content-image image="banner2.large" image-id="banner2"></site-content-image>
</div>

<!-- Banner 2 -->
<div class="col-xs-12 hidden-sm hidden-md hidden-lg">
<site-content-image image="banner1.small" image-id="banner1"></site-content-image>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
<img src="./img/homePg-banner4.jpg" alt="flight collection" />
<div class="col-xs-12 hidden-sm hidden-md hidden-lg">
<site-content-image image="banner2.small" image-id="banner2"></site-content-image>
</div>

</div>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions public/js/app/home/templates/site-content-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

<div ng-if="image.hyperlinkUrl !== ''">
<a ng-if="image.internal" href="{{image.hyperlinkUrl}}">
<img ng-src="{{image.imageUrl}}" id="{{id}}" class="banner" />
</a>
<a ng-if="!image.internal" href="{{image.hyperlinkUrl}}" target="_blank">
<img ng-src="{{image.imageUrl}}" id="{{id}}" class="banner" />
</a>
</div>
<img ng-if="image.hyperlinkUrl === ''" ng-src="{{image.imageUrl}}" id="{{id}}" class="banner" />
15 changes: 11 additions & 4 deletions public/js/app/shared/services/global-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ angular.module('ds.shared')
}

//Emit site change for cart
$rootScope.$emit('site:updated');
$rootScope.$broadcast('site:updated');
}
},

Expand Down Expand Up @@ -358,10 +358,17 @@ angular.module('ds.shared')
return null;
}
},

getEmailRegEx: function(){

getSiteBanners: function () {
if (!!currentSite && !!currentSite.mixins) {
return currentSite.mixins.siteContentDetails;
}
return null;
},

getEmailRegEx: function () {
return (/^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i);

},

getUserTitles: function () {
Expand Down
1 change: 1 addition & 0 deletions public/js/app/shared/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ angular.module('ds.shared')

homeState: 'base.home',
checkoutState: 'base.checkout.details',
allProductsState: 'base.category',

eventSource: {
login: 'login',
Expand Down
10 changes: 1 addition & 9 deletions test/e2e/coupon-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ describe('coupons:', function () {
it('should not allow user to add coupon if not logged in', function () {
tu.loadProductIntoCart('1', '$14.92');
tu.clickElement('linkText', 'ADD COUPON CODE');
tu.sendKeys('id', 'coupon-code', '10PERCENT');
tu.sendKeys('id', 'coupon-code', 'SIGNEDIN');
tu.clickElement('id', 'apply-coupon');
expect(element(by.binding('couponErrorMessage')).getText()).toEqual('SIGN IN TO USE COUPON CODE');
});

it('should not allow user to add coupon below minimum on cart', function () {
tu.loginHelper('[email protected]', 'password');
tu.loadProductIntoCart('1', '$14.92');
tu.clickElement('linkText', 'ADD COUPON CODE');
tu.sendKeys('id', 'coupon-code', '20MINIMUM');
Expand All @@ -76,7 +75,6 @@ describe('coupons:', function () {
});

it('should not allow user to add coupon with incorrect currency', function () {
tu.loginHelper('[email protected]', 'password');
browser.wait(function () {
return element(by.xpath(tu.whiteCoffeeMug)).isPresent();
});
Expand Down Expand Up @@ -110,23 +108,20 @@ describe('coupons:', function () {
});

it('should add percentage off coupon on cart', function () {
tu.loginHelper('[email protected]', 'password');
addProductandApplyCoupon('10PERCENT', '$14.92');
verifyCartDetails('1', '$13.77', '-$1.07');
tu.clickElement('id', 'remove-coupon');
removeFromCart();
});

it('should add dollar off coupon on cart', function () {
tu.loginHelper('[email protected]', 'password');
addProductandApplyCoupon('10DOLLAR', '$14.92');
verifyCartDetails('1', '$4.22', '-$10.00');
tu.clickElement('id', 'remove-coupon');
removeFromCart();
});

it('update coupon totals when item is added and removed from cart', function () {
tu.loginHelper('[email protected]', 'password');
addProductandApplyCoupon('10PERCENT', '$14.92');
verifyCartDetails('1', '$13.77', '-$1.07');
tu.clickElement('id', 'continue-shopping');
Expand Down Expand Up @@ -157,7 +152,6 @@ describe('coupons:', function () {
});

it('should update coupon totals when quantity is changed', function () {
tu.loginHelper('[email protected]', 'password');
addProductandApplyCoupon('10PERCENT', '$14.92');
verifyCartDetails('1', '$13.77', '-$1.07');
tu.sendKeys('xpath', tu.cartQuantity, '5');
Expand All @@ -169,7 +163,6 @@ describe('coupons:', function () {
});

it('should remove coupon on cart', function () {
tu.loginHelper('[email protected]', 'password');
addProductandApplyCoupon('10PERCENT', '$14.92');
verifyCartDetails('1', '$13.77', '-$1.07');
tu.clickElement('id', 'remove-coupon')
Expand All @@ -179,7 +172,6 @@ describe('coupons:', function () {
});

it('should not allow user to use expired coupon on cart', function () {
tu.loginHelper('[email protected]', 'password');
addProductandApplyCoupon('EXPIRED', '$14.92');
expect(element(by.binding('couponErrorMessage')).getText()).toEqual('COUPON HAS EXPIRED.');
removeFromCart();
Expand Down
Loading

0 comments on commit e92bcb7

Please sign in to comment.