From 8287c3d05a67065c1e494d3679fc2e9c6ab13cb0 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Fri, 29 Nov 2019 15:52:29 +0530 Subject: [PATCH 01/74] feat(marketplace): unpublish item from hub --- erpnext/hub_node/api.py | 19 ++++++++++++++++++- erpnext/public/js/hub/pages/Item.vue | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index 0d01c67650..b0b00b2b46 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -70,7 +70,7 @@ def map_fields(items): field_mappings = get_field_mappings() table_fields = [d.fieldname for d in frappe.get_meta('Item').get_table_fields()] - hub_seller_name = frappe.db.get_value('Marketplace Settings' , 'Marketplace Settings', 'hub_seller_name') + hub_seller_name = frappe.db.get_value('Marketplace Settings', 'Marketplace Settings', 'hub_seller_name') for item in items: for fieldname in table_fields: @@ -147,6 +147,23 @@ def publish_selected_items(items_to_publish): except Exception as e: frappe.log_error(message=e, title='Hub Sync Error') +@frappe.whitelist() +def unpublish_item(item): + ''' Remove item listing from the marketplace ''' + item = json.loads(item) + + item_code = item.get('item_code') + frappe.db.set_value('Item', item_code, 'publish_in_hub', 0) + + item = map_fields([item])[0] + + try: + connection = get_hub_connection() + connection.set_value('Hub Item', item.get('name'), 'published', 0) + + except Exception as e: + frappe.log_error(message=e, title='Hub Sync Error') + @frappe.whitelist() def get_unregistered_users(): settings = frappe.get_single('Marketplace Settings') diff --git a/erpnext/public/js/hub/pages/Item.vue b/erpnext/public/js/hub/pages/Item.vue index 841d0046db..285f696926 100644 --- a/erpnext/public/js/hub/pages/Item.vue +++ b/erpnext/public/js/hub/pages/Item.vue @@ -300,7 +300,21 @@ export default { }, unpublish_item() { - frappe.msgprint(__('This feature is under development...')); + let me = this; + frappe.confirm(__(`Unpublish ${this.item.item_name}?`), function () { + frappe.call( + 'erpnext.hub_node.api.unpublish_item', + { + item: me.item + } + ) + .then((r) => { + frappe.set_route(`marketplace/home`); + frappe.show_alert(__('Item listing removed')) + + }) + + }) } } } From fa170e3c8455b16fc8aac02a8d7adbd742378cf8 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Wed, 4 Dec 2019 15:59:17 +0530 Subject: [PATCH 02/74] fix(marketplace): add watcher for route change to fetch new items --- erpnext/public/js/hub/pages/Home.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/public/js/hub/pages/Home.vue b/erpnext/public/js/hub/pages/Home.vue index 353656957d..84a42367b2 100644 --- a/erpnext/public/js/hub/pages/Home.vue +++ b/erpnext/public/js/hub/pages/Home.vue @@ -58,6 +58,11 @@ export default { this.search_value = ''; this.get_items(); }, + watch:{ + $route (to, from){ + this.get_items() + } + }, methods: { get_items() { hub.call('get_data_for_homepage', frappe.defaults ? { From 6d4f4bef7ebd44d8579f9915de6a6f74e1802408 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Thu, 5 Dec 2019 01:01:01 +0530 Subject: [PATCH 03/74] fix(marketplace): autocomplete hub category --- erpnext/public/js/hub/components/item_publish_dialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/hub/components/item_publish_dialog.js b/erpnext/public/js/hub/components/item_publish_dialog.js index e49ba53918..05eaffd1c5 100644 --- a/erpnext/public/js/hub/components/item_publish_dialog.js +++ b/erpnext/public/js/hub/components/item_publish_dialog.js @@ -31,7 +31,8 @@ function ItemPublishDialog(primary_action, secondary_action) { hub.call('get_categories') .then(categories => { categories = categories.map(d => d.name); - dialog.fields_dict.hub_category.set_data(categories); + dialog.fields_dict.hub_category.df.options = categories; + dialog.fields_dict.hub_category.set_options(); }); return dialog; From d249d4c94789416ad6999af7c95906ec983146b7 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Mon, 9 Dec 2019 15:44:31 +0530 Subject: [PATCH 04/74] style: change formatting --- .../js/hub/components/item_publish_dialog.js | 42 ++--- erpnext/public/js/hub/pages/Item.vue | 169 +++++++++--------- 2 files changed, 106 insertions(+), 105 deletions(-) diff --git a/erpnext/public/js/hub/components/item_publish_dialog.js b/erpnext/public/js/hub/components/item_publish_dialog.js index 05eaffd1c5..08de5b30b6 100644 --- a/erpnext/public/js/hub/components/item_publish_dialog.js +++ b/erpnext/public/js/hub/components/item_publish_dialog.js @@ -3,24 +3,24 @@ function ItemPublishDialog(primary_action, secondary_action) { title: __('Edit Publishing Details'), fields: [ { - "label": "Item Code", - "fieldname": "item_code", - "fieldtype": "Data", - "read_only": 1 + label: __('Item Code'), + fieldname: 'item_code', + fieldtype: 'Data', + read_only: 1 }, { - "label": "Hub Category", - "fieldname": "hub_category", - "fieldtype": "Autocomplete", - "options": [], - "reqd": 1 + label: __('Hub Category'), + fieldname: 'hub_category', + fieldtype: 'Autocomplete', + options: [], + reqd: 1 }, { - "label": "Images", - "fieldname": "image_list", - "fieldtype": "MultiSelect", - "options": [], - "reqd": 1 + label: __('Images'), + fieldname: 'image_list', + fieldtype: 'MultiSelect', + options: [], + reqd: 1 } ], primary_action_label: primary_action.label || __('Set Details'), @@ -28,16 +28,12 @@ function ItemPublishDialog(primary_action, secondary_action) { secondary_action: secondary_action.fn }); - hub.call('get_categories') - .then(categories => { - categories = categories.map(d => d.name); - dialog.fields_dict.hub_category.df.options = categories; - dialog.fields_dict.hub_category.set_options(); - }); + hub.call('get_categories').then(categories => { + categories = categories.map(d => d.name); + dialog.fields_dict.hub_category.set_data(categories); + }); return dialog; } -export { - ItemPublishDialog -} +export { ItemPublishDialog }; diff --git a/erpnext/public/js/hub/pages/Item.vue b/erpnext/public/js/hub/pages/Item.vue index 285f696926..e4b0eeaecb 100644 --- a/erpnext/public/js/hub/pages/Item.vue +++ b/erpnext/public/js/hub/pages/Item.vue @@ -1,10 +1,5 @@