From 23e27c127580fed31886128b4eb8515797709e93 Mon Sep 17 00:00:00 2001 From: Software Date: Wed, 3 Oct 2018 13:58:32 +0530 Subject: [PATCH 1/2] on delete product from tag also remove from elastic search --- src/views/Tag/productMapping.vue | 2 +- src/views/Tag/productTags.vue | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/views/Tag/productMapping.vue b/src/views/Tag/productMapping.vue index e6f6e07..02a713f 100644 --- a/src/views/Tag/productMapping.vue +++ b/src/views/Tag/productMapping.vue @@ -230,7 +230,7 @@ export default { this.$Notice.error({title: 'Error!!', desc: 'Tag already mapped.', duration: 2}) } else { - if(Array.isArray(tag_list)) { + if(Array.isArray(tag_list) && tag_list.length > 0) { tag_list.push(res.data.tag_name); } else { diff --git a/src/views/Tag/productTags.vue b/src/views/Tag/productTags.vue index 8a72e8f..a333c72 100644 --- a/src/views/Tag/productTags.vue +++ b/src/views/Tag/productTags.vue @@ -207,6 +207,40 @@ export default { }).catch(err => { this.$Notice.error({ title: 'Error!', desc: 'Not Deleted.', duration: 3}) }) + + //change in elasticsearch product + let websiteDetails = _.find(this.webOptions, {value: this.tdata.website}); + axios.get(tagsUrl + '/' + this.ptdata.data[finx].tag_id).then(tagRes => { + axios.get( + productApiUrl + '?_id=' + this.ptdata.data[finx].product_id, + { headers: { 'vid': websiteDetails.vid } } + ) + .then(productRes => { + let tag_list = productRes.data.hits.hits[0]._source.tags; + + if(tag_list.includes(tagRes.data.tag_name)) { + if(Array.isArray(tag_list) && tag_list.length > 0) { + const index = tag_list.indexOf(tagRes.data.tag_name); + tag_list.splice(index, 1); + } + + let esData = { "supplier_id":productRes.data.hits.hits[0]._source.supplier_id, "tags":tag_list }; + axios({ + method: 'PATCH', + url: productApiUrl+"/"+this.ptdata.data[finx].product_id, + data: esData, + headers: {'vid':websiteDetails.vid} + }).then(res3 => { + this.$Spin.hide(); + this.$Notice.success({title: 'Success!!', desc: 'Product removed from ES.', duration: 2}) + }).catch(err => { + this.$Spin.hide(); + this.$Notice.error({title: 'Error!!', desc: 'Not removed from ES.', duration: 2}) + }) + } + }) + }) + //end elasticsearch } }, async init (item) { From db59062c3de88bc2bb10740362339ceb728f716a Mon Sep 17 00:00:00 2001 From: gkumar9 Date: Mon, 15 Oct 2018 16:30:00 +0530 Subject: [PATCH 2/2] changed delete code --- src/views/index.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/views/index.vue b/src/views/index.vue index 0444905..43a057a 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -5836,8 +5836,11 @@ async remove(store, data) { // console.log('remove called:') // Get Config.json file data - let configFileUrl = this.$store.state.fileUrl.replace(/\\/g, "\/"); - let urlparts = configFileUrl.split("/"); + let configFileUrl = this.$store.state.fileUrl; + + if(configFileUrl!=undefined){ + configFileUrl.replace(/\\/g, "\/") + let urlparts = configFileUrl.split("/"); let fileNameOrginal = urlparts[urlparts.length - 1]; let foldername = urlparts[urlparts.length - 2]; // let fileName = '/' + urlparts[urlparts.length - 2] + '/' + urlparts[urlparts.length - 1]; @@ -6171,6 +6174,8 @@ // }).catch((dismiss) => { // console.log('error', dismiss) // }) + } + }, // Remove Folder manipulating config.json @@ -6345,6 +6350,7 @@ async removeProject(store, data) { // Get Config File let folderUrl = this.$store.state.fileUrl.replace(/\\/g, "\/"); + if(folderUrl!=undefined){ let foldername = folderUrl.split('/'); foldername = foldername[(foldername.length - 1)]; @@ -6432,7 +6438,7 @@ }) // delete project configuration from RethinkDB - axios.delete(config.baseURL + '/project-configuration/' + foldername, {}) + await axios.delete(config.baseURL + '/project-configuration/' + foldername, {}) .then((res) => { this.$message({ showClose: true, @@ -6519,6 +6525,8 @@ location.reload() }); }) + } + }, quickPreview(filePath) {