Skip to content

Commit

Permalink
Merge pull request #94 from ordercloud-api/v1.0.0-pre-release
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
yb0rc1ty authored May 18, 2017
2 parents e90452c + f7494bd commit 595fb1e
Show file tree
Hide file tree
Showing 130 changed files with 2,723 additions and 2,253 deletions.
1 change: 1 addition & 0 deletions gulp.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function getConstants() {
result.apiurl = 'https://api.ordercloud.io';
}
if (process.env.clientid) result.clientid = process.env.clientid;
if (process.env.anonymous) result.anonymous = process.env.anonymous;
if (process.env.appname) result.appname = process.env.appname;
if (process.env.scope) result.scope = process.env.scope;
if (process.env.ocscope) result.ocscope = process.env.ocscope;
Expand Down
6 changes: 3 additions & 3 deletions src/app/account/templates/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<li ui-sref-active="active">
<a href="" ui-sref="favoriteProducts">Favorite Products</a>
</li>
<li ng-class="{active: application.$state.includes('orders') || application.$state.includes('orderDetails')}">
<li ng-class="{active: application.$state.includes('orders') || application.$state.includes('orderDetail')}">
<a href="" ui-sref="orders({tab: 'history'})">Orders</a>
</li>
</ul>
Expand All @@ -22,7 +22,7 @@
<h3><i class="fa fa-cog"></i> My Account</h3>
<hr>
<form class="progressive" name="account.profileForm" autocomplete="off" novalidate ng-submit="account.updateProfile()" oc-readonly-roles="MeAdmin"
pretty-submit>
oc-pretty-submit>
<fieldset class="form-group row">
<div class="col-xs-6">
<label for="FirstName">First name</label>
Expand All @@ -46,7 +46,7 @@ <h3><i class="fa fa-cog"></i> My Account</h3>
</form>
<hr>
<form name="account.settingsForm" ng-submit="account.updateUsername()" autocomplete="off" novalidate oc-readonly-roles="MeAdmin"
pretty-submit>
oc-pretty-submit>
<fieldset class="form-group">
<label for="Username">Username</label>
<input id="Username" name="Username" ng-change="account.usernameChange()" type="text" class="form-control" ng-model="account.profile.Username" required>
Expand Down
4 changes: 2 additions & 2 deletions src/app/account/templates/accountSettings.modal.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<form name="EditAccountInfoForm" ng-submit="accountEditModal.update()">
<form name="EditAccountInfoForm" ng-submit="accountEditModal.update()" oc-pretty-submit>
<div class="modal-header">
<button type="button" class="close" aria-label="Close" ng-click="accountEditModal.cancel()"><span aria-hidden="true">&times;</span></button>
<h3 class="modal-title"><i class="fa fa-edit"></i> Edit Profile Info</h3>
<h4 class="modal-title"><i class="fa fa-edit"></i> Edit Profile Info</h4>
</div>
<div class="modal-body">
<div class="form-group">
Expand Down
12 changes: 6 additions & 6 deletions src/app/account/templates/changePassword.modal.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form name="ChangePasswordForm" ng-submit="changePasswordModal.submit()" novalidate autocomplete="off">
<form name="ChangePasswordForm" ng-submit="changePasswordModal.submit()" novalidate autocomplete="off" oc-pretty-submit>
<div class="modal-header">
<button type="button" class="close" aria-label="Close" ng-click="changePasswordModal.cancel()"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><i class="fa fa-lock"></i> Change Password</h4>
Expand All @@ -12,19 +12,19 @@ <h4 class="modal-title"><i class="fa fa-lock"></i> Change Password</h4>
<div class="form-group">
<label>New Password</label>
<input type="password" ng-model="changePasswordModal.currentUser.NewPassword" pattern="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!$%@#£€*?&]{8,}$"
pattern-err-type="customPassword" class="form-control" confirmpassword="{{changePasswordModal.currentUser.ConfirmPassword}}"
required />
pattern-err-type="customPassword" class="form-control" required />
</div>
<div class="form-group">
<label>Confirm Password</label>
<input type="password" ng-model="changePasswordModal.currentUser.ConfirmPassword" pattern="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!$%@#£€*?&]{8,}$"
pattern-err-type="customPassword" class="form-control" confirmpassword="{{changePasswordModal.currentUser.NewPassword}}"
<input type="password" ng-model="changePasswordModal.currentUser.ConfirmPassword" class="form-control"
oc-match-field="changePasswordModal.currentUser.NewPassword"
oc-match-field-err-type="ocMatchPassword"
required />
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-block" ng-disabled="ChangePasswordForm.$invalid || changePasswordModal.currentUser.NewPassword != changePasswordModal.currentUser.ConfirmPassword">
<button type="submit" class="btn btn-primary btn-block" ng-disabled="changePasswordModal.currentUser.NewPassword != changePasswordModal.currentUser.ConfirmPassword">
Update Password
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/account/templates/confirmPassword.modal.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form name="confirmPasswordModal.form" ng-submit="confirmPasswordModal.submit()">
<form name="confirmPasswordModal.form" ng-submit="confirmPasswordModal.submit()" oc-pretty-submit>
<div class="modal-header">
<button type="button" class="close" aria-label="Close" ng-click="confirmPasswordModal.cancel()"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Confirm Your Password</h4>
Expand All @@ -11,6 +11,6 @@ <h4 class="modal-title">Confirm Your Password</h4>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary btn-block" type="submit" ng-disabled="confirmPasswordModal.form.$invalid">Update Profile</button>
<button class="btn btn-primary btn-block" type="submit">Update Profile</button>
</div>
</form>
11 changes: 9 additions & 2 deletions src/app/base/js/base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function BaseConfig($stateProvider) {
filters: {Status: 'Unsubmitted'}
};
return OrderCloudSDK.Me.ListOrders(options)
.then(function(data) {
return data.Items[0];
.then(function(orders) {
return orders.Items[0];
});
},
CurrentOrder: function(ExistingOrder, ocNewOrder, CurrentUser) {
Expand All @@ -39,6 +39,13 @@ function BaseConfig($stateProvider) {
return ExistingOrder;
}
},
TotalQuantity: function(OrderCloudSDK, CurrentOrder) {
return OrderCloudSDK.LineItems.List('outgoing', CurrentOrder.ID)
.then(function(lineItems) {
var quantities = _.pluck(lineItems.Items, 'Quantity');
return quantities.reduce(function(a, b) {return a + b}, 0);
});
},
AnonymousUser: function(OrderCloudSDK, CurrentUser) {
CurrentUser.Anonymous = angular.isDefined(JSON.parse(atob(OrderCloudSDK.GetToken().split('.')[1])).orderid);
}
Expand Down
29 changes: 25 additions & 4 deletions src/app/base/js/base.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ angular.module('orderCloud')
.controller('BaseCtrl', BaseController)
;

function BaseController($rootScope, $state, OrderCloudSDK, ocProductSearch, CurrentUser, CurrentOrder) {
function BaseController($rootScope, $state, OrderCloudSDK, ocProductSearch, ocLineItems, CurrentUser, CurrentOrder, TotalQuantity) {
var vm = this;
vm.currentUser = CurrentUser;
vm.currentOrder = CurrentOrder;
vm.totalQuantity = TotalQuantity;

vm.mobileSearch = mobileSearch;

Expand All @@ -15,7 +16,7 @@ function BaseController($rootScope, $state, OrderCloudSDK, ocProductSearch, Curr
if (data.productID) {
$state.go('productDetail', {productid: data.productID});
} else {
$state.go('productSearchResults', {searchTerm: data.searchTerm});
$state.go('productSearchResults', {search: data.search});
}
});
}
Expand All @@ -25,8 +26,28 @@ function BaseController($rootScope, $state, OrderCloudSDK, ocProductSearch, Curr
message: message
};
vm.orderLoading.promise = OrderCloudSDK.Orders.Get('outgoing', OrderID)
.then(function(data) {
vm.currentOrder = data;
.then(function(order) {
vm.currentOrder = order;
});
});

$rootScope.$on('OC:UpdateTotalQuantity', function(event, lineItems, add, difference) {
if (lineItems.length >= 1) {
var quantities = _.pluck(lineItems, 'Quantity');
vm.totalQuantity = quantities.reduce(function(a, b) {return a + b}, 0);
} else {
var li = lineItems[0] || lineItems;
if (vm.totalQuantity) {
if (add) {
var newQuantity = difference ? difference : li.Quantity;
vm.totalQuantity = newQuantity + vm.totalQuantity || 0;
} else {
var newQuantity = difference ? difference : li.Quantity;
vm.totalQuantity = vm.totalQuantity - newQuantity || 0;
}
} else {
vm.totalQuantity = li.Quantity || 0;
}
}
})
}
19 changes: 16 additions & 3 deletions src/app/base/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
<li>
<a ui-sref="categoryBrowse({page:'', sortBy:'', categoryID:''})">Category Browse</a>
</li>
<li ng-if="base.currentUser.Anonymous">
<a ui-sref="login">Login</a>
</li>
<li ng-if="base.currentUser.Anonymous">
<a ui-sref="register">Register</a>
</li>
<li uib-dropdown ng-if="!base.currentUser.Anonymous">
<a uib-dropdown-toggle role="button">Account <span class="caret"></a>
<ul class="dropdown-menu navmenu-nav" uib-dropdown-menu role="menu">
Expand Down Expand Up @@ -67,11 +73,18 @@
<a href="" ng-click="base.mobileSearch()"><i class="fa fa-search"></i></a>
</li>
<li>
<a ui-sref="cart"><i class="fa fa-shopping-cart"></i> <span class="sr-only">Shopping Cart</span> <span class="badge" ng-bind="base.currentOrder.LineItemCount"></span></a>
<a ui-sref="cart"><i class="fa fa-shopping-cart"></i> <span class="sr-only">Shopping Cart</span> <span class="badge" ng-bind="base.totalQuantity"></span></a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right c-desktop-nav" ng-if="!base.currentUser.Anonymous">
<li class="c-desktop-nav" uib-dropdown>

