Skip to content

Commit

Permalink
shifted controllers to diff files, fetching data via api
Browse files Browse the repository at this point in the history
  • Loading branch information
l3limp committed Aug 5, 2024
1 parent 4bc69ed commit 1f35b78
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 278 deletions.
6 changes: 3 additions & 3 deletions directives/cartItemCard.htm
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ <h5 class="card-subtitle mb-2 horizontal-margin">
<div>
<a
class="btn btn-primary horizontal-margin"
ng-click="changeItemQuantityInCart( {action:-1, itemID:item.id})"
ng-click="changeItemQuantityInCart( {action:-1, itemId:item.id})"
>-</a
>
{{getCartQuantity({itemID: item.id})}}
{{getCartQuantity({itemId: item.id})}}
<a
class="btn btn-primary horizontal-margin"
ng-click="changeItemQuantityInCart({action: 1, itemID: item.id})"
ng-click="changeItemQuantityInCart({action: 1, itemId: item.id})"
>+</a
>
</div>
Expand Down
4 changes: 2 additions & 2 deletions directives/cartSidebar.htm
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<div class="card" style="width: 14rem" ng-repeat="item in cart">
<cart-item-card
item="item"
get-cart-quantity="getCartQuantity(itemID)"
change-item-quantity-in-cart="changeItemQuantityInCart(action, itemID)"
get-cart-quantity="getCartQuantity(itemId)"
change-item-quantity-in-cart="changeItemQuantityInCart(action, itemId)"
></cart-item-card>
</div>

Expand Down
5 changes: 3 additions & 2 deletions directives/homeNavbar.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<a
class="btn"
style="color: slategrey"
ng-click="toggleFilter({filterType:'type', property:'veg'})"
ng-click="toggleFilter({filterType:'type', property:'Veg'})"
uib-tooltip="Toggle Veg dishes" tooltip-placement="bottom"
>VEG</a
>Veg</a
>
</li>

Expand All @@ -34,4 +34,5 @@
</li>
</ul>
</div>
<hr />
</div>
10 changes: 5 additions & 5 deletions directives/itemCard.htm
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ <h5 class="card-title">{{item.name}}</h5>
><small style="color: white">.</small>
</div>
</div>
<div ng-if="getCartQuantity({itemID: item.id}) === 0">
<div ng-if="getCartQuantity({itemId: item.id}) === 0">
<a class="btn btn-primary" ng-click="addItemToCart({item: item})"
>ADD</a
>
</div>
<div ng-if="getCartQuantity({itemID: item.id}) !== 0">
<div ng-if="getCartQuantity({itemId: item.id}) !== 0">
<a
class="btn btn-primary horizontal-margin"
ng-click="changeItemQuantityInCart({action: -1, itemID:item.id})"
ng-click="changeItemQuantityInCart({action: -1, itemId:item.id})"
>-</a
>
{{getCartQuantity({itemID: item.id})}}
{{getCartQuantity({itemId: item.id})}}
<a
class="btn btn-primary horizontal-margin"
ng-click="changeItemQuantityInCart({action: 1, itemID:item.id})"
ng-click="changeItemQuantityInCart({action: 1, itemId:item.id})"
>+</a
>
</div>
Expand Down
2 changes: 1 addition & 1 deletion directives/navbar.htm
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
<a ng-click="toggleCartVisibility()">Cart</a>
</li>
</ul>
</div>
</div >
</nav>
File renamed without changes
Binary file added images/Non Veg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
is-cart-open="isCartOpen"
cart="cart"
toggle-cart-visibility="toggleCartVisibility()"
change-item-quantity-in-cart="changeItemQuantityInCart(action, itemID)"
get-cart-quantity="getCartQuantity(itemID)"
change-item-quantity-in-cart="changeItemQuantityInCart(action, itemId)"
get-cart-quantity="getCartQuantity(itemId)"
get-cart-subtotal="getCartSubtotal()"
get-cart-subtotal-without-discount = "getCartSubtotalWithoutDiscount()"
></cart-sidebar>
Expand All @@ -46,7 +46,10 @@

<script src="ng/app.js"></script>
<script src="ng/routes.js"></script>
<script src="ng/controllers.js"></script>
<script src="ng/controllers/bodyController.js"></script>
<script src="ng/controllers/buyNowModalController.js"></script>
<script src="ng/controllers/homeController.js"></script>
<script src="ng/controllers/itemDetailsController.js"></script>
<script src="ng/services.js"></script>
<script src="ng/directives.js"></script>
</body>
Expand Down
181 changes: 0 additions & 181 deletions ng/controllers.js

This file was deleted.

18 changes: 18 additions & 0 deletions ng/controllers/bodyController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
oldMenu.controller("bodyController", [
"$scope",
"cartService",
function ($scope, cartService) {
$scope.isCartOpen = false;

$scope.toggleCartVisibility = function () {
$scope.cart = cartService.cart;
$scope.isCartOpen = !$scope.isCartOpen;
};

$scope.getCartQuantity = cartService.getCartQuantity;
$scope.changeItemQuantityInCart = cartService.changeItemQuantityInCart;
$scope.getCartSubtotal = cartService.getCartSubtotal;
$scope.getCartSubtotalWithoutDiscount =
cartService.getCartSubtotalWithoutDiscount;
},
]);
46 changes: 46 additions & 0 deletions ng/controllers/buyNowModalController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
oldMenu.controller("ModalController", [
"$scope",
"$uibModal",
"cartService",
function ($scope, $uibModal, cartService) {
$scope.openModal = function () {
var modalInstance = $uibModal.open({
templateUrl: "checkoutModal.htm",
controller: "ModalInstanceController",
size: "lg",
resolve: {
cartService: cartService,
},
});

modalInstance.result.then(
function (selectedItem) {
$scope.selected = selectedItem;
},
function () {
console.log("Modal dismissed");
}
);
};
},
]);

oldMenu.controller("ModalInstanceController", [
"$scope",
"$uibModalInstance",
"cartService",
function ($scope, $uibModalInstance, cartService) {
$scope.cart = cartService.cart;

$scope.getCartSubtotal = cartService.getCartSubtotal;
console.log($scope.getCartSubtotal);

$scope.ok = function () {
$uibModalInstance.close("Some result");
};

$scope.cancel = function () {
$uibModalInstance.dismiss("cancel");
};
},
]);
Loading

0 comments on commit 1f35b78

Please sign in to comment.