[fix] company listing context

This commit is contained in:
Prateeksha Singh 2018-04-05 14:44:16 +05:30
parent d77e8e5b02
commit 420c79041e
10 changed files with 352 additions and 204 deletions

View File

@ -135,7 +135,7 @@ def get_details(hub_sync_id=None, doctype='Hub Item'):
connection = get_client_connection() connection = get_client_connection()
details = connection.get_doc(doctype, hub_sync_id) details = connection.get_doc(doctype, hub_sync_id)
reviews = details.get('reviews') reviews = details.get('reviews')
if len(reviews): if reviews and len(reviews):
for r in reviews: for r in reviews:
r.setdefault('pretty_date', frappe.utils.pretty_date(r.get('modified'))) r.setdefault('pretty_date', frappe.utils.pretty_date(r.get('modified')))
details.setdefault('reviews', reviews) details.setdefault('reviews', reviews)

View File

@ -10,12 +10,10 @@ from frappe import _
from erpnext.utilities.product import get_price, get_qty_in_stock from erpnext.utilities.product import get_price, get_qty_in_stock
from six import string_types from six import string_types
# hub_url = "https://hubmarket.org" hub_url = "https://hubmarket.org"
hub_url = "http://159.89.175.122" # hub_url = "http://159.89.175.122"
# hub_url = "http://erpnext.hub:8000" # hub_url = "http://erpnext.hub:8000"
# test_hub_url = "https://hubmarket.org"
class OAuth2Session(): class OAuth2Session():
def __init__(self, headers): def __init__(self, headers):
self.headers = headers self.headers = headers

View File

View File

@ -516,3 +516,4 @@ erpnext.patches.v10_0.set_student_party_type
erpnext.patches.v10_0.update_project_in_sle erpnext.patches.v10_0.update_project_in_sle
erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
erpnext.patches.v11_0.add_index_on_nestedset_doctypes erpnext.patches.v11_0.add_index_on_nestedset_doctypes
erpnext.patches.v11_0.remove_modules_setup_page

View File

@ -0,0 +1,8 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.delete_doc("Page", "modules_setup")

View File

