From d1224ca662df31e8f694ddc7b365dfc0fe0d7149 Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Thu, 26 Jul 2018 13:39:06 +0530 Subject: [PATCH] [hub][init] add profile page --- erpnext/hub_node/__init__.py | 14 +++--- erpnext/public/js/hub/hub_listing.js | 65 +++++++++++++++++++++++----- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/erpnext/hub_node/__init__.py b/erpnext/hub_node/__init__.py index c8e40eb8e8..5c86bb927c 100644 --- a/erpnext/hub_node/__init__.py +++ b/erpnext/hub_node/__init__.py @@ -34,9 +34,14 @@ def get_list(doctype, start=0, limit=20, fields=["*"], filters="{}", order_by=No #### LOCAL ITEMS @frappe.whitelist() def get_valid_items(search_value=''): - items = frappe.get_list('Item', fields=["*"], filters={ - 'item_name': ['like', '%' + search_value + '%'] - }) + items = frappe.get_list( + 'Item', fields=["*"], + filters={ + 'item_name': ['like', '%' + search_value + '%'], + 'publish_in_hub': 0 + }, + order_by="modified desc" + ) valid_items = filter(lambda x: x.image and x.description, items) @@ -52,9 +57,6 @@ def publish_selected_items(items_to_publish, items_to_unpublish): for item_code in json.loads(items_to_publish): frappe.db.set_value('Item', item_code, 'publish_in_hub', 1) - for item_code in json.loads(items_to_unpublish): - frappe.db.set_value('Item', item_code, 'publish_in_hub', 0) - hub_settings = frappe.get_doc('Hub Settings') hub_settings.sync() diff --git a/erpnext/public/js/hub/hub_listing.js b/erpnext/public/js/hub/hub_listing.js index eb55806784..6d0f3e96ac 100644 --- a/erpnext/public/js/hub/hub_listing.js +++ b/erpnext/public/js/hub/hub_listing.js @@ -137,11 +137,14 @@ erpnext.hub.Marketplace = class Marketplace { this.subpages.register = new erpnext.hub.Register(this.$body); } + if (route[1] === 'profile' && !this.subpages.profile) { + this.subpages.profile = new erpnext.hub.Profile(this.$body, this.hub_settings); + } + if (route[1] === 'publish' && !this.subpages.publish) { this.subpages.publish = new erpnext.hub.Publish(this.$body); } - if (!Object.keys(this.subpages).includes(route[1])) { frappe.show_not_found(); return; @@ -572,6 +575,51 @@ erpnext.hub.Register = class Register extends SubPage { } } +erpnext.hub.Profile = class Profile extends SubPage { + constructor(parent, profile_data) { + super(parent); + this.profile_data = profile_data; + } + + make_wrapper() { + super.make_wrapper(); + const profile_html = `
+
+
+ +
+
+
+
+
+ +
+
+
+

${'title'}

+
+

${'where'}${'dot_spacer'}${'when'}

+

${'rating_html'}${'rating_count'}

+
+
+
+ ${'description' ? + `${__('Description')} +

${'description'}

+ ` : __('No description') + } +
+
+
+
`; + + this.$wrapper.html(profile_html); + } + + refresh() {} + + render() {} +} erpnext.hub.Publish = class Publish extends SubPage { make_wrapper() { super.make_wrapper(); @@ -604,9 +652,6 @@ erpnext.hub.Publish = class Publish extends SubPage { ${search_html} - - ${select_all_button} - ${deselect_all_button} `); this.$wrapper.append(subpage_header); @@ -615,13 +660,13 @@ erpnext.hub.Publish = class Publish extends SubPage { } setup_events() { - this.$wrapper.find('.select-all').on('click', () => { - this.$wrapper.find('.hub-card').addClass('active'); - }); + // this.$wrapper.find('.select-all').on('click', () => { + // this.$wrapper.find('.hub-card').addClass('active'); + // }); - this.$wrapper.find('.deselect-all').on('click', () => { - this.$wrapper.find('.hub-card').removeClass('active'); - }); + // this.$wrapper.find('.deselect-all').on('click', () => { + // this.$wrapper.find('.hub-card').removeClass('active'); + // }); this.$wrapper.find('.publish-items').on('click', () => { this.publish_selected_items()