style: change formatting

This commit is contained in:
Mangesh-Khairnar
2019-12-09 15:44:31 +05:30
parent 6d4f4bef7e
commit d249d4c947
2 changed files with 106 additions and 105 deletions

View File

@@ -3,24 +3,24 @@ function ItemPublishDialog(primary_action, secondary_action) {
title: __('Edit Publishing Details'), title: __('Edit Publishing Details'),
fields: [ fields: [
{ {
"label": "Item Code", label: __('Item Code'),
"fieldname": "item_code", fieldname: 'item_code',
"fieldtype": "Data", fieldtype: 'Data',
"read_only": 1 read_only: 1
}, },
{ {
"label": "Hub Category", label: __('Hub Category'),
"fieldname": "hub_category", fieldname: 'hub_category',
"fieldtype": "Autocomplete", fieldtype: 'Autocomplete',
"options": [], options: [],
"reqd": 1 reqd: 1
}, },
{ {
"label": "Images", label: __('Images'),
"fieldname": "image_list", fieldname: 'image_list',
"fieldtype": "MultiSelect", fieldtype: 'MultiSelect',
"options": [], options: [],
"reqd": 1 reqd: 1
} }
], ],
primary_action_label: primary_action.label || __('Set Details'), primary_action_label: primary_action.label || __('Set Details'),
@@ -28,16 +28,12 @@ function ItemPublishDialog(primary_action, secondary_action) {
secondary_action: secondary_action.fn secondary_action: secondary_action.fn
}); });
hub.call('get_categories') hub.call('get_categories').then(categories => {
.then(categories => { categories = categories.map(d => d.name);
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; return dialog;
} }
export { export { ItemPublishDialog };
ItemPublishDialog
}

View File

@@ -1,10 +1,5 @@
<template> <template>
<div <div class="marketplace-page" :data-page-name="page_name" v-if="init || item">
class="marketplace-page"
:data-page-name="page_name"
v-if="init || item"
>
<detail-view <detail-view
:title="title" :title="title"
:image="image" :image="image"
@@ -12,20 +7,15 @@
:menu_items="menu_items" :menu_items="menu_items"
:show_skeleton="init" :show_skeleton="init"
> >
<detail-header-item slot="detail-header-item" <detail-header-item slot="detail-header-item" :value="item_subtitle"></detail-header-item>
:value="item_subtitle" <detail-header-item slot="detail-header-item" :value="item_views_and_ratings"></detail-header-item>
></detail-header-item>
<detail-header-item slot="detail-header-item"
:value="item_views_and_ratings"
></detail-header-item>
<button v-if="primary_action" slot="detail-header-item" <button
v-if="primary_action"
slot="detail-header-item"
class="btn btn-primary btn-sm margin-top" class="btn btn-primary btn-sm margin-top"
@click="primary_action.action" @click="primary_action.action"
> >{{ primary_action.label }}</button>
{{ primary_action.label }}
</button>
</detail-view> </detail-view>
<review-area v-if="!init" :hub_item_name="hub_item_name"></review-area> <review-area v-if="!init" :hub_item_name="hub_item_name"></review-area>
@@ -51,21 +41,20 @@ export default {
item: null, item: null,
title: null, title: null,
image: null, image: null,
sections: [], sections: []
}; };
}, },
computed: { computed: {
is_own_item() { is_own_item() {
let is_own_item = false; let is_own_item = false;
if(this.item) { if (this.item) {
if(this.item.hub_seller === hub.settings.hub_seller_name) { if (this.item.hub_seller === hub.settings.hub_seller_name) {
is_own_item = true; is_own_item = true;
} }
} }
return is_own_item; return is_own_item;
}, },
menu_items(){ menu_items() {
return [ return [
{ {
label: __('Save Item'), label: __('Save Item'),
@@ -92,11 +81,11 @@ export default {
condition: hub.is_user_registered() && this.is_own_item, condition: hub.is_user_registered() && this.is_own_item,
action: this.unpublish_item action: this.unpublish_item
} }
] ];
}, },
item_subtitle() { item_subtitle() {
if(!this.item) { if (!this.item) {
return ''; return '';
} }
@@ -105,25 +94,31 @@ export default {
const rating = this.item.average_rating; const rating = this.item.average_rating;
if (rating > 0) { if (rating > 0) {
subtitle_items.push(rating + `<i class='fa fa-fw fa-star-o'></i>`) subtitle_items.push(rating + `<i class='fa fa-fw fa-star-o'></i>`);
} }
subtitle_items.push({value:this.item.company,on_click:this.go_to_seller_profile_page}); subtitle_items.push({
value: this.item.company,
on_click: this.go_to_seller_profile_page
});
return subtitle_items; return subtitle_items;
}, },
item_views_and_ratings() { item_views_and_ratings() {
if(!this.item) { if (!this.item) {
return ''; return '';
} }
let stats = __('No views yet'); let stats = __('No views yet');
if(this.item.view_count) { if (this.item.view_count) {
const views_message = __(`${this.item.view_count} Views`); const views_message = __(`${this.item.view_count} Views`);
const rating_html = get_rating_html(this.item.average_rating); const rating_html = get_rating_html(this.item.average_rating);
const rating_count = this.item.no_of_ratings > 0 ? `${this.item.no_of_ratings} reviews` : __('No reviews yet'); const rating_count =
this.item.no_of_ratings > 0
? `${this.item.no_of_ratings} reviews`
: __('No reviews yet');
stats = [views_message, rating_html, rating_count]; stats = [views_message, rating_html, rating_count];
} }
@@ -136,7 +131,7 @@ export default {
return { return {
label: __('Contact Seller'), label: __('Contact Seller'),
action: this.contact_seller.bind(this) action: this.contact_seller.bind(this)
} };
} else { } else {
return undefined; return undefined;
} }
@@ -156,7 +151,7 @@ export default {
setTimeout(() => { setTimeout(() => {
hub.call('add_item_view', { hub.call('add_item_view', {
hub_item_name: this.hub_item_name hub_item_name: this.hub_item_name
}) });
// .then(() => { // .then(() => {
// erpnext.hub.item_view_cache.push(this.hub_item_name); // erpnext.hub.item_view_cache.push(this.hub_item_name);
// }); // });
@@ -165,14 +160,15 @@ export default {
}, },
methods: { methods: {
get_item_details() { get_item_details() {
this.item_received = hub.call('get_item_details', { hub_item_name: this.hub_item_name }) this.item_received = hub
.call('get_item_details', { hub_item_name: this.hub_item_name })
.then(item => { .then(item => {
this.init = false; this.init = false;
this.item = item; this.item = item;
this.build_data(); this.build_data();
this.make_dialogs(); this.make_dialogs();
}); });
}, },
go_to_seller_profile_page(seller_name) { go_to_seller_profile_page(seller_name) {
frappe.set_route(`marketplace/seller/${seller_name}`); frappe.set_route(`marketplace/seller/${seller_name}`);
@@ -203,33 +199,39 @@ export default {
}, },
add_to_saved_items() { add_to_saved_items() {
hub.call('add_item_to_user_saved_items', { hub
hub_item_name: this.hub_item_name, .call('add_item_to_user_saved_items', {
hub_user: frappe.session.user hub_item_name: this.hub_item_name,
}) hub_user: frappe.session.user
.then(() => { })
const saved_items_link = `<b><a href="#marketplace/saved-items">${__('Saved')}</a></b>` .then(() => {
frappe.show_alert(saved_items_link); const saved_items_link = `<b><a href="#marketplace/saved-items">${__(
erpnext.hub.trigger('action:item_save'); 'Saved'
}) )}</a></b>`;
.catch(e => { frappe.show_alert(saved_items_link);
console.error(e); erpnext.hub.trigger('action:item_save');
}); })
.catch(e => {
console.error(e);
});
}, },
add_to_featured_items() { add_to_featured_items() {
hub.call('add_item_to_seller_featured_items', { hub
hub_item_name: this.hub_item_name, .call('add_item_to_seller_featured_items', {
hub_user: frappe.session.user hub_item_name: this.hub_item_name,
},) hub_user: frappe.session.user
.then(() => { })
const featured_items_link = `<b><a href="#marketplace/featured-items">${__('Added to Featured Items')}</a></b>` .then(() => {
frappe.show_alert(featured_items_link); const featured_items_link = `<b><a href="#marketplace/featured-items">${__(
erpnext.hub.trigger('action:item_feature'); 'Added to Featured Items'
}) )}</a></b>`;
.catch(e => { frappe.show_alert(featured_items_link);
console.error(e); erpnext.hub.trigger('action:item_feature');
}); })
.catch(e => {
console.error(e);
});
}, },
make_contact_seller_dialog() { make_contact_seller_dialog() {
@@ -251,14 +253,15 @@ export default {
primary_action: ({ message }) => { primary_action: ({ message }) => {
if (!message) return; if (!message) return;
hub.call('send_message', { hub
hub_item: this.item.name, .call('send_message', {
message hub_item: this.item.name,
}) message
})
.then(() => { .then(() => {
this.contact_seller_dialog.hide(); this.contact_seller_dialog.hide();
frappe.set_route('marketplace', 'buying', this.item.name); frappe.set_route('marketplace', 'buying', this.item.name);
erpnext.hub.trigger('action:send_message') erpnext.hub.trigger('action:send_message');
}); });
} }
}); });
@@ -275,7 +278,11 @@ export default {
} }
], ],
primary_action: ({ message }) => { primary_action: ({ message }) => {
hub.call('add_reported_item', { hub_item_name: this.item.name, message }) hub
.call('add_reported_item', {
hub_item_name: this.item.name,
message
})
.then(() => { .then(() => {
d.hide(); d.hide();
frappe.show_alert(__('Item Reported')); frappe.show_alert(__('Item Reported'));
@@ -290,7 +297,9 @@ export default {
report_item() { report_item() {
if (!hub.is_seller_registered()) { if (!hub.is_seller_registered()) {
frappe.throw(__('Please login as a Marketplace User to report this item.')); frappe.throw(
__('Please login as a Marketplace User to report this item.')
);
} }
this.report_item_dialog.show(); this.report_item_dialog.show();
}, },
@@ -301,23 +310,19 @@ export default {
unpublish_item() { unpublish_item() {
let me = this; let me = this;
frappe.confirm(__(`Unpublish ${this.item.item_name}?`), function () { frappe.confirm(__(`Unpublish ${this.item.item_name}?`), function() {
frappe.call( frappe
'erpnext.hub_node.api.unpublish_item', .call('erpnext.hub_node.api.unpublish_item', {
{
item: me.item item: me.item
} })
) .then(r => {
.then((r) => { frappe.set_route(`marketplace/home`);
frappe.set_route(`marketplace/home`); frappe.show_alert(__('Item listing removed'));
frappe.show_alert(__('Item listing removed')) });
});
})
})
} }
} }
} };
</script> </script>
<style scoped></style> <style scoped></style>