<ul class="nav navbar-nav navbar-right c-desktop-nav">
<li ng-if="base.currentUser.Anonymous">
<a ui-sref="login">Login</a>
</li>
<li ng-if="base.currentUser.Anonymous">
<a ui-sref="register">Register</a>
</li>
<li class="c-desktop-nav" uib-dropdown ng-if="!base.currentUser.Anonymous">
<a uib-dropdown-toggle role="button">Account <span class="caret"></span></a>
<ul class="dropdown-menu-right" uib-dropdown-menu>
<li>
Expand Down
4 changes: 2 additions & 2 deletions src/app/base/templates/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<a ui-sref="categoryBrowse({page:'', sortBy:'', categoryID:''})"><i class="fa fa-th"></i> <span>Category Browse</span></a>
</li>
</ul>
<form class="navbar-form navbar-left">
<form class="navbar-form navbar-left" oc-pretty-submit>
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
Expand Down Expand Up @@ -46,7 +46,7 @@
</ul>
</li>
<li>
<a ui-sref="cart"><i class="fa fa-shopping-cart"></i> <span class="sr-only">Shopping Cart</span> <span class="badge" ng-bind="base.currentOrder.LineItemCount"></span></a>
<a ui-sref="cart"><i class="fa fa-shopping-cart"></i> <span class="sr-only">Shopping Cart</span> <span class="badge" ng-bind="base.totalQuantity"></span></a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
Expand Down
8 changes: 7 additions & 1 deletion src/app/cart/js/cart.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ angular.module('orderCloud')
.controller('CartCtrl', CartController)
;

