From c5a9972785174a811c2265f93a779841f298793e Mon Sep 17 00:00:00 2001 From: Prateeksha Singh Date: Mon, 13 Aug 2018 21:36:07 +0530 Subject: [PATCH] [refactor][major] Separate out Components - item_card - item_card_container - detail_view - search_bar - reviews - skeleton_state - empty_state - empty_state --- .../public/js/hub/components/detail_view.js | 160 ++++++++++ .../public/js/hub/components/empty_state.js | 10 + .../{helpers.js => components/item_card.js} | 48 +-- .../js/hub/components/items_container.js | 22 ++ erpnext/public/js/hub/components/reviews.js | 71 +++++ .../public/js/hub/components/search_bar.js | 20 ++ .../js/hub/components/skeleton_state.js | 27 ++ erpnext/public/js/hub/marketplace.js | 1 - erpnext/public/js/hub/pages/category.js | 2 +- erpnext/public/js/hub/pages/favourites.js | 8 +- erpnext/public/js/hub/pages/home.js | 4 +- erpnext/public/js/hub/pages/item.js | 282 ++++-------------- erpnext/public/js/hub/pages/messages.js | 4 +- erpnext/public/js/hub/pages/not_found.js | 1 + erpnext/public/js/hub/pages/publish.js | 4 +- .../public/js/hub/pages/published_products.js | 2 +- erpnext/public/js/hub/pages/register.js | 44 +-- erpnext/public/js/hub/pages/search.js | 3 +- erpnext/public/js/hub/pages/seller.js | 61 +--- erpnext/public/js/hub/pages/subpage.js | 8 +- erpnext/public/less/hub.less | 16 +- 21 files changed, 425 insertions(+), 373 deletions(-) create mode 100644 erpnext/public/js/hub/components/detail_view.js create mode 100644 erpnext/public/js/hub/components/empty_state.js rename erpnext/public/js/hub/{helpers.js => components/item_card.js} (68%) create mode 100644 erpnext/public/js/hub/components/items_container.js create mode 100644 erpnext/public/js/hub/components/reviews.js create mode 100644 erpnext/public/js/hub/components/search_bar.js create mode 100644 erpnext/public/js/hub/components/skeleton_state.js diff --git a/erpnext/public/js/hub/components/detail_view.js b/erpnext/public/js/hub/components/detail_view.js new file mode 100644 index 0000000000..1f0d5426f2 --- /dev/null +++ b/erpnext/public/js/hub/components/detail_view.js @@ -0,0 +1,160 @@ +function get_detail_view_html(item, allow_edit) { + const title = item.item_name || item.name; + const seller = item.company; + + const who = __('Posted By {0}', [seller]); + const when = comment_when(item.creation); + + const city = item.city ? item.city + ', ' : ''; + const country = item.country ? item.country : ''; + const where = `${city}${country}`; + + const dot_spacer = ''; + + const description = item.description || ''; + + let stats = __('No views yet'); + if(item.view_count) { + const views_message = __(`${item.view_count} Views`); + + const rating_html = get_rating_html(item.average_rating); + const rating_count = item.no_of_ratings > 0 ? `${item.no_of_ratings} reviews` : __('No reviews yet'); + + stats = `${views_message}${dot_spacer}${rating_html} (${rating_count})`; + } + + + let menu_items = ''; + + if(allow_edit) { + menu_items = ` +
  • ${__('Edit Details')}
  • +
  • ${__('Unpublish')}
  • `; + } else { + menu_items = ` +
  • ${__('Report this item')}
  • + `; + } + + const html = ` +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    ${title}

    +
    +

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

    +

    ${stats}

    +
    +
    + +
    + + +
    +
    +
    + +
    +
    +
    +
    + Product Description +
    +

    + ${description ? description : __('No details')} +

    +
    +
    + +
    + Seller Information +
    +
    + +
    +
    + +
    +
    + +
    + +
    +
    + `; + + return html; +} + +function get_profile_html(profile) { + const p = profile; + const profile_html = `
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +

    ${p.company}

    +
    +

    ${p.country}

    +

    ${p.site_name}

    +

    ${__(`Joined ${comment_when(p.creation)}`)}

    +
    +
    +
    + ${'description' + ? `

    ${p.company_description}

    ` + : `

    __('No description') +

    +
    + +
    `; + + return profile_html; +} + +export { + get_detail_view_html, + get_profile_html +} diff --git a/erpnext/public/js/hub/components/empty_state.js b/erpnext/public/js/hub/components/empty_state.js new file mode 100644 index 0000000000..0e1ad46d2f --- /dev/null +++ b/erpnext/public/js/hub/components/empty_state.js @@ -0,0 +1,10 @@ +function get_empty_state(message, action) { + return `
    +

    ${message}

    + ${action ? `

    ${action}

    `: ''} +
    `; +} + +export { + get_empty_state +} diff --git a/erpnext/public/js/hub/helpers.js b/erpnext/public/js/hub/components/item_card.js similarity index 68% rename from erpnext/public/js/hub/helpers.js rename to erpnext/public/js/hub/components/item_card.js index 7c4c9193e0..733df62e6a 100644 --- a/erpnext/public/js/hub/helpers.js +++ b/erpnext/public/js/hub/components/item_card.js @@ -1,27 +1,3 @@ -function get_empty_state(message, action) { - return `
    -

    ${message}

    - ${action ? `

    ${action}

    `: ''} -
    `; -} - -function get_item_card_container_html(items, title='', get_item_html = get_item_card_html, action='') { - const items_html = (items || []).map(item => get_item_html(item)).join(''); - const title_html = title - ? `
    -

    ${title}

    - ${action} -
    ` - : ''; - - const html = `
    - ${title_html} - ${items_html} -
    `; - - return html; -} - function get_item_card_html(item) { const item_name = item.item_name || item.name; const title = strip_html(item_name); @@ -117,28 +93,8 @@ function get_rating_html(rating) { return rating_html; } -function make_search_bar({wrapper, on_search, placeholder = __('Search for anything')}) { - const $search = $(` -
    - -
    ` - ); - wrapper.append($search); - const $search_input = $search.find('input'); - - $search_input.on('keydown', frappe.utils.debounce((e) => { - if (e.which === frappe.ui.keyCode.ENTER) { - const search_value = $search_input.val(); - on_search(search_value); - } - }, 300)); -} - export { - get_empty_state, - get_item_card_container_html, get_item_card_html, - get_local_item_card_html, - get_rating_html, - make_search_bar, + get_local_item_card_html, + get_rating_html } diff --git a/erpnext/public/js/hub/components/items_container.js b/erpnext/public/js/hub/components/items_container.js new file mode 100644 index 0000000000..dd29836917 --- /dev/null +++ b/erpnext/public/js/hub/components/items_container.js @@ -0,0 +1,22 @@ +import { get_item_card_html } from './item_card'; + +function get_item_card_container_html(items, title='', get_item_html = get_item_card_html, action='') { + const items_html = (items || []).map(item => get_item_html(item)).join(''); + const title_html = title + ? `
    +

    ${title}

    + ${action} +
    ` + : ''; + + const html = `
    + ${title_html} + ${items_html} +
    `; + + return html; +} + +export { + get_item_card_container_html +} diff --git a/erpnext/public/js/hub/components/reviews.js b/erpnext/public/js/hub/components/reviews.js new file mode 100644 index 0000000000..616f2fb705 --- /dev/null +++ b/erpnext/public/js/hub/components/reviews.js @@ -0,0 +1,71 @@ +import { get_rating_html } from './item_card'; + +function get_review_html(review) { + let username = review.username || review.user || __("Anonymous"); + + let image_html = review.user_image + ? `
    ` + : `
    ${frappe.get_abbr(username)}
    ` + + let edit_html = review.own + ? ` +
    + + ${'data.edit'} + +
    ` + : ''; + + let rating_html = get_rating_html(review.rating); + + return get_timeline_item(review, image_html, edit_html, rating_html); +} + +function get_timeline_item(data, image_html, edit_html, rating_html) { + return `
    + +
    +
    +
    ${edit_html}
    + +
    + + ${image_html} + + +
    + + + ${data.username} + + + + + +
    +
    +
    +
    +

    + ${rating_html} +

    +
    ${data.subject}
    +

    + ${data.content} +

    +
    +
    +
    +
    +
    `; +} + +export { + get_review_html +} diff --git a/erpnext/public/js/hub/components/search_bar.js b/erpnext/public/js/hub/components/search_bar.js new file mode 100644 index 0000000000..9526516ee9 --- /dev/null +++ b/erpnext/public/js/hub/components/search_bar.js @@ -0,0 +1,20 @@ +function make_search_bar({wrapper, on_search, placeholder = __('Search for anything')}) { + const $search = $(` +
    + +
    ` + ); + wrapper.append($search); + const $search_input = $search.find('input'); + + $search_input.on('keydown', frappe.utils.debounce((e) => { + if (e.which === frappe.ui.keyCode.ENTER) { + const search_value = $search_input.val(); + on_search(search_value); + } + }, 300)); +} + +export { + make_search_bar +} diff --git a/erpnext/public/js/hub/components/skeleton_state.js b/erpnext/public/js/hub/components/skeleton_state.js new file mode 100644 index 0000000000..7c6880224c --- /dev/null +++ b/erpnext/public/js/hub/components/skeleton_state.js @@ -0,0 +1,27 @@ +function get_detail_skeleton_html() { + const skeleton = `
    +
    +
    +
    +
    +
    +

    Name

    +
    +

    Details

    +

    Ratings

    +
    +
    +
    +

    Desc

    +

    Desc

    +
    +
    +
    +
    `; + + return skeleton; +} + +export { + get_detail_skeleton_html +} diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index 18a1bb0629..154324338d 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -13,7 +13,6 @@ import './pages/messages'; import './pages/not_found'; // helpers -import './helpers'; import './hub_call'; frappe.provide('hub'); diff --git a/erpnext/public/js/hub/pages/category.js b/erpnext/public/js/hub/pages/category.js index 13a0a92f8c..118d196d55 100644 --- a/erpnext/public/js/hub/pages/category.js +++ b/erpnext/public/js/hub/pages/category.js @@ -1,5 +1,5 @@ import SubPage from './subpage'; -import { get_item_card_container_html } from '../helpers'; +import { get_item_card_container_html } from '../components/items_container'; erpnext.hub.Category = class Category extends SubPage { refresh() { diff --git a/erpnext/public/js/hub/pages/favourites.js b/erpnext/public/js/hub/pages/favourites.js index 704caeabbb..d4a8cb3ee0 100644 --- a/erpnext/public/js/hub/pages/favourites.js +++ b/erpnext/public/js/hub/pages/favourites.js @@ -1,5 +1,5 @@ import SubPage from './subpage'; -import { get_item_card_container_html } from '../helpers'; +import { get_item_card_container_html } from '../components/items_container'; erpnext.hub.Favourites = class Favourites extends SubPage { refresh() { @@ -10,7 +10,9 @@ erpnext.hub.Favourites = class Favourites extends SubPage { } get_favourites() { - return hub.call('get_item_favourites'); + return hub.call('get_favourite_items_of_seller', { + hub_seller: hub.settings.company_email + }); } render(items) { @@ -18,4 +20,4 @@ erpnext.hub.Favourites = class Favourites extends SubPage { const html = get_item_card_container_html(items, __('Favourites')); this.$wrapper.append(html) } -} \ No newline at end of file +} diff --git a/erpnext/public/js/hub/pages/home.js b/erpnext/public/js/hub/pages/home.js index eefe3b8797..b7a55cec05 100644 --- a/erpnext/public/js/hub/pages/home.js +++ b/erpnext/public/js/hub/pages/home.js @@ -1,5 +1,7 @@ import SubPage from './subpage'; -import { make_search_bar, get_item_card_container_html, get_item_card_html } from '../helpers'; +import { make_search_bar } from '../components/search_bar'; +import { get_item_card_container_html } from '../components/items_container'; +import { get_item_card_html } from '../components/item_card'; erpnext.hub.Home = class Home extends SubPage { make_wrapper() { diff --git a/erpnext/public/js/hub/pages/item.js b/erpnext/public/js/hub/pages/item.js index ec3d6edc3e..207c94cb90 100644 --- a/erpnext/public/js/hub/pages/item.js +++ b/erpnext/public/js/hub/pages/item.js @@ -1,5 +1,7 @@ import SubPage from './subpage'; -import { get_rating_html } from '../helpers'; +import { get_detail_view_html } from '../components/detail_view'; +import { get_detail_skeleton_html } from '../components/skeleton_state'; +import { get_review_html } from '../components/reviews'; erpnext.hub.Item = class Item extends SubPage { refresh() { @@ -16,30 +18,12 @@ erpnext.hub.Item = class Item extends SubPage { }); } - show_skeleton() { - const skeleton = `
    -
    -
    -
    -
    -
    -

    Name

    -
    -

    Details

    -

    Ratings

    -
    -
    -
    -

    Desc

    -

    Desc

    -
    -
    -
    -
    `; - this.$wrapper.html(skeleton); + show_skeleton() { + this.$wrapper.html(get_detail_skeleton_html()); } + get_item(hub_item_code) { return hub.call('get_item_details', { hub_seller: hub.settings.company_email, @@ -47,123 +31,9 @@ erpnext.hub.Item = class Item extends SubPage { }); } + render(item) { - const title = item.item_name || item.name; - const seller = item.company; - - const who = __('Posted By {0}', [seller]); - const when = comment_when(item.creation); - - const city = item.city ? item.city + ', ' : ''; - const country = item.country ? item.country : ''; - const where = `${city}${country}`; - - const dot_spacer = ''; - - const description = item.description || ''; - - let stats = __('No views yet'); - if(item.view_count) { - const views_message = __(`${item.view_count} Views`); - - const rating_html = get_rating_html(item.average_rating); - const rating_count = item.no_of_ratings > 0 ? `${item.no_of_ratings} reviews` : __('No reviews yet'); - - stats = `${views_message}${dot_spacer}${rating_html} (${rating_count})`; - } - - - let menu_items = ''; - - if(this.own_item) { - menu_items = ` -
  • ${__('Edit Details')}
  • -
  • ${__('Unpublish')}
  • `; - } else { - menu_items = ` -
  • ${__('Report this item')}
  • - `; - } - - const html = ` -
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -

    ${title}

    -
    -

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

    -

    ${stats}

    -
    -
    - -
    - - -
    -
    -
    - -
    -
    -
    -
    - Product Description -
    -

    - ${description ? description : __('No details')} -

    -
    -
    - -
    - Seller Information -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    - `; - + const html = get_detail_view_html(item, this.own_item); this.$wrapper.html(html); this.make_review_area(); @@ -171,10 +41,11 @@ erpnext.hub.Item = class Item extends SubPage { this.get_reviews() .then(reviews => { this.reviews = reviews; - this.render_reviews(reviews); + this.render_reviews(); }); } + edit_details() { if (!this.edit_dialog) { this.edit_dialog = new frappe.ui.Dialog({ @@ -185,6 +56,7 @@ erpnext.hub.Item = class Item extends SubPage { this.edit_dialog.show(); } + unpublish_item() { if(!this.unpublish_dialog) { this.unpublish_dialog = new frappe.ui.Dialog({ @@ -196,6 +68,16 @@ erpnext.hub.Item = class Item extends SubPage { this.unpublish_dialog.show(); } + + add_to_favourites(favourite_button) { + $(favourite_button).html('Added to Favourites').addClass('disabled'); + return hub.call('remove_item_from_seller_favourites', { + hub_item_code: this.hub_item_code, + hub_seller: hub.settings.company_email + }); + } + + contact_seller() { const d = new frappe.ui.Dialog({ title: __('Send a message'), @@ -220,37 +102,48 @@ erpnext.hub.Item = class Item extends SubPage { d.show(); } + make_review_area() { this.comment_area = new frappe.ui.ReviewArea({ parent: this.$wrapper.find('.timeline-head').empty(), mentions: [], - on_submit: (values) => { - values.user = frappe.session.user; - values.username = frappe.session.user_fullname; - - hub.call('add_item_review', { - hub_item_code: this.hub_item_code, - review: JSON.stringify(values) - }) - .then(review => { - this.reviews = this.reviews || []; - this.reviews.push(review); - this.render_reviews(this.reviews); - - this.comment_area.reset(); - }); - } + on_submit: this.on_submit_review.bind(this) }); } + + on_submit_review(values) { + values.user = frappe.session.user; + values.username = frappe.session.user_fullname; + + hub.call('add_item_review', { + hub_item_code: this.hub_item_code, + review: JSON.stringify(values) + }) + .then(this.push_review_in_review_area.bind(this)); + } + + + push_review_in_review_area(review) { + this.reviews = this.reviews || []; + this.reviews.push(review); + this.render_reviews(); + + this.comment_area.reset(); + } + + get_reviews() { return hub.call('get_item_reviews', { hub_item_code: this.hub_item_code }).catch(() => {}); } - render_reviews(reviews=[]) { - this.$wrapper.find('.timeline-items').empty(); - reviews.sort((a, b) => { + render_reviews() { + const $timeline = this.$wrapper.find('.timeline-items'); + + $timeline.empty(); + + this.reviews.sort((a, b) => { if (a.modified > b.modified) { return -1; } @@ -262,75 +155,8 @@ erpnext.hub.Item = class Item extends SubPage { return 0; }); - reviews.forEach(review => this.render_review(review)); - } - - render_review(review) { - let username = review.username || review.user || __("Anonymous"); - - let image_html = review.user_image - ? `
    ` - : `
    ${frappe.get_abbr(username)}
    ` - - let edit_html = review.own - ? ` -
    - - ${'data.edit'} - -
    ` - : ''; - - let rating_html = get_rating_html(review.rating); - - const $timeline_items = this.$wrapper.find('.timeline-items'); - - $(this.get_timeline_item(review, image_html, edit_html, rating_html)) - .appendTo($timeline_items); - } - - get_timeline_item(data, image_html, edit_html, rating_html) { - return `
    - -
    -
    -
    ${edit_html}
    - -
    - - ${image_html} - - -
    - - - ${data.username} - - - - - -
    -
    -
    -
    -

    - ${rating_html} -

    -
    ${data.subject}
    -

    - ${data.content} -

    -
    -
    -
    -
    -
    `; + this.reviews.forEach(review => { + $(get_review_html(review)).appendTo($timeline); + }); } } diff --git a/erpnext/public/js/hub/pages/messages.js b/erpnext/public/js/hub/pages/messages.js index 7bc99a7253..8531e0b3f9 100644 --- a/erpnext/public/js/hub/pages/messages.js +++ b/erpnext/public/js/hub/pages/messages.js @@ -1,5 +1,5 @@ import SubPage from './subpage'; -import { make_search_bar } from '../helpers'; +import { make_search_bar } from '../components/search_bar'; erpnext.hub.Messages = class Messages extends SubPage { make_wrapper() { @@ -115,4 +115,4 @@ function get_message_html(message) {

    ${message.content}

    `; -} \ No newline at end of file +} diff --git a/erpnext/public/js/hub/pages/not_found.js b/erpnext/public/js/hub/pages/not_found.js index 3b864464f3..f7ccc2f5b3 100644 --- a/erpnext/public/js/hub/pages/not_found.js +++ b/erpnext/public/js/hub/pages/not_found.js @@ -1,4 +1,5 @@ import SubPage from './subpage'; +import { get_empty_state } from '../components/empty_state'; erpnext.hub.NotFound = class NotFound extends SubPage { refresh() { diff --git a/erpnext/public/js/hub/pages/publish.js b/erpnext/public/js/hub/pages/publish.js index 859782edbf..a76f9467c6 100644 --- a/erpnext/public/js/hub/pages/publish.js +++ b/erpnext/public/js/hub/pages/publish.js @@ -1,5 +1,7 @@ import SubPage from './subpage'; -import { make_search_bar, get_item_card_container_html, get_local_item_card_html } from '../helpers'; +import { get_item_card_container_html } from '../components/items_container'; +import { get_local_item_card_html } from '../components/item_card'; +import { make_search_bar } from '../components/search_bar'; erpnext.hub.Publish = class Publish extends SubPage { make_wrapper() { diff --git a/erpnext/public/js/hub/pages/published_products.js b/erpnext/public/js/hub/pages/published_products.js index 1b19a51da7..f20fb27762 100644 --- a/erpnext/public/js/hub/pages/published_products.js +++ b/erpnext/public/js/hub/pages/published_products.js @@ -1,5 +1,5 @@ import SubPage from './subpage'; -import { get_item_card_container_html } from '../helpers'; +import { get_item_card_container_html } from '../components/items_container'; erpnext.hub.PublishedProducts = class PublishedProducts extends SubPage { get_items_and_render() { diff --git a/erpnext/public/js/hub/pages/register.js b/erpnext/public/js/hub/pages/register.js index b95ec04444..9b07f29a6b 100644 --- a/erpnext/public/js/hub/pages/register.js +++ b/erpnext/public/js/hub/pages/register.js @@ -82,29 +82,33 @@ erpnext.hub.Register = class Register extends SubPage { this.$form_container.find('.form-message').removeClass('hidden small').addClass('h4').text(__('Become a Seller')) this.$form_container.on('click', '.btn-register', (e) => { - const form_values = this.field_group.get_values(); + this.register_seller(); + }); + } - let values_filled = true; - const mandatory_fields = ['company', 'company_email', 'company_description']; - mandatory_fields.forEach(field => { - const value = form_values[field]; - if (!value) { - this.field_group.set_df_property(field, 'reqd', 1); - values_filled = false; - } - }); - if (!values_filled) return; + register_seller() { + const form_values = this.field_group.get_values(); - frappe.call({ - method: 'erpnext.hub_node.doctype.hub_settings.hub_settings.register_seller', - args: form_values, - btn: $(e.currentTarget) - }).then(() => { - frappe.set_route('marketplace', 'publish'); + let values_filled = true; + const mandatory_fields = ['company', 'company_email', 'company_description']; + mandatory_fields.forEach(field => { + const value = form_values[field]; + if (!value) { + this.field_group.set_df_property(field, 'reqd', 1); + values_filled = false; + } + }); + if (!values_filled) return; - // custom jquery event - this.$wrapper.trigger('seller-registered'); - }); + frappe.call({ + method: 'erpnext.hub_node.doctype.hub_settings.hub_settings.register_seller', + args: form_values, + btn: $(e.currentTarget) + }).then(() => { + frappe.set_route('marketplace', 'publish'); + + // custom jquery event + this.$wrapper.trigger('seller-registered'); }); } } diff --git a/erpnext/public/js/hub/pages/search.js b/erpnext/public/js/hub/pages/search.js index 33c2b78e20..f3dd6fb0c5 100644 --- a/erpnext/public/js/hub/pages/search.js +++ b/erpnext/public/js/hub/pages/search.js @@ -1,5 +1,6 @@ import SubPage from './subpage'; -import { make_search_bar, get_item_card_container_html } from '../helpers'; +import { make_search_bar } from '../components/search_bar'; +import { get_item_card_container_html } from '../components/items_container'; erpnext.hub.SearchPage = class SearchPage extends SubPage { make_wrapper() { diff --git a/erpnext/public/js/hub/pages/seller.js b/erpnext/public/js/hub/pages/seller.js index 27b39247ba..b86e46e544 100644 --- a/erpnext/public/js/hub/pages/seller.js +++ b/erpnext/public/js/hub/pages/seller.js @@ -1,5 +1,7 @@ import SubPage from './subpage'; -import { get_item_card_container_html } from '../helpers'; +import { get_profile_html } from '../components/detail_view'; +import { get_item_card_container_html } from '../components/items_container'; +import { get_detail_skeleton_html } from '../components/skeleton_state'; erpnext.hub.Seller = class Seller extends SubPage { make_wrapper() { @@ -18,64 +20,11 @@ erpnext.hub.Seller = class Seller extends SubPage { } show_skeleton() { - const skeleton = `
    -
    -
    -
    -
    -
    -

    Name

    -
    -

    Details

    -

    Ratings

    -
    -
    -
    -

    Desc

    -

    Desc

    -
    -
    -
    -
    `; - - this.$wrapper.html(skeleton); + this.$wrapper.html(get_detail_skeleton_html()); } render(data) { - const p = data.profile; - - const profile_html = `
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -

    ${p.company}

    -
    -

    ${p.country}

    -

    ${p.site_name}

    -

    ${__(`Joined ${comment_when(p.creation)}`)}

    -
    -
    -
    - ${'description' - ? `

    ${p.company_description}

    ` - : `

    __('No description') -

    -
    - -
    `; - - this.$wrapper.html(profile_html); + this.$wrapper.html(get_profile_html(data.profile)); let html = get_item_card_container_html(data.items, __('Products by ' + p.company)); this.$wrapper.append(html); diff --git a/erpnext/public/js/hub/pages/subpage.js b/erpnext/public/js/hub/pages/subpage.js index a030e7e33b..7c75b1379e 100644 --- a/erpnext/public/js/hub/pages/subpage.js +++ b/erpnext/public/js/hub/pages/subpage.js @@ -5,11 +5,11 @@ export default class SubPage { // generic action handler this.$wrapper.on('click', '[data-action]', e => { - const $this = $(e.currentTarget); - const action = $this.data().action; + const $target = $(e.currentTarget); + const action = $target.data().action; if (action && this[action]) { - this[action].apply(this); + this[action].apply(this, $target); } }) @@ -42,4 +42,4 @@ export default class SubPage { hide() { this.$wrapper.hide(); } -} \ No newline at end of file +} diff --git a/erpnext/public/less/hub.less b/erpnext/public/less/hub.less index d8ac9dd9c9..7ac168486a 100644 --- a/erpnext/public/less/hub.less +++ b/erpnext/public/less/hub.less @@ -25,15 +25,15 @@ body[data-route^="marketplace/"] { font-size: @text-medium; } - .btn-primary { - background-color: #89da28; - border-color: #61ca23; - } + // .btn-primary { + // background-color: #89da28; + // border-color: #61ca23; + // } - .btn-primary:hover { - background-color: #61ca23; - border-color: #59b81c; - } + // .btn-primary:hover { + // background-color: #61ca23; + // border-color: #59b81c; + // } .progress-bar { background-color: #89da28;