{"version":3,"sources":["IntelGatherForm.js"],"names":["IntelGatherForm","subjectType","subjectID","subjectName","contacts","teamContactsUrl","GetTeamMembers","outletid","length","$","ajax","method","url","data","JSON","stringify","outletId","contentType","beforeSend","selectize","create","sortField","settings","placeholder","updatePlaceholder","disable","success","response","Success","Data","map","contact","ProfileID","FullName","Email","ContactID","forEach","addOption","value","text","enable","error","complete","Init","document","ready","BtnToggleFlag","$btn","$input","prop","addClass","removeClass","on","subjectText","hide","find","val","e","flags","preventDefault","list","GetStringIfSelected","$e","push","join","followUp","followUpDate","outcomeSelect","outcomes","message","OutletServiceId","Comment","SubjectType","SubjectID","InsightType","Importance","Risk","FollowUp","AssignedProfileID","AssignedDate","CommentFlags","Outcome","formValid","querySelector","reportValidity","window","AppSettings","ApiUrl","dataType","res","notify","title","icon","type","placement","from","align","delay","timer","trigger","Message","modal","off","_this","this","CommentID","DataTable","reload","onChange","parent","plugins","show","daterangepicker","singleDatePicker","showDropdowns","minYear","parseInt","moment","format","minDate","maxYear","locale","start","end","label","$regionSelectize","clear","clearOptions","onSearchChange","valueField","labelField","searchField","delimiter","dropdownParent","preload","selectOnTab","openOnFocus","closeAfterSelect","hideSelected","load","query","callback","s","dataset","Results"],"mappings":"AAAA,IAAIA,iBACJ,SAAWA,GACP,IAAIC,EAAc,GACdC,EAAY,EACZC,EAAc,GACdC,EAAW,GACXC,EAAkB,GA8UtB,SAASC,EAAeC,GAChBA,GAAuB,EAAXA,GAAgBH,GAAgC,IAApBA,EAASI,QACjDC,EAAEC,KAAK,CACHC,OAAQ,OACRC,IAAKP,EACLQ,KAAMC,KAAKC,UAAU,CAAEC,SAAUT,IACjCU,YAAa,mBACbC,WAAY,WACRT,EAAE,8BAA8BU,UAAU,CACtCC,QAAQ,EACRC,UAAW,SAEfZ,EAAE,8BAA8B,GAAGU,UAAUG,SAASC,YAAc,+BACpEd,EAAE,8BAA8B,GAAGU,UAAUK,oBAC7Cf,EAAE,8BAA8B,GAAGU,UAAUM,WAEjDC,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eAC7BR,EAAkB,wCAClBC,EAAeG,EAAE,sBAAsB8C,KAAK,mBAAmBC,OAC/D/C,EAAE,sBAAsB8C,KAAK,iBAAiBC,IAAI,aAClD/C,EAAE,uEAAuEU,UAAU,CAC/EyF,SAAU,SAAUtE,GAChB,IAAIuF,EAAmBpH,EAAE,sEAAsE,GAAGU,UAClG0G,EAAiBrF,SACjBqF,EAAiBC,QACjBD,EAAiBE,eACjBF,EAAiBG,eAAe,OAGxCvH,EAAE,sEAAsE2C,GAAG,SAAU,WACjF3C,EAAE,sBAAsB8C,KAAK,eAAeC,IAAI/C,EAAE+F,MAAMhD,SAE5D/C,EAAE,sEAAsEU,UAAU,CAC9EC,QAAQ,EACR6G,WAAY,mBACZC,WAAY,aACZC,YAAa,aACb9G,UAAW,aACXyF,QAAS,CAAC,iBACVsB,UAAW,IACXC,eAAgB,OAChBC,SAAS,EACTC,aAAa,EACbC,aAAa,EACbC,kBAAkB,EAClBC,cAAc,EACdnH,YAAa,qBACboH,KAAM,SAAUC,EAAOC,GACnBpI,EAAEC,KAAK,CACHE,IAAK,mCACLiF,KAAM,MACNL,SAAU,OACV3E,KAAM,CACFiI,EAAGF,EACHG,QAAStI,EAAE,uEAAuE+C,OAEtFf,MAAO,SAAU5B,GACbgI,EAAShI,IAEbK,WAAY,WACRT,EAAE,sEAAsE,GAAGU,UAAUG,SAASC,YAAc,yBAC5Gd,EAAE,sEAAsE,GAAGU,UAAUK,oBACrFf,EAAE,sEAAsE,GAAGU,UAAUM,WAEzFC,QAAS,SAAUb,GACfJ,EAAE,sEAAsE,GAAGU,UAAUG,SAASC,YAAc,qBAC5Gd,EAAE,sEAAsE,GAAGU,UAAUK,oBACrFf,EAAE,sEAAsE,GAAGU,UAAUqB,SACrFqG,EAAShI,EAAKmI,iBA3U1C,CA6duBhJ,gBAApBA,iBAAsC","file":"IntelGatherForm.min.js","sourcesContent":["var IntelGatherForm;\r\n(function (IntelGatherForm) {\r\n var subjectType = \"\";\r\n var subjectID = 0;\r\n var subjectName = \"\";\r\n var contacts = [];\r\n var teamContactsUrl = \"\";\r\n function Init() {\r\n $(document).ready(function () {\r\n $('#intel-gather-form').on('show.bs.modal', function () {\r\n //reset fields\r\n $('#intel-gather-form input[name=\"message-type\"]:checked').prop('checked', false);\r\n $('#intel-gather-form input[name=\"follow-up-select\"]:checked').prop('checked', false);\r\n $('#intel-gather-form .follow-up-group').hide();\r\n subjectType = $('#intel-gather-form').find('#subject-type').val();\r\n subjectID = $('#intel-gather-form').find('#subject-id').val();\r\n subjectName = $('#intel-gather-form').find('#subject-name').val();\r\n teamContactsUrl = \"/Manage/TeamMembers/GetOutletContacts\";\r\n var subjectText;\r\n switch (subjectType) {\r\n case \"Service\":\r\n subjectText = \"[This Service] \" + subjectName;\r\n break;\r\n case \"Organisation\":\r\n subjectText = \"[This Organisation] \" + subjectName;\r\n break;\r\n case \"Outlet\":\r\n subjectText = \"[This Location] \" + subjectName;\r\n break;\r\n case \"Event\":\r\n subjectText = \"[This Event] \" + subjectName;\r\n teamContactsUrl = \"/Account/GetOutletContacts\";\r\n break;\r\n case \"Profile\":\r\n subjectText = subjectName;\r\n break;\r\n }\r\n $('#subject-text').text(subjectText);\r\n //TODO: reset fields and flags\r\n GetTeamMembers($('#intel-gather-form #user-outlet-id').val());\r\n $('#intel-gather-form').find('#importance-low').prop('checked', true);\r\n $('#intel-gather-form').find('#risk-low').prop('checked', true);\r\n $('#intel-gather-form').find('#follow-up-select-no').prop('checked', true);\r\n $('#intel-gather-form').find('#key-outcome-select').val();\r\n $('#intel-gather-form').find('#intel-gather-form-message').val();\r\n });\r\n $('#btn-intel-gather-form-submit').on('click touchend', function (e) {\r\n e.preventDefault();\r\n var flags;\r\n {\r\n var list = [];\r\n function GetStringIfSelected($e) {\r\n if ($e.prop('checked')) {\r\n list.push($e.val());\r\n }\r\n }\r\n GetStringIfSelected($('#intel-flag-phone'));\r\n GetStringIfSelected($('#intel-flag-user'));\r\n GetStringIfSelected($('#intel-flag-email'));\r\n GetStringIfSelected($('#intel-flag-important'));\r\n GetStringIfSelected($('#intel-flag-favourite'));\r\n flags = list.join(',');\r\n }\r\n var followUp = $('#intel-gather-form #follow-up-select-yes').prop('checked');\r\n var followUpDate = null;\r\n if (followUp) {\r\n followUpDate = $('#follow-up-date').val();\r\n }\r\n var outcomeSelect = $('#key-outcome-select').val();\r\n var outcomes = \"\";\r\n if (outcomeSelect && outcomeSelect.length > 0) {\r\n outcomes = outcomeSelect.join(', ');\r\n }\r\n // get latest data\r\n subjectType = $('#intel-gather-form').find('#subject-type').val();\r\n subjectID = $('#intel-gather-form').find('#subject-id').val();\r\n subjectName = $('#intel-gather-form').find('#subject-name').val();\r\n var message = {\r\n OutletServiceId: -1,\r\n Comment: $('#intel-gather-form-message').val(),\r\n SubjectType: subjectType,\r\n SubjectID: subjectID,\r\n InsightType: $('#intel-gather-form input[name=\"message-type\"]:checked').val(),\r\n Importance: $('#intel-gather-form input[name=\"importance-select\"]:checked').val(),\r\n Risk: $('#intel-gather-form input[name=\"risk-select\"]:checked').val(),\r\n FollowUp: followUp,\r\n AssignedProfileID: $('#follow-up-assignee-select').val(),\r\n AssignedDate: followUpDate,\r\n CommentFlags: flags,\r\n Outcome: outcomes\r\n };\r\n var formValid = document.querySelector('#intel-gather-form form');\r\n if (formValid && formValid.reportValidity()) {\r\n $.ajax({\r\n url: window.AppSettings.ApiUrl + \"/api/v1/organisationcomments/add\",\r\n method: 'POST',\r\n data: JSON.stringify(message),\r\n dataType: 'json',\r\n contentType: 'application/json',\r\n success: function (res) {\r\n if (res && res.length > 0) {\r\n res.forEach(function (response) {\r\n if (response.Success) {\r\n $.notify({\r\n title: '<strong>Success!</strong>',\r\n message: \"Your message has been submitted\",\r\n icon: \"fa-solid fa-circle-check\"\r\n }, {\r\n type: 'success',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n $('#btn-intel-gather-form-submit').trigger('geographySubmit', ['success']);\r\n }\r\n else {\r\n $.notify({\r\n title: '<strong>Error!</strong>',\r\n message: response.Message,\r\n icon: \"fa-solid fa-triangle-exclamation\"\r\n }, {\r\n type: 'danger',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n }\r\n });\r\n }\r\n else {\r\n $.notify({\r\n title: '<strong>Error!</strong>',\r\n message: \"An error has occurred\",\r\n icon: \"fa-solid fa-triangle-exclamation\"\r\n }, {\r\n type: 'danger',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n }\r\n },\r\n error: function () {\r\n $.notify({\r\n title: '<strong>Error!</strong>',\r\n message: \"An error has occurred\",\r\n icon: \"fa-solid fa-triangle-exclamation\"\r\n }, {\r\n type: 'danger',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n },\r\n complete: function () {\r\n $('#intel-gather-form').modal('hide');\r\n }\r\n });\r\n }\r\n });\r\n $('#btn-intel-gather-form-submit-edit-message').off('click touchend').on('click touchend', function (e) {\r\n var _this = this;\r\n e.preventDefault();\r\n $(this).prop('disabled', true);\r\n var message = {\r\n CommentID: $('#intel-gather-form').find('#comment-id').val(),\r\n OutletServiceId: -1,\r\n Comment: $('#intel-gather-form-message').val(),\r\n //SubjectType: subjectType,\r\n SubjectID: $('#intel-gather-form').find('#subject-id').val(),\r\n };\r\n var formValid = document.querySelector('#intel-gather-form form');\r\n if (formValid && formValid.reportValidity()) {\r\n $.ajax({\r\n url: window.AppSettings.ApiUrl + \"/api/v1/organisationcomments/edit\",\r\n method: 'POST',\r\n data: JSON.stringify(message),\r\n dataType: 'json',\r\n contentType: 'application/json',\r\n success: function (res) {\r\n if (res && res.length > 0) {\r\n res.forEach(function (response) {\r\n if (response.Success) {\r\n if ($('#comments-table').length) {\r\n $('#comments-table').DataTable().ajax.reload();\r\n $.notify({\r\n title: '<strong>Success!</strong>',\r\n message: \"The comment has been updated. The table is fetching new data.\",\r\n icon: \"fa-solid fa-circle-check\"\r\n }, {\r\n type: 'success',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n }\r\n }\r\n else {\r\n $.notify({\r\n title: '<strong>Error!</strong>',\r\n message: response.Message,\r\n icon: \"fa-solid fa-triangle-exclamation\"\r\n }, {\r\n type: 'danger',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n }\r\n });\r\n }\r\n else {\r\n $.notify({\r\n title: '<strong>Error!</strong>',\r\n message: \"An error has occurred\",\r\n icon: \"fa-solid fa-triangle-exclamation\"\r\n }, {\r\n type: 'danger',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n }\r\n },\r\n error: function () {\r\n $.notify({\r\n title: '<strong>Error!</strong>',\r\n message: \"An error has occurred\",\r\n icon: \"fa-solid fa-triangle-exclamation\"\r\n }, {\r\n type: 'danger',\r\n placement: {\r\n from: \"top\",\r\n align: \"right\"\r\n },\r\n delay: 4000,\r\n timer: 500,\r\n });\r\n },\r\n complete: function () {\r\n $(_this).prop('disabled', false);\r\n $('#intel-gather-form').modal('hide');\r\n },\r\n });\r\n }\r\n });\r\n $('#key-outcome-select').selectize({\r\n placeholder: \"Type or select outcome...\",\r\n onChange: function (value) {\r\n $('#key-outcome-select').parent().find('.selectize-control .items .item').removeClass('active');\r\n },\r\n plugins: [\"remove_button\"],\r\n });\r\n SetupMessageType();\r\n SetupFollowup();\r\n SetupTags();\r\n });\r\n // geography stuff\r\n // TODO: init this differently than default Init\r\n if ($('#intel-gather-form').data('form-type') === 'geography-comment') {\r\n teamContactsUrl = \"/Manage/TeamMembers/GetOutletContacts\";\r\n GetTeamMembers($('#intel-gather-form').find('#user-outlet-id').val());\r\n $('#intel-gather-form').find('#subject-type').val('Geography');\r\n $('#intel-gather-form select.geography-select.geography-select-dataset').selectize({\r\n onChange: function (value) {\r\n var $regionSelectize = $('#intel-gather-form select.geography-select.geography-select-region')[0].selectize;\r\n $regionSelectize.enable();\r\n $regionSelectize.clear();\r\n $regionSelectize.clearOptions();\r\n $regionSelectize.onSearchChange(\"\");\r\n }\r\n });\r\n $('#intel-gather-form select.geography-select.geography-select-region').on('change', function () {\r\n $('#intel-gather-form').find('#subject-id').val($(this).val());\r\n });\r\n $('#intel-gather-form select.geography-select.geography-select-region').selectize({\r\n create: false,\r\n valueField: 'OtherGeographyID',\r\n labelField: 'OtherTitle',\r\n searchField: 'OtherTitle',\r\n sortField: 'OtherTitle',\r\n plugins: ['remove_button'],\r\n delimiter: '|',\r\n dropdownParent: \"body\",\r\n preload: true,\r\n selectOnTab: true,\r\n openOnFocus: true,\r\n closeAfterSelect: false,\r\n hideSelected: true,\r\n placeholder: \"Select a geography\",\r\n load: function (query, callback) {\r\n $.ajax({\r\n url: \"/Manage/Download/LoadGeographies\",\r\n type: 'GET',\r\n dataType: 'json',\r\n data: {\r\n s: query,\r\n dataset: $('#intel-gather-form select.geography-select.geography-select-dataset').val()\r\n },\r\n error: function (data) {\r\n callback(data);\r\n },\r\n beforeSend: function () {\r\n $('#intel-gather-form select.geography-select.geography-select-region')[0].selectize.settings.placeholder = \"Loading geographies...\";\r\n $('#intel-gather-form select.geography-select.geography-select-region')[0].selectize.updatePlaceholder();\r\n $('#intel-gather-form select.geography-select.geography-select-region')[0].selectize.disable();\r\n },\r\n success: function (data) {\r\n $('#intel-gather-form select.geography-select.geography-select-region')[0].selectize.settings.placeholder = \"Select a geography\";\r\n $('#intel-gather-form select.geography-select.geography-select-region')[0].selectize.updatePlaceholder();\r\n $('#intel-gather-form select.geography-select.geography-select-region')[0].selectize.enable();\r\n callback(data.Results);\r\n },\r\n });\r\n }\r\n });\r\n }\r\n }\r\n IntelGatherForm.Init = Init;\r\n function GetTeamMembers(outletid) {\r\n if (outletid && outletid > 0 && contacts && contacts.length === 0) {\r\n $.ajax({\r\n method: 'POST',\r\n url: teamContactsUrl,\r\n data: JSON.stringify({ outletId: outletid }),\r\n contentType: 'application/json',\r\n beforeSend: function () {\r\n $('#follow-up-assignee-select').selectize({\r\n create: false,\r\n sortField: 'text'\r\n });\r\n $('#follow-up-assignee-select')[0].selectize.settings.placeholder = \"Loading your team members...\";\r\n $('#follow-up-assignee-select')[0].selectize.updatePlaceholder();\r\n $('#follow-up-assignee-select')[0].selectize.disable();\r\n },\r\n success: function (response) {\r\n if (response && response.Success && response.Data && response.Data.length > 0) {\r\n var data = response.Data.map(function (contact) {\r\n //const emailParts = contact.Email?.split('@');\r\n //var emailStart = \"\";\r\n //var emailAt = \"\";\r\n //if (emailParts && emailParts.length == 2) {\r\n // emailStart = emailParts[0];\r\n // emailAt = emailParts[1];\r\n //}\r\n return {\r\n ProfileID: contact.ProfileID,\r\n FullName: contact.FullName,\r\n Email: contact.Email,\r\n ContactID: contact.ContactID\r\n };\r\n });\r\n // Clear previous options\r\n //$('#follow-up-assignee-select').empty();\r\n // Initialize or reinitialize Selectize after adding the options\r\n //var selectize = $('#follow-up-assignee-select')[0].selectize;\r\n //if (selectize) {\r\n // selectize.destroy();\r\n //}\r\n // Add the new options dynamically\r\n data.forEach(function (contact) {\r\n $('#follow-up-assignee-select')[0].selectize.addOption({ value: contact.ProfileID, text: contact.FullName + \" (\" + contact.Email + \")\" });\r\n //$('#follow-up-assignee-select').append(\r\n // $('<option>', {\r\n // value: contact.ProfileID,\r\n // text: contact.FullName + \" (\" + contact.Email + \")\"\r\n // })\r\n //);\r\n });\r\n // Re-initialize Selectize\r\n //$('#follow-up-assignee-select').selectize({\r\n // create: false,\r\n // sortField: 'text'\r\n //});\r\n //if (data.length > 0) {\r\n // $('#follow-up-assignee-select')[0].selectize.removeOption(-1);\r\n // $('#follow-up-assignee-select')[0].selectize.refreshOptions();\r\n //}\r\n $('#follow-up-assignee-select')[0].selectize.settings.placeholder = 'Select an assignee from your team';\r\n $('#follow-up-assignee-select')[0].selectize.updatePlaceholder();\r\n // Enable the select element after loading options\r\n $('#follow-up-assignee-select')[0].selectize.enable();\r\n }\r\n },\r\n error: function (response) { },\r\n complete: function () { }\r\n });\r\n }\r\n }\r\n function SetupFollowupDate() {\r\n $('#intel-gather-form input[name=\"date\"]').daterangepicker({\r\n singleDatePicker: true,\r\n showDropdowns: true,\r\n minYear: parseInt(moment().format('YYYY'), 10),\r\n minDate: moment(),\r\n maxYear: parseInt(moment().format('YYYY'), 10) + 2,\r\n locale: {\r\n format: 'DD/MM/YYYY'\r\n }\r\n }, function (start, end, label) { });\r\n }\r\n function SetupMessageType() {\r\n $('input[name=\"message-type\"]').off('click touchend').on('click touchend', function () { });\r\n }\r\n function SetupFollowup() {\r\n $('input[name=\"follow-up-select\"]').off('click touchend').on('click touchend', function () {\r\n if ($('input[name=\"follow-up-select\"]:checked').length > 0\r\n && $('input[name=\"follow-up-select\"]:checked').val() === $(this).val()\r\n && $(this).val() === '1') {\r\n $('.follow-up-group').show();\r\n $('#follow-up-date').prop('required', true);\r\n }\r\n else {\r\n $('.follow-up-group').hide();\r\n $('#follow-up-date').prop('required', false);\r\n }\r\n });\r\n SetupFollowupDate();\r\n }\r\n function SetupTags() {\r\n function BtnToggleFlag($btn, $input) {\r\n function EnableTag() {\r\n $btn.addClass(\"flag-active\");\r\n $input.prop('checked', true);\r\n }\r\n function DisableTag() {\r\n $btn.removeClass(\"flag-active\");\r\n $input.prop('checked', false);\r\n }\r\n if ($input.prop('checked') === false) {\r\n EnableTag();\r\n }\r\n else {\r\n DisableTag();\r\n }\r\n }\r\n $('#btn-flag-phone').off('click touchend').on('click touchend', function (e) {\r\n e.preventDefault();\r\n BtnToggleFlag($(this), $('#intel-flag-phone'));\r\n });\r\n $('#btn-flag-user').off('click touchend').on('click touchend', function (e) {\r\n e.preventDefault();\r\n BtnToggleFlag($(this), $('#intel-flag-user'));\r\n });\r\n $('#btn-flag-email').off('click touchend').on('click touchend', function (e) {\r\n e.preventDefault();\r\n BtnToggleFlag($(this), $('#intel-flag-email'));\r\n });\r\n $('#btn-flag-important').off('click touchend').on('click touchend', function (e) {\r\n e.preventDefault();\r\n BtnToggleFlag($(this), $('#intel-flag-important'));\r\n });\r\n $('#btn-flag-favourite').off('click touchend').on('click touchend', function (e) {\r\n e.preventDefault();\r\n BtnToggleFlag($(this), $('#intel-flag-favourite'));\r\n });\r\n }\r\n})(IntelGatherForm || (IntelGatherForm = {}));\r\n"]}