@ -1,112 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg <svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="330"
height="345.43808"
viewBox="0 0 87.312496 91.397155" viewBox="0 0 87.312496 91.397155"
version="1.1" class="hub-icon"
id="svg4635" height="345.43808"
inkscape:version="0.92.2 5c3e80d, 2017-08-06" width="330">
sodipodi:docname="hub-logo.svg"
inkscape:export-filename="/home/raghu/Desktop/hub-logo.png"
inkscape:export-xdpi="95.878258"
inkscape:export-ydpi="95.878258">
<defs
id="defs4629" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="234.27717"
inkscape:cy="167.57445"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1149"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata4632">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g <g
inkscape:label="Layer 1" transform="translate(121.51931,-138.66452)"
inkscape:groupmode="layer" id="layer1">
id="layer1"
transform="translate(121.51931,-138.66452)">
<rect <rect
rx="13.229166" ry="13.229166"
inkscape:export-ydpi="96"
inkscape:export-xdpi="96"
inkscape:export-filename="/home/raghu/Desktop/send/hub-02.png"
style="opacity:1;vector-effect:none;fill:#89da29;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect828"
width="87.3125"
height="87.3125"
x="-121.51931"
y="142.74918" y="142.74918"
ry="13.229166" /> x="-121.51931"
height="87.3125"
width="87.3125"
id="rect828"
style="opacity:1;vector-effect:none;fill:#89da29;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
rx="13.229166" />
<path <path
style="opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
clip-path="none"
d="m -121.51931,202.96343 v 13.86892 c 0,7.32897 5.90017,13.22917 13.22916,13.22917 h 60.854162 c 6.610072,0 12.056133,-4.80013 13.061216,-11.1187 -43.339761,0.1608 -54.359752,-16.03276 -87.144538,-15.97939 z"
id="path830" id="path830"
inkscape:connector-curvature="0" /> d="m -121.51931,202.96343 v 13.86892 c 0,7.32897 5.90017,13.22917 13.22916,13.22917 h 60.854162 c 6.610072,0 12.056133,-4.80013 13.061216,-11.1187 -43.339761,0.1608 -54.359752,-16.03276 -87.144538,-15.97939 z"
<path
style="opacity:1;vector-effect:none;fill:#59b81c;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
clip-path="none" clip-path="none"
d="m -34.20681,202.96343 c -32.784694,-0.0533 -43.804846,16.14019 -87.14455,15.97939 1.00509,6.31857 6.45115,11.1187 13.06122,11.1187 h 60.854164 c 7.328992,0 13.229166,-5.9002 13.229166,-13.22917 z" style="opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<path
id="path832" id="path832"
inkscape:connector-curvature="0" /> d="m -34.20681,202.96343 c -32.784694,-0.0533 -43.804846,16.14019 -87.14455,15.97939 1.00509,6.31857 6.45115,11.1187 13.06122,11.1187 h 60.854164 c 7.328992,0 13.229166,-5.9002 13.229166,-13.22917 z"
clip-path="none"
style="opacity:1;vector-effect:none;fill:#59b81c;fill-opacity:1;stroke:none;stroke-width:3.96875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<path <path
id="path834"
d="m -84.351263,175.75725 c -1.30945,0 -2.376091,1.06665 -2.376091,2.37608 v 10.02885 0.001 c 0.06583,4.83083 4.01156,8.73477 8.857351,8.73486 4.8718,5e-5 8.846821,-3.94421 8.871295,-8.81134 v -0.001 -9.95288 c 0,-1.30943 -1.066113,-2.37557 -2.375589,-2.37557 -1.309396,0 -2.376064,1.06614 -2.376064,2.37557 v 9.8888 c 0,2.26045 -1.858169,4.10983 -4.119642,4.10983 -2.263616,0 -4.105699,-1.82766 -4.105699,-4.08968 v -9.90844 c 0,-1.30943 -1.066138,-2.37608 -2.375561,-2.37608 z m -20.887107,0.0925 c -1.30943,0 -2.37609,1.06717 -2.37609,2.3766 v 16.45119 c 0,1.30944 1.06666,2.37609 2.37609,2.37609 1.30945,0 2.37556,-1.06665 2.37556,-2.37609 v -5.97327 h 8.22534 v 5.97327 c 0,1.30944 1.066641,2.37609 2.376091,2.37609 1.309423,0 2.375561,-1.06665 2.375561,-2.37609 v -16.45119 c 0,-1.30943 -1.066138,-2.3766 -2.375561,-2.3766 -1.30945,0 -2.376091,1.06717 -2.376091,2.3766 v 5.72627 h -8.22534 v -5.72627 c 0,-1.30943 -1.06611,-2.3766 -2.37556,-2.3766 z m 41.77419,0 c -0.654712,0 -1.248675,0.26711 -1.678967,0.69764 -0.05368,0.0537 -0.105119,0.10983 -0.153458,0.16846 v 5.3e-4 c -0.04839,0.0586 -0.09427,0.11929 -0.136949,0.18242 v 5.3e-4 c -0.256381,0.37936 -0.406691,0.83617 -0.406691,1.32705 v 16.45119 c 0,0.1635 0.01693,0.3242 0.04858,0.47852 0.09512,0.46331 0.32594,0.87828 0.64852,1.20096 0.161369,0.16136 0.345308,0.29938 0.547264,0.40928 v 0 c 0.134567,0.0732 0.276781,0.13403 0.425318,0.18035 v 0 c 0.148537,0.0463 0.303186,0.0783 0.462518,0.0946 v 0 c 0.07959,0.008 0.160708,0.0124 0.242358,0.0124 h 8.33181 c 0.08747,0 0.167931,-0.0145 0.251142,-0.0238 l 0.09509,0.005 c 0.06019,0.003 0.119407,0.005 0.178779,0.006 h 0.0037 0.0048 c 3.578305,-2e-5 6.487954,-2.90916 6.487981,-6.48747 v -0.001 c -0.0026,-1.51334 -0.578009,-2.9475 -1.540484,-4.10673 0.962448,-1.15892 1.537785,-2.59314 1.540484,-4.10621 v -0.001 c -2.7e-5,-3.57831 -2.909676,-6.48744 -6.487981,-6.48746 h -0.533294 z m 8.865103,4.75062 c 0.96393,0 1.736831,0.77394 1.736831,1.73788 0,0.96394 -0.772901,1.73684 -1.736831,1.73684 v 0 h -0.532792 -5.955718 v -3.47317 h 5.956248 z m 0,8.21552 v 0 c 0.963507,5.3e-4 1.735799,0.77373 1.735799,1.73736 0,0.96394 -0.772901,1.73684 -1.736831,1.73684 h -0.0048 l -0.533294,0.0119 h -5.951591 v -3.4742 h 5.959846 z"
style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.79375005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.79375005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
inkscape:connector-curvature="0" /> d="m -84.351263,175.75725 c -1.30945,0 -2.376091,1.06665 -2.376091,2.37608 v 10.02885 0.001 c 0.06583,4.83083 4.01156,8.73477 8.857351,8.73486 4.8718,5e-5 8.846821,-3.94421 8.871295,-8.81134 v -0.001 -9.95288 c 0,-1.30943 -1.066113,-2.37557 -2.375589,-2.37557 -1.309396,0 -2.376064,1.06614 -2.376064,2.37557 v 9.8888 c 0,2.26045 -1.858169,4.10983 -4.119642,4.10983 -2.263616,0 -4.105699,-1.82766 -4.105699,-4.08968 v -9.90844 c 0,-1.30943 -1.066138,-2.37608 -2.375561,-2.37608 z m -20.887107,0.0925 c -1.30943,0 -2.37609,1.06717 -2.37609,2.3766 v 16.45119 c 0,1.30944 1.06666,2.37609 2.37609,2.37609 1.30945,0 2.37556,-1.06665 2.37556,-2.37609 v -5.97327 h 8.22534 v 5.97327 c 0,1.30944 1.066641,2.37609 2.376091,2.37609 1.309423,0 2.375561,-1.06665 2.375561,-2.37609 v -16.45119 c 0,-1.30943 -1.066138,-2.3766 -2.375561,-2.3766 -1.30945,0 -2.376091,1.06717 -2.376091,2.3766 v 5.72627 h -8.22534 v -5.72627 c 0,-1.30943 -1.06611,-2.3766 -2.37556,-2.3766 z m 41.77419,0 c -0.654712,0 -1.248675,0.26711 -1.678967,0.69764 -0.05368,0.0537 -0.105119,0.10983 -0.153458,0.16846 v 5.3e-4 c -0.04839,0.0586 -0.09427,0.11929 -0.136949,0.18242 v 5.3e-4 c -0.256381,0.37936 -0.406691,0.83617 -0.406691,1.32705 v 16.45119 c 0,0.1635 0.01693,0.3242 0.04858,0.47852 0.09512,0.46331 0.32594,0.87828 0.64852,1.20096 0.161369,0.16136 0.345308,0.29938 0.547264,0.40928 v 0 c 0.134567,0.0732 0.276781,0.13403 0.425318,0.18035 v 0 c 0.148537,0.0463 0.303186,0.0783 0.462518,0.0946 v 0 c 0.07959,0.008 0.160708,0.0124 0.242358,0.0124 h 8.33181 c 0.08747,0 0.167931,-0.0145 0.251142,-0.0238 l 0.09509,0.005 c 0.06019,0.003 0.119407,0.005 0.178779,0.006 h 0.0037 0.0048 c 3.578305,-2e-5 6.487954,-2.90916 6.487981,-6.48747 v -0.001 c -0.0026,-1.51334 -0.578009,-2.9475 -1.540484,-4.10673 0.962448,-1.15892 1.537785,-2.59314 1.540484,-4.10621 v -0.001 c -2.7e-5,-3.57831 -2.909676,-6.48744 -6.487981,-6.48746 h -0.533294 z m 8.865103,4.75062 c 0.96393,0 1.736831,0.77394 1.736831,1.73788 0,0.96394 -0.772901,1.73684 -1.736831,1.73684 v 0 h -0.532792 -5.955718 v -3.47317 h 5.956248 z m 0,8.21552 v 0 c 0.963507,5.3e-4 1.735799,0.77373 1.735799,1.73736 0,0.96394 -0.772901,1.73684 -1.736831,1.73684 h -0.0048 l -0.533294,0.0119 h -5.951591 v -3.4742 h 5.959846 z"
id="path834" />
<path <path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.93750048;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m -77.859375,138.66406 c -9.653316,0 -18.439915,3.93483 -24.767575,10.28125 a 3.9691471,3.9691471 0 1 0 5.621091,5.60352 c 4.899576,-4.9141 11.6422,-7.94727 19.146484,-7.94727 7.501101,0 14.241542,3.03098 19.140625,7.94141 a 3.9691471,3.9691471 0 1 0 5.619141,-5.60547 c -6.327038,-6.34169 -15.110547,-10.27344 -24.759766,-10.27344 z"
id="path838" id="path838"
inkscape:connector-curvature="0" /> d="m -77.859375,138.66406 c -9.653316,0 -18.439915,3.93483 -24.767575,10.28125 a 3.9691471,3.9691471 0 1 0 5.621091,5.60352 c 4.899576,-4.9141 11.6422,-7.94727 19.146484,-7.94727 7.501101,0 14.241542,3.03098 19.140625,7.94141 a 3.9691471,3.9691471 0 1 0 5.619141,-5.60547 c -6.327038,-6.34169 -15.110547,-10.27344 -24.759766,-10.27344 z"
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#63c923;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.93750048;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -40,10 +40,6 @@ erpnext.hub.HubDetailsPage = class HubDetailsPage extends frappe.views.BaseList
wrapper: this.$page.find('.layout-side-section'), wrapper: this.$page.find('.layout-side-section'),
css_class: 'hub-form-sidebar' css_class: 'hub-form-sidebar'
}); });
this.attachFooter();
this.attachTimeline();
this.attachReviewArea();
} }
setup_filter_area() { } setup_filter_area() { }
@ -132,8 +128,8 @@ erpnext.hub.HubDetailsPage = class HubDetailsPage extends frappe.views.BaseList
this.form.set_values(this.data); this.form.set_values(this.data);
this.$result.show(); this.$result.show();
this.$timelineList.empty(); this.$timelineList && this.$timelineList.empty();
if(this.data.reviews.length) { if(this.data.reviews && this.data.reviews.length) {
this.data.reviews.map(review => { this.data.reviews.map(review => {
this.addReviewToTimeline(review); this.addReviewToTimeline(review);
}) })
@ -323,6 +319,58 @@ erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubDetailsPage {
this.image_field_name = 'image'; this.image_field_name = 'image';
} }
setup_page_head() {
super.setup_page_head();
this.set_primary_action();
}
setup_side_bar() {
this.setup_side_bar();
this.attachFooter();
this.attachTimeline();
this.attachReviewArea();
}
set_primary_action() {
let item = this.data;
this.page.set_primary_action(__('Request a Quote'), () => {
this.show_rfq_modal()
.then(values => {
item.item_code = values.item_code;
delete values.item_code;
const supplier = values;
return [item, supplier];
})
.then(([item, supplier]) => {
return this.make_rfq(item, supplier, this.page.btn_primary);
})
.then(r => {
console.log(r);
if (r.message && r.message.rfq) {
this.page.btn_primary.addClass('disabled').html(`<span><i class='fa fa-check'></i> ${__('Quote Requested')}</span>`);
} else {
throw r;
}
})
.catch((e) => {
console.log(e); //eslint-disable-line
});
}, 'octicon octicon-plus');
}
make_rfq(item, supplier, btn) {
console.log(supplier);
return new Promise((resolve, reject) => {
frappe.call({
method: 'erpnext.hub_node.make_rfq_and_send_opportunity',
args: { item, supplier },
callback: resolve,
btn,
}).fail(reject);
});
}
postRender() { postRender() {
this.categoryDialog = new frappe.ui.Dialog({ this.categoryDialog = new frappe.ui.Dialog({
title: __('Suggest Category'), title: __('Suggest Category'),
@ -345,6 +393,7 @@ erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubDetailsPage {
category: values.category category: values.category
}, },
callback: () => { callback: () => {
this.categoryDialog.hide();
this.refresh(); this.refresh();
}, },
freeze: true freeze: true
@ -383,6 +432,36 @@ erpnext.hub.ItemPage = class ItemPage extends erpnext.hub.HubDetailsPage {
]; ];
this.formFields = colOneFields.concat(miscFields, colTwoFields); this.formFields = colOneFields.concat(miscFields, colTwoFields);
} }
show_rfq_modal() {
let item = this.data;
return new Promise(res => {
let fields = [
{ label: __('Item Code'), fieldtype: 'Data', fieldname: 'item_code', default: item.item_code },
{ fieldtype: 'Column Break' },
{ label: __('Item Group'), fieldtype: 'Link', fieldname: 'item_group', default: item.item_group },
{ label: __('Supplier Details'), fieldtype: 'Section Break' },
{ label: __('Supplier Name'), fieldtype: 'Data', fieldname: 'supplier_name', default: item.company_name },
{ label: __('Supplier Email'), fieldtype: 'Data', fieldname: 'supplier_email', default: item.seller },
{ fieldtype: 'Column Break' },
{ label: __('Supplier Type'), fieldname: 'supplier_type',
fieldtype: 'Link', options: 'Supplier Type' }
];
fields = fields.map(f => { f.reqd = 1; return f; });
const d = new frappe.ui.Dialog({
title: __('Request for Quotation'),
fields: fields,
primary_action_label: __('Send'),
primary_action: (values) => {
res(values);
d.hide();
}
});
d.show();
});
}
} }
erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubDetailsPage { erpnext.hub.CompanyPage = class CompanyPage extends erpnext.hub.HubDetailsPage {

View File

@ -152,9 +152,8 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList {
var html = this.data.map(this.item_html.bind(this)).join(""); var html = this.data.map(this.item_html.bind(this)).join("");
if (this.start === 0) { if (this.start === 0) {
// this.renderHeader(); // ${this.getHeaderHtml()}
this.$result.html(` this.$result.html(`
${this.getHeaderHtml()}
<div class="image-view-container small"> <div class="image-view-container small">
${html} ${html}
</div> </div>
@ -173,17 +172,21 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList {
}); });
} }
getHeaderHtml() { getHeaderHtml(title, image, content) {
// let company_html = // let company_html =
return ` return `
<header class="list-row-head text-muted small"> <header class="list-row-head text-muted small">
<div style="display: flex;"> <div style="display: flex;">
<div class="list-header-icon"> <div class="list-header-icon">
<img title="Riadco%20Group" alt="Riadco Group" src="https://cdn.pbrd.co/images/HdaPxcg.png"> <img title="${title}" alt="${title}" src="${image}">
</div> </div>
<div class="list-header-info"> <div class="list-header-info">
<h5>Riadco Group</h5> <h5>
<span class="margin-vertical-10 level-item">Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam</span> ${title}
</h5>
<span class="margin-vertical-10 level-item">
${content}
</span>
</div> </div>
</div> </div>
</header> </header>
@ -246,69 +249,6 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList {
) )
} }
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 += `<i class='fa fa-fw ${starClass} star-icon' data-index=${i}></i>`;
}
let item_html = `
<div class="image-view-item">
<div class="image-view-header">
<div class="list-row-col list-subject ellipsis level">
<span class="level-item bold ellipsis" title="McGuffin">
<a href="${route}">${title}</a>
</span>
</div>
<div class="text-muted small" style="margin: 5px 0px;">
${ratingHtml}
(${reviewLength})
</div>
<div class="list-row-col">
<a href="${'#Hub/Company/'+company_name}"><p>${ company_name }</p></a>
</div>
</div>
<div class="image-view-body">
<a data-name="${encoded_name}"
title="${encoded_name}"
href="${route}"
>
<div class="image-field ${_class}"
data-name="${encoded_name}"
>
<button class="btn btn-default zoom-view" data-name="${encoded_name}">
<i class="octicon octicon-eye" data-name="${encoded_name}"></i>
</button>
<button class="btn btn-default like-button" data-name="${encoded_name}">
<i class="octicon octicon-heart" data-name="${encoded_name}"></i>
</button>
</div>
</a>
</div>
</div>
`;
return item_html;
}
setup_quick_view() { setup_quick_view() {
if(this.quick_view) return; if(this.quick_view) return;
@ -316,6 +256,31 @@ erpnext.hub.HubListing = class HubListing extends frappe.views.BaseList {
title: 'Quick View', title: 'Quick View',
fields: this.formFields fields: this.formFields
}); });
this.quick_view.set_primary_action(__('Request a Quote'), () => {
this.show_rfq_modal()
.then(values => {
item.item_code = values.item_code;
delete values.item_code;
const supplier = values;
return [item, supplier];
})
.then(([item, supplier]) => {
return this.make_rfq(item, supplier, this.page.btn_primary);
})
.then(r => {
console.log(r);
if (r.message && r.message.rfq) {
this.page.btn_primary.addClass('disabled').html(`<span><i class='fa fa-check'></i> ${__('Quote Requested')}</span>`);
} else {
throw r;
}
})
.catch((e) => {
console.log(e); //eslint-disable-line
});
}, 'octicon octicon-plus');
this.$result.on('click', '.btn.zoom-view', (e) => { this.$result.on('click', '.btn.zoom-view', (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -400,6 +365,14 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
this.filters = []; this.filters = [];
} }
render() {
this.data_dict = {};
this.render_image_view();
this.setup_quick_view();
this.setup_like();
}
bootstrap_data(response) { bootstrap_data(response) {
let companies = response.companies.map(d => d.name); let companies = response.companies.map(d => d.name);
this.custom_filter_configs = [ this.custom_filter_configs = [
@ -486,6 +459,11 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
label: __("Favourites"), label: __("Favourites"),
on_click: () => frappe.set_route('Hub', 'Favourites') on_click: () => frappe.set_route('Hub', 'Favourites')
}, __("Account")); }, __("Account"));
this.sidebar.add_item({
label: __("Settings"),
on_click: () => frappe.set_route('Form', 'Hub Settings')
}, __("Account"));
} }
update_category(label) { update_category(label) {
@ -514,6 +492,70 @@ erpnext.hub.ItemListing = class ItemListing extends erpnext.hub.HubListing {
this.data_dict[d.hub_item_code] = d; this.data_dict[d.hub_item_code] = d;
}); });
} }
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 += `<i class='fa fa-fw ${starClass} star-icon' data-index=${i}></i>`;
}
let item_html = `
<div class="image-view-item">
<div class="image-view-header">
<div class="list-row-col list-subject ellipsis level">
<span class="level-item bold ellipsis" title="McGuffin">
<a href="${route}">${title}</a>
</span>
</div>
<div class="text-muted small" style="margin: 5px 0px;">
${ratingHtml}
(${reviewLength})
</div>
<div class="list-row-col">
<a href="${'#Hub/Company/'+company_name}"><p>${ company_name }</p></a>
</div>
</div>
<div class="image-view-body">
<a data-name="${encoded_name}"
title="${encoded_name}"
href="${route}"
>
<div class="image-field ${_class}"
data-name="${encoded_name}"
>
<button class="btn btn-default zoom-view" data-name="${encoded_name}">
<i class="octicon octicon-eye" data-name="${encoded_name}"></i>
</button>
<button class="btn btn-default like-button" data-name="${encoded_name}">
<i class="octicon octicon-heart" data-name="${encoded_name}"></i>
</button>
</div>
</a>
</div>
</div>
`;
return item_html;
}
}; };
erpnext.hub.Favourites = class Favourites extends erpnext.hub.ItemListing { erpnext.hub.Favourites = class Favourites extends erpnext.hub.ItemListing {
@ -564,16 +606,6 @@ erpnext.hub.Favourites = class Favourites extends erpnext.hub.ItemListing {
label: __('Back to Products'), label: __('Back to Products'),
on_click: () => frappe.set_route('Hub', 'Item') 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) { update_category(label) {
@ -610,6 +642,11 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing
this.show(); this.show();
} }
render() {
this.data_dict = {};
this.render_image_view();
}
setup_defaults() { setup_defaults() {
super.setup_defaults(); super.setup_defaults();
this.doctype = 'Hub Company'; this.doctype = 'Hub Company';
@ -628,6 +665,18 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing
this.imageFieldName = 'company_logo'; this.imageFieldName = 'company_logo';
} }
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')
});
}
get_filters_for_args() { get_filters_for_args() {
let filters = {}; let filters = {};
this.filter_area.get().forEach(f => { this.filter_area.get().forEach(f => {
@ -637,29 +686,41 @@ erpnext.hub.CompanyListing = class CompanyListing extends erpnext.hub.HubListing
return filters; return filters;
} }
card_html(company) { item_html(company) {
company._name = encodeURI(company.name); company._name = encodeURI(company.company_name);
const route = `#Hub/Company/${company.company_name}`; const encoded_name = company._name;
const title = strip_html(company.company_name);
const _class = !company[this.imageFieldName] ? 'no-image' : '';
const company_name = company['company_name'];
const route = `#Hub/Company/${company_name}`;
let image_html = company.company_logo ? let image_html = company.company_logo ?
`<img src="${company.company_logo}"><span class="helper"></span>` : `<img src="${company.company_logo}"><span class="helper"></span>` :
`<div class="standard-image">${frappe.get_abbr(company.company_name)}</div>`; `<div class="standard-image">${frappe.get_abbr(company.company_name)}</div>`;
return ` let item_html = `
<div class="hub-item-wrapper margin-bottom" style="width: 200px;"> <div class="image-view-item">
<a href="${route}"> <div class="image-view-header">
<div class="hub-item-image"> <div class="list-row-col list-subject ellipsis level">
<div class="img-wrapper" style="height: 200px; width: 200px"> <span class="level-item bold ellipsis" title="McGuffin">
${ image_html } <a href="${route}">${title}</a>
</span>
</div>
</div>
<div class="image-view-body">
<a data-name="${encoded_name}"
title="${encoded_name}"
href="${route}">
<div class="image-field ${_class}"
data-name="${encoded_name}">
</div> </div>
</div> </a>
<div class="hub-item-title"> </div>
<h5 class="bold">
${ company.company_name }
</h5>
</div>
</a>
</div> </div>
`; `;
return item_html;
} }
}; };

View File

@ -23,6 +23,20 @@
margin-top: -3px; margin-top: -3px;
} }
.app-icon-svg {
display: inline-block;
margin: auto;
text-align: center;
border-radius: 16px;
cursor: pointer;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.15);
}
.app-icon-svg .hub-icon {
height: 72px;
width: 72px;
}
.dashboard-list-item { .dashboard-list-item {
background-color: inherit; background-color: inherit;
padding: 5px 0px; padding: 5px 0px;

View File

@ -3,6 +3,7 @@
body[data-route^="Hub/"] { body[data-route^="Hub/"] {
.hub-icon { .hub-icon {
width: 40px; width: 40px;
height: 40px;
} }
.hub-page-title { .hub-page-title {
@ -73,6 +74,67 @@ body[data-route^="Hub/"] {
.frappe-list .result { .frappe-list .result {
min-height: 100px; min-height: 100px;
} }
.frappe-control[data-fieldtype="Attach Image"] {
width: 140px;
height: 180px;
margin-top: 20px;
}
.frappe-control[data-fieldtype="Attach Image"] .form-group {
display: none;
}
.frappe-control[data-fieldtype="Attach Image"] .clearfix {
display: none;
}
.missing-image {
display: block;
position: relative;
border-radius: 4px;
border: 1px solid #d1d8dd;
border-radius: 6px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.missing-image .octicon {
position: relative;
top: 50%;
transform: translate(0px, -50%);
-webkit-transform: translate(0px, -50%);
}
.attach-image-display {
display: block;
position: relative;
border-radius: 4px;
}
.img-container {
height: 100%;
width: 100%;
padding: 2px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
border: 1px solid #d1d8dd;
border-radius: 6px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.img-overlay {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
width: 100%;
height: 100%;
color: #777777;
background-color: rgba(255, 255, 255, 0.7);
opacity: 0;
}
.img-overlay:hover {
opacity: 1;
cursor: pointer;
}
} }
.image-view-container { .image-view-container {