From 23e45ada69e528110d3dafc446d0ca28b1c457e2 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 26 Aug 2018 22:19:29 +0530 Subject: [PATCH 1/3] chore: Remove old messages files --- .../public/js/hub/pages/buying_messages.js | 101 ----------------- erpnext/public/js/hub/pages/messages.js | 104 ------------------ 2 files changed, 205 deletions(-) delete mode 100644 erpnext/public/js/hub/pages/buying_messages.js delete mode 100644 erpnext/public/js/hub/pages/messages.js diff --git a/erpnext/public/js/hub/pages/buying_messages.js b/erpnext/public/js/hub/pages/buying_messages.js deleted file mode 100644 index 7835fc36fd..0000000000 --- a/erpnext/public/js/hub/pages/buying_messages.js +++ /dev/null @@ -1,101 +0,0 @@ -import SubPage from './subpage'; - -erpnext.hub.MessageList = class BuyingMessages extends SubPage { - make_wrapper() { - const messages_of = this.options[0]; - if (messages_of === 'Buying') { - this.back_route = 'marketplace/buying-messages' - } else { - this.back_route = 'marketplace/selling-messages' - } - super.make_wrapper(); - this.add_back_link(__('Back to Messages'), this.back_route); - this.$message_container = this.add_section({ title: 'Buy' }); - } - - refresh() { - const item_code = frappe.get_route()[2] || null; - if (!item_code) { - frappe.set_route(this.back_route); - return; - } - this.get_item_details(item_code) - .then(item_details => { - this.item_details = item_details; - this.$message_container.find('.hub-section-header h4').text(this.item_details.item_name); - - // make chat area - this.$message_container.find('.hub-section-body').html(` -
-
-
-
- `) - this.make_message_input(); - - // fetch messages - this.get_messages(item_details) - .then(messages => { - const $message_list = this.$message_container.find('.message-list'); - const html = messages.map(get_message_html).join(''); - $message_list.html(html); - frappe.dom.scroll_to_bottom($message_list); - }); - }); - - } - - get_messages(item_details) { - return hub.call('get_messages', { - against_seller: item_details.hub_seller, - against_item: item_details.hub_item_code - }); - } - - get_item_details(hub_item_code) { - return hub.call('get_item_details', { hub_item_code }) - } - - make_message_input() { - this.message_input = new frappe.ui.CommentArea({ - parent: this.$message_container.find('.message-input'), - on_submit: (message) => { - this.message_input.reset(); - - // append message html - const $message_list = this.$message_container.find('.message-list'); - const message_html = get_message_html({ - sender: hub.settings.company_email, - content: message - }); - $message_list.append(message_html); - frappe.dom.scroll_to_bottom($message_list); - - // send message - hub.call('send_message', { - from_seller: hub.settings.company_email, - to_seller: this.item_details.hub_seller, - hub_item: this.item_details.hub_item_code, - message - }); - }, - no_wrapper: true - }); - } -} - -function get_message_html(message) { - return ` -
-
- ${frappe.avatar(message.sender)} -
- ${message.content} -
-
-
- ${comment_when(message.creation, true)} -
-
- `; -} \ No newline at end of file diff --git a/erpnext/public/js/hub/pages/messages.js b/erpnext/public/js/hub/pages/messages.js deleted file mode 100644 index 6222f53648..0000000000 --- a/erpnext/public/js/hub/pages/messages.js +++ /dev/null @@ -1,104 +0,0 @@ -import SubPage from './subpage'; -// import { get_item_card_container_html } from '../components/items_container'; -import { get_buying_item_message_card_html } from '../components/item_card'; -import { get_selling_item_message_card_html } from '../components/item_card'; -import { get_empty_state } from '../components/empty_state'; - -erpnext.hub.Buying = class Buying extends SubPage { - refresh() { - this.get_items_for_messages().then((items) => { - this.empty(); - if (items.length) { - items.map(item => { - item.route = `marketplace/buying/${item.hub_item_code}` - }) - this.render(items, __('Buying')); - } - - if (!items.length && !items.length) { - this.render_empty_state(); - } - }); - } - - render(items = [], title) { - // const html = get_item_card_container_html(items, title, get_buying_item_message_card_html); - this.$wrapper.append(html); - } - - render_empty_state() { - const empty_state = get_empty_state(__('You haven\'t interacted with any seller yet.')); - this.$wrapper.html(empty_state); - } - - get_items_for_messages() { - return hub.call('get_buying_items_for_messages', {}, 'action:send_message'); - } -} - -erpnext.hub.Selling = class Selling extends SubPage { - refresh() { - this.get_items_for_messages().then((items) => { - this.empty(); - if (items.length) { - items.map(item => { - item.route = `marketplace/selling/${item.hub_item_code}` - }) - this.render(items, __('Selling')); - } - - if (!items.length && !items.length) { - this.render_empty_state(); - } - }); - } - - render(items = [], title) { - // const html = get_item_card_container_html(items, title, get_selling_item_message_card_html); - this.$wrapper.append(html); - } - - render_empty_state() { - const empty_state = get_empty_state(__('You haven\'t interacted with any seller yet.')); - this.$wrapper.html(empty_state); - } - - get_items_for_messages() { - return hub.call('get_selling_items_for_messages', {}); - } -} - -function get_message_area_html() { - return ` -
-
-
-
-
-
- `; -} - -function get_list_item_html(seller) { - const active_class = frappe.get_route()[2] === seller.email ? 'active' : ''; - - return ` -
-
- -
-
- ${seller.company} -
-
- `; -} - -function get_message_html(message) { - return ` -
-
${message.sender}
-

${message.content}

-
- `; -} From d37108d18e7063a7d96c4092f0948db408c8b51b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 26 Aug 2018 22:19:56 +0530 Subject: [PATCH 2/3] fix: Add back link to Buying --- erpnext/public/js/hub/pages/BuyingMessages.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/hub/pages/BuyingMessages.vue b/erpnext/public/js/hub/pages/BuyingMessages.vue index c71864783f..63a746a459 100644 --- a/erpnext/public/js/hub/pages/BuyingMessages.vue +++ b/erpnext/public/js/hub/pages/BuyingMessages.vue @@ -1,6 +1,8 @@