diff --git a/.jhipster/Cart.json b/.jhipster/Cart.json new file mode 100644 index 0000000..7a5cc43 --- /dev/null +++ b/.jhipster/Cart.json @@ -0,0 +1,25 @@ +{ + "fluentMethods": true, + "relationships": [ + { + "relationshipType": "one-to-many", + "relationshipName": "item", + "otherEntityName": "item", + "otherEntityRelationshipName": "cart" + }, + { + "relationshipType": "one-to-one", + "relationshipName": "customer", + "otherEntityName": "customer", + "ownerSide": false, + "otherEntityRelationshipName": "cart" + } + ], + "fields": [], + "changelogDate": "20171208125341", + "entityTableName": "cart", + "dto": "no", + "pagination": "no", + "service": "no", + "jpaMetamodelFiltering": false +} \ No newline at end of file diff --git a/.jhipster/Customer.json b/.jhipster/Customer.json index 6955f65..d681b33 100644 --- a/.jhipster/Customer.json +++ b/.jhipster/Customer.json @@ -2,9 +2,11 @@ "fluentMethods": true, "relationships": [ { - "relationshipType": "one-to-many", - "relationshipName": "item", - "otherEntityName": "item", + "relationshipType": "one-to-one", + "relationshipName": "cart", + "otherEntityName": "cart", + "otherEntityField": "id", + "ownerSide": true, "otherEntityRelationshipName": "customer" } ], diff --git a/.jhipster/Item.json b/.jhipster/Item.json index 24d9539..e7fca8d 100644 --- a/.jhipster/Item.json +++ b/.jhipster/Item.json @@ -8,8 +8,8 @@ "otherEntityField": "id" }, { - "relationshipName": "customer", - "otherEntityName": "customer", + "relationshipName": "cart", + "otherEntityName": "cart", "relationshipType": "many-to-one", "otherEntityField": "id" } @@ -34,7 +34,7 @@ "changelogDate": "20171118104226", "entityTableName": "item", "dto": "no", - "pagination": "infinite-scroll", + "pagination": "pagination", "service": "serviceClass", "jpaMetamodelFiltering": false } \ No newline at end of file diff --git a/src/main/java/org/apeps/firstapp/config/CacheConfiguration.java b/src/main/java/org/apeps/firstapp/config/CacheConfiguration.java index de3cae3..3f410d0 100644 --- a/src/main/java/org/apeps/firstapp/config/CacheConfiguration.java +++ b/src/main/java/org/apeps/firstapp/config/CacheConfiguration.java @@ -48,6 +48,8 @@ public JCacheManagerCustomizer cacheManagerCustomizer() { cm.createCache(org.apeps.firstapp.domain.Category.class.getName() + ".items", jcacheConfiguration); cm.createCache(org.apeps.firstapp.domain.Customer.class.getName(), jcacheConfiguration); cm.createCache(org.apeps.firstapp.domain.Customer.class.getName() + ".items", jcacheConfiguration); + cm.createCache(org.apeps.firstapp.domain.Cart.class.getName(), jcacheConfiguration); + cm.createCache(org.apeps.firstapp.domain.Cart.class.getName() + ".items", jcacheConfiguration); // jhipster-needle-ehcache-add-entry }; } diff --git a/src/main/java/org/apeps/firstapp/domain/Cart.java b/src/main/java/org/apeps/firstapp/domain/Cart.java new file mode 100644 index 0000000..b46874b --- /dev/null +++ b/src/main/java/org/apeps/firstapp/domain/Cart.java @@ -0,0 +1,111 @@ +package org.apeps.firstapp.domain; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * A Cart. + */ +@Entity +@Table(name = "cart") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Cart implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @OneToMany(mappedBy = "cart") + @JsonIgnore + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + private Set items = new HashSet<>(); + + @OneToOne(mappedBy = "cart") + @JsonIgnore + private Customer customer; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Set getItems() { + return items; + } + + public Cart items(Set items) { + this.items = items; + return this; + } + + public Cart addItem(Item item) { + this.items.add(item); + item.setCart(this); + return this; + } + + public Cart removeItem(Item item) { + this.items.remove(item); + item.setCart(null); + return this; + } + + public void setItems(Set items) { + this.items = items; + } + + public Customer getCustomer() { + return customer; + } + + public Cart customer(Customer customer) { + this.customer = customer; + return this; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cart cart = (Cart) o; + if (cart.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), cart.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "Cart{" + + "id=" + getId() + + "}"; + } +} diff --git a/src/main/java/org/apeps/firstapp/domain/Customer.java b/src/main/java/org/apeps/firstapp/domain/Customer.java index 0b2f000..6b590d9 100644 --- a/src/main/java/org/apeps/firstapp/domain/Customer.java +++ b/src/main/java/org/apeps/firstapp/domain/Customer.java @@ -1,13 +1,10 @@ package org.apeps.firstapp.domain; -import com.fasterxml.jackson.annotation.JsonIgnore; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import javax.persistence.*; import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; import java.util.Objects; /** @@ -37,10 +34,9 @@ public class Customer implements Serializable { @Column(name = "telephone") private String telephone; - @OneToMany(mappedBy = "customer") - @JsonIgnore - @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) - private Set items = new HashSet<>(); + @OneToOne + @JoinColumn(unique = true) + private Cart cart; // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { @@ -103,29 +99,17 @@ public void setTelephone(String telephone) { this.telephone = telephone; } - public Set getItems() { - return items; + public Cart getCart() { + return cart; } - public Customer items(Set items) { - this.items = items; + public Customer cart(Cart cart) { + this.cart = cart; return this; } - public Customer addItem(Item item) { - this.items.add(item); - item.setCustomer(this); - return this; - } - - public Customer removeItem(Item item) { - this.items.remove(item); - item.setCustomer(null); - return this; - } - - public void setItems(Set items) { - this.items = items; + public void setCart(Cart cart) { + this.cart = cart; } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove diff --git a/src/main/java/org/apeps/firstapp/domain/Item.java b/src/main/java/org/apeps/firstapp/domain/Item.java index 1f4a59f..40626ab 100644 --- a/src/main/java/org/apeps/firstapp/domain/Item.java +++ b/src/main/java/org/apeps/firstapp/domain/Item.java @@ -37,7 +37,7 @@ public class Item implements Serializable { private Category category; @ManyToOne - private Customer customer; + private Cart cart; // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove public Long getId() { @@ -100,17 +100,17 @@ public void setCategory(Category category) { this.category = category; } - public Customer getCustomer() { - return customer; + public Cart getCart() { + return cart; } - public Item customer(Customer customer) { - this.customer = customer; + public Item cart(Cart cart) { + this.cart = cart; return this; } - public void setCustomer(Customer customer) { - this.customer = customer; + public void setCart(Cart cart) { + this.cart = cart; } // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove diff --git a/src/main/java/org/apeps/firstapp/repository/CartRepository.java b/src/main/java/org/apeps/firstapp/repository/CartRepository.java new file mode 100644 index 0000000..47ad7f1 --- /dev/null +++ b/src/main/java/org/apeps/firstapp/repository/CartRepository.java @@ -0,0 +1,16 @@ +package org.apeps.firstapp.repository; + +import org.apeps.firstapp.domain.Cart; +import org.springframework.stereotype.Repository; + +import org.springframework.data.jpa.repository.*; + + +/** + * Spring Data JPA repository for the Cart entity. + */ +@SuppressWarnings("unused") +@Repository +public interface CartRepository extends JpaRepository { + +} diff --git a/src/main/java/org/apeps/firstapp/web/rest/CartResource.java b/src/main/java/org/apeps/firstapp/web/rest/CartResource.java new file mode 100644 index 0000000..265eb56 --- /dev/null +++ b/src/main/java/org/apeps/firstapp/web/rest/CartResource.java @@ -0,0 +1,129 @@ +package org.apeps.firstapp.web.rest; + +import com.codahale.metrics.annotation.Timed; +import org.apeps.firstapp.domain.Cart; + +import org.apeps.firstapp.repository.CartRepository; +import org.apeps.firstapp.web.rest.errors.BadRequestAlertException; +import org.apeps.firstapp.web.rest.util.HeaderUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +/** + * REST controller for managing Cart. + */ +@RestController +@RequestMapping("/api") +public class CartResource { + + private final Logger log = LoggerFactory.getLogger(CartResource.class); + + private static final String ENTITY_NAME = "cart"; + + private final CartRepository cartRepository; + + public CartResource(CartRepository cartRepository) { + this.cartRepository = cartRepository; + } + + /** + * POST /carts : Create a new cart. + * + * @param cart the cart to create + * @return the ResponseEntity with status 201 (Created) and with body the new cart, or with status 400 (Bad Request) if the cart has already an ID + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PostMapping("/carts") + @Timed + public ResponseEntity createCart(@RequestBody Cart cart) throws URISyntaxException { + log.debug("REST request to save Cart : {}", cart); + if (cart.getId() != null) { + throw new BadRequestAlertException("A new cart cannot already have an ID", ENTITY_NAME, "idexists"); + } + Cart result = cartRepository.save(cart); + return ResponseEntity.created(new URI("/api/carts/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * PUT /carts : Updates an existing cart. + * + * @param cart the cart to update + * @return the ResponseEntity with status 200 (OK) and with body the updated cart, + * or with status 400 (Bad Request) if the cart is not valid, + * or with status 500 (Internal Server Error) if the cart couldn't be updated + * @throws URISyntaxException if the Location URI syntax is incorrect + */ + @PutMapping("/carts") + @Timed + public ResponseEntity updateCart(@RequestBody Cart cart) throws URISyntaxException { + log.debug("REST request to update Cart : {}", cart); + if (cart.getId() == null) { + return createCart(cart); + } + Cart result = cartRepository.save(cart); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, cart.getId().toString())) + .body(result); + } + + /** + * GET /carts : get all the carts. + * + * @param filter the filter of the request + * @return the ResponseEntity with status 200 (OK) and the list of carts in body + */ + @GetMapping("/carts") + @Timed + public List getAllCarts(@RequestParam(required = false) String filter) { + if ("customer-is-null".equals(filter)) { + log.debug("REST request to get all Carts where customer is null"); + return StreamSupport + .stream(cartRepository.findAll().spliterator(), false) + .filter(cart -> cart.getCustomer() == null) + .collect(Collectors.toList()); + } + log.debug("REST request to get all Carts"); + return cartRepository.findAll(); + } + + /** + * GET /carts/:id : get the "id" cart. + * + * @param id the id of the cart to retrieve + * @return the ResponseEntity with status 200 (OK) and with body the cart, or with status 404 (Not Found) + */ + @GetMapping("/carts/{id}") + @Timed + public ResponseEntity getCart(@PathVariable Long id) { + log.debug("REST request to get Cart : {}", id); + Cart cart = cartRepository.findOne(id); + return ResponseUtil.wrapOrNotFound(Optional.ofNullable(cart)); + } + + /** + * DELETE /carts/:id : delete the "id" cart. + * + * @param id the id of the cart to delete + * @return the ResponseEntity with status 200 (OK) + */ + @DeleteMapping("/carts/{id}") + @Timed + public ResponseEntity deleteCart(@PathVariable Long id) { + log.debug("REST request to delete Cart : {}", id); + cartRepository.delete(id); + return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_Item.xml b/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_Item.xml index 480fd4e..7bf2e55 100644 --- a/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_Item.xml +++ b/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_Item.xml @@ -37,7 +37,7 @@ - + diff --git a/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_constraints_Item.xml b/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_constraints_Item.xml index 4b066bb..ae17d33 100644 --- a/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_constraints_Item.xml +++ b/src/main/resources/config/liquibase/changelog/20171118104226_added_entity_constraints_Item.xml @@ -14,11 +14,11 @@ referencedColumnNames="id" referencedTableName="category"/> - + referencedTableName="cart"/> diff --git a/src/main/resources/config/liquibase/changelog/20171118104228_added_entity_Customer.xml b/src/main/resources/config/liquibase/changelog/20171118104228_added_entity_Customer.xml index bb7a88f..7b6c814 100644 --- a/src/main/resources/config/liquibase/changelog/20171118104228_added_entity_Customer.xml +++ b/src/main/resources/config/liquibase/changelog/20171118104228_added_entity_Customer.xml @@ -36,7 +36,9 @@ - + + + diff --git a/src/main/resources/config/liquibase/changelog/20171118104228_added_entity_constraints_Customer.xml b/src/main/resources/config/liquibase/changelog/20171118104228_added_entity_constraints_Customer.xml new file mode 100644 index 0000000..59f34ba --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20171118104228_added_entity_constraints_Customer.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20171208125341_added_entity_Cart.xml b/src/main/resources/config/liquibase/changelog/20171208125341_added_entity_Cart.xml new file mode 100644 index 0000000..e0fc9bf --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20171208125341_added_entity_Cart.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index 44f5320..e2f860a 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -8,8 +8,10 @@ + + diff --git a/src/main/webapp/app/entities/cart/cart-delete-dialog.controller.js b/src/main/webapp/app/entities/cart/cart-delete-dialog.controller.js new file mode 100644 index 0000000..66bf5a9 --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart-delete-dialog.controller.js @@ -0,0 +1,28 @@ +(function() { + 'use strict'; + + angular + .module('firstApp') + .controller('CartDeleteController',CartDeleteController); + + CartDeleteController.$inject = ['$uibModalInstance', 'entity', 'Cart']; + + function CartDeleteController($uibModalInstance, entity, Cart) { + var vm = this; + + vm.cart = entity; + vm.clear = clear; + vm.confirmDelete = confirmDelete; + + function clear () { + $uibModalInstance.dismiss('cancel'); + } + + function confirmDelete (id) { + Cart.delete({id: id}, + function () { + $uibModalInstance.close(true); + }); + } + } +})(); diff --git a/src/main/webapp/app/entities/cart/cart-delete-dialog.html b/src/main/webapp/app/entities/cart/cart-delete-dialog.html new file mode 100644 index 0000000..413db89 --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart-delete-dialog.html @@ -0,0 +1,19 @@ +
+ + + +
diff --git a/src/main/webapp/app/entities/cart/cart-detail.controller.js b/src/main/webapp/app/entities/cart/cart-detail.controller.js new file mode 100644 index 0000000..c5ff8a0 --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart-detail.controller.js @@ -0,0 +1,21 @@ +(function() { + 'use strict'; + + angular + .module('firstApp') + .controller('CartDetailController', CartDetailController); + + CartDetailController.$inject = ['$scope', '$rootScope', '$stateParams', 'previousState', 'entity', 'Cart', 'Item', 'Customer']; + + function CartDetailController($scope, $rootScope, $stateParams, previousState, entity, Cart, Item, Customer) { + var vm = this; + + vm.cart = entity; + vm.previousState = previousState.name; + + var unsubscribe = $rootScope.$on('firstApp:cartUpdate', function(event, result) { + vm.cart = result; + }); + $scope.$on('$destroy', unsubscribe); + } +})(); diff --git a/src/main/webapp/app/entities/cart/cart-detail.html b/src/main/webapp/app/entities/cart/cart-detail.html new file mode 100644 index 0000000..0dbeb26 --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart-detail.html @@ -0,0 +1,19 @@ + +
+

Cart {{vm.cart.id}}

+
+ +
+
+ + + + +
diff --git a/src/main/webapp/app/entities/cart/cart-dialog.controller.js b/src/main/webapp/app/entities/cart/cart-dialog.controller.js new file mode 100644 index 0000000..82e80ef --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart-dialog.controller.js @@ -0,0 +1,48 @@ +(function() { + 'use strict'; + + angular + .module('firstApp') + .controller('CartDialogController', CartDialogController); + + CartDialogController.$inject = ['$timeout', '$scope', '$stateParams', '$uibModalInstance', 'entity', 'Cart', 'Item', 'Customer']; + + function CartDialogController ($timeout, $scope, $stateParams, $uibModalInstance, entity, Cart, Item, Customer) { + var vm = this; + + vm.cart = entity; + vm.clear = clear; + vm.save = save; + vm.items = Item.query(); + vm.customers = Customer.query(); + + $timeout(function (){ + angular.element('.form-group:eq(1)>input').focus(); + }); + + function clear () { + $uibModalInstance.dismiss('cancel'); + } + + function save () { + vm.isSaving = true; + if (vm.cart.id !== null) { + Cart.update(vm.cart, onSaveSuccess, onSaveError); + } else { + Cart.save(vm.cart, onSaveSuccess, onSaveError); + } + } + + function onSaveSuccess (result) { + $scope.$emit('firstApp:cartUpdate', result); + $uibModalInstance.close(result); + vm.isSaving = false; + } + + function onSaveError () { + vm.isSaving = false; + } + + + } +})(); diff --git a/src/main/webapp/app/entities/cart/cart-dialog.html b/src/main/webapp/app/entities/cart/cart-dialog.html new file mode 100644 index 0000000..f4b9d3f --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart-dialog.html @@ -0,0 +1,26 @@ + +
+ + + + +
diff --git a/src/main/webapp/app/entities/cart/cart.controller.js b/src/main/webapp/app/entities/cart/cart.controller.js new file mode 100644 index 0000000..60d6f31 --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart.controller.js @@ -0,0 +1,25 @@ +(function() { + 'use strict'; + + angular + .module('firstApp') + .controller('CartController', CartController); + + CartController.$inject = ['Cart']; + + function CartController(Cart) { + + var vm = this; + + vm.carts = []; + + loadAll(); + + function loadAll() { + Cart.query(function(result) { + vm.carts = result; + vm.searchQuery = null; + }); + } + } +})(); diff --git a/src/main/webapp/app/entities/cart/cart.service.js b/src/main/webapp/app/entities/cart/cart.service.js new file mode 100644 index 0000000..6f95787 --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart.service.js @@ -0,0 +1,26 @@ +(function() { + 'use strict'; + angular + .module('firstApp') + .factory('Cart', Cart); + + Cart.$inject = ['$resource']; + + function Cart ($resource) { + var resourceUrl = 'api/carts/:id'; + + return $resource(resourceUrl, {}, { + 'query': { method: 'GET', isArray: true}, + 'get': { + method: 'GET', + transformResponse: function (data) { + if (data) { + data = angular.fromJson(data); + } + return data; + } + }, + 'update': { method:'PUT' } + }); + } +})(); diff --git a/src/main/webapp/app/entities/cart/cart.state.js b/src/main/webapp/app/entities/cart/cart.state.js new file mode 100644 index 0000000..057a9fe --- /dev/null +++ b/src/main/webapp/app/entities/cart/cart.state.js @@ -0,0 +1,160 @@ +(function() { + 'use strict'; + + angular + .module('firstApp') + .config(stateConfig); + + stateConfig.$inject = ['$stateProvider']; + + function stateConfig($stateProvider) { + $stateProvider + .state('cart', { + parent: 'entity', + url: '/cart', + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Carts' + }, + views: { + 'content@': { + templateUrl: 'app/entities/cart/carts.html', + controller: 'CartController', + controllerAs: 'vm' + } + }, + resolve: { + } + }) + .state('cart-detail', { + parent: 'cart', + url: '/cart/{id}', + data: { + authorities: ['ROLE_USER'], + pageTitle: 'Cart' + }, + views: { + 'content@': { + templateUrl: 'app/entities/cart/cart-detail.html', + controller: 'CartDetailController', + controllerAs: 'vm' + } + }, + resolve: { + entity: ['$stateParams', 'Cart', function($stateParams, Cart) { + return Cart.get({id : $stateParams.id}).$promise; + }], + previousState: ["$state", function ($state) { + var currentStateData = { + name: $state.current.name || 'cart', + params: $state.params, + url: $state.href($state.current.name, $state.params) + }; + return currentStateData; + }] + } + }) + .state('cart-detail.edit', { + parent: 'cart-detail', + url: '/detail/edit', + data: { + authorities: ['ROLE_USER'] + }, + onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) { + $uibModal.open({ + templateUrl: 'app/entities/cart/cart-dialog.html', + controller: 'CartDialogController', + controllerAs: 'vm', + backdrop: 'static', + size: 'lg', + resolve: { + entity: ['Cart', function(Cart) { + return Cart.get({id : $stateParams.id}).$promise; + }] + } + }).result.then(function() { + $state.go('^', {}, { reload: false }); + }, function() { + $state.go('^'); + }); + }] + }) + .state('cart.new', { + parent: 'cart', + url: '/new', + data: { + authorities: ['ROLE_USER'] + }, + onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) { + $uibModal.open({ + templateUrl: 'app/entities/cart/cart-dialog.html', + controller: 'CartDialogController', + controllerAs: 'vm', + backdrop: 'static', + size: 'lg', + resolve: { + entity: function () { + return { + id: null + }; + } + } + }).result.then(function() { + $state.go('cart', null, { reload: 'cart' }); + }, function() { + $state.go('cart'); + }); + }] + }) + .state('cart.edit', { + parent: 'cart', + url: '/{id}/edit', + data: { + authorities: ['ROLE_USER'] + }, + onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) { + $uibModal.open({ + templateUrl: 'app/entities/cart/cart-dialog.html', + controller: 'CartDialogController', + controllerAs: 'vm', + backdrop: 'static', + size: 'lg', + resolve: { + entity: ['Cart', function(Cart) { + return Cart.get({id : $stateParams.id}).$promise; + }] + } + }).result.then(function() { + $state.go('cart', null, { reload: 'cart' }); + }, function() { + $state.go('^'); + }); + }] + }) + .state('cart.delete', { + parent: 'cart', + url: '/{id}/delete', + data: { + authorities: ['ROLE_USER'] + }, + onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) { + $uibModal.open({ + templateUrl: 'app/entities/cart/cart-delete-dialog.html', + controller: 'CartDeleteController', + controllerAs: 'vm', + size: 'md', + resolve: { + entity: ['Cart', function(Cart) { + return Cart.get({id : $stateParams.id}).$promise; + }] + } + }).result.then(function() { + $state.go('cart', null, { reload: 'cart' }); + }, function() { + $state.go('^'); + }); + }] + }); + } + +})(); diff --git a/src/main/webapp/app/entities/cart/carts.html b/src/main/webapp/app/entities/cart/carts.html new file mode 100644 index 0000000..961f74f --- /dev/null +++ b/src/main/webapp/app/entities/cart/carts.html @@ -0,0 +1,54 @@ +
+

Carts

+ +
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + +
ID
{{cart.id}} +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/customer/customer-detail.controller.js b/src/main/webapp/app/entities/customer/customer-detail.controller.js index be9a4dc..936cdf5 100644 --- a/src/main/webapp/app/entities/customer/customer-detail.controller.js +++ b/src/main/webapp/app/entities/customer/customer-detail.controller.js @@ -5,9 +5,9 @@ .module('firstApp') .controller('CustomerDetailController', CustomerDetailController); - CustomerDetailController.$inject = ['$scope', '$rootScope', '$stateParams', 'previousState', 'entity', 'Customer', 'Item']; + CustomerDetailController.$inject = ['$scope', '$rootScope', '$stateParams', 'previousState', 'entity', 'Customer', 'Cart']; - function CustomerDetailController($scope, $rootScope, $stateParams, previousState, entity, Customer, Item) { + function CustomerDetailController($scope, $rootScope, $stateParams, previousState, entity, Customer, Cart) { var vm = this; vm.customer = entity; diff --git a/src/main/webapp/app/entities/customer/customer-detail.html b/src/main/webapp/app/entities/customer/customer-detail.html index d933a78..f9eb809 100644 --- a/src/main/webapp/app/entities/customer/customer-detail.html +++ b/src/main/webapp/app/entities/customer/customer-detail.html @@ -20,6 +20,10 @@

Customer {{vm.customer.id}}

{{vm.customer.telephone}}
+
Cart
+
+ {{vm.customer.cart.id}} +