diff --git a/js/dist/forum.js b/js/dist/forum.js index 80ca79a..744c2af 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -module.exports=function(t){var a={};function e(o){if(a[o])return a[o].exports;var n=a[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,e),n.l=!0,n.exports}return e.m=t,e.c=a,e.d=function(t,a,o){e.o(t,a)||Object.defineProperty(t,a,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,a){if(1&a&&(t=e(t)),8&a)return t;if(4&a&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&a&&"string"!=typeof t)for(var n in t)e.d(o,n,function(a){return t[a]}.bind(null,n));return o},e.n=function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(a,"a",a),a},e.o=function(t,a){return Object.prototype.hasOwnProperty.call(t,a)},e.p="",e(e.s=18)}([function(t,a){t.exports=flarum.core.compat.app},function(t,a){t.exports=flarum.core.compat.Model},function(t,a){t.exports=flarum.core.compat.extend},function(t,a){t.exports=flarum.core.compat["components/DiscussionComposer"]},function(t,a){t.exports=flarum.core.compat["components/Button"]},function(t,a){t.exports=flarum.core.compat["models/User"]},function(t,a){t.exports=flarum.core.compat["utils/mixin"]},function(t,a){t.exports=flarum.core.compat["components/Page"]},function(t,a){t.exports=flarum.core.compat.Component},function(t,a){t.exports=flarum.core.compat["components/LoadingIndicator"]},function(t,a){t.exports=flarum.core.compat["helpers/avatar"]},function(t,a){t.exports=flarum.core.compat["helpers/icon"]},function(t,a){t.exports=flarum.core.compat["helpers/humanTime"]},function(t,a){t.exports=flarum.core.compat["utils/string"]},function(t,a){t.exports=flarum.core.compat["components/HeaderSecondary"]},function(t,a){t.exports=flarum.core.compat["components/NotificationsDropdown"]},function(t,a){t.exports=flarum.core.compat["components/Alert"]},,function(t,a,e){"use strict";e.r(a);var o=e(2),n=e(5),r=e.n(n),i=e(1),s=e.n(i);function p(t,a){t.prototype=Object.create(a.prototype),t.prototype.constructor=t,t.__proto__=a}var c=e(6),f=function(t){function a(){return t.apply(this,arguments)||this}return p(a,t),a}(e.n(c)()(s.a,{user:s.a.hasOne("user"),content:s.a.attribute("content"),title:s.a.attribute("title"),relationships:s.a.attribute("relationships"),updatedAt:s.a.attribute("updatedAt",s.a.transformDate)})),u=e(7),d=e.n(u),l=e(8),h=e.n(l),y=e(9),g=e.n(y),v=e(3),x=e.n(v),b=e(10),N=e.n(b),w=e(11),O=e.n(w),j=e(12),A=e.n(j),C=e(13),_=e(4),P=e.n(_),k=function(t){function a(){return t.apply(this,arguments)||this}p(a,t);var e=a.prototype;return e.init=function(){this.loading=!1},e.config=function(t){t&&$(".draft--delete").on("click tap",function(t){t.stopPropagation()})},e.view=function(){var t=this,a=app.cache.drafts||[];return m("div",{className:"NotificationList RequestsList"},m("div",{className:"NotificationList-header"},m("h4",{className:"App-titleControl App-titleControl--text"},app.translator.trans("fof-drafts.forum.dropdown.title"))),m("div",{className:"NotificationList-content"},m("ul",{className:"NotificationGroup-content"},a.length?a.sort(function(t,a){return a.updatedAt()-t.updatedAt()}).map(function(a){return m("li",null,m("a",{onclick:t.showComposer.bind(t,a),className:"Notification draft--item"},N()(a.user()),O()("fas fa-edit",{className:"Notification-icon"}),m("span",{className:"Notification-content"},a.title()),A()(a.updatedAt()),P.a.component({icon:"fas fa-times",style:"float: right; z-index: 20;",className:"Button Button--icon Button--link draft--delete",title:app.translator.trans("fof-drafts.forum.dropdown.button"),onclick:t.deleteDraft.bind(t,a)}),m("div",{className:"Notification-excerpt"},Object(C.truncate)(a.content(),200))))}):this.loading?g.a.component({className:"LoadingIndicator--block"}):m("div",{className:"NotificationList-empty"},app.translator.trans("fof-drafts.forum.dropdown.empty_text")))))},e.deleteDraft=function(t){this.loading=!0,window.confirm(app.translator.trans("fof-drafts.forum.dropdown.alert"))&&(t.delete(),app.cache.drafts.some(function(a,e){a.id()===t.id()&&app.cache.drafts.splice(e,1)}),app.composer.hide(),this.loading=!1)},e.showComposer=function(t){if(!this.loading){var a=m.deferred(),e={originalContent:t.content(),title:t.title(),user:app.session.user,draft:t};t.relationships()&&Object.keys(t.relationships()).forEach(function(a){t.relationships()[a].data.map(function(e,o){t.relationships()[a].data[o]=app.store.getById(e.type,e.id)}),e[a]=t.relationships()[a].data});var o=new x.a(e);return app.composer.load(o),app.composer.show(),a.resolve(o),a.promise}},e.load=function(){var t=this;app.cache.drafts||(this.loading=!0,m.redraw(),app.store.find("drafts").then(function(t){delete t.payload,app.cache.drafts=t}).catch(function(){}).then(function(){t.loading=!1,m.redraw()}))},a}(h.a),D=function(t){function a(){return t.apply(this,arguments)||this}p(a,t);var e=a.prototype;return e.init=function(){t.prototype.init.call(this),app.history.push("drafts"),this.list=new k,this.list.load(),this.bodyClass="App--drafts"},e.view=function(){return m("div",{className:"DraftsPage"},this.list.render())},a}(d.a),B=e(0),S=e.n(B),L=e(14),M=e.n(L),I=e(15),T=function(t){function a(){return t.apply(this,arguments)||this}p(a,t),a.initProps=function(a){a.label=a.label||app.translator.trans("fof-drafts.forum.dropdown.tooltip"),a.icon=a.icon||"fas fa-edit",t.initProps.call(this,a)};var e=a.prototype;return e.init=function(){t.prototype.init.call(this),this.list=new k},e.goToRoute=function(){m.route(app.route("drafts"))},e.getUnreadCount=function(){return app.cache.drafts?app.cache.drafts.length:app.session.user.data.relationships.drafts.data.length},e.getNewCount=function(){return app.cache.drafts?app.cache.drafts.length:app.session.user.data.relationships.drafts.data.length},a}(e.n(I).a),R=e(16),z=e.n(R);app.initializers.add("fof-drafts",function(){app.store.models.drafts=f,r.a.prototype.drafts=s.a.hasMany("drafts"),app.routes.drafts={path:"/drafts",component:m(D,null)},Object(o.extend)(x.a.prototype,"headerItems",function(t){var a=this;app.forum.attribute("canSaveDrafts")&&t.add("save-draft",P.a.component({icon:"fas fa-save",className:"Button Button--icon Button--link",style:"margin: 0 10px 2px -10px;",title:app.translator.trans("fof-drafts.forum.composer.title"),onclick:function(){a.draft?(delete a.draft.data.attributes.relationships,a.draft.save(a.data()).then(function(t){app.cache.drafts||(app.cache.drafts=[]),app.cache.drafts.some(function(a,e){if(a.id()===t.id()){var o=new Date;t.data.attributes.updatedAt=o.toString(),app.cache.drafts[e]=t}})})):app.store.createRecord("drafts").save(a.data()).then(function(t){app.cache.drafts?app.cache.drafts.push(t):app.session.user.data.relationships.drafts.data.push(t),m.redraw()}),app.alerts.show(a.successAlert=new z.a({type:"success",children:app.translator.trans("fof-drafts.forum.composer.alert")})),app.composer.hide()}}),20)}),Object(o.extend)(x.a.prototype,"init",function(){var t=this;Object.keys(this.props).forEach(function(a){["originalContent","title","user"].includes(a)?"title"===a&&(t.title=m.prop(t.props.title)):t[a]=t.props[a]})}),Object(o.extend)(M.a.prototype,"items",function(t){S.a.session.user&&(S.a.session.user.data.relationships.drafts&&S.a.session.user.data.relationships.drafts.data.length&&!S.a.cache.drafts||S.a.cache.drafts&&0!==S.a.cache.drafts.length)&&t.add("Drafts",m(T,null),20)})})}]); +module.exports=function(t){var e={};function o(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=t,o.c=e,o.d=function(t,e,a){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(a,n,function(e){return t[e]}.bind(null,n));return a},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=18)}([function(t,e){t.exports=flarum.core.compat.app},function(t,e){t.exports=flarum.core.compat.Model},function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat["components/DiscussionComposer"]},function(t,e){t.exports=flarum.core.compat["components/Button"]},function(t,e){t.exports=flarum.core.compat["models/User"]},function(t,e){t.exports=flarum.core.compat["utils/mixin"]},function(t,e){t.exports=flarum.core.compat["components/Page"]},function(t,e){t.exports=flarum.core.compat.Component},function(t,e){t.exports=flarum.core.compat["components/LoadingIndicator"]},function(t,e){t.exports=flarum.core.compat["helpers/avatar"]},function(t,e){t.exports=flarum.core.compat["helpers/icon"]},function(t,e){t.exports=flarum.core.compat["helpers/humanTime"]},function(t,e){t.exports=flarum.core.compat["utils/string"]},function(t,e){t.exports=flarum.core.compat["components/HeaderSecondary"]},function(t,e){t.exports=flarum.core.compat["components/NotificationsDropdown"]},function(t,e){t.exports=flarum.core.compat["components/Alert"]},,function(t,e,o){"use strict";o.r(e);var a=o(2),n=o(5),r=o.n(n),i=o(1),s=o.n(i);function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var p=o(6),f=function(t){function e(){return t.apply(this,arguments)||this}return c(e,t),e}(o.n(p)()(s.a,{user:s.a.hasOne("user"),content:s.a.attribute("content"),title:s.a.attribute("title"),relationships:s.a.attribute("relationships"),updatedAt:s.a.attribute("updatedAt",s.a.transformDate)})),u=o(7),l=o.n(u),d=o(8),h=o.n(d),y=o(9),g=o.n(y),v=o(3),x=o.n(v),b=o(10),N=o.n(b),w=o(11),O=o.n(w),j=o(12),A=o.n(j),C=o(13),_=o(4),P=o.n(_),k=function(t){function e(){return t.apply(this,arguments)||this}c(e,t);var o=e.prototype;return o.init=function(){this.loading=!1},o.config=function(t){t&&$(".draft--delete").on("click tap",function(t){t.stopPropagation()})},o.view=function(){var t=this,e=app.cache.drafts||[];return m("div",{className:"NotificationList RequestsList"},m("div",{className:"NotificationList-header"},m("h4",{className:"App-titleControl App-titleControl--text"},app.translator.trans("fof-drafts.forum.dropdown.title"))),m("div",{className:"NotificationList-content"},m("ul",{className:"NotificationGroup-content"},e.length?e.sort(function(t,e){return e.updatedAt()-t.updatedAt()}).map(function(e){return m("li",null,m("a",{onclick:t.showComposer.bind(t,e),className:"Notification draft--item"},N()(e.user()),O()("fas fa-edit",{className:"Notification-icon"}),m("span",{className:"Notification-content"},e.title()),A()(e.updatedAt()),P.a.component({icon:"fas fa-times",style:"float: right; z-index: 20;",className:"Button Button--icon Button--link draft--delete",title:app.translator.trans("fof-drafts.forum.dropdown.button"),onclick:t.deleteDraft.bind(t,e)}),m("div",{className:"Notification-excerpt"},Object(C.truncate)(e.content(),200))))}):this.loading?g.a.component({className:"LoadingIndicator--block"}):m("div",{className:"NotificationList-empty"},app.translator.trans("fof-drafts.forum.dropdown.empty_text")))))},o.deleteDraft=function(t){this.loading=!0,window.confirm(app.translator.trans("fof-drafts.forum.dropdown.alert"))&&(t.delete(),app.cache.drafts.some(function(e,o){e.id()===t.id()&&app.cache.drafts.splice(o,1)}),app.composer.hide(),this.loading=!1)},o.showComposer=function(t){if(!this.loading){var e=m.deferred(),o={originalContent:t.content(),title:t.title(),user:app.session.user,draft:t};t.relationships()&&Object.keys(t.relationships()).forEach(function(e){t.relationships()[e].data.map(function(o,a){t.relationships()[e].data[a]=app.store.getById(o.type,o.id)}),o[e]=t.relationships()[e].data});var a=new x.a(o);return app.composer.load(a),app.composer.show(),e.resolve(a),e.promise}},o.load=function(){var t=this;app.cache.drafts||(this.loading=!0,m.redraw(),app.store.find("drafts").then(function(t){delete t.payload,app.cache.drafts=t}).catch(function(){}).then(function(){t.loading=!1,m.redraw()}))},e}(h.a),D=function(t){function e(){return t.apply(this,arguments)||this}c(e,t);var o=e.prototype;return o.init=function(){t.prototype.init.call(this),app.history.push("drafts"),this.list=new k,this.list.load(),this.bodyClass="App--drafts"},o.view=function(){return m("div",{className:"DraftsPage"},this.list.render())},e}(l.a),B=o(0),S=o.n(B),L=o(14),M=o.n(L),I=o(15),T=function(t){function e(){return t.apply(this,arguments)||this}c(e,t),e.initProps=function(e){e.label=e.label||app.translator.trans("fof-drafts.forum.dropdown.tooltip"),e.icon=e.icon||"fas fa-edit",t.initProps.call(this,e)};var o=e.prototype;return o.init=function(){t.prototype.init.call(this),this.list=new k},o.goToRoute=function(){m.route(app.route("drafts"))},o.getUnreadCount=function(){return app.cache.drafts?app.cache.drafts.length:app.session.user.drafts().length},o.getNewCount=function(){return app.cache.drafts?app.cache.drafts.length:app.session.user.drafts().length},e}(o.n(I).a),R=o(16),z=o.n(R);app.initializers.add("fof-drafts",function(){app.store.models.drafts=f,r.a.prototype.drafts=s.a.hasMany("drafts"),app.routes.drafts={path:"/drafts",component:m(D,null)},Object(a.extend)(x.a.prototype,"headerItems",function(t){var e=this;app.forum.attribute("canSaveDrafts")&&t.add("save-draft",P.a.component({icon:"fas fa-save",className:"Button Button--icon Button--link",style:"margin: 0 10px 2px -10px;",title:app.translator.trans("fof-drafts.forum.composer.title"),onclick:function(){e.draft?(delete e.draft.data.attributes.relationships,e.draft.save(e.data()).then(function(t){app.cache.drafts||(app.cache.drafts=[]),app.cache.drafts.some(function(e,o){if(e.id()===t.id()){var a=new Date;t.data.attributes.updatedAt=a.toString(),app.cache.drafts[o]=t}})})):app.store.createRecord("drafts").save(e.data()).then(function(t){app.cache.drafts?app.cache.drafts.push(t):app.session.user.data.relationships.drafts.data.push(t),m.redraw()}),app.alerts.show(e.successAlert=new z.a({type:"success",children:app.translator.trans("fof-drafts.forum.composer.alert")})),app.composer.hide()}}),20)}),Object(a.extend)(x.a.prototype,"init",function(){var t=this;Object.keys(this.props).forEach(function(e){["originalContent","title","user"].includes(e)?"title"===e&&(t.title=m.prop(t.props.title)):t[e]=t.props[e]})}),Object(a.extend)(M.a.prototype,"items",function(t){S.a.session.user&&(S.a.session.user.drafts()&&S.a.session.user.drafts().length&&!S.a.cache.drafts||S.a.cache.drafts&&0!==S.a.cache.drafts.length)&&t.add("Drafts",m(T,null),20)})})}]); //# sourceMappingURL=forum.js.map \ No newline at end of file diff --git a/js/dist/forum.js.map b/js/dist/forum.js.map index 8bfeb49..469805d 100644 --- a/js/dist/forum.js.map +++ b/js/dist/forum.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://@fof/drafts/webpack/bootstrap","webpack://@fof/drafts/external \"flarum.core.compat['app']\"","webpack://@fof/drafts/external \"flarum.core.compat['Model']\"","webpack://@fof/drafts/external \"flarum.core.compat['extend']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/DiscussionComposer']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/Button']\"","webpack://@fof/drafts/external \"flarum.core.compat['models/User']\"","webpack://@fof/drafts/external \"flarum.core.compat['utils/mixin']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/Page']\"","webpack://@fof/drafts/external \"flarum.core.compat['Component']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/LoadingIndicator']\"","webpack://@fof/drafts/external \"flarum.core.compat['helpers/avatar']\"","webpack://@fof/drafts/external \"flarum.core.compat['helpers/icon']\"","webpack://@fof/drafts/external \"flarum.core.compat['helpers/humanTime']\"","webpack://@fof/drafts/external \"flarum.core.compat['utils/string']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/HeaderSecondary']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/NotificationsDropdown']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/Alert']\"","webpack://@fof/drafts/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/drafts/./src/forum/models/Draft.js","webpack://@fof/drafts/./src/forum/components/DraftsList.js","webpack://@fof/drafts/./src/forum/components/DraftsPage.js","webpack://@fof/drafts/./src/forum/components/DraftsDropdown.js","webpack://@fof/drafts/./src/forum/index.js","webpack://@fof/drafts/./src/forum/addDraftsDropdown.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","_inheritsLoose","subClass","superClass","constructor","__proto__","Draft","mixin","Model","user","hasOne","content","attribute","title","relationships","updatedAt","transformDate","FlagList","init","this","loading","config","isIntialized","$","on","event","stopPropagation","view","_this","drafts","app","cache","className","translator","trans","length","sort","a","b","map","draft","onclick","showComposer","avatar","icon","humanTime","Button","component","style","deleteDraft","truncate","LoadingIndicator","window","confirm","some","cacheDraft","id","splice","composer","hide","deferred","data","originalContent","session","keys","forEach","relationship","model","store","getById","type","DiscussionComposer","load","show","resolve","promise","_this2","redraw","find","then","response","payload","Component","DraftsPage","_Page","history","push","list","DraftsList","bodyClass","render","Page","DraftsDropdown","initProps","props","label","_NotificationsDropdow","goToRoute","route","getUnreadCount","getNewCount","NotificationsDropdown","initializers","add","models","User","hasMany","routes","path","DraftsPage_DraftsPage","extend","items","forum","attributes","save","now","Date","toString","createRecord","alerts","successAlert","Alert","children","includes","prop","HeaderSecondary","DraftsDropdown_DraftsDropdown"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKh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IzDtE,EAAE2G,WAId/C,IAAIyF,OAAO9C,KAAK7C,EAAK4F,aAAe,IAAIC,IAAM,CAACnD,KAAM,UAAWoD,SAAU5F,IAAIG,WAAWC,MAAM,sCAC/FJ,IAAI4B,SAASC,UAGnB,MAIVmD,iBAAOvC,IAAmB7E,UAAW,OAAQ,WAAY,IAAAkF,EAAAzD,KACrD3C,OAAOwF,KAAK7C,KAAK2E,OAAO7B,QAAQ,SAAA5E,GACvB,CAAC,kBAAmB,QAAS,QAAQsI,SAAStI,GAEhC,UAARA,IACPuF,EAAK/D,MAAQ3C,EAAE0J,KAAKhD,EAAKkB,MAAMjF,QAF/B+D,EAAKvF,GAAOuF,EAAKkB,MAAMzG,OCxDnCyH,iBAAOe,IAAgBnI,UAAW,QAAS,SAASqH,GAC3CjF,IAAIiC,QAAQtD,OACZqB,IAAIiC,QAAQtD,KAAKoD,KAAK/C,cAAce,QAAUC,IAAIiC,QAAQtD,KAAKoD,KAAK/C,cAAce,OAAOgC,KAAK1B,SAAWL,IAAIC,MAAMF,QAAYC,IAAIC,MAAMF,QAAsC,IAA5BC,IAAIC,MAAMF,OAAOM,SACrK4E,EAAMR,IAAI,SAAUrI,EAAC4J,EAAD,MAAmB","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 18);\n","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['Model'];","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['components/DiscussionComposer'];","module.exports = flarum.core.compat['components/Button'];","module.exports = flarum.core.compat['models/User'];","module.exports = flarum.core.compat['utils/mixin'];","module.exports = flarum.core.compat['components/Page'];","module.exports = flarum.core.compat['Component'];","module.exports = flarum.core.compat['components/LoadingIndicator'];","module.exports = flarum.core.compat['helpers/avatar'];","module.exports = flarum.core.compat['helpers/icon'];","module.exports = flarum.core.compat['helpers/humanTime'];","module.exports = flarum.core.compat['utils/string'];","module.exports = flarum.core.compat['components/HeaderSecondary'];","module.exports = flarum.core.compat['components/NotificationsDropdown'];","module.exports = flarum.core.compat['components/Alert'];","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\nimport Model from 'flarum/Model';\r\nimport mixin from 'flarum/utils/mixin';\r\n\r\nexport default class Draft extends mixin(Model, {\r\n user: Model.hasOne('user'),\r\n content: Model.attribute('content'),\r\n title: Model.attribute('title'),\r\n relationships: Model.attribute('relationships'),\r\n updatedAt: Model.attribute('updatedAt', Model.transformDate)\r\n}) {}\r\n","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport Component from 'flarum/Component';\r\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\r\nimport DiscussionComposer from 'flarum/components/DiscussionComposer';\r\nimport avatar from 'flarum/helpers/avatar';\r\nimport icon from 'flarum/helpers/icon';\r\nimport humanTime from 'flarum/helpers/humanTime';\r\nimport {truncate} from 'flarum/utils/string';\r\nimport Button from 'flarum/components/Button';\r\n\r\nexport default class FlagList extends Component {\r\n init() {\r\n\r\n this.loading = false;\r\n }\r\n\r\n config(isIntialized) {\r\n if (!isIntialized) return;\r\n\r\n $(\".draft--delete\").on('click tap', function (event) {\r\n event.stopPropagation();\r\n });\r\n }\r\n\r\n view() {\r\n const drafts = app.cache.drafts || [];\r\n\r\n return (\r\n
\r\n
\r\n