function CartController($rootScope, $state, toastr, OrderCloudSDK, LineItemsList, CurrentPromotions, ocConfirm) {
function CartController($rootScope, $state, toastr, OrderCloudSDK, LineItemsList, CurrentPromotions, CurrentUser, ocConfirm, ocAnonymous) {
var vm = this;
vm.lineItems = LineItemsList;
vm.promotions = CurrentPromotions.Meta ? CurrentPromotions.Items : CurrentPromotions;
vm.removeItem = removeItem;
vm.removePromotion = removePromotion;
vm.cancelOrder = cancelOrder;
vm.proceedToCheckout = proceedToCheckout;

$rootScope.$on('OC:UpdatePromotions', function(event, orderid) {
return OrderCloudSDK.Orders.ListPromotions('outgoing', orderid)
Expand All @@ -27,6 +28,7 @@ function CartController($rootScope, $state, toastr, OrderCloudSDK, LineItemsList
.then(function () {
$rootScope.$broadcast('OC:UpdateOrder', order.ID);
vm.lineItems.Items.splice(scope.$index, 1);
$rootScope.$broadcast('OC:UpdateTotalQuantity', vm.lineItems.Items, true);
toastr.success(scope.lineItem.Product.Name + ' was removed from your shopping cart.');
});
}
Expand All @@ -51,4 +53,8 @@ function CartController($rootScope, $state, toastr, OrderCloudSDK, LineItemsList
});
});
}

