{"version":3,"file":"notificationMonitor-b68daa53.js","sources":["../../../app/javascript/common/components/onestopNotification/notificationManager.ts","../../../app/javascript/common/components/onestopNotification/notification-monitor.vue","../../../app/javascript/common/components/onestopNotification/notification-monitor.vue?vue&type=template&lang.js","../../../app/javascript/common/components/onestopNotification/notificationMonitor.ts"],"sourcesContent":["import {Hash} from \"~/interfaces/hashInterfaces\";\nimport Vue from \"vue\";\n\nenum NotificationType {\n unclaimedRecord = \"unclaimed_record\"\n}\n\nexport class NotificationManager {\n collection: Array = [];\n\n notificationTypes: {[key: string]: {type: NotificationType, idKey: string}} = {\n unclaimed_record: {\n type: NotificationType.unclaimedRecord,\n idKey: \"unclaimed_record_id\"\n }\n };\n\n constructor() {\n this.init();\n }\n\n findOrInitLocalNotifications(): Array {\n let localNotifications: string = localStorage.getItem('notifications');\n if ([\"undefined\", null, undefined].includes(localNotifications)) {\n localStorage.setItem('notifications', JSON.stringify([]));\n }\n return JSON.parse(localStorage.getItem('notifications'));\n }\n\n reconcileNotifications(serverNotifications, localNotifications): void {\n const keepNotifications = [];\n Object.keys(this.notificationTypes).forEach(key => {\n let {type, idKey} = this.notificationTypes[key];\n\n localNotifications.filter(n => n.type === type).forEach(ln => {\n const target = serverNotifications.find(sn => {\n return (sn[idKey] === ln[idKey]);\n });\n if (target) {\n delete target.isSeen;\n keepNotifications.push(Object.assign(ln, target))\n }\n });\n\n serverNotifications.forEach(n => {\n const target = keepNotifications.find(kn => {\n return (kn[idKey] === n[idKey]);\n });\n if (!target) keepNotifications.push(Object.assign({}, n))\n })\n });\n Vue.set(this, \"collection\", keepNotifications.slice());\n }\n\n async init() {\n const serverNotifications = await this.getNotifications();\n const localNotifications = this.findOrInitLocalNotifications();\n this.reconcileNotifications(serverNotifications, localNotifications);\n this.syncNotifications();\n }\n\n markAsSeen(notification) {\n notification.isSeen = true;\n this.syncNotifications()\n }\n\n async getNotifications() {\n const res = await $.ajax({\n method: \"GET\",\n url: \"/notifications\",\n headers: {\n Accepts: \"application/json\"\n }\n });\n const {notifications} = res;\n return notifications;\n }\n\n syncNotifications(): void {\n localStorage.setItem(\"notifications\", JSON.stringify(this.collection.slice()))\n }\n}\n\n","\n\n","\n
\n \n
    \n\n
  • \n \n
  • \n
\n
\n","import Vue from \"vue\";\nimport NotificationMonitor from \"./notification-monitor.vue\"\n\nconst onReady = function () {\n \n if ((window as any).ONE_STOP) {\n const $rootElements = $(\"div[data-vue-notification-monitor]\");\n\n $rootElements.each((ind, el) => {\n new Vue({\n el: el,\n render: h => h(NotificationMonitor),\n })\n });\n }\n};\n\n\n$(onReady);"],"names":["NotificationManager","constructor","this","collection","notificationTypes","unclaimed_record","type","idKey","init","findOrInitLocalNotifications","localNotifications","localStorage","getItem","includes","setItem","JSON","stringify","parse","reconcileNotifications","serverNotifications","keepNotifications","Object","keys","forEach","key","filter","n","ln","target","find","sn","isSeen","push","assign","kn","Vue","set","slice","async","getNotifications","syncNotifications","markAsSeen","notification","res","$","ajax","method","url","headers","Accepts","notifications","__vue2_script","extend","data","notificationManager","mounted","document","on","beforeDestroy","off","methods","keyFor","markAndNavigate","window","location","computed","unseenNotifications","_vm","_h","$createElement","_c","_self","staticClass","attrs","id","_v","_s","length","_l","click","$event","message","sub_message","_e","ONE_STOP","each","ind","el","render","h","NotificationMonitor"],"mappings":"mGAOO,MAAMA,EAUXC,cATAC,KAAAC,WAA0B,GAEoDD,KAAAE,kBAAA,CAC5EC,iBAAkB,CAChBC,KAAM,mBACNC,MAAO,wBAKTL,KAAKM,MACP,CAEAC,+BACM,IAAAC,EAA6BC,aAAaC,QAAQ,iBAItD,MAHI,CAAC,YAAa,UAAM,GAAWC,SAASH,IAC1CC,aAAaG,QAAQ,gBAAiBC,KAAKC,UAAU,KAEhDD,KAAKE,MAAMN,aAAaC,QAAQ,iBACzC,CAEAM,uBAAuBC,EAAqBT,GAC1C,MAAMU,EAAoB,GAC1BC,OAAOC,KAAKpB,KAAKE,mBAAmBmB,SAAeC,IACjD,IAAIlB,KAACA,E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