{app.translator.trans('fof-drafts.forum.dropdown.title')}

\r\n
\r\n
\r\n \r\n
\r\n
\r\n );\r\n }\r\n\r\n deleteDraft(draft) {\r\n this.loading = true;\r\n\r\n if (!window.confirm(app.translator.trans('fof-drafts.forum.dropdown.alert'))) return;\r\n\r\n draft.delete();\r\n app.cache.drafts.some((cacheDraft, i) => {\r\n if (cacheDraft.id() === draft.id()) {\r\n app.cache.drafts.splice(i, 1);\r\n }\r\n });\r\n app.composer.hide();\r\n\r\n this.loading = false;\r\n }\r\n\r\n\r\n showComposer(draft) {\r\n if (this.loading) return;\r\n\r\n const deferred = m.deferred();\r\n\r\n var data = {\r\n originalContent: draft.content(),\r\n title: draft.title(),\r\n user: app.session.user,\r\n draft\r\n };\r\n\r\n if (draft.relationships()) {\r\n Object.keys(draft.relationships()).forEach(relationship => {\r\n draft.relationships()[relationship].data.map((model, i) => {\r\n draft.relationships()[relationship].data[i] = app.store.getById(model.type, model.id)\r\n });\r\n data[relationship] = draft.relationships()[relationship].data\r\n });\r\n }\r\n\r\n var component = new DiscussionComposer(data);\r\n\r\n app.composer.load(component);\r\n app.composer.show();\r\n\r\n deferred.resolve(component);\r\n\r\n return deferred.promise;\r\n }\r\n\r\n load() {\r\n if (app.cache.drafts) {\r\n return;\r\n }\r\n\r\n this.loading = true;\r\n m.redraw();\r\n\r\n app.store.find('drafts')\r\n .then(response => {\r\n delete response.payload;\r\n app.cache.drafts = response;\r\n })\r\n .catch(() => {\r\n })\r\n .then(() => {\r\n this.loading = false;\r\n m.redraw();\r\n });\r\n }\r\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport Page from 'flarum/components/Page';\r\n\r\nimport DraftsList from './DraftsList';\r\n\r\nexport default class DraftsPage extends Page {\r\n init() {\r\n super.init();\r\n\r\n app.history.push('drafts');\r\n\r\n this.list = new DraftsList();\r\n this.list.load();\r\n\r\n this.bodyClass = 'App--drafts';\r\n }\r\n\r\n view() {\r\n return
{this.list.render()}
;\r\n }\r\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport NotificationsDropdown from 'flarum/components/NotificationsDropdown';\r\n\r\nimport DraftsList from './DraftsList';\r\n\r\nexport default class DraftsDropdown extends NotificationsDropdown {\r\n static initProps(props) {\r\n props.label = props.label || app.translator.trans('fof-drafts.forum.dropdown.tooltip');\r\n props.icon = props.icon || 'fas fa-edit';\r\n\r\n super.initProps(props);\r\n }\r\n\r\n init() {\r\n super.init();\r\n\r\n this.list = new DraftsList();\r\n }\r\n\r\n goToRoute() {\r\n m.route(app.route('drafts'));\r\n }\r\n\r\n getUnreadCount() {\r\n if (app.cache.drafts) {\r\n return app.cache.drafts.length\r\n }\r\n return app.session.user.data.relationships.drafts.data.length\r\n }\r\n\r\n getNewCount() {\r\n if (app.cache.drafts) {\r\n return app.cache.drafts.length\r\n }\r\n return app.session.user.data.relationships.drafts.data.length\r\n }\r\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport {extend} from 'flarum/extend';\r\nimport User from 'flarum/models/User';\r\nimport Model from 'flarum/Model';\r\nimport Draft from './models/Draft';\r\nimport DraftsPage from './components/DraftsPage';\r\nimport addDraftsDropdown from './addDraftsDropdown';\r\nimport DiscussionComposer from 'flarum/components/DiscussionComposer';\r\nimport Button from 'flarum/components/Button';\r\nimport Alert from 'flarum/components/Alert';\r\n\r\napp.initializers.add('fof-drafts', () => {\r\n app.store.models.drafts = Draft;\r\n User.prototype.drafts = Model.hasMany('drafts');\r\n\r\n app.routes.drafts = {path: '/drafts', component: };\r\n\r\n extend(DiscussionComposer.prototype, 'headerItems', function (items) {\r\n if (!app.forum.attribute('canSaveDrafts')) return;\r\n items.add('save-draft',\r\n Button.component({\r\n icon: 'fas fa-save',\r\n className: 'Button Button--icon Button--link',\r\n style: 'margin: 0 10px 2px -10px;',\r\n title: app.translator.trans('fof-drafts.forum.composer.title'),\r\n onclick: () => {\r\n if (this.draft) {\r\n delete this.draft.data.attributes.relationships;\r\n this.draft.save(this.data()).then(\r\n (draft) => {\r\n if (!app.cache.drafts) app.cache.drafts = [];\r\n app.cache.drafts.some((cacheDraft, i) => {\r\n if (cacheDraft.id() === draft.id()) {\r\n var now = new Date();\r\n draft.data.attributes.updatedAt = now.toString();\r\n app.cache.drafts[i] = draft;\r\n }\r\n });\r\n }\r\n );\r\n } else {\r\n app.store.createRecord('drafts').save(this.data()).then(\r\n (draft) => {\r\n if (!app.cache.drafts) {\r\n app.session.user.data.relationships.drafts.data.push(draft);\r\n } else {\r\n app.cache.drafts.push(draft);\r\n }\r\n m.redraw();\r\n }\r\n );\r\n }\r\n app.alerts.show(this.successAlert = new Alert({type: 'success', children: app.translator.trans('fof-drafts.forum.composer.alert')}));\r\n app.composer.hide();\r\n }\r\n })\r\n , 20);\r\n\r\n });\r\n\r\n extend(DiscussionComposer.prototype, 'init', function () {\r\n Object.keys(this.props).forEach(key => {\r\n if (!['originalContent', 'title', 'user'].includes(key)) {\r\n this[key] = this.props[key];\r\n } else if (key === 'title') {\r\n this.title = m.prop(this.props.title)\r\n }\r\n });\r\n });\r\n\r\n addDraftsDropdown();\r\n});\r\n","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport { extend } from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport HeaderSecondary from 'flarum/components/HeaderSecondary';\r\nimport DraftsDropdown from './components/DraftsDropdown';\r\n\r\nexport default function() {\r\n extend(HeaderSecondary.prototype, 'items', function(items) {\r\n if (!app.session.user) return;\r\n if ((app.session.user.data.relationships.drafts && app.session.user.data.relationships.drafts.data.length && !app.cache.drafts) || (app.cache.drafts && app.cache.drafts.length !== 0)) {\r\n items.add('Drafts', , 20);\r\n }\r\n });\r\n}\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://@fof/drafts/webpack/bootstrap","webpack://@fof/drafts/external \"flarum.core.compat['app']\"","webpack://@fof/drafts/external \"flarum.core.compat['Model']\"","webpack://@fof/drafts/external \"flarum.core.compat['extend']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/DiscussionComposer']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/Button']\"","webpack://@fof/drafts/external \"flarum.core.compat['models/User']\"","webpack://@fof/drafts/external \"flarum.core.compat['utils/mixin']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/Page']\"","webpack://@fof/drafts/external \"flarum.core.compat['Component']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/LoadingIndicator']\"","webpack://@fof/drafts/external \"flarum.core.compat['helpers/avatar']\"","webpack://@fof/drafts/external \"flarum.core.compat['helpers/icon']\"","webpack://@fof/drafts/external \"flarum.core.compat['helpers/humanTime']\"","webpack://@fof/drafts/external \"flarum.core.compat['utils/string']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/HeaderSecondary']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/NotificationsDropdown']\"","webpack://@fof/drafts/external \"flarum.core.compat['components/Alert']\"","webpack://@fof/drafts/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@fof/drafts/./src/forum/models/Draft.js","webpack://@fof/drafts/./src/forum/components/DraftsList.js","webpack://@fof/drafts/./src/forum/components/DraftsPage.js","webpack://@fof/drafts/./src/forum/components/DraftsDropdown.js","webpack://@fof/drafts/./src/forum/index.js","webpack://@fof/drafts/./src/forum/addDraftsDropdown.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","_inheritsLoose","subClass","superClass","constructor","__proto__","Draft","mixin","Model","user","hasOne","content","attribute","title","relationships","updatedAt","transformDate","FlagList","init","this","loading","config","isIntialized","$","on","event","stopPropagation","view","_this","drafts","app","cache","className","translator","trans","length","sort","a","b","map","draft","onclick","showComposer","avatar","icon","humanTime","Button","component","style","deleteDraft","truncate","LoadingIndicator","window","confirm","some","cacheDraft","id","splice","composer","hide","deferred","data","originalContent","session","keys","forEach","relationship","model","store","getById","type","DiscussionComposer","load","show","resolve","promise","_this2","redraw","find","then","response","payload","Component","DraftsPage","_Page","history","push","list","DraftsList","bodyClass","render","Page","DraftsDropdown","initProps","props","label","_NotificationsDropdow","goToRoute","route","getUnreadCount","getNewCount","NotificationsDropdown","initializers","add","models","User","hasMany","routes","path","DraftsPage_DraftsPage","extend","items","forum","attributes","save","now","Date","toString","createRecord","alerts","successAlert","Alert","children","includes","prop","HeaderSecondary","DraftsDropdown_DraftsDropdown"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxB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AAIC,MAAMF,OAAOyD,KAAK9C,GAFtBV,IAAIiC,QAAQtD,KAAKoD,KAAK/C,cAAce,OAAOgC,KAAKyB,KAAK9C,GAIzDtE,EAAE2G,WAId/C,IAAIyF,OAAO9C,KAAK7C,EAAK4F,aAAe,IAAIC,IAAM,CAACnD,KAAM,UAAWoD,SAAU5F,IAAIG,WAAWC,MAAM,sCAC/FJ,IAAI4B,SAASC,UAGnB,MAIVmD,iBAAOvC,IAAmB7E,UAAW,OAAQ,WAAY,IAAAkF,EAAAzD,KACrD3C,OAAOwF,KAAK7C,KAAK2E,OAAO7B,QAAQ,SAAA5E,GACvB,CAAC,kBAAmB,QAAS,QAAQsI,SAAStI,GAEhC,UAARA,IACPuF,EAAK/D,MAAQ3C,EAAE0J,KAAKhD,EAAKkB,MAAMjF,QAF/B+D,EAAKvF,GAAOuF,EAAKkB,MAAMzG,OCxDnCyH,iBAAOe,IAAgBnI,UAAW,QAAS,SAASqH,GAC3CjF,IAAIiC,QAAQtD,OACZqB,IAAIiC,QAAQtD,KAAKoB,UAAYC,IAAIiC,QAAQtD,KAAKoB,SAASM,SAAWL,IAAIC,MAAMF,QAAYC,IAAIC,MAAMF,QAAsC,IAA5BC,IAAIC,MAAMF,OAAOM,SAC9H4E,EAAMR,IAAI,SAAUrI,EAAC4J,EAAD,MAAmB","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 18);\n","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['Model'];","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['components/DiscussionComposer'];","module.exports = flarum.core.compat['components/Button'];","module.exports = flarum.core.compat['models/User'];","module.exports = flarum.core.compat['utils/mixin'];","module.exports = flarum.core.compat['components/Page'];","module.exports = flarum.core.compat['Component'];","module.exports = flarum.core.compat['components/LoadingIndicator'];","module.exports = flarum.core.compat['helpers/avatar'];","module.exports = flarum.core.compat['helpers/icon'];","module.exports = flarum.core.compat['helpers/humanTime'];","module.exports = flarum.core.compat['utils/string'];","module.exports = flarum.core.compat['components/HeaderSecondary'];","module.exports = flarum.core.compat['components/NotificationsDropdown'];","module.exports = flarum.core.compat['components/Alert'];","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\nimport Model from 'flarum/Model';\r\nimport mixin from 'flarum/utils/mixin';\r\n\r\nexport default class Draft extends mixin(Model, {\r\n user: Model.hasOne('user'),\r\n content: Model.attribute('content'),\r\n title: Model.attribute('title'),\r\n relationships: Model.attribute('relationships'),\r\n updatedAt: Model.attribute('updatedAt', Model.transformDate)\r\n}) {}\r\n","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport Component from 'flarum/Component';\r\nimport LoadingIndicator from 'flarum/components/LoadingIndicator';\r\nimport DiscussionComposer from 'flarum/components/DiscussionComposer';\r\nimport avatar from 'flarum/helpers/avatar';\r\nimport icon from 'flarum/helpers/icon';\r\nimport humanTime from 'flarum/helpers/humanTime';\r\nimport {truncate} from 'flarum/utils/string';\r\nimport Button from 'flarum/components/Button';\r\n\r\nexport default class FlagList extends Component {\r\n init() {\r\n\r\n this.loading = false;\r\n }\r\n\r\n config(isIntialized) {\r\n if (!isIntialized) return;\r\n\r\n $(\".draft--delete\").on('click tap', function (event) {\r\n event.stopPropagation();\r\n });\r\n }\r\n\r\n view() {\r\n const drafts = app.cache.drafts || [];\r\n\r\n return (\r\n
\r\n
\r\n

{app.translator.trans('fof-drafts.forum.dropdown.title')}

\r\n
\r\n
\r\n \r\n
\r\n
\r\n );\r\n }\r\n\r\n deleteDraft(draft) {\r\n this.loading = true;\r\n\r\n if (!window.confirm(app.translator.trans('fof-drafts.forum.dropdown.alert'))) return;\r\n\r\n draft.delete();\r\n app.cache.drafts.some((cacheDraft, i) => {\r\n if (cacheDraft.id() === draft.id()) {\r\n app.cache.drafts.splice(i, 1);\r\n }\r\n });\r\n app.composer.hide();\r\n\r\n this.loading = false;\r\n }\r\n\r\n\r\n showComposer(draft) {\r\n if (this.loading) return;\r\n\r\n const deferred = m.deferred();\r\n\r\n var data = {\r\n originalContent: draft.content(),\r\n title: draft.title(),\r\n user: app.session.user,\r\n draft\r\n };\r\n\r\n if (draft.relationships()) {\r\n Object.keys(draft.relationships()).forEach(relationship => {\r\n draft.relationships()[relationship].data.map((model, i) => {\r\n draft.relationships()[relationship].data[i] = app.store.getById(model.type, model.id)\r\n });\r\n data[relationship] = draft.relationships()[relationship].data\r\n });\r\n }\r\n\r\n var component = new DiscussionComposer(data);\r\n\r\n app.composer.load(component);\r\n app.composer.show();\r\n\r\n deferred.resolve(component);\r\n\r\n return deferred.promise;\r\n }\r\n\r\n load() {\r\n if (app.cache.drafts) {\r\n return;\r\n }\r\n\r\n this.loading = true;\r\n m.redraw();\r\n\r\n app.store.find('drafts')\r\n .then(response => {\r\n delete response.payload;\r\n app.cache.drafts = response;\r\n })\r\n .catch(() => {\r\n })\r\n .then(() => {\r\n this.loading = false;\r\n m.redraw();\r\n });\r\n }\r\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport Page from 'flarum/components/Page';\r\n\r\nimport DraftsList from './DraftsList';\r\n\r\nexport default class DraftsPage extends Page {\r\n init() {\r\n super.init();\r\n\r\n app.history.push('drafts');\r\n\r\n this.list = new DraftsList();\r\n this.list.load();\r\n\r\n this.bodyClass = 'App--drafts';\r\n }\r\n\r\n view() {\r\n return
{this.list.render()}
;\r\n }\r\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport NotificationsDropdown from 'flarum/components/NotificationsDropdown';\r\n\r\nimport DraftsList from './DraftsList';\r\n\r\nexport default class DraftsDropdown extends NotificationsDropdown {\r\n static initProps(props) {\r\n props.label = props.label || app.translator.trans('fof-drafts.forum.dropdown.tooltip');\r\n props.icon = props.icon || 'fas fa-edit';\r\n\r\n super.initProps(props);\r\n }\r\n\r\n init() {\r\n super.init();\r\n\r\n this.list = new DraftsList();\r\n }\r\n\r\n goToRoute() {\r\n m.route(app.route('drafts'));\r\n }\r\n\r\n getUnreadCount() {\r\n if (app.cache.drafts) {\r\n return app.cache.drafts.length\r\n }\r\n return app.session.user.drafts().length\r\n }\r\n\r\n getNewCount() {\r\n if (app.cache.drafts) {\r\n return app.cache.drafts.length\r\n }\r\n return app.session.user.drafts().length\r\n }\r\n}","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport {extend} from 'flarum/extend';\r\nimport User from 'flarum/models/User';\r\nimport Model from 'flarum/Model';\r\nimport Draft from './models/Draft';\r\nimport DraftsPage from './components/DraftsPage';\r\nimport addDraftsDropdown from './addDraftsDropdown';\r\nimport DiscussionComposer from 'flarum/components/DiscussionComposer';\r\nimport Button from 'flarum/components/Button';\r\nimport Alert from 'flarum/components/Alert';\r\n\r\napp.initializers.add('fof-drafts', () => {\r\n app.store.models.drafts = Draft;\r\n User.prototype.drafts = Model.hasMany('drafts');\r\n\r\n app.routes.drafts = {path: '/drafts', component: };\r\n\r\n extend(DiscussionComposer.prototype, 'headerItems', function (items) {\r\n if (!app.forum.attribute('canSaveDrafts')) return;\r\n items.add('save-draft',\r\n Button.component({\r\n icon: 'fas fa-save',\r\n className: 'Button Button--icon Button--link',\r\n style: 'margin: 0 10px 2px -10px;',\r\n title: app.translator.trans('fof-drafts.forum.composer.title'),\r\n onclick: () => {\r\n if (this.draft) {\r\n delete this.draft.data.attributes.relationships;\r\n this.draft.save(this.data()).then(\r\n (draft) => {\r\n if (!app.cache.drafts) app.cache.drafts = [];\r\n app.cache.drafts.some((cacheDraft, i) => {\r\n if (cacheDraft.id() === draft.id()) {\r\n var now = new Date();\r\n draft.data.attributes.updatedAt = now.toString();\r\n app.cache.drafts[i] = draft;\r\n }\r\n });\r\n }\r\n );\r\n } else {\r\n app.store.createRecord('drafts').save(this.data()).then(\r\n (draft) => {\r\n if (!app.cache.drafts) {\r\n app.session.user.data.relationships.drafts.data.push(draft);\r\n } else {\r\n app.cache.drafts.push(draft);\r\n }\r\n m.redraw();\r\n }\r\n );\r\n }\r\n app.alerts.show(this.successAlert = new Alert({type: 'success', children: app.translator.trans('fof-drafts.forum.composer.alert')}));\r\n app.composer.hide();\r\n }\r\n })\r\n , 20);\r\n\r\n });\r\n\r\n extend(DiscussionComposer.prototype, 'init', function () {\r\n Object.keys(this.props).forEach(key => {\r\n if (!['originalContent', 'title', 'user'].includes(key)) {\r\n this[key] = this.props[key];\r\n } else if (key === 'title') {\r\n this.title = m.prop(this.props.title)\r\n }\r\n });\r\n });\r\n\r\n addDraftsDropdown();\r\n});\r\n","/*\r\n *\r\n * This file is part of fof/drafts.\r\n *\r\n * Copyright (c) 2019 FriendsOfFlarum..\r\n *\r\n * For the full copyright and license information, please view the license.md\r\n * file that was distributed with this source code.\r\n *\r\n */\r\n\r\nimport { extend } from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport HeaderSecondary from 'flarum/components/HeaderSecondary';\r\nimport DraftsDropdown from './components/DraftsDropdown';\r\n\r\nexport default function() {\r\n extend(HeaderSecondary.prototype, 'items', function(items) {\r\n if (!app.session.user) return;\r\n if ((app.session.user.drafts() && app.session.user.drafts().length && !app.cache.drafts) || (app.cache.drafts && app.cache.drafts.length !== 0)) {\r\n items.add('Drafts', , 20);\r\n }\r\n });\r\n}\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/js/src/forum/addDraftsDropdown.js b/js/src/forum/addDraftsDropdown.js index 31729f3..dd65371 100644 --- a/js/src/forum/addDraftsDropdown.js +++ b/js/src/forum/addDraftsDropdown.js @@ -17,7 +17,7 @@ import DraftsDropdown from './components/DraftsDropdown'; export default function() { extend(HeaderSecondary.prototype, 'items', function(items) { if (!app.session.user) return; - if ((app.session.user.data.relationships.drafts && app.session.user.data.relationships.drafts.data.length && !app.cache.drafts) || (app.cache.drafts && app.cache.drafts.length !== 0)) { + if ((app.session.user.drafts() && app.session.user.drafts().length && !app.cache.drafts) || (app.cache.drafts && app.cache.drafts.length !== 0)) { items.add('Drafts', , 20); } }); diff --git a/js/src/forum/components/DraftsDropdown.js b/js/src/forum/components/DraftsDropdown.js index ebbb02f..6321471 100644 --- a/js/src/forum/components/DraftsDropdown.js +++ b/js/src/forum/components/DraftsDropdown.js @@ -35,13 +35,13 @@ export default class DraftsDropdown extends NotificationsDropdown { if (app.cache.drafts) { return app.cache.drafts.length } - return app.session.user.data.relationships.drafts.data.length + return app.session.user.drafts().length } getNewCount() { if (app.cache.drafts) { return app.cache.drafts.length } - return app.session.user.data.relationships.drafts.data.length + return app.session.user.drafts().length } } \ No newline at end of file