').appendTo(this.page.main.parent());
+ this.$footer = $(footerHtml).appendTo(parent);
+ }
+
+ attachTimeline() {
+ let timelineHtml = `
+
+
+
+
+ ${ __("Reply") }
+
+
+
+
`;
+
+ let parent = this.$footer.find(".form-comments");
+ this.$timeline = $(timelineHtml).appendTo(parent);
+
+ this.$timelineList = this.$timeline.find(".timeline-items");
+ }
+
+ attachReviewArea() {
+ this.comment_area = new frappe.ui.ReviewArea({
+ parent: this.$footer.find('.timeline-head'),
+ mentions: [],
+ on_submit: (val) => {
+ val.user = frappe.session.user;
+ val.username = frappe.session.user_fullname;
+ frappe.call({
+ method: 'erpnext.hub_node.send_review',
+ args: {
+ hub_item_code: this.data.hub_item_code,
+ review: val
+ },
+ callback: (r) => {
+ this.refresh();
+ this.comment_area.reset();
+ },
+ freeze: true
+ });
+ }
+ });
+ }
+
+ addReviewToTimeline(data) {
+ let username = data.username || data.user || __("Anonymous")
+ let imageHtml = data.user_image
+ ? `
`
+ : `
${frappe.get_abbr(username)}
`
+
+ let editHtml = data.own
+ ? `
+
+ ${'data.delete'}
+
+
+
+
+ ${'data.edit'}
+
+
`
+ : '';
+
+ let ratingHtml = '';
+
+ for(var i = 0; i < 5; i++) {
+ let starIcon = 'fa-star-o'
+ if(i < data.rating) {
+ starIcon = 'fa-star';
+ }
+ ratingHtml += `
`;
+ }
+
+ $(this.getTimelineItem(data, imageHtml, editHtml, ratingHtml))
+ .appendTo(this.$timelineList);
+ }
+
+ getTimelineItem(data, imageHtml, editHtml, ratingHtml) {
+ return `
+
+ ${imageHtml}
+
+
+
+
+
${editHtml}
+
+
+
+
+
+ ${data.subject}
+
+
+
+
+
+ ${ratingHtml}
+
+
+
+
+ ${data.content}
+
+
+
+
+
+
`;
+ }
+
+ prepareFormFields(fields, fieldnames) {
+ return fields
+ .filter(field => fieldnames.includes(field.fieldname))
+ .map(field => {
+ let {
+ label,
+ fieldname,
+ fieldtype,
+ } = field;
+ let read_only = 1;
+ return {
+ label,
+ fieldname,
+ fieldtype,
+ read_only,
+ };
+ });
}
};
-erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubForm{
+erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubDetailsPage {
+ constructor(opts) {
+ super(opts);
+
+ this.show();
+ }
+
setup_defaults() {
super.setup_defaults();
this.doctype = 'Item';
this.image_field_name = 'image';
}
- get_field_configs() {
- let fields = [];
- this.fields.map(fieldname => {
- fields.push({
- label: toTitle(frappe.model.unscrub(fieldname)),
- fieldname,
+ postRender() {
+ this.categoryDialog = new frappe.ui.Dialog({
+ title: __('Suggest Category'),
+ fields: [
+ {
+ label: __('Category'),
+ fieldname: 'category',
+ fieldtype: 'Autocomplete',
+ options: this.categories,
+ reqd: 1
+ }
+ ],
+ primary_action_label: __("Send"),
+ primary_action: () => {
+ let values = this.categoryDialog.get_values();
+ frappe.call({
+ method: 'erpnext.hub_node.update_category',
+ args: {
+ hub_item_code: this.data.hub_item_code,
+ category: values.category
+ },
+ callback: () => {
+ this.refresh();
+ },
+ freeze: true
+ }).fail(() => {});
+ }
+ });
+ }
+
+ getFormFields() {
+ let colOneFieldnames = ['item_name', 'item_code', 'description'];
+ let colTwoFieldnames = ['seller', 'company_name', 'country'];
+ let colOneFields = this.prepareFormFields(this.meta.fields, colOneFieldnames);
+ let colTwoFields = this.prepareFormFields(this.meta.fields, colTwoFieldnames);
+
+ let miscFields = [
+ {
+ label: __('Category'),
+ fieldname: 'hub_category',
fieldtype: 'Data',
read_only: 1
- });
- });
+ },
- let category_field = {
- label: 'Hub Category',
- fieldname: 'hub_category',
- fieldtype: 'Data'
- }
+ {
+ label: __('Suggest Category?'),
+ fieldname: 'set_category',
+ fieldtype: 'Button',
+ click: () => {
+ this.categoryDialog.show();
+ }
+ },
- if(this.data.company_name === this.hub_settings.company) {
- this.page.set_primary_action(__('Update'), () => {
- this.update_on_hub();
- }, 'octicon octicon-plus');
- } else {
- category_field.read_only = 1;
- }
-
- fields.unshift(category_field);
-
- return fields;
- }
-
- update_on_hub() {
- return new Promise((resolve, reject) => {
- frappe.call({
- method: 'erpnext.hub_node.update_category',
- args: { item: this.unique_id, category: this.form.get_value('hub_category') },
- callback: resolve,
- freeze: true
- }).fail(reject);
- });
- }
-
- setup_fields() {
- this.fields = ['hub_item_code', 'item_name', 'item_code', 'description',
- 'seller', 'company_name', 'country'];
+ {
+ fieldname: 'cb1',
+ fieldtype: 'Column Break'
+ }
+ ];
+ this.formFields = colOneFields.concat(miscFields, colTwoFields);
}
}
-erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubForm{
+erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubDetailsPage {
+ constructor(opts) {
+ super(opts);
+
+ this.show();
+ }
+
setup_defaults() {
super.setup_defaults();
this.doctype = 'Company';
this.image_field_name = 'company_logo';
}
- get_field_configs() {
- let fields = [];
- this.fields.map(fieldname => {
- fields.push({
- label: toTitle(frappe.model.unscrub(fieldname)),
- fieldname,
- fieldtype: 'Data',
- read_only: 1
- });
- });
-
- return fields;
- }
-
- setup_fields() {
- this.fields = ['company_name', 'description', 'route', 'country', 'seller', 'site_name'];
+ getFormFields() {
+ let fieldnames = ['company_name', 'description', 'route', 'country', 'seller', 'site_name'];;
+ this.formFields = this.prepareFormFields(this.meta.fields, fieldnames);
}
}
diff --git a/erpnext/public/js/hub/hub_listing.js b/erpnext/public/js/hub/hub_listing.js
new file mode 100644
index 0000000000..9e19f73835
--- /dev/null
+++ b/erpnext/public/js/hub/hub_listing.js
@@ -0,0 +1,665 @@
+frappe.provide('erpnext.hub');
+
+erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList {
+ setup_defaults() {
+ super.setup_defaults();
+ this.page_title = __('');
+ this.method = 'erpnext.hub_node.get_list';
+
+ this.cache = {};
+
+ const route = frappe.get_route();
+ this.page_name = route[1];
+
+ this.menu_items = this.menu_items.concat(this.get_menu_items());
+
+ this.imageFieldName = 'image';
+
+ this.show_filters = 0;
+ }
+
+ set_title() {
+ const title = this.page_title;
+ let iconHtml = `
`;
+ let titleHtml = `
${title} `;
+ this.page.set_title(iconHtml + titleHtml, '', false, title);
+ }
+
+ setup_fields() {
+ return this.get_meta()
+ .then(r => {
+ this.meta = r.message.meta || this.meta;
+ frappe.model.sync(this.meta);
+ this.bootstrap_data(r.message);
+
+ this.prepareFormFields();
+ });
+ }
+
+ get_meta() {
+ return new Promise(resolve =>
+ frappe.call('erpnext.hub_node.get_meta', {doctype: this.doctype}, resolve));
+ }
+
+ set_breadcrumbs() { }
+
+ prepareFormFields() { }
+
+ bootstrap_data() { }
+
+ get_menu_items() {
+ const items = [
+ {
+ label: __('Hub Settings'),
+ action: () => frappe.set_route('Form', 'Hub Settings'),
+ standard: true
+ },
+ {
+ label: __('Favourites'),
+ action: () => frappe.set_route('Hub', 'Favourites'),
+ standard: true
+ },
+ // {
+ // label: __('Toggle Sidebar'),
+ // action: () => this.toggle_side_bar(),
+ // standard: true
+ // }
+ ];
+
+ return items;
+ }
+
+ setup_side_bar() {
+ this.sidebar = new frappe.ui.Sidebar({
+ wrapper: this.page.wrapper.find('.layout-side-section'),
+ css_class: 'hub-sidebar'
+ });
+ }
+
+ setup_sort_selector() {
+ this.sort_selector = new frappe.ui.SortSelector({
+ parent: this.filter_area.$filter_list_wrapper,
+ doctype: this.doctype,
+ args: this.order_by,
+ onchange: () => this.refresh(true)
+ });
+ }
+
+ setup_view() { }
+
+ get_args() {
+ return {
+ doctype: this.doctype,
+ start: this.start,
+ limit: this.page_length,
+ order_by: this.order_by,
+ // fields: this.fields,
+ filters: this.get_filters_for_args()
+ };
+ }
+
+ update_data(r) {
+ const data = r.message;
+
+ if (this.start === 0) {
+ this.data = data;
+ } else {
+ this.data = this.data.concat(data);
+ }
+
+ this.data_dict = {};
+ }
+
+ freeze(toggle) {
+ // if(!this.$freeze) return;
+ // this.$freeze.toggle(toggle);
+ // if (this.$freeze.find('.image-view-container').length) return;
+
+ // const html = Array.from(new Array(4)).map(d => this.card_html({
+ // name: 'Loading...',
+ // item_name: 'Loading...'
+ // })).join('');
+
+ // this.$freeze.html(`
${html}
`);
+ }
+
+ render() {
+ this.data_dict = {};
+ this.render_image_view();
+
+ this.setup_quick_view();
+ this.setup_like();
+ }
+
+ render_offline_card() {
+ let html = `
+
+
+ {{ _("Payment Cancelled") }}
+
+
${ __("Your payment is cancelled.") }
+
+
`;
+
+ let page = this.page.wrapper.find('.layout-side-section')
+ page.append(html);
+
+ return;
+ }
+
+ render_image_view() {
+ var html = this.data.map(this.item_html.bind(this)).join("");
+
+ if (this.start === 0) {
+ // this.renderHeader();
+ this.$result.html(`
+ ${this.getHeaderHtml()}
+
+ ${html}
+
+ `);
+ }
+
+ if(this.data.length) {
+ this.doc = this.data[0];
+ }
+
+ this.data.map(this.loadImage.bind(this));
+
+ this.data_dict = {};
+ this.data.map(d => {
+ this.data_dict[d.hub_item_code] = d;
+ });
+ }
+
+ getHeaderHtml() {
+ // let company_html =
+ return `
+
+ `;
+ }
+
+ renderHeader() {
+ return `
`;
+ }
+
+ get_image_html(encoded_name, src, alt_text) {
+ return `
`;
+ }
+
+ get_image_placeholder(title) {
+ return `
${ frappe.get_abbr(title) } `;
+ }
+
+ loadImage(item) {
+ item._name = encodeURI(item.name);
+ const encoded_name = item._name;
+ const title = strip_html(item[this.meta.title_field || 'name']);
+
+ let placeholder = this.get_image_placeholder(title);
+ let $container = this.$result.find(`.image-field[data-name="${encoded_name}"]`);
+
+ if(!item[this.imageFieldName]) {
+ $container.prepend(placeholder);
+ $container.addClass('no-image');
+ }
+
+ frappe.load_image(item[this.imageFieldName],
+ (imageObj) => {
+ $container.prepend(imageObj)
+ },
+ () => {
+ $container.prepend(placeholder);
+ $container.addClass('no-image');
+ },
+ (imageObj) => {
+ imageObj.title = encoded_name;
+ imageObj.alt = title;
+ }
+ )
+ }
+
+ item_html(item) {
+ item._name = encodeURI(item.name);
+ const encoded_name = item._name;
+ const title = strip_html(item[this.meta.title_field || 'name']);
+ const _class = !item[this.imageFieldName] ? 'no-image' : '';
+ const route = `#Hub/Item/${item.hub_item_code}`;
+ const company_name = item['company_name'];
+
+ const reviewLength = (item.reviews || []).length;
+ const ratingAverage = reviewLength
+ ? item.reviews
+ .map(r => r.rating)
+ .reduce((a, b) => (a + b, 0))/reviewLength
+ : -1;
+
+ let ratingHtml = ``;
+
+ for(var i = 0; i < 5; i++) {
+ let starClass = 'fa-star';
+ if(i >= ratingAverage) starClass = 'fa-star-o';
+ ratingHtml += `
`;
+ }
+
+ let item_html = `
+
+ `;
+
+ return item_html;
+ }
+
+ setup_quick_view() {
+ if(this.quick_view) return;
+
+ this.quick_view = new frappe.ui.Dialog({
+ title: 'Quick View',
+ fields: this.formFields
+ });
+ this.$result.on('click', '.btn.zoom-view', (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ var name = $(e.target).attr('data-name');
+ name = decodeURIComponent(name);
+
+ this.quick_view.set_title(name);
+ let values = this.data_dict[name];
+ this.quick_view.set_values(values);
+
+ let fields = [];
+
+ this.quick_view.show();
+
+ return false;
+ });
+ }
+
+ setup_like() {
+ if(this.setup_like_done) return;
+ this.setup_like_done = 1;
+ this.$result.on('click', '.btn.like-button', (e) => {
+ if($(e.target).hasClass('changing')) return;
+ $(e.target).addClass('changing');
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ var name = $(e.target).attr('data-name');
+ name = decodeURIComponent(name);
+ let values = this.data_dict[name];
+
+ let heart = $(e.target);
+ if(heart.hasClass('like-button')) {
+ heart = $(e.target).find('.octicon');
+ }
+
+ let remove = 1;
+
+ if(heart.hasClass('liked')) {
+ // unlike
+ heart.removeClass('liked');
+ } else {
+ // like
+ remove = 0;
+ heart.addClass('liked');
+ }
+
+ frappe.call({
+ method: 'erpnext.hub_node.update_wishlist_item',
+ args: {
+ item_name: values.hub_item_code,
+ remove: remove
+ },
+ callback: (r) => {
+ let message = __("Added to Favourites");
+ if(remove) {
+ message = __("Removed from Favourites");
+ }
+ frappe.show_alert(message);
+ },
+ freeze: true
+ });
+
+ $(e.target).removeClass('changing');
+ return false;
+ });
+ }
+}
+
+erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
+ constructor(opts) {
+ super(opts);
+ this.show();
+ }
+
+ setup_defaults() {
+ super.setup_defaults();
+ this.doctype = 'Hub Item';
+ this.page_title = __('Products');
+ this.fields = ['name', 'hub_item_code', 'image', 'item_name', 'item_code', 'company_name', 'description', 'country'];
+ this.filters = [];
+ }
+
+ bootstrap_data(response) {
+ let companies = response.companies.map(d => d.name);
+ this.custom_filter_configs = [
+ {
+ fieldtype: 'Autocomplete',
+ label: __('Select Company'),
+ condition: 'like',
+ fieldname: 'company_name',
+ options: companies
+ },
+ {
+ fieldtype: 'Link',
+ label: __('Select Country'),
+ options: 'Country',
+ condition: 'like',
+ fieldname: 'country'
+ }
+ ];
+ }
+
+ prepareFormFields() {
+ let fieldnames = ['item_name', 'description', 'company_name', 'country'];
+ this.formFields = this.meta.fields
+ .filter(field => fieldnames.includes(field.fieldname))
+ .map(field => {
+ let {
+ label,
+ fieldname,
+ fieldtype,
+ } = field;
+ let read_only = 1;
+ return {
+ label,
+ fieldname,
+ fieldtype,
+ read_only,
+ };
+ });
+
+ this.formFields.unshift({
+ label: 'image',
+ fieldname: 'image',
+ fieldtype: 'Attach Image'
+ });
+ }
+
+ setup_side_bar() {
+ super.setup_side_bar();
+
+ let $pitch = $(`
+
Sell on HubMarket
+
Over 2000 products listed. Register your company to start selling.
+
`);
+
+ this.sidebar.$sidebar.append($pitch);
+
+ this.category_tree = new frappe.ui.Tree({
+ parent: this.sidebar.$sidebar,
+ label: 'All Categories',
+ expandable: true,
+
+ args: {parent: this.current_category},
+ method: 'erpnext.hub_node.get_categories',
+ on_click: (node) => {
+ this.update_category(node.label);
+ }
+ });
+
+ this.sidebar.add_item({
+ label: __('Companies'),
+ on_click: () => frappe.set_route('Hub', 'Company')
+ }, undefined, true);
+
+ this.sidebar.add_item({
+ label: this.hub_settings.company,
+ on_click: () => frappe.set_route('Form', 'Company', this.hub_settings.company)
+ }, __("Account"));
+
+ this.sidebar.add_item({
+ label: __("Favourites"),
+ on_click: () => frappe.set_route('Hub', 'Favourites')
+ }, __("Account"));
+ }
+
+ update_category(label) {
+ this.current_category = (label=='All Categories') ? undefined : label;
+ this.refresh();
+ }
+
+ get_filters_for_args() {
+ if(!this.filter_area) return;
+ let filters = {};
+ this.filter_area.get().forEach(f => {
+ let field = f[1] !== 'name' ? f[1] : 'item_name';
+ filters[field] = [f[2], f[3]];
+ });
+ if(this.current_category) {
+ filters['hub_category'] = this.current_category;
+ }
+ return filters;
+ }
+
+ update_data(r) {
+ super.update_data(r);
+
+ this.data_dict = {};
+ this.data.map(d => {
+ this.data_dict[d.hub_item_code] = d;
+ });
+ }
+};
+
+erpnext.hub.Favourites = class Favourites extends erpnext.hub.ItemListing {
+ constructor(opts) {
+ super(opts);
+ this.show();
+ }
+
+ setup_defaults() {
+ super.setup_defaults();
+ this.doctype = 'Hub Item';
+ this.page_title = __('Favourites');
+ this.fields = ['name', 'hub_item_code', 'image', 'item_name', 'item_code', 'company_name', 'description', 'country'];
+ this.filters = [];
+ this.method = 'erpnext.hub_node.get_item_favourites';
+ }
+
+ setup_filter_area() { }
+
+ setup_sort_selector() { }
+
+ // setupHe
+
+ getHeaderHtml() {
+ return '';
+ }
+
+ get_args() {
+ return {
+ start: this.start,
+ limit: this.page_length,
+ order_by: this.order_by,
+ fields: this.fields
+ };
+ }
+
+ bootstrap_data(response) { }
+
+ prepareFormFields() { }
+
+ setup_side_bar() {
+ this.sidebar = new frappe.ui.Sidebar({
+ wrapper: this.page.wrapper.find('.layout-side-section'),
+ css_class: 'hub-sidebar'
+ });
+
+ this.sidebar.add_item({
+ label: __('Back to Products'),
+ on_click: () => frappe.set_route('Hub', 'Item')
+ });
+
+ // this.sidebar.add_item({
+ // label: this.hub_settings.company,
+ // on_click: () => frappe.set_route('Form', 'Company', this.hub_settings.company)
+ // }, __("Account"));
+
+ // this.sidebar.add_item({
+ // label: __("My Orders"),
+ // on_click: () => frappe.set_route('List', 'Request for Quotation')
+ // }, __("Account"));
+ }
+
+ update_category(label) {
+ this.current_category = (label=='All Categories') ? undefined : label;
+ this.refresh();
+ }
+
+ get_filters_for_args() {
+ if(!this.filter_area) return;
+ let filters = {};
+ this.filter_area.get().forEach(f => {
+ let field = f[1] !== 'name' ? f[1] : 'item_name';
+ filters[field] = [f[2], f[3]];
+ });
+ if(this.current_category) {
+ filters['hub_category'] = this.current_category;
+ }
+ return filters;
+ }
+
+ update_data(r) {
+ super.update_data(r);
+
+ this.data_dict = {};
+ this.data.map(d => {
+ this.data_dict[d.hub_item_code] = d;
+ });
+ }
+};
+
+erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing {
+ constructor(opts) {
+ super(opts);
+ this.show();
+ }
+
+ setup_defaults() {
+ super.setup_defaults();
+ this.doctype = 'Hub Company';
+ this.page_title = __('Companies');
+ this.fields = ['company_logo', 'name', 'site_name', 'seller_city', 'seller_description', 'seller', 'country', 'company_name'];
+ this.filters = [];
+ this.custom_filter_configs = [
+ {
+ fieldtype: 'Link',
+ label: 'Country',
+ options: 'Country',
+ condition: 'like',
+ fieldname: 'country'
+ }
+ ];
+ this.imageFieldName = 'company_logo';
+ }
+
+ get_filters_for_args() {
+ let filters = {};
+ this.filter_area.get().forEach(f => {
+ let field = f[1] !== 'name' ? f[1] : 'company_name';
+ filters[field] = [f[2], f[3]];
+ });
+ return filters;
+ }
+
+ card_html(company) {
+ company._name = encodeURI(company.name);
+ const route = `#Hub/Company/${company.company_name}`;
+
+ let image_html = company.company_logo ?
+ `
` :
+ `
${frappe.get_abbr(company.company_name)}
`;
+
+ return `
+
+ `;
+ }
+};
\ No newline at end of file
diff --git a/erpnext/public/js/hub/hub_page.js b/erpnext/public/js/hub/hub_page.js
deleted file mode 100644
index 27986de563..0000000000
--- a/erpnext/public/js/hub/hub_page.js
+++ /dev/null
@@ -1,244 +0,0 @@
-frappe.provide('erpnext.hub');
-
-erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList {
- setup_defaults() {
- super.setup_defaults();
- this.page_title = __('Hub');
- this.method = 'erpnext.hub_node.get_list';
-
- const route = frappe.get_route();
- this.page_name = route[1];
- }
-
- setup_fields() {
- return this.get_meta()
- .then(r => {
- this.meta = r.message || this.meta;
- frappe.model.sync(this.meta);
- });
- }
-
- get_meta() {
- return new Promise(resolve =>
- frappe.call('erpnext.hub_node.get_meta', {doctype: this.doctype}, resolve));
- }
-
- set_breadcrumbs() { }
-
- setup_side_bar() {
- this.sidebar = new frappe.ui.Sidebar({
- wrapper: this.page.wrapper.find('.layout-side-section'),
- css_class: 'hub-sidebar'
- });
- }
-
- setup_sort_selector() { }
-
- setup_view() { }
-
- get_args() {
- return {
- doctype: this.doctype,
- start: this.start,
- limit: this.page_length,
- order_by: this.order_by,
- fields: this.fields,
- filters: this.get_filters_for_args()
- };
- }
-
- update_data(r) {
- const data = r.message;
-
- if (this.start === 0) {
- this.data = data;
- } else {
- this.data = this.data.concat(data);
- }
-
- }
-
- freeze(toggle) {
- this.$freeze.toggle(toggle);
- if (this.$freeze.find('.image-view-container').length) return;
-
- const html = Array.from(new Array(4)).map(d => this.card_html({
- name: 'Loading...',
- item_name: 'Loading...'
- })).join('');
-
- this.$freeze.html(`
${html}
`);
- }
-
- render() {
- this.render_image_view();
- }
-
- render_image_view() {
- let data = this.data;
- if (this.start === 0) {
- this.$result.html('
');
- data = this.data.slice(this.start);
- }
-
- var html = data.map(this.card_html.bind(this)).join("");
- this.$result.find('.image-view-container').append(html);
- }
-}
-
-erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
- setup_defaults() {
- super.setup_defaults();
- this.doctype = 'Hub Item';
- this.fields = ['name', 'hub_item_code', 'image', 'item_name', 'item_code', 'company_name'];
- this.filters = [];
- this.custom_filter_configs = [
- {
- fieldtype: 'Data',
- label: 'Company',
- condition: 'like',
- fieldname: 'company_name',
- },
- {
- fieldtype: 'Link',
- label: 'Country',
- options: 'Country',
- condition: 'like',
- fieldname: 'country'
- }
- ];
- }
-
- setup_side_bar() {
- super.setup_side_bar();
- this.category_tree = new frappe.ui.Tree({
- parent: this.sidebar.$sidebar,
- label: 'All Categories',
- expandable: true,
-
- args: {parent: this.current_category},
- method: 'erpnext.hub_node.get_categories',
- on_click: (node) => {
- this.update_category(node.label);
- }
- });
-
- this.sidebar.add_item({
- label: __('Companies'),
- on_click: () => frappe.set_route('Hub', 'Company')
- });
-
- this.sidebar.add_item({
- label: this.hub_settings.company,
- on_click: () => frappe.set_route('Form', 'Company', this.hub_settings.company)
- }, __("Account"));
-
- this.sidebar.add_item({
- label: __("My Orders"),
- on_click: () => frappe.set_route('List', 'Request for Quotation')
- }, __("Account"));
- }
-
- update_category(label) {
- this.current_category = (label=='All Categories') ? undefined : label;
- this.refresh();
- }
-
- get_filters_for_args() {
- let filters = {};
- this.filter_area.get().forEach(f => {
- let field = f[1] !== 'name' ? f[1] : 'item_name';
- filters[field] = [f[2], f[3]];
- });
- if(this.current_category) {
- filters['hub_category'] = this.current_category;
- }
- return filters;
- }
-
- card_html(item) {
- item._name = encodeURI(item.name);
- const encoded_name = item._name;
- const title = strip_html(item['item_name' || 'item_code']);
- const company_name = item['company_name'];
-
- const route = `#Hub/Item/${item.hub_item_code}`;
-
- const image_html = item.image ?
- `
-
` :
- `
${frappe.get_abbr(title)}
`;
-
- return `
-
- `;
- }
-};
-
-erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing {
- setup_defaults() {
- super.setup_defaults();
- this.doctype = 'Hub Company';
- this.fields = ['company_logo', 'name', 'site_name', 'seller_city', 'seller_description', 'seller', 'country', 'company_name'];
- this.filters = [];
- this.custom_filter_configs = [
- {
- fieldtype: 'Link',
- label: 'Country',
- options: 'Country',
- condition: 'like',
- fieldname: 'country'
- }
- ];
- }
-
- get_filters_for_args() {
- let filters = {};
- this.filter_area.get().forEach(f => {
- let field = f[1] !== 'name' ? f[1] : 'company_name';
- filters[field] = [f[2], f[3]];
- });
- return filters;
- }
-
- card_html(company) {
- company._name = encodeURI(company.name);
- const route = `#Hub/Company/${company.company_name}`;
-
- let image_html = company.company_logo ?
- `
` :
- `
${frappe.get_abbr(company.company_name)}
`;
-
- return `
-
- `;
- }
-};
\ No newline at end of file
diff --git a/erpnext/public/less/hub.less b/erpnext/public/less/hub.less
index 66199a47bc..f202fa4345 100644
--- a/erpnext/public/less/hub.less
+++ b/erpnext/public/less/hub.less
@@ -1,176 +1,109 @@
@import "../../../../frappe/frappe/public/less/variables.less";
body[data-route^="Hub/"] {
- .freeze .image-view-container {
- .list-row-col {
- background-color: @light-bg;
- color: @light-bg;
- }
-
- .placeholder-text {
- color: @light-bg;
- }
+ .hub-icon {
+ width: 40px;
}
- .freeze {
- display: none;
- }
-
- .image-view-container {
- justify-content: space-around;
- }
-}
-
-.img-wrapper {
- border: 1px solid #d1d8dd;
- border-radius: 3px;
- padding: 12px;
- overflow: hidden;
- text-align: center;
- white-space: nowrap;
-
- .helper {
- height: 100%;
- display: inline-block;
- vertical-align: middle;
- }
-}
-
-/* hub */
-div[data-page-route="hub"] {
- .page-head {
- height: 80px;
-
- .title-text {
- cursor: pointer;
- }
- }
-
- .page-content {
- margin-top: 80px;
- }
-
- .page-title h1 {
- margin-bottom: 0px;
- }
-
- .account-details {
- margin-top: 20px;
- }
-
- [data-original-title="Search"] {
- float: right;
- width: 220px;
- }
-
- .hub-main-section {
- padding: 30px;
- }
-
- .listing-body {
- margin: 0;
- }
-
- .main-list-section {
- padding: 0;
- // border-right: 1px solid #d1d8dd;
- }
-
- .side-list-section {
- padding: 0;
- }
-
- .item-list-header h3 {
- font-weight: normal;
- }
-
- .hub-item-page {
-
- h2 {
- margin-top: 10px;
- }
-
- .item-header {
- display: flex;
- }
-
- .item-page-image {
- flex: 1;
- }
-
- .title-content {
- flex: 3;
-
- .description {
- margin: 30px 0px;
- }
-
- .actions {
- margin-top: 30px;
-
- .rfq-btn.disabled {
- background-color: #b1bdca;
- color: #fff;
- border-color: #b1bdca;
- }
- }
- }
-
- .company-items {
- margin-top: 40px;
- }
- }
-
- .company-header {
- display: flex;
- }
-
- .item-list {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- }
-
- .hub-item-wrapper {
- margin-bottom: 20px;
+ .hub-page-title {
+ margin-left: 10px;
}
.img-wrapper {
- border: 1px solid @border-color;
+ border: 1px solid #d1d8dd;
border-radius: 3px;
padding: 12px;
overflow: hidden;
text-align: center;
white-space: nowrap;
- img {
- max-width: 100%;
- max-height: 100%;
- display: inline-block;
- vertical-align: middle;
- }
-
.helper {
height: 100%;
display: inline-block;
vertical-align: middle;
}
+ }
- .standard-image {
- font-size: 72px;
- border: none;
- background-color: @light-bg;
+ .tree {
+ margin: 10px 0px;
+ padding: 0px;
+ height: 100%;
+ position: relative;
+ }
+
+ .tree.with-skeleton.opened::before {
+ left: 9px;
+ top: 14px;
+ height: calc(~"100% - 32px");
+ }
+
+ .list-header-icon {
+ width: 72px;
+ border-radius: 4px;
+ flex-shrink: 0;
+ margin: 10px;
+ padding: 1px;
+ border: 1px solid @border-color;
+ height: 72px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
+ img {
+ border-radius: 4px;
}
}
- .hub-item-title {
- width: 100%;
+ .star-icon.fa-star {
+ color: @indicator-orange;
}
- .breadcrumb {
- padding-left: 0;
- padding-top: 0;
- margin-bottom: 10px;
+ .octicon-heart.liked {
+ color: @indicator-red;
}
-}
\ No newline at end of file
+ .margin-vertical-10 {
+ margin: 10px 0px;
+ }
+
+ .margin-vertical-15 {
+ margin: 15px 0px;
+ }
+
+ .frappe-list .result {
+ min-height: 100px;
+ }
+}
+
+.image-view-container {
+ .image-view-body {
+ &:hover .like-button {
+ opacity: 0.7;
+ }
+ }
+
+ .like-button {
+ bottom: 10px !important;
+ left: 10px !important;
+ width: 36px;
+ height: 36px;
+ opacity: 0;
+ font-size: 16px;
+ color: @text-color;
+ position: absolute;
+
+ // show zoom button on mobile devices
+ @media (max-width: @screen-xs) {
+ opacity: 0.5
+ }
+ }
+
+ .image-view-body:hover .like-button {
+ opacity: 0.7;
+ }
+}
+
+.rating-area .star-icon {
+ cursor: pointer;
+ font-size: 15px;
+}
diff --git a/erpnext/utilities/user_progress.py b/erpnext/utilities/user_progress.py
index 9f5935e3cb..ae156b83d3 100644
--- a/erpnext/utilities/user_progress.py
+++ b/erpnext/utilities/user_progress.py
@@ -13,7 +13,7 @@ def get_slide_settings():
doc = frappe.get_doc("Setup Progress")
item = [d for d in doc.get("actions") if d.action_name == "Set Sales Target"]
-
+
if len(item):
item = item[0]
if not item.action_document: