diff --git a/frappe/chat/doctype/chat_profile/chat_profile.json b/frappe/chat/doctype/chat_profile/chat_profile.json index 1918727e1a..9131fe9f3a 100644 --- a/frappe/chat/doctype/chat_profile/chat_profile.json +++ b/frappe/chat/doctype/chat_profile/chat_profile.json @@ -136,6 +136,37 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "1", + "fieldname": "message_preivew", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Message Preview", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -270,8 +301,8 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-01-01 18:44:47.226982", - "modified_by": "Administrator", + "modified": "2018-01-08 18:58:59.569481", + "modified_by": "faris@erpnext.com", "module": "Chat", "name": "Chat Profile", "name_case": "", diff --git a/frappe/chat/doctype/chat_profile/chat_profile.py b/frappe/chat/doctype/chat_profile/chat_profile.py index bc621cfe71..e34ec02fa8 100644 --- a/frappe/chat/doctype/chat_profile/chat_profile.py +++ b/frappe/chat/doctype/chat_profile/chat_profile.py @@ -44,6 +44,7 @@ def get(user, fields = None): duser = frappe.get_doc('User', user) dprof = frappe.get_doc('Chat Profile', user) + # If you're adding something here, make sure the client recieves it. profile = dict( # User name = duser.name, @@ -56,6 +57,7 @@ def get(user, fields = None): # Chat Profile status = dprof.status, chat_background = dprof.chat_background, + message_preview = bool(dprof.message_preview), notification_tones = bool(dprof.notification_tones), conversation_tones = bool(dprof.conversation_tones), display_widget = bool(dprof.display_widget) diff --git a/frappe/public/js/frappe/chat.js b/frappe/public/js/frappe/chat.js index a435a01291..7110036e2f 100644 --- a/frappe/public/js/frappe/chat.js +++ b/frappe/public/js/frappe/chat.js @@ -1425,7 +1425,9 @@ class extends Component } make ( ) { - frappe.chat.profile.create(["status", "display_widget", "notification_tones", "conversation_tones"]).then(profile => + frappe.chat.profile.create([ + "status", "display_widget", "message_preview", "notification_tones", "conversation_tones" + ]).then(profile => { frappe.log.info(`Chat Profile created for User ${frappe.session.user} - ${JSON.stringify(profile)}.`) this.set_state({ profile }) @@ -1504,6 +1506,21 @@ class extends Component state.profile.conversation_tones && frappe.chat.sound.play('message') else state.profile.notification_tones && frappe.chat.sound.play('notification') + + if ( r.user !== frappe.session.user && state.profile.message_preview && !state.toggle ) + { + const $element = $('body').find('.frappe-chat-alert') + $element.remove(); + + const alert = // TODO: ellipses content + ` + + ${frappe.user.first_name(r.user)}: ${r.content} + + ` + + frappe.show_alert(alert, 3) + } if ( r.room === state.room.name ) { @@ -1654,7 +1671,8 @@ class extends Component const component = props.layout === frappe.Chat.Layout.POPPER ? state.profile.display_widget ? - h(frappe.Chat.Widget.Popper, { page: state.room.name && Room, target: props.target }, + h(frappe.Chat.Widget.Popper, { page: state.room.name && Room, target: props.target, + toggle: (t) => this.set_state({ toggle: t }) }, h("span", null, ActionBar, RoomList ) @@ -1688,7 +1706,8 @@ frappe.Chat.Widget.defaultState = query: "", profile: { }, rooms: [ ], - room: { name: null, messages: [ ], typing: [ ] } + room: { name: null, messages: [ ], typing: [ ] }, + toggle: false } frappe.Chat.Widget.defaultProps = { @@ -1715,7 +1734,6 @@ class extends Component toggle (active) { - let toggle if ( arguments.length === 1 ) toggle = active @@ -1723,9 +1741,11 @@ class extends Component toggle = this.state.active ? false : true this.set_state({ active: toggle }) + + this.props.toggle(toggle) } - render ( ) + render ( ) { const { props, state } = this