diff --git a/app/scripts/cart/cart.services.ts b/app/scripts/cart/cart.services.ts index cc907d163..736e2a1eb 100644 --- a/app/scripts/cart/cart.services.ts +++ b/app/scripts/cart/cart.services.ts @@ -241,32 +241,27 @@ module ngApp.cart.services { } sizeWarning() { - var cartAvailable = this.getCartVacancySize(), - template = ["Only", this.$filter("number")(cartAvailable)]; - - if (cartAvailable !== this.getMaxSize()) { - if (cartAvailable > 1) { - template.push("more"); - template.push("files"); - } else if (cartAvailable === 1) { - template.push("more"); - template.push("file"); - } else { - template = ["No more files"]; - } - } else { - template.push("files"); + var cartAvailable = this.getCartVacancySize() + var template = [ + "The cart is limited to " + this.$filter("number")(this.getMaxSize()) + " files.", + !this.files.length + ? "Please narrow down your search criteria to be able to add files to your cart." + : this.files.length < this.getMaxSize() + ? this.$filter("number")(cartAvailable) + getRemaining() + "can be added to the cart." + : "You cannot add anymore files to the cart." + ]; + + function getRemaining() { + return cartAvailable > 1 ? " more files " : " more file "; } - template.push("can be added to the cart."); - - template = "" + this.gettextCatalog.getString(template.join(" ")) + ""; + var messageTemplate = "" + this.gettextCatalog.getString(template.join(" ")) + ""; this.notify.config({ duration: 5000 }); this.notify.closeAll(); this.notify({ message: "", - messageTemplate: template, + messageTemplate: messageTemplate, container: "#notification", classes: "alert-warning" });