function proceedToCheckout() {
$state.go('checkout.shipping');
}
}
9 changes: 4 additions & 5 deletions src/app/cart/templates/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ <h5 ng-repeat="promotion in cart.promotions" class="text-danger">
<span class="pull-right">- {{promotion.Amount | currency}}</span></h5>
</div>
<div class="panel-footer">
<button ng-if="cart.lineItems.Items.length > 0" type="button" ui-sref="checkout.shipping" class="btn btn-block btn-primary" ng-disabled="OrderLineItemForm.$invalid">Proceed to Checkout</button>
<button ng-if="cart.lineItems.Items.length > 0" type="button" ng-click="cart.proceedToCheckout()" class="btn btn-block btn-primary" ng-disabled="OrderLineItemForm.$invalid">Proceed to Checkout</button>
</div>
</div>
</aside>
<div class="col-md-8 col-md-pull-4">
<form name="OrderLineItemForm">
<form name="OrderLineItemForm" oc-pretty-submit>
<div class="row hidden-xs c-line-item__header">
<div class="col-xs-3 col-sm-2"></div>
<div class="col-xs-9 col-sm-10">
Expand Down Expand Up @@ -108,8 +108,7 @@ <h4 class="c-line-item__total text-right">{{lineItem.LineTotal | currency}}</h4>
</div>
</div>
<div class="form-group">
<button ng-if="cart.lineItems.Items.length > 0" type="button" ui-sref="checkout.shipping"
class="btn btn-block btn-primary hidden-lg hidden-md"
ng-disabled="OrderLineItemForm.$invalid">Proceed to Checkout</button>
<button ng-if="cart.lineItems.Items.length > 0" type="button" ng-click="cart.proceedToCheckout()"
class="btn btn-block btn-primary hidden-lg hidden-md">Proceed to Checkout</button>
</div>
</article>
5 changes: 2 additions & 3 deletions src/app/categoryBrowse/templates/categoryBrowse.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ <h3 class="c-category-card__title">{{category.Name || category.ID}}</h3>
<h3 class="page-header">{{categoryBrowse.productList.Items.length > 1 ? 'Products' : 'Product'}}</h3>
<b class="pull-right">{{categoryBrowse.getNumberOfResults('productList')}}</b><br>
<div class="row l-product-grid">
<div class="col-sm-6 col-md-4 col-lg-3 l-product-grid__item"
ng-repeat="product in categoryBrowse.productList.Items"
ng-include="'common/templates/card.product.html'">
<div class="col-sm-6 col-md-4 col-lg-3 l-product-grid__item" ng-repeat="product in categoryBrowse.productList.Items">
<oc-product-card product="product" current-user="base.currentUser" current-order="base.currentOrder"></oc-product-card>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<h2 class="page-header">
Order Submitted <br>
<small>Thank you for your order. Check your <a href="" ui-sref="orderDetail({orderid:checkoutConfirmation.order.ID})">order history</a> to track your delivery!</small>
<span class="pull-right"><ordercloud-favorite-order current-user="base.currentUser" order="checkoutConfirmation.order"></ordercloud-favorite-order></span>
</h2>
<div class="row">
<div class="col-md-5">
Expand Down Expand Up @@ -92,7 +93,7 @@ <h4>
<div class="row c-line-item" ng-repeat="lineItem in checkoutConfirmation.lineItems.Items track by $index">
<div class="col-xs-3 col-sm-2">
<div class="thumbnail c-line-item__img">
<img class="img-responsive" ng-src="{{lineItem.xp.image.URL || 'http://placehold.it/100x100?text=' + lineItem.Product.Name}}"
<img class="img-responsive" ng-src="{{lineItem.Product.xp.image.URL || 'http://placehold.it/100x100?text=' + lineItem.Product.Name}}"
alt="{{lineItem.Product.xp.image.Name || 'Product Image'}}">
</div>
</div>
Expand Down
20 changes: 20 additions & 0 deletions src/app/checkout/js/checkout.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ function CheckoutConfig($urlRouterProvider, $stateProvider) {
controller: 'CheckoutCtrl',
controllerAs: 'checkout',
resolve: {
IdentifyUser: function($state, ocAnonymous, CurrentUser) {
if (CurrentUser.Anonymous) {
ocAnonymous.Identify('cart')
.then(function(data) {
//TODO: placeholder for guest checkout functionality
})
.catch(function(ex) {
if (ex === 'LOGIN') {
$state.go('login');
} else if (ex === 'REGISTER') {
$state.go('register');
} else {
//User closed the modal
$state.go('cart');
}
});
} else {
return;
}
},
OrderShipAddress: function($q, OrderCloudSDK, CurrentOrder){
var deferred = $q.defer();
if (CurrentOrder.ShippingAddressID) {
Expand Down
1 change: 1 addition & 0 deletions src/app/checkout/js/checkout.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function CheckoutConfigConstants() {
var constants = {
ShippingRates: true,
TaxRates: false,
AllowMultiplePayments: false,
AvailablePaymentMethods: ['PurchaseOrder', 'CreditCard', 'SpendingAccount']
};

Expand Down
28 changes: 0 additions & 28 deletions src/app/checkout/payment/directives/README.md

This file was deleted.

Loading

0 comments on commit 595fb1e

Please sign in to comment.