function get_item_card_html(item) { const item_name = item.item_name || item.name; const title = strip_html(item_name); const img_url = item.image; const company_name = item.company; // Subtitle let subtitle = [comment_when(item.creation)]; const rating = item.average_rating; if (rating > 0) { subtitle.push(rating + ``) } subtitle.push(company_name); let dot_spacer = ''; subtitle = subtitle.join(dot_spacer); // route if (!item.route) { item.route = `marketplace/item/${item.hub_item_code}` } let recent_message_block = '' if(item.recent_message) { let message = item.recent_message let sender = message.sender === frappe.session.user ? 'You' : message.sender let content = $('

' + message.content + '

').text() //https://stackoverflow.com/a/14337611 recent_message_block = `
${comment_when(message.creation, true)}
${message.receiver}
${sender}: ${content}
` } const item_html = `
${title}
${subtitle}
${recent_message_block}
`; return item_html; } function get_local_item_card_html(item) { const item_name = item.item_name || item.name; const title = strip_html(item_name); const img_url = item.image; const company_name = item.company; const is_active = item.publish_in_hub; const id = item.hub_item_code || item.item_code; // Subtitle let subtitle = [comment_when(item.creation)]; const rating = item.average_rating; if (rating > 0) { subtitle.push(rating + ``) } if(company_name) { subtitle.push(company_name); } let dot_spacer = ''; subtitle = subtitle.join(dot_spacer); const edit_item_button = `
`; const item_html = `
${title}
${subtitle}
${edit_item_button}
`; return item_html; } export { get_item_card_html, get_local_item_card_html }