brotherton-erpnext/erpnext/public/js/hub/components/item_card.js

81 lines
2.1 KiB
JavaScript
Raw Normal View History

function get_buying_item_message_card_html(item) {
2018-08-22 16:01:16 +00:00
const item_name = item.item_name || item.name;
const title = strip_html(item_name);
const message = item.recent_message
const sender = message.sender === frappe.session.user ? 'You' : message.sender
const content = strip_html(message.content)
// route
2018-08-27 08:41:48 +00:00
item.route = `marketplace/buying/${item.name}`
2018-08-22 16:01:16 +00:00
const item_html = `
2018-08-25 15:52:55 +00:00
<div class="col-md-7">
<div class="hub-list-item" data-route="${item.route}">
<div class="hub-list-left">
<img class="hub-list-image" src="${item.image}">
<div class="hub-list-body ellipsis">
<div class="hub-list-title">${item_name}</div>
<div class="hub-list-subtitle ellipsis">
<span>${sender}: </span>
<span>${content}</span>
</div>
</div>
</div>
<div class="hub-list-right">
<span class="text-muted">${comment_when(message.creation, true)}</span>
2018-08-22 16:01:16 +00:00
</div>
</div>
</div>
`;
return item_html;
}
function get_selling_item_message_card_html(item) {
const item_name = item.item_name || item.name;
const title = strip_html(item_name);
// route
if (!item.route) {
2018-08-27 08:41:48 +00:00
item.route = `marketplace/item/${item.name}`
}
let received_messages = '';
2018-08-25 15:52:55 +00:00
item.received_messages.forEach(message => {
const sender = message.sender === frappe.session.user ? 'You' : message.sender
const content = strip_html(message.content)
received_messages += `
<div class="received-message">
<span class="text-muted">${comment_when(message.creation, true)}</span>
<div class="ellipsis">
<span class="bold">${sender}: </span>
<span>${content}</span>
</div>
</div>
`
});
const item_html = `
<div class="selling-item-message-card">
<div class="selling-item-detail" data-route="${item.route}">
<img class="item-image" src="${item.image}">
<h5 class="item-name">${item_name}</h5>
<div class="received-message-container">
${received_messages}
</div>
</div>
</div>
`;
return item_html;
}
export {
2018-08-25 15:52:55 +00:00
get_item_card_html,
get_local_item_card_html,
get_buying_item_message_card_html,
get_selling_item_message_card_html
2018-08-06 13:43:10 +00:00
}