diff --git a/.gitignore b/.gitignore index d9190bfa04e..9d84cbedb85 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .fileStorage/ +.vscode .idea *.csv *.dat diff --git a/imports/plugins/included/product-admin/client/containers/productAdminContainer.js b/imports/plugins/included/product-admin/client/containers/productAdminContainer.js index c7d40ad3179..111eb542130 100644 --- a/imports/plugins/included/product-admin/client/containers/productAdminContainer.js +++ b/imports/plugins/included/product-admin/client/containers/productAdminContainer.js @@ -24,7 +24,7 @@ class ProductAdminContainer extends Component { } handleDeleteProduct = (product) => { - ReactionProduct.maybeDeleteProduct(product || this.product); + ReactionProduct.archiveProduct(product || this.product); } handleProductFieldSave = (productId, fieldName, value) => { diff --git a/imports/plugins/included/product-detail-simple/client/containers/productDetailContainer.js b/imports/plugins/included/product-detail-simple/client/containers/productDetailContainer.js index d7701fc8aac..c73880254e4 100644 --- a/imports/plugins/included/product-detail-simple/client/containers/productDetailContainer.js +++ b/imports/plugins/included/product-detail-simple/client/containers/productDetailContainer.js @@ -148,7 +148,7 @@ class ProductDetailContainer extends Component { } handleDeleteProduct = () => { - ReactionProduct.maybeDeleteProduct(this.props.product); + ReactionProduct.archiveProduct(this.props.product); } render() { diff --git a/imports/plugins/included/product-detail-simple/client/containers/publishContainer.js b/imports/plugins/included/product-detail-simple/client/containers/publishContainer.js index 3f411705381..12254c9300a 100644 --- a/imports/plugins/included/product-detail-simple/client/containers/publishContainer.js +++ b/imports/plugins/included/product-detail-simple/client/containers/publishContainer.js @@ -20,7 +20,7 @@ class ProductPublishContainer extends Component { handlePublishActions = (event, action, documentIds) => { if (action === "archive") { - ReactionProduct.maybeDeleteProduct(documentIds); + ReactionProduct.archiveProduct(documentIds); } } diff --git a/imports/plugins/included/product-variant/client/containers/gridPublishContainer.js b/imports/plugins/included/product-variant/client/containers/gridPublishContainer.js index 7aafd2e22af..689c205ba8f 100644 --- a/imports/plugins/included/product-variant/client/containers/gridPublishContainer.js +++ b/imports/plugins/included/product-variant/client/containers/gridPublishContainer.js @@ -20,7 +20,7 @@ class GridProductPublishContainer extends Component { handlePublishActions = (event, action) => { if (action === "archive") { - ReactionProduct.maybeDeleteProduct(this.props.documents); + ReactionProduct.archiveProduct(this.props.documents); } } diff --git a/imports/plugins/included/product-variant/client/templates/products/productDetail/productDetail.js b/imports/plugins/included/product-variant/client/templates/products/productDetail/productDetail.js index 4b1860538e2..0d568bf6260 100644 --- a/imports/plugins/included/product-variant/client/templates/products/productDetail/productDetail.js +++ b/imports/plugins/included/product-variant/client/templates/products/productDetail/productDetail.js @@ -430,7 +430,7 @@ Template.productDetail.events({ ReactionProduct.cloneProduct(this); }, "click [data-event-action=deleteProduct]": function () { - ReactionProduct.maybeDeleteProduct(this); + ReactionProduct.archiveProduct(this); } }); @@ -516,7 +516,7 @@ Template.productDetailForm.events({ }, "click [data-event-action=deleteProduct]": function (event, instance) { const product = instance.state.get("product"); - ReactionProduct.maybeDeleteProduct(product); + ReactionProduct.archiveProduct(product); }, "click [data-event-action=cloneProduct]": function (event, instance) { const product = instance.state.get("product"); diff --git a/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/childVariant.html b/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/childVariant.html index 16d1d73484e..2b500ec10ac 100644 --- a/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/childVariant.html +++ b/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/childVariant.html @@ -46,13 +46,13 @@ {{> button icon="refresh" className="btn btn-default js-restore-child-variant" - tooltip="Restore from Trash" + tooltip="Restore from Archive" }} {{else}} {{> button - icon="trash" + icon="archive" className="btn btn-default js-remove-child-variant" - tooltip="Remove Variant" + tooltip="Archive Option" }} {{/if}} diff --git a/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/variantForm.html b/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/variantForm.html index 284025e5935..3c38906c0f5 100644 --- a/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/variantForm.html +++ b/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/variantForm.html @@ -41,9 +41,9 @@ }} {{else}} {{> button - icon="trash-o" - className="rui btn btn-danger btn-remove-variant flat" - tooltip="Archive" + icon="archive" + className="rui btn btn-default btn-remove-variant flat" + tooltip="Archive Variant" i18nTooltip="productDetailEdit.removeVariant" onClick=(removeVariant this) }} diff --git a/imports/plugins/included/product-variant/client/templates/products/productGrid/item.js b/imports/plugins/included/product-variant/client/templates/products/productGrid/item.js index 47f3a53ed2b..8e03f7d1b6c 100644 --- a/imports/plugins/included/product-variant/client/templates/products/productGrid/item.js +++ b/imports/plugins/included/product-variant/client/templates/products/productGrid/item.js @@ -258,7 +258,7 @@ Template.productGridItems.events({ }, "click .delete-product": function (event) { event.preventDefault(); - ReactionProduct.maybeDeleteProduct(this); + ReactionProduct.archiveProduct(this); }, "click .update-product-weight": function (event) { event.preventDefault(); diff --git a/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.html b/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.html index 67a078592c0..745922f186e 100644 --- a/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.html +++ b/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.html @@ -32,13 +32,13 @@ diff --git a/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.js b/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.js index ac957629746..fc66b537364 100644 --- a/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.js +++ b/imports/plugins/included/product-variant/client/templates/products/productSettings/productSettings.js @@ -172,8 +172,8 @@ Template.productSettings.events({ "click [data-event-action=cloneProduct]": function () { ReactionProduct.cloneProduct(this.products); }, - "click [data-event-action=deleteProduct]": function () { - ReactionProduct.maybeDeleteProduct(this.products); + "click [data-event-action=archiveProduct]": function () { + ReactionProduct.archiveProduct(this.products); }, "click [data-event-action=changeProductWeight]": function (event) { event.preventDefault(); diff --git a/imports/plugins/included/ui-search/client/templates/productSearch/productItem.js b/imports/plugins/included/ui-search/client/templates/productSearch/productItem.js index 880394b129d..435cf8f24f6 100644 --- a/imports/plugins/included/ui-search/client/templates/productSearch/productItem.js +++ b/imports/plugins/included/ui-search/client/templates/productSearch/productItem.js @@ -137,7 +137,7 @@ Template.productItem.events({ }, "click .delete-product": function (event) { event.preventDefault(); - ReactionProduct.maybeDeleteProduct(this); + ReactionProduct.archiveProduct(this); }, "click .update-product-weight": function (event) { event.preventDefault(); diff --git a/lib/api/products.js b/lib/api/products.js index 5f8c74b9b07..aa21381cd19 100644 --- a/lib/api/products.js +++ b/lib/api/products.js @@ -425,12 +425,12 @@ ReactionProduct.cloneProduct = function (productOrArray) { }; /** - * maybeDeleteProduct - * @summary confirm product deletion, delete, and alert + * archiveProduct + * @summary confirm to archive product * @param {Object} productOrArray - product Object * @returns {undefined} - returns nothing, and alerts, happen here */ -ReactionProduct.maybeDeleteProduct = function (productOrArray) { +ReactionProduct.archiveProduct = function (productOrArray) { const products = !_.isArray(productOrArray) ? [productOrArray] : productOrArray; const productIds = _.map(products, product => typeof product === "string" ? product : product._id); let confirmTitle; @@ -451,14 +451,14 @@ ReactionProduct.maybeDeleteProduct = function (productOrArray) { confirmButtonText: "Archive" }, (isConfirm) => { if (isConfirm) { - Meteor.call("products/deleteProduct", productIds, function (error, result) { + Meteor.call("products/archiveProduct", productIds, function (error, result) { let title; if (error) { title = products.length === 1 ? - products[0].title || i18next.t("productDetail.deleteErrorTheProduct") : + products[0].title || i18next.t("productDetail.archiveErrorTheProduct") : i18next.t("productDetail.theSelectedProducts"); - Alerts.toast(i18next.t("productDetail.productDeleteError", { product: title }), "error"); - throw new Meteor.Error("Error deleting " + title, error); + Alerts.toast(i18next.t("productDetail.productArchiveError", { product: title }), "error"); + throw new Meteor.Error("Error archiving " + title, error); } if (result) { FlowRouter.go("/"); diff --git a/private/data/i18n/en.json b/private/data/i18n/en.json index 2452d24d3b8..117ba7ef655 100644 --- a/private/data/i18n/en.json +++ b/private/data/i18n/en.json @@ -185,9 +185,8 @@ "addToCart": "Add to cart", "chooseOptions": "Please choose options before adding to cart", "outOfStock": "Sorry, this item is out of stock!", - "productDeleteError": "There was an error deleting {{product}}.", - "deleteErrorTheProduct": "the product", - "deleteErrorTheSelectedProducts": "the selected products", + "productArchiveError": "There was an error while sending {{product}} to the archives.", + "archiveErrorTheProduct": "the product", "publishFirst": "Publish product before adding to cart.", "quantityAbbreviation": "QTY", "selectOption": "Select an option before adding to cart", @@ -200,8 +199,6 @@ "publishProductHidden": "{{product}} is now hidden", "clonedAlert": "Cloned {{product}}", "clonedAlert_plural": "Cloned {{product}}", - "deletedAlert": "Deleted {{product}}", - "deletedAlert_plural": "Deleted {{product}}", "archivedAlert": "Archived {{product}}", "archivedAlert_plural": "Archived {{product}}", "theProduct": "the product", @@ -247,7 +244,7 @@ "cloneVariantFail": "Unable to clone variant for {{title}}.", "removeVariant": "Remove", "removeVariantConfirm": "Are you sure you want to delete {{title}}", - "restoreVariantConfirm": "Are you sure you want to restore {{title}} from the trash?", + "restoreVariantConfirm": "Are you sure you want to restore {{title}} from the archive?", "restoreVariantFail": "Unable to restore {{title}}.", "archiveVariantConfirm": "Are you sure you want to archive {{title}}", "thisVariant": "this variant", @@ -255,9 +252,8 @@ "duplicateProduct": "Duplicate Product", "pinProduct": "Pin Product", "toggleSize": "Toggle Size", - "deleteProduct": "Delete Product", - "restoreProduct": "Restore Product from Trash", - "deleteSelectedProducts": "Delete selected products?", + "archiveProduct": "Archive Product", + "restoreProduct": "Restore Product from archive", "archiveThisProduct": "Archive this product?", "archiveSelectedProducts": "Archive selected products?", "publish": "Publish", diff --git a/server/methods/catalog.app-test.js b/server/methods/catalog.app-test.js index cd2315a6345..90d769d4872 100644 --- a/server/methods/catalog.app-test.js +++ b/server/methods/catalog.app-test.js @@ -427,14 +427,14 @@ describe("core product methods", function () { it("should throw 403 error by non admin", function () { sandbox.stub(Reaction, "hasPermission", () => false); const removeProductSpy = sandbox.spy(Products, "remove"); - expect(() => Meteor.call("products/deleteProduct", "fakeId")).to.throw(Meteor.Error, /Access Denied/); + expect(() => Meteor.call("products/archiveProduct", "fakeId")).to.throw(Meteor.Error, /Access Denied/); expect(removeProductSpy).to.not.have.been.called; }); it("should not mark product as deleted by admin", function () { sandbox.stub(Reaction, "hasPermission", () => true); let product = addProduct(); - Meteor.call("products/deleteProduct", product._id); + Meteor.call("products/archiveProduct", product._id); product = Products.findOne(product._id); expect(product.isDeleted).to.equal(false); }); @@ -442,7 +442,7 @@ describe("core product methods", function () { it("should mark product revision as deleted by admin", function () { sandbox.stub(Reaction, "hasPermission", () => true); const product = addProduct(); - Meteor.call("products/deleteProduct", product._id); + Meteor.call("products/archiveProduct", product._id); const productRevision = Revisions.findOne({ documentId: product._id }); expect(productRevision.documentData.isDeleted).to.equal(true); }); @@ -450,7 +450,7 @@ describe("core product methods", function () { it("should publish product revision marked as deleted by admin", function () { sandbox.stub(Reaction, "hasPermission", () => true); let product = addProduct(); - Meteor.call("products/deleteProduct", product._id); + Meteor.call("products/archiveProduct", product._id); Meteor.call("revisions/publish", product._id); product = Products.findOne(product._id); expect(product.isDeleted).to.equal(true); @@ -460,7 +460,7 @@ describe("core product methods", function () { sandbox.stub(Reaction, "hasPermission", () => true); const product = addProduct(); sandbox.stub(Products, "remove"); - expect(() => Meteor.call("products/deleteProduct", product._id)).to.throw(Meteor.Error, + expect(() => Meteor.call("products/archiveProduct", product._id)).to.throw(Meteor.Error, /Something went wrong, nothing was deleted/); expect(Products.find(product._id).count()).to.equal(1); }); diff --git a/server/methods/catalog.js b/server/methods/catalog.js index 48187da05a4..e20a3cba1a6 100644 --- a/server/methods/catalog.js +++ b/server/methods/catalog.js @@ -700,12 +700,12 @@ Meteor.methods({ }, /** - * products/deleteProduct - * @summary delete a product and unlink it from all media + * products/archiveProduct + * @summary archive a product and unlink it from all media * @param {String} productId - productId to delete * @returns {Number} returns number of removed products */ - "products/deleteProduct": function (productId) { + "products/archiveProduct": function (productId) { check(productId, Match.OneOf(Array, String)); // must have admin permission to delete if (!Reaction.hasPermission("createProduct") && !Reaction.hasAdminAccess()) {