1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
|
"use strict";(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["common-EmbeddedMessageCommon"],{7664:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"EmbeddedMessage\": () => (/* binding */ EmbeddedMessage)\n/* harmony export */ });\n/* harmony import */ var linkifyjs_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5853);\n/* harmony import */ var linkifyjs_string__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(linkifyjs_string__WEBPACK_IMPORTED_MODULE_0__);\n/* provided dependency */ var $ = __webpack_require__(9755);\n\nvar EmbeddedMessage = {\n\tmessage_control_api: null,\n\tevent_bus: new TTEventBus({ view_id: 'embedded_message' }),\n\t/**\n\t * Initializes embedded messages with a call to EmbeddedMessage.init()\n\t * Requires that initUI be called when the editviewui is built\n\t *\n\t * @param item_id (current_edit_record.id)\n\t * @param object_type (50 for requests)\n\t */\n\tinit: function( item_id, object_type, view_object, edit_view, edit_view_tab, edit_view_ui_dic, callback ) {\n\t\tvar args = {};\n\t\targs.filter_data = {};\n\t\targs.filter_data.object_type_id = object_type;\n\t\targs.filter_data.object_id = item_id;\n\t\tvar read_ids = [];\n\t\tthis.message_control_api = TTAPI.APIMessageControl;\n\n\t\tvar $this = this;\n\t\tthis.message_control_api['getEmbeddedMessage']( args, {\n\t\t\tonResult: function( res ) {\n\t\t\t\t// Error: Uncaught TypeError: Cannot read property 'setValue' of undefined in interface/html5/#!m=RequestAuthorization&id=1306 line 1547\n\t\t\t\tif ( !edit_view || !edit_view_ui_dic['from'] ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar data = res.getResult();\n\t\t\t\tif ( Global.isArray( data ) ) {\n\t\t\t\t\t$( edit_view.find( '.separate' ) ).css( 'display', 'block' );\n\n\t\t\t\t\tview_object.messages = data;\n\n\t\t\t\t\tvar container = $( '<div></div>' );\n\n\t\t\t\t\tfor ( var key in data ) {\n\n\t\t\t\t\t\tvar currentItem = data[key];\n\t\t\t\t\t\t/* jshint ignore:start */\n\t\t\t\t\t\tif ( currentItem.status_id == 10 ) {\n\t\t\t\t\t\t\tread_ids.push( currentItem.id );\n\t\t\t\t\t\t}\n\t\t\t\t\t\t/* jshint ignore:end */\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * This can be a little confusing to look at so here's the process:\n\t\t\t\t\t\t * 1. Set the hidden fields' values\n\t\t\t\t\t\t * 2. Clone the message template\n\t\t\t\t\t\t * 3. Append the message templage to container\n\t\t\t\t\t\t * 4. Append the contents of the the container variable to the visible form\n\t\t\t\t\t\t */\n\t\t\t\t\t\tvar from = currentItem.from_first_name + ' ' + currentItem.from_last_name + ' @ ' + currentItem.updated_date;\n\t\t\t\t\t\tedit_view_ui_dic['from'].setValue( from );\n\n\t\t\t\t\t\tedit_view_ui_dic['subject'].setValue( Global.htmlDecode( currentItem.subject ) );\n\t\t\t\t\t\t// The function setValue is not used on the body to avoid double encoding issues on the content as linkify (parses links in text) already handles that.\n\t\t\t\t\t\tedit_view_ui_dic['body'].html( Global.htmlDecode( currentItem.body ).linkify( { nl2br: true, className: 'linkified' } ) );\n\t\t\t\t\t\tedit_view_ui_dic['body'].setResizeEvent();\n\n\t\t\t\t\t\tvar cloneMessageControl = $( edit_view_tab.find( '#tab_request' ).find( '.edit-view-tab' ).find( '.embedded-message-template' ) ).clone();\n\t\t\t\t\t\tcloneMessageControl.removeClass( 'embedded-message-template' );\n\t\t\t\t\t\tcloneMessageControl.addClass( 'embedded-message-container' );\n\t\t\t\t\t\tcloneMessageControl.css( 'display', 'block' );\n\t\t\t\t\t\tcloneMessageControl.css( 'margin', '0px' );\n\t\t\t\t\t\tcloneMessageControl.appendTo( container );\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( read_ids.length > 0 ) {\n\t\t\t\t\t\t$this.message_control_api['markRecipientMessageAsRead']( read_ids, {\n\t\t\t\t\t\t\tonResult: function( res ) {\n\t\t\t\t\t\t\t\t//commented out as it is needed on the message screen, but not here and results in a big api call we'd rather avoi
|