Commit a02d3181274e6b4da9d4cd4b0e90444385ad5c28

Authored by Adhidarma Hadiwinoto
1 parent b8392962c1
Exists in master

APISERVER: /remote-products/del terima multiple product

Showing 1 changed file with 15 additions and 5 deletions Side-by-side Diff

api-server/router-remote-products.js
... ... @@ -66,20 +66,30 @@ function pageDel(req, res, next) {
66 66 });
67 67 }
68 68  
69   - const localProduct = req.params.localProduct || req.query.local;
70   - if (!localProduct) {
  69 + let localProducts = req.params.localProduct || req.query.local;
  70 + if (!localProducts) {
71 71 responseWithUsageHelp();
72 72 return;
73 73 }
74 74  
  75 + if (typeof localProducts === 'string') {
  76 + localProducts = localProducts.split(/[\s,]+/);
  77 + }
75 78  
76   - delete config.remote_products[localProduct];
77   - matrix.config_is_dirty = true;
  79 + const localProductsCount = localProducts.length;
  80 + for (let i=0; i<localProductsCount; i++) {
  81 + const localProduct = localProducts[i];
  82 +
  83 + if (localProduct) {
  84 + delete config.remote_products[localProduct];
  85 + matrix.config_is_dirty = true;
  86 + }
  87 + }
78 88  
79 89 res.json({
80 90 method: '/remote-products/del',
81 91 error: null,
82   - local_product: localProduct,
  92 + deleted_product: localProducts,
83 93 remote_products: config.remote_products
84 94 })
85 95 }