diff --git a/composer.json b/composer.json index 72247af..4bb5077 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Add views to flarum discussions", "type": "flarum-extension", "require": { - "flarum/core": "^0.1.0-beta.13" + "flarum/core": "^0.1.0-beta.14" }, "license": "MIT", "authors": [ diff --git a/js/dist/admin.js b/js/dist/admin.js index 6cd80d9..c9a3503 100644 --- a/js/dist/admin.js +++ b/js/dist/admin.js @@ -1,2 +1,2 @@ -module.exports=function(e){var i={};function t(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,t),s.l=!0,s.exports}return t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,i){if(1&i&&(e=t(e)),8&i)return e;if(4&i&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&i&&"string"!=typeof e)for(var s in e)t.d(n,s,function(i){return e[i]}.bind(null,s));return n},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,i){return Object.prototype.hasOwnProperty.call(e,i)},t.p="",t(t.s=21)}([function(e,i){e.exports=flarum.core.compat.extend},,function(e,i){e.exports=flarum.core.compat.app},function(e,i,t){"use strict";function n(e,i){e.prototype=Object.create(i.prototype),e.prototype.constructor=e,e.__proto__=i}t.d(i,"a",(function(){return n}))},function(e,i){e.exports=flarum.core.compat["components/Switch"]},,,,,function(e,i){e.exports=flarum.core.compat["components/PermissionGrid"]},,,,,,,,,,function(e,i){e.exports=flarum.core.compat["components/SettingsModal"]},,function(e,i,t){"use strict";t.r(i);var n=t(0),s=t(2),o=t.n(s),r=t(9),a=t.n(r),u=t(3),c=t(19),l=t.n(c),p=t(4),d=t.n(p),b=function(e){function i(){return e.apply(this,arguments)||this}Object(u.a)(i,e);var t=i.prototype;return t.className=function(){return"Modal--small"},t.title=function(){return app.translator.trans("michaelbelgium-discussion-views.admin.settings.title")},t.form=function(){return[m("div",{className:"Form-group"},d.a.component({state:1==this.setting("michaelbelgium-discussionviews.track_unique")(),onchange:this.setting("michaelbelgium-discussionviews.track_unique"),children:app.translator.trans("michaelbelgium-discussion-views.admin.settings.track_unique_label")}),d.a.component({state:1==this.setting("michaelbelgium-discussionviews.abbr_numbers")(),onchange:this.setting("michaelbelgium-discussionviews.abbr_numbers"),children:app.translator.trans("michaelbelgium-discussion-views.admin.settings.abbr_numbers_label")}),d.a.component({state:1==this.setting("michaelbelgium-discussionviews.show_filter")(),onchange:this.setting("michaelbelgium-discussionviews.show_filter"),children:app.translator.trans("michaelbelgium-discussion-views.admin.settings.show_filter_label")}),d.a.component({state:1==this.setting("michaelbelgium-discussionviews.show_viewlist")(),onchange:this.setting("michaelbelgium-discussionviews.show_viewlist"),children:app.translator.trans("michaelbelgium-discussion-views.admin.settings.show_viewlist_label")})),m(".Form-group",[m("label",app.translator.trans("michaelbelgium-discussion-views.admin.settings.max_viewcount_label")),m("input[type=number].FormControl",{bidi:this.setting("michaelbelgium-discussionviews.max_listcount"),min:1})])]},i}(l.a);o.a.initializers.add("michaelbelgium-admin-discussion-views",(function(){Object(n.extend)(a.a.prototype,"moderateItems",(function(e){e.add("resetViews",{icon:"far fa-eye",label:o.a.translator.trans("michaelbelgium-discussion-views.admin.permissions.reset_views_label"),permission:"discussion.resetViews"})})),Object(n.extend)(a.a.prototype,"viewItems",(function(e){e.add("viewDiscussionNumber",{icon:"far fa-eye",label:o.a.translator.trans("michaelbelgium-discussion-views.admin.permissions.view_number_label"),permission:"discussion.readViewnumber",allowGuest:!0})})),o.a.extensionSettings["michaelbelgium-discussion-views"]=function(){return o.a.modal.show(new b)}}))}]); +module.exports=function(e){var i={};function t(s){if(i[s])return i[s].exports;var n=i[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=i,t.d=function(e,i,s){t.o(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:s})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,i){if(1&i&&(e=t(e)),8&i)return e;if(4&i&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(t.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&i&&"string"!=typeof e)for(var n in e)t.d(s,n,function(i){return e[i]}.bind(null,n));return s},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,i){return Object.prototype.hasOwnProperty.call(e,i)},t.p="",t(t.s=22)}({0:function(e,i){e.exports=flarum.core.compat.extend},2:function(e,i){e.exports=flarum.core.compat.app},20:function(e,i){e.exports=flarum.core.compat["components/SettingsModal"]},22:function(e,i,t){"use strict";t.r(i);var s=t(0),n=t(2),o=t.n(n),r=t(7),a=t.n(r),u=t(3),l=t(20),c=t.n(l),p=t(4),d=t.n(p),b=function(e){function i(){return e.apply(this,arguments)||this}Object(u.a)(i,e);var t=i.prototype;return t.className=function(){return"Modal--small"},t.title=function(){return app.translator.trans("michaelbelgium-discussion-views.admin.settings.title")},t.form=function(){return[m("div",{className:"Form-group"},m(d.a,{state:this.setting("michaelbelgium-discussionviews.track_unique")(),onchange:this.setting("michaelbelgium-discussionviews.track_unique")},app.translator.trans("michaelbelgium-discussion-views.admin.settings.track_unique_label")),m(d.a,{state:this.setting("michaelbelgium-discussionviews.abbr_numbers")(),onchange:this.setting("michaelbelgium-discussionviews.abbr_numbers")},app.translator.trans("michaelbelgium-discussion-views.admin.settings.abbr_numbers_label")),m(d.a,{state:this.setting("michaelbelgium-discussionviews.show_filter")(),onchange:this.setting("michaelbelgium-discussionviews.show_filter")},app.translator.trans("michaelbelgium-discussion-views.admin.settings.show_filter_label")),m(d.a,{state:this.setting("michaelbelgium-discussionviews.show_viewlist")(),onchange:this.setting("michaelbelgium-discussionviews.show_viewlist")},app.translator.trans("michaelbelgium-discussion-views.admin.settings.show_viewlist_label"))),m("div",{className:"Form-group"},m("label",null,app.translator.trans("michaelbelgium-discussion-views.admin.settings.max_viewcount_label")),m("input",{type:"number",className:"FormControl",bidi:this.setting("michaelbelgium-discussionviews.max_listcount")}))]},i}(c.a);o.a.initializers.add("michaelbelgium-admin-discussion-views",(function(){Object(s.extend)(a.a.prototype,"moderateItems",(function(e){e.add("resetViews",{icon:"far fa-eye",label:o.a.translator.trans("michaelbelgium-discussion-views.admin.permissions.reset_views_label"),permission:"discussion.resetViews"})})),Object(s.extend)(a.a.prototype,"viewItems",(function(e){e.add("viewDiscussionNumber",{icon:"far fa-eye",label:o.a.translator.trans("michaelbelgium-discussion-views.admin.permissions.view_number_label"),permission:"discussion.readViewnumber",allowGuest:!0})})),o.a.extensionSettings["michaelbelgium-discussion-views"]=function(){return o.a.modal.show(b)}}))},3:function(e,i,t){"use strict";function s(e,i){e.prototype=Object.create(i.prototype),e.prototype.constructor=e,e.__proto__=i}t.d(i,"a",(function(){return s}))},4:function(e,i){e.exports=flarum.core.compat["components/Switch"]},7:function(e,i){e.exports=flarum.core.compat["components/PermissionGrid"]}}); //# sourceMappingURL=admin.js.map \ No newline at end of file diff --git a/js/dist/admin.js.map b/js/dist/admin.js.map index 4b344a9..d463cc8 100644 --- a/js/dist/admin.js.map +++ b/js/dist/admin.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://@michaelbelgium/flarum-discussion-views/webpack/bootstrap","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['extend']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['app']\"","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/Switch']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/PermissionGrid']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/SettingsModal']\"","webpack://@michaelbelgium/flarum-discussion-views/./src/admin/components/DiscussionviewSettingsModal.js","webpack://@michaelbelgium/flarum-discussion-views/./src/admin/index.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__","DiscussionviewSettingsModal","className","title","app","translator","trans","form","Switch","component","state","this","setting","onchange","children","bidi","min","SettingsModal","initializers","add","extend","PermissionGrid","items","icon","label","permission","allowGuest","extensionSettings","modal","show"],"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,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDr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,MAAM,yD,EAGhCC,KAAA,WACI,MAAO,CACH,SAAKL,UAAU,cACVM,IAAOC,UAAU,CACdC,MAAwE,GAAjEC,KAAKC,QAAQ,8CAAbD,GACPE,SAAUF,KAAKC,QAAQ,+CACvBE,SAAUV,IAAIC,WAAWC,MAAM,uEAGlCE,IAAOC,UAAU,CACdC,MAAwE,GAAjEC,KAAKC,QAAQ,8CAAbD,GACPE,SAAUF,KAAKC,QAAQ,+CACvBE,SAAUV,IAAIC,WAAWC,MAAM,uEAGlCE,IAAOC,UAAU,CACdC,MAAuE,GAAhEC,KAAKC,QAAQ,6CAAbD,GACPE,SAAUF,KAAKC,QAAQ,8CACvBE,SAAUV,IAAIC,WAAWC,MAAM,sEAGlCE,IAAOC,UAAU,CACdC,MAAyE,GAAlEC,KAAKC,QAAQ,+CAAbD,GACPE,SAAUF,KAAKC,QAAQ,gDACvBE,SAAUV,IAAIC,WAAWC,MAAM,yEAIvCzC,EAAE,cAAe,CACbA,EAAE,QAASuC,IAAIC,WAAWC,MAAM,uEAChCzC,EAAE,iCAAkC,CAChCkD,KAAMJ,KAAKC,QAAQ,gDACnBI,IAAK,Q,GAzCgCC,KCEzDb,IAAIc,aAAaC,IAAI,yCAAyC,WAC7DC,iBAAOC,IAAehC,UAAW,iBAAiB,SAAAiC,GACjDA,EAAMH,IAAI,aAAc,CACvBI,KAAM,aACNC,MAAOpB,IAAIC,WAAWC,MAAM,uEAC5BmB,WAAY,6BAIdL,iBAAOC,IAAehC,UAAW,aAAa,SAAAiC,GAC7CA,EAAMH,IAAI,uBAAwB,CACjCI,KAAM,aACNC,MAAOpB,IAAIC,WAAWC,MAAM,uEAC5BmB,WAAY,4BACZC,YAAY,OAIdtB,IAAIuB,kBAAkB,mCAAqC,kBAAMvB,IAAIwB,MAAMC,KAAK,IAAI5B","file":"admin.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 = 21);\n","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['app'];","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","module.exports = flarum.core.compat['components/Switch'];","module.exports = flarum.core.compat['components/PermissionGrid'];","module.exports = flarum.core.compat['components/SettingsModal'];","import SettingsModal from 'flarum/components/SettingsModal';\r\nimport Switch from 'flarum/components/Switch';\r\n\r\nexport default class DiscussionviewSettingsModal extends SettingsModal {\r\n className() {\r\n return 'Modal--small';\r\n }\r\n\r\n title() {\r\n return app.translator.trans('michaelbelgium-discussion-views.admin.settings.title');\r\n }\r\n\r\n form() {\r\n return [\r\n
\r\n {Switch.component({\r\n state: this.setting('michaelbelgium-discussionviews.track_unique')() == 1,\r\n onchange: this.setting('michaelbelgium-discussionviews.track_unique'),\r\n children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.track_unique_label')\r\n })}\r\n \r\n {Switch.component({\r\n state: this.setting('michaelbelgium-discussionviews.abbr_numbers')() == 1,\r\n onchange: this.setting('michaelbelgium-discussionviews.abbr_numbers'),\r\n children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.abbr_numbers_label')\r\n })}\r\n \r\n {Switch.component({\r\n state: this.setting('michaelbelgium-discussionviews.show_filter')() == 1,\r\n onchange: this.setting('michaelbelgium-discussionviews.show_filter'),\r\n children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_filter_label')\r\n })}\r\n\r\n {Switch.component({\r\n state: this.setting('michaelbelgium-discussionviews.show_viewlist')() == 1,\r\n onchange: this.setting('michaelbelgium-discussionviews.show_viewlist'),\r\n children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_viewlist_label')\r\n })}\r\n
,\r\n\r\n m('.Form-group', [\r\n m('label', app.translator.trans('michaelbelgium-discussion-views.admin.settings.max_viewcount_label')),\r\n m('input[type=number].FormControl', {\r\n bidi: this.setting('michaelbelgium-discussionviews.max_listcount'),\r\n min: 1\r\n })\r\n ])\r\n ];\r\n }\r\n}","import { extend } from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport PermissionGrid from 'flarum/components/PermissionGrid';\r\nimport DiscussionviewSettingsModal from './components/DiscussionviewSettingsModal';\r\n\r\napp.initializers.add('michaelbelgium-admin-discussion-views', () => {\r\n\textend(PermissionGrid.prototype, 'moderateItems', items => {\r\n\t\titems.add('resetViews', {\r\n\t\t\ticon: 'far fa-eye',\r\n\t\t\tlabel: app.translator.trans('michaelbelgium-discussion-views.admin.permissions.reset_views_label'),\r\n\t\t\tpermission: 'discussion.resetViews'\r\n\t\t});\r\n\t});\r\n\r\n\textend(PermissionGrid.prototype, 'viewItems', items => {\r\n\t\titems.add('viewDiscussionNumber', {\r\n\t\t\ticon: 'far fa-eye',\r\n\t\t\tlabel: app.translator.trans('michaelbelgium-discussion-views.admin.permissions.view_number_label'),\r\n\t\t\tpermission: 'discussion.readViewnumber',\r\n\t\t\tallowGuest: true\r\n\t\t});\r\n\t});\r\n\r\n\tapp.extensionSettings['michaelbelgium-discussion-views'] = () => app.modal.show(new DiscussionviewSettingsModal());\r\n});\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://@michaelbelgium/flarum-discussion-views/webpack/bootstrap","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['extend']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['app']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/SettingsModal']\"","webpack://@michaelbelgium/flarum-discussion-views/./src/admin/components/DiscussionviewSettingsModal.js","webpack://@michaelbelgium/flarum-discussion-views/./src/admin/index.js","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/Switch']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/PermissionGrid']\""],"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","DiscussionviewSettingsModal","className","title","app","translator","trans","form","state","this","setting","onchange","type","bidi","SettingsModal","initializers","add","extend","PermissionGrid","items","icon","label","permission","allowGuest","extensionSettings","modal","show","_inheritsLoose","subClass","superClass","constructor","__proto__"],"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,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EA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N,IAAIC,WAAWC,MAAM,sEAG1B,EAAC,IAAD,CACIE,MAAOC,KAAKC,QAAQ,6CAAbD,GACPE,SAAUF,KAAKC,QAAQ,+CAEtBN,IAAIC,WAAWC,MAAM,qEAG1B,EAAC,IAAD,CACIE,MAAOC,KAAKC,QAAQ,+CAAbD,GACPE,SAAUF,KAAKC,QAAQ,iDAEtBN,IAAIC,WAAWC,MAAM,wEAI9B,SAAKJ,UAAU,cACX,eAAQE,IAAIC,WAAWC,MAAM,uEAC7B,WAAOM,KAAK,SAASV,UAAU,cAAcW,KAAMJ,KAAKC,QAAQ,qD,GA3CvBI,KCEzDV,IAAIW,aAAaC,IAAI,yCAAyC,WAC7DC,iBAAOC,IAAexB,UAAW,iBAAiB,SAAAyB,GACjDA,EAAMH,IAAI,aAAc,CACvBI,KAAM,aACNC,MAAOjB,IAAIC,WAAWC,MAAM,uEAC5BgB,WAAY,6BAIdL,iBAAOC,IAAexB,UAAW,aAAa,SAAAyB,GAC7CA,EAAMH,IAAI,uBAAwB,CACjCI,KAAM,aACNC,MAAOjB,IAAIC,WAAWC,MAAM,uEAC5BgB,WAAY,4BACZC,YAAY,OAIdnB,IAAIoB,kBAAkB,mCAAqC,kBAAMpB,IAAIqB,MAAMC,KAAKzB,Q,+BCvBlE,SAAS0B,EAAeC,EAAUC,GAC/CD,EAASlC,UAAYlB,OAAOY,OAAOyC,EAAWnC,WAC9CkC,EAASlC,UAAUoC,YAAcF,EACjCA,EAASG,UAAYF,EAHvB,mC,gBCAAhE,EAAOD,QAAUkC,OAAOC,KAAKC,OAAO,sB,gBCApCnC,EAAOD,QAAUkC,OAAOC,KAAKC,OAAO","file":"admin.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 = 22);\n","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['components/SettingsModal'];","import SettingsModal from 'flarum/components/SettingsModal';\r\nimport Switch from 'flarum/components/Switch';\r\n\r\nexport default class DiscussionviewSettingsModal extends SettingsModal {\r\n className() {\r\n return 'Modal--small';\r\n }\r\n\r\n title() {\r\n return app.translator.trans('michaelbelgium-discussion-views.admin.settings.title');\r\n }\r\n\r\n form() {\r\n return [\r\n
\r\n \r\n {app.translator.trans('michaelbelgium-discussion-views.admin.settings.track_unique_label')}\r\n \r\n \r\n \r\n {app.translator.trans('michaelbelgium-discussion-views.admin.settings.abbr_numbers_label')}\r\n \r\n \r\n \r\n {app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_filter_label')}\r\n \r\n\r\n \r\n {app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_viewlist_label')}\r\n \r\n
,\r\n\r\n
\r\n \r\n \r\n
\r\n ];\r\n }\r\n}","import { extend } from 'flarum/extend';\r\nimport app from 'flarum/app';\r\nimport PermissionGrid from 'flarum/components/PermissionGrid';\r\nimport DiscussionviewSettingsModal from './components/DiscussionviewSettingsModal';\r\n\r\napp.initializers.add('michaelbelgium-admin-discussion-views', () => {\r\n\textend(PermissionGrid.prototype, 'moderateItems', items => {\r\n\t\titems.add('resetViews', {\r\n\t\t\ticon: 'far fa-eye',\r\n\t\t\tlabel: app.translator.trans('michaelbelgium-discussion-views.admin.permissions.reset_views_label'),\r\n\t\t\tpermission: 'discussion.resetViews'\r\n\t\t});\r\n\t});\r\n\r\n\textend(PermissionGrid.prototype, 'viewItems', items => {\r\n\t\titems.add('viewDiscussionNumber', {\r\n\t\t\ticon: 'far fa-eye',\r\n\t\t\tlabel: app.translator.trans('michaelbelgium-discussion-views.admin.permissions.view_number_label'),\r\n\t\t\tpermission: 'discussion.readViewnumber',\r\n\t\t\tallowGuest: true\r\n\t\t});\r\n\t});\r\n\r\n\tapp.extensionSettings['michaelbelgium-discussion-views'] = () => app.modal.show(DiscussionviewSettingsModal);\r\n});\r\n","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","module.exports = flarum.core.compat['components/Switch'];","module.exports = flarum.core.compat['components/PermissionGrid'];"],"sourceRoot":""} \ No newline at end of file diff --git a/js/dist/forum.js b/js/dist/forum.js index e32b2e7..5863aec 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -module.exports=function(t){var e={};function n(o){if(e[o])return e[o].exports;var s=e[o]={i:o,l:!1,exports:{}};return t[o].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(o,s,function(e){return t[e]}.bind(null,s));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=20)}([function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat.Model},function(t,e){t.exports=flarum.core.compat.app},function(t,e,n){"use strict";function o(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}n.d(e,"a",(function(){return o}))},,function(t,e){t.exports=flarum.core.compat["components/DiscussionList"]},function(t,e){t.exports=flarum.core.compat["components/Button"]},function(t,e){t.exports=flarum.core.compat["models/Discussion"]},function(t,e){t.exports=flarum.core.compat["utils/DiscussionControls"]},,function(t,e){t.exports=flarum.core.compat["components/DiscussionListItem"]},function(t,e){t.exports=flarum.core.compat["components/DiscussionPage"]},function(t,e){t.exports=flarum.core.compat["components/FieldSet"]},function(t,e){t.exports=flarum.core.compat["utils/abbreviateNumber"]},function(t,e){t.exports=flarum.core.compat["helpers/avatar"]},function(t,e){t.exports=flarum.core.compat["utils/ItemList"]},function(t,e){t.exports=flarum.core.compat["utils/string"]},function(t,e){t.exports=flarum.core.compat["utils/humanTime"]},function(t,e){t.exports=flarum.core.compat["components/Modal"]},,function(t,e,n){"use strict";n.r(e);var o=n(2),s=n.n(o),i=n(0),r=n(5),a=n.n(r),u=n(1),c=n.n(u),l=n(7),p=n.n(l),f=n(10),d=n.n(f),b=n(11),v=n.n(b),h=n(12),w=n.n(h),y=n(13),x=n.n(y);function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var _=n(3);function O(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var j=function(t){function e(){for(var e,n=arguments.length,o=new Array(n),s=0;s0&&t.add("reset",L.a.component({children:app.translator.trans("michaelbelgium-discussion-views.forum.discussion_controls.resetviews_button"),icon:"far fa-eye-slash",onclick:this.resetViewsAction.bind(e)}))})),F.a.resetViewsAction=function(){return app.modal.show(new R({discussion:this}))}}))}]); +module.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var o=e[s]={i:s,l:!1,exports:{}};return t[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(s,o,function(e){return t[e]}.bind(null,o));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=21)}([function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat.Model},function(t,e){t.exports=flarum.core.compat.app},function(t,e,n){"use strict";function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}n.d(e,"a",(function(){return s}))},,function(t,e){t.exports=flarum.core.compat["components/Button"]},function(t,e){t.exports=flarum.core.compat["models/Discussion"]},,function(t,e){t.exports=flarum.core.compat["states/DiscussionListState"]},function(t,e){t.exports=flarum.core.compat["components/DiscussionListItem"]},function(t,e){t.exports=flarum.core.compat["components/DiscussionList"]},function(t,e){t.exports=flarum.core.compat["components/DiscussionPage"]},function(t,e){t.exports=flarum.core.compat["components/FieldSet"]},function(t,e){t.exports=flarum.core.compat["utils/abbreviateNumber"]},function(t,e){t.exports=flarum.core.compat["helpers/avatar"]},function(t,e){t.exports=flarum.core.compat["utils/ItemList"]},function(t,e){t.exports=flarum.core.compat["utils/string"]},function(t,e){t.exports=flarum.core.compat["utils/humanTime"]},function(t,e){t.exports=flarum.core.compat["utils/DiscussionControls"]},function(t,e){t.exports=flarum.core.compat["components/Modal"]},,function(t,e,n){"use strict";n.r(e);var s=n(2),o=n.n(s),i=n(0),r=n(8),a=n.n(r),u=n(1),c=n.n(u),l=n(6),p=n.n(l),f=n(9),d=n.n(f),b=n(10),v=n.n(b),h=n(11),w=n.n(h),y=n(12),x=n.n(y),_=n(13),g=n.n(_);function O(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var j=n(3);function C(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var D=function(t){function e(){for(var e,n=arguments.length,s=new Array(n),o=0;o0&&t.add("reset",m(F.a,{icon:"far fa-eye-slash",onclick:function(){return app.modal.show(T,{discussion:e})}},app.translator.trans("michaelbelgium-discussion-views.forum.discussion_controls.resetviews_button")))}))}))}]); //# 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 f85761b..65e22a9 100644 --- a/js/dist/forum.js.map +++ b/js/dist/forum.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://@michaelbelgium/flarum-discussion-views/webpack/bootstrap","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['extend']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['Model']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['app']\"","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/DiscussionList']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/Button']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['models/Discussion']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/DiscussionControls']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/DiscussionListItem']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/DiscussionPage']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/FieldSet']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/abbreviateNumber']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['helpers/avatar']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/ItemList']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/string']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/humanTime']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/Modal']\"","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/defineProperty.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/models/DiscussionView.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/ResetDiscussionViewsModal.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/index.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/AddPopularSort.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/AddViewsToModelAndDisplay.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/AddModerationControl.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__","_assertThisInitialized","self","ReferenceError","_defineProperty","obj","configurable","writable","DiscussionView","Model","attribute","transformDate","hasOne","ResetDiscussionViewsModal","init","this","discussion","props","currentViewsCount","viewCount","content","className","app","translator","transChoice","count","Button","component","type","loading","children","trans","title","onsubmit","e","preventDefault","save","resetViews","then","redraw","reason","console","log","hide","Modal","initializers","add","extend","DiscussionList","map","forum","popular","unpopular","store","models","discussionviews","Discussion","views","hasMany","canReset","DiscussionListItem","items","number","abbreviateNumber","params","include","push","DiscussionPage","viewList","ItemList","$","each","view","userName","user","ucfirst","username","listitem","avatar","visitedAt","toLocaleString","humanTime","href","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G,SAAUR,IAAIC,WAAWQ,MAAM,+EAC/ByD,KAAM,mBACNC,QAAS1E,KAAK2E,iBAAiBzG,KAAK+B,SAKhDuE,IAAmBG,iBAAmB,WAClC,OAAOpE,IAAIqE,MAAMC,KAAK,IAAI/E,EAA0B,CAChDG,WAAYD","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 = 20);\n","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['Model'];","module.exports = flarum.core.compat['app'];","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","module.exports = flarum.core.compat['components/DiscussionList'];","module.exports = flarum.core.compat['components/Button'];","module.exports = flarum.core.compat['models/Discussion'];","module.exports = flarum.core.compat['utils/DiscussionControls'];","module.exports = flarum.core.compat['components/DiscussionListItem'];","module.exports = flarum.core.compat['components/DiscussionPage'];","module.exports = flarum.core.compat['components/FieldSet'];","module.exports = flarum.core.compat['utils/abbreviateNumber'];","module.exports = flarum.core.compat['helpers/avatar'];","module.exports = flarum.core.compat['utils/ItemList'];","module.exports = flarum.core.compat['utils/string'];","module.exports = flarum.core.compat['utils/humanTime'];","module.exports = flarum.core.compat['components/Modal'];","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}","export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}","import Model from 'flarum/Model';\r\n\r\nexport default class DiscussionView extends Model {\r\n //comes from DiscussionViewSerializer (user(), discussion(), visited_at)\r\n visitedAt = Model.attribute('visited_at', Model.transformDate);\r\n user = Model.hasOne('user');\r\n discussion = Model.hasOne('discussion');\r\n}","import Modal from 'flarum/components/Modal';\r\nimport Button from 'flarum/components/Button';\r\n\r\nexport default class ResetDiscussionViewsModal extends Modal {\r\n init()\r\n {\r\n super.init();\r\n\r\n this.discussion = this.props.discussion;\r\n this.currentViewsCount = this.discussion.viewCount();\r\n }\r\n\r\n content()\r\n {\r\n return (\r\n
\r\n
\r\n

{app.translator.transChoice('michaelbelgium-discussion-views.forum.modal_resetviews.label', this.currentViewsCount, {count: this.currentViewsCount })}

\r\n
\r\n {Button.component({\r\n className: 'Button Button--primary Button--block',\r\n type: 'submit',\r\n loading: this.loading,\r\n children: app.translator.trans('michaelbelgium-discussion-views.forum.modal_resetviews.submit_button')\r\n })}\r\n
\r\n
\r\n
\r\n )\r\n }\r\n\r\n title()\r\n {\r\n return app.translator.trans('michaelbelgium-discussion-views.forum.modal_resetviews.title');\r\n }\r\n\r\n className()\r\n {\r\n return 'Modal--small';\r\n }\r\n\r\n onsubmit(e)\r\n {\r\n e.preventDefault();\r\n this.loading = true;\r\n\r\n this.props.discussion\r\n .save({ resetViews: true })\r\n .then(() => { m.redraw(); })\r\n .catch((reason) => {\r\n this.loading = false;\r\n console.log(reason)\r\n });\r\n\r\n this.hide();\r\n }\r\n}\r\n","import app from 'flarum/app';\r\nimport AddPopularSort from './components/AddPopularSort';\r\nimport AddViewsToModelAndDisplay from './components/AddViewsToModelAndDisplay';\r\nimport AddModerationControl from './components/AddModerationControl';\r\n\r\napp.initializers.add('michaelbelgium-discussion-views', function () {\r\n AddPopularSort();\r\n AddViewsToModelAndDisplay();\r\n AddModerationControl();\r\n});\r\n","import { extend } from 'flarum/extend';\r\nimport DiscussionList from 'flarum/components/DiscussionList';\r\n\r\nexport default function () {\r\n extend(DiscussionList.prototype, 'sortMap', function (map) {\r\n if(app.forum.attribute('mb-discussionviews.show_filter') == 1) {\r\n map.popular = '-view_count';\r\n map.unpopular = 'view_count';\r\n }\r\n });\r\n}\r\n","import { extend } from 'flarum/extend';\r\nimport Model from 'flarum/Model';\r\nimport Discussion from 'flarum/models/Discussion';\r\nimport DiscussionListItem from 'flarum/components/DiscussionListItem';\r\nimport DiscussionList from 'flarum/components/DiscussionList';\r\nimport DiscussionPage from 'flarum/components/DiscussionPage';\r\nimport FieldSet from 'flarum/components/FieldSet';\r\nimport abbreviateNumber from 'flarum/utils/abbreviateNumber';\r\nimport DiscussionView from '../models/DiscussionView';\r\nimport avatar from 'flarum/helpers/avatar';\r\nimport ItemList from 'flarum/utils/ItemList';\r\nimport {ucfirst} from 'flarum/utils/string';\r\nimport humanTime from 'flarum/utils/humanTime';\r\n\r\nexport default function () {\r\n app.store.models.discussionviews = DiscussionView; //discussionviews = serializer type\r\n\r\n Discussion.prototype.views = Model.hasMany('latestViews');\r\n Discussion.prototype.canReset = Model.attribute('canReset');\r\n Discussion.prototype.viewCount = Model.attribute('viewCount');\r\n\r\n extend(DiscussionListItem.prototype, 'infoItems', function(items) {\r\n if(this.props.discussion.attribute('canViewNumber')) {\r\n const views = this.props.discussion.viewCount();\r\n\r\n var number = app.forum.attribute('mb-discussionviews.abbr_numbers') == 1 ? abbreviateNumber(views) : views;\r\n items.add('discussion-views', number); \r\n }\r\n });\r\n\r\n extend(DiscussionList.prototype, 'requestParams', function(params) {\r\n params.include.push('latestViews'); //fixes not loading relationship when navigating back to the discussion list if you directly went to a discussion or another page\r\n })\r\n \r\n extend(DiscussionPage.prototype, 'sidebarItems', function(items) {\r\n if(app.forum.attribute('mb-discussionviews.show_viewlist') == 0) return;\r\n \r\n const views = this.discussion.views();\r\n const viewList = new ItemList();\r\n\r\n $.each(views, function(key, view) {\r\n var userName = view.user() === false ? 'Guest' : ucfirst(view.user().username());\r\n\r\n var listitem = \r\n
\r\n {avatar(view.user())}\r\n
\r\n {userName}\r\n {humanTime(view.visitedAt())}\r\n
\r\n
;\r\n\r\n if(view.user() !== false) {\r\n listitem = {listitem};\r\n }\r\n\r\n viewList.add('lastUser-' + key, listitem);\r\n });\r\n\r\n items.add('lastDiscussionViewers', FieldSet.component({\r\n label: app.translator.trans('michaelbelgium-discussion-views.forum.viewlist.title'),\r\n className: 'LastDiscussionUsers',\r\n children: viewList.toArray()\r\n }));\r\n });\r\n}\r\n","import { extend } from 'flarum/extend';\r\nimport Button from 'flarum/components/Button';\r\nimport DiscussionControls from 'flarum/utils/DiscussionControls';\r\nimport ResetDiscussionViewsModal from './ResetDiscussionViewsModal';\r\n\r\nexport default function () {\r\n extend(DiscussionControls, 'moderationControls', function(items, discussion) {\r\n if(discussion.attribute('canReset') && discussion.viewCount() > 0)\r\n {\r\n items.add('reset', Button.component({\r\n children: app.translator.trans('michaelbelgium-discussion-views.forum.discussion_controls.resetviews_button'),\r\n icon: 'far fa-eye-slash',\r\n onclick: this.resetViewsAction.bind(discussion)\r\n }));\r\n }\r\n });\r\n\r\n DiscussionControls.resetViewsAction = function() {\r\n return app.modal.show(new ResetDiscussionViewsModal({\r\n discussion: this\r\n }));\r\n };\r\n}\r\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://@michaelbelgium/flarum-discussion-views/webpack/bootstrap","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['extend']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['Model']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['app']\"","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/Button']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['models/Discussion']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['states/DiscussionListState']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/DiscussionListItem']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/DiscussionList']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/DiscussionPage']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/FieldSet']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/abbreviateNumber']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['helpers/avatar']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/ItemList']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/string']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/humanTime']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['utils/DiscussionControls']\"","webpack://@michaelbelgium/flarum-discussion-views/external \"flarum.core.compat['components/Modal']\"","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js","webpack://@michaelbelgium/flarum-discussion-views/./node_modules/@babel/runtime/helpers/esm/defineProperty.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/models/DiscussionView.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/ResetDiscussionViewsModal.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/index.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/AddPopularSort.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/AddViewsToModelAndDisplay.js","webpack://@michaelbelgium/flarum-discussion-views/./src/forum/components/AddModerationControl.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__","_assertThisInitialized","self","ReferenceError","_defineProperty","obj","configurable","writable","DiscussionView","Model","attribute","transformDate","hasOne","ResetDiscussionViewsModal","oninit","vnode","this","discussion","attrs","currentViewsCount","viewCount","content","className","app","translator","transChoice","count","Button","component","type","loading","trans","title","onsubmit","e","preventDefault","save","resetViews","loaded","hide","Modal","initializers","add","extend","DiscussionListState","map","forum","popular","unpopular","store","models","discussionviews","Discussion","views","hasMany","canReset","DiscussionListItem","items","number","abbreviateNumber","DiscussionList","params","include","push","DiscussionPage","viewList","ItemList","$","each","view","userName","user","ucfirst","username","listitem","avatar","visitedAt","toLocaleString","humanTime","href","route","label","toArray","DiscussionControls","icon","onclick","modal","show"],"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,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,E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AAOqC,EAAKO,YAAYC,kBAAmBC,IAAUT,EAAKO,iBAItF,IAAhBP,EAAKE,SACJG,EAAW,OAAGK,KAAMxD,IAAIyD,MAAMT,KAAKF,EAAKE,SAAUG,IAGtDT,EAASvB,IAAI,YAAc1D,EAAK0F,MAGpCjB,EAAMf,IACF,wBACA,EAAC,IAAD,CAAUpB,UAAU,sBAAsB2D,MAAO1D,IAAIC,WAAWO,MAAM,yDACjEkC,EAASiB,gBCxDtBvC,iBAAOwC,IAAoB,sBAAsB,SAAS1B,EAAOxC,GAC1DA,EAAWP,UAAU,aAAeO,EAAWG,YAAc,GAE5DqC,EAAMf,IACF,QACA,EAAC,IAAD,CAAQ0C,KAAK,mBAAmBC,QAAS,kBAAM9D,IAAI+D,MAAMC,KAAK1E,EAA2B,CAAEI,iBACtFM,IAAIC,WAAWO,MAAM","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 = 21);\n","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['Model'];","module.exports = flarum.core.compat['app'];","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","module.exports = flarum.core.compat['components/Button'];","module.exports = flarum.core.compat['models/Discussion'];","module.exports = flarum.core.compat['states/DiscussionListState'];","module.exports = flarum.core.compat['components/DiscussionListItem'];","module.exports = flarum.core.compat['components/DiscussionList'];","module.exports = flarum.core.compat['components/DiscussionPage'];","module.exports = flarum.core.compat['components/FieldSet'];","module.exports = flarum.core.compat['utils/abbreviateNumber'];","module.exports = flarum.core.compat['helpers/avatar'];","module.exports = flarum.core.compat['utils/ItemList'];","module.exports = flarum.core.compat['utils/string'];","module.exports = flarum.core.compat['utils/humanTime'];","module.exports = flarum.core.compat['utils/DiscussionControls'];","module.exports = flarum.core.compat['components/Modal'];","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}","export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}","import Model from 'flarum/Model';\r\n\r\nexport default class DiscussionView extends Model {\r\n //comes from DiscussionViewSerializer (user(), discussion(), visited_at)\r\n visitedAt = Model.attribute('visited_at', Model.transformDate);\r\n user = Model.hasOne('user');\r\n discussion = Model.hasOne('discussion');\r\n}","import Modal from 'flarum/components/Modal';\r\nimport Button from 'flarum/components/Button';\r\n\r\nexport default class ResetDiscussionViewsModal extends Modal {\r\n oninit(vnode)\r\n {\r\n super.oninit(vnode);\r\n\r\n this.discussion = this.attrs.discussion;\r\n this.currentViewsCount = this.discussion.viewCount();\r\n }\r\n\r\n content()\r\n {\r\n return (\r\n
\r\n
\r\n

{app.translator.transChoice('michaelbelgium-discussion-views.forum.modal_resetviews.label', this.currentViewsCount, {count: this.currentViewsCount })}

\r\n
\r\n {Button.component(\r\n {\r\n className: 'Button Button--primary Button--block',\r\n type: 'submit',\r\n loading: this.loading\r\n }, \r\n app.translator.trans('michaelbelgium-discussion-views.forum.modal_resetviews.submit_button')\r\n )}\r\n
\r\n
\r\n
\r\n )\r\n }\r\n\r\n title()\r\n {\r\n return app.translator.trans('michaelbelgium-discussion-views.forum.modal_resetviews.title');\r\n }\r\n\r\n className()\r\n {\r\n return 'Modal--small';\r\n }\r\n\r\n onsubmit(e)\r\n {\r\n e.preventDefault();\r\n this.loading = true;\r\n\r\n this.attrs.discussion\r\n .save({ resetViews: true })\r\n .catch(() => {\r\n this.loaded();\r\n });\r\n\r\n this.hide();\r\n }\r\n}\r\n","import app from 'flarum/app';\r\nimport AddPopularSort from './components/AddPopularSort';\r\nimport AddViewsToModelAndDisplay from './components/AddViewsToModelAndDisplay';\r\nimport AddModerationControl from './components/AddModerationControl';\r\n\r\napp.initializers.add('michaelbelgium-discussion-views', function () {\r\n AddPopularSort();\r\n AddViewsToModelAndDisplay();\r\n AddModerationControl();\r\n});\r\n","import { extend } from 'flarum/extend';\r\nimport DiscussionListState from 'flarum/states/DiscussionListState'\r\n\r\nexport default function () {\r\n extend(DiscussionListState.prototype, 'sortMap', function (map) {\r\n if(app.forum.attribute('mb-discussionviews.show_filter') == 1) {\r\n map.popular = '-view_count';\r\n map.unpopular = 'view_count';\r\n }\r\n });\r\n}\r\n","import { extend } from 'flarum/extend';\r\nimport Model from 'flarum/Model';\r\nimport Discussion from 'flarum/models/Discussion';\r\nimport DiscussionListItem from 'flarum/components/DiscussionListItem';\r\nimport DiscussionList from 'flarum/components/DiscussionList';\r\nimport DiscussionPage from 'flarum/components/DiscussionPage';\r\nimport FieldSet from 'flarum/components/FieldSet';\r\nimport abbreviateNumber from 'flarum/utils/abbreviateNumber';\r\nimport DiscussionView from '../models/DiscussionView';\r\nimport avatar from 'flarum/helpers/avatar';\r\nimport ItemList from 'flarum/utils/ItemList';\r\nimport {ucfirst} from 'flarum/utils/string';\r\nimport humanTime from 'flarum/utils/humanTime';\r\n\r\nexport default function () {\r\n app.store.models.discussionviews = DiscussionView; //discussionviews = serializer type\r\n\r\n Discussion.prototype.views = Model.hasMany('latestViews');\r\n Discussion.prototype.canReset = Model.attribute('canReset');\r\n Discussion.prototype.viewCount = Model.attribute('viewCount');\r\n\r\n extend(DiscussionListItem.prototype, 'infoItems', function(items) {\r\n if(this.attrs.discussion.attribute('canViewNumber')) {\r\n const views = this.attrs.discussion.viewCount();\r\n\r\n var number = app.forum.attribute('mb-discussionviews.abbr_numbers') == 1 ? abbreviateNumber(views) : views;\r\n items.add('discussion-views', {number}); \r\n }\r\n });\r\n\r\n extend(DiscussionList.prototype, 'requestParams', function(params) {\r\n params.include.push('latestViews'); //fixes not loading relationship when navigating back to the discussion list if you directly went to a discussion or another page\r\n })\r\n \r\n extend(DiscussionPage.prototype, 'sidebarItems', function(items) {\r\n if(app.forum.attribute('mb-discussionviews.show_viewlist') == 0) return;\r\n \r\n const views = this.discussion.views();\r\n const viewList = new ItemList();\r\n\r\n $.each(views, function(key, view) {\r\n var userName = view.user() === false ? 'Guest' : ucfirst(view.user().username());\r\n\r\n var listitem = \r\n
\r\n {avatar(view.user())}\r\n
\r\n {userName}\r\n {humanTime(view.visitedAt())}\r\n
\r\n
;\r\n\r\n if(view.user() !== false) {\r\n listitem = {listitem};\r\n }\r\n\r\n viewList.add('lastUser-' + key, listitem);\r\n });\r\n\r\n items.add(\r\n 'lastDiscussionViewers', \r\n
\r\n {viewList.toArray()}\r\n
\r\n );\r\n });\r\n}\r\n","import { extend } from 'flarum/extend';\r\nimport Button from 'flarum/components/Button';\r\nimport DiscussionControls from 'flarum/utils/DiscussionControls';\r\nimport ResetDiscussionViewsModal from './ResetDiscussionViewsModal';\r\n\r\nexport default function () {\r\n extend(DiscussionControls, 'moderationControls', function(items, discussion) {\r\n if(discussion.attribute('canReset') && discussion.viewCount() > 0)\r\n {\r\n items.add(\r\n 'reset',\r\n \r\n );\r\n }\r\n });\r\n}\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/js/package.json b/js/package.json index c983719..ea44139 100644 --- a/js/package.json +++ b/js/package.json @@ -3,7 +3,7 @@ "name": "@michaelbelgium/flarum-discussion-views", "dependencies": { "flarum-webpack-config": "0.1.0-beta.10", - "webpack": "^4.0.0", + "webpack": "^4.44.2", "webpack-cli": "^3.0.7" }, "scripts": { diff --git a/js/src/admin/components/DiscussionviewSettingsModal.js b/js/src/admin/components/DiscussionviewSettingsModal.js index db5b8d6..7299704 100644 --- a/js/src/admin/components/DiscussionviewSettingsModal.js +++ b/js/src/admin/components/DiscussionviewSettingsModal.js @@ -13,38 +13,39 @@ export default class DiscussionviewSettingsModal extends SettingsModal { form() { return [
- {Switch.component({ - state: this.setting('michaelbelgium-discussionviews.track_unique')() == 1, - onchange: this.setting('michaelbelgium-discussionviews.track_unique'), - children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.track_unique_label') - })} + + {app.translator.trans('michaelbelgium-discussion-views.admin.settings.track_unique_label')} + - {Switch.component({ - state: this.setting('michaelbelgium-discussionviews.abbr_numbers')() == 1, - onchange: this.setting('michaelbelgium-discussionviews.abbr_numbers'), - children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.abbr_numbers_label') - })} + + {app.translator.trans('michaelbelgium-discussion-views.admin.settings.abbr_numbers_label')} + - {Switch.component({ - state: this.setting('michaelbelgium-discussionviews.show_filter')() == 1, - onchange: this.setting('michaelbelgium-discussionviews.show_filter'), - children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_filter_label') - })} + + {app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_filter_label')} + - {Switch.component({ - state: this.setting('michaelbelgium-discussionviews.show_viewlist')() == 1, - onchange: this.setting('michaelbelgium-discussionviews.show_viewlist'), - children: app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_viewlist_label') - })} + + {app.translator.trans('michaelbelgium-discussion-views.admin.settings.show_viewlist_label')} +
, - m('.Form-group', [ - m('label', app.translator.trans('michaelbelgium-discussion-views.admin.settings.max_viewcount_label')), - m('input[type=number].FormControl', { - bidi: this.setting('michaelbelgium-discussionviews.max_listcount'), - min: 1 - }) - ]) +
+ + +
]; } } \ No newline at end of file diff --git a/js/src/admin/index.js b/js/src/admin/index.js index 0217044..95e4bcf 100644 --- a/js/src/admin/index.js +++ b/js/src/admin/index.js @@ -21,5 +21,5 @@ app.initializers.add('michaelbelgium-admin-discussion-views', () => { }); }); - app.extensionSettings['michaelbelgium-discussion-views'] = () => app.modal.show(new DiscussionviewSettingsModal()); + app.extensionSettings['michaelbelgium-discussion-views'] = () => app.modal.show(DiscussionviewSettingsModal); }); diff --git a/js/src/forum/components/AddModerationControl.js b/js/src/forum/components/AddModerationControl.js index f8e2298..1fb24ce 100644 --- a/js/src/forum/components/AddModerationControl.js +++ b/js/src/forum/components/AddModerationControl.js @@ -7,17 +7,12 @@ export default function () { extend(DiscussionControls, 'moderationControls', function(items, discussion) { if(discussion.attribute('canReset') && discussion.viewCount() > 0) { - items.add('reset', Button.component({ - children: app.translator.trans('michaelbelgium-discussion-views.forum.discussion_controls.resetviews_button'), - icon: 'far fa-eye-slash', - onclick: this.resetViewsAction.bind(discussion) - })); + items.add( + 'reset', + + ); } }); - - DiscussionControls.resetViewsAction = function() { - return app.modal.show(new ResetDiscussionViewsModal({ - discussion: this - })); - }; } diff --git a/js/src/forum/components/AddPopularSort.js b/js/src/forum/components/AddPopularSort.js index f32394d..f15a4c3 100644 --- a/js/src/forum/components/AddPopularSort.js +++ b/js/src/forum/components/AddPopularSort.js @@ -1,8 +1,8 @@ import { extend } from 'flarum/extend'; -import DiscussionList from 'flarum/components/DiscussionList'; +import DiscussionListState from 'flarum/states/DiscussionListState' export default function () { - extend(DiscussionList.prototype, 'sortMap', function (map) { + extend(DiscussionListState.prototype, 'sortMap', function (map) { if(app.forum.attribute('mb-discussionviews.show_filter') == 1) { map.popular = '-view_count'; map.unpopular = 'view_count'; diff --git a/js/src/forum/components/AddViewsToModelAndDisplay.js b/js/src/forum/components/AddViewsToModelAndDisplay.js index 0fcb9e2..73cd6e3 100644 --- a/js/src/forum/components/AddViewsToModelAndDisplay.js +++ b/js/src/forum/components/AddViewsToModelAndDisplay.js @@ -20,11 +20,11 @@ export default function () { Discussion.prototype.viewCount = Model.attribute('viewCount'); extend(DiscussionListItem.prototype, 'infoItems', function(items) { - if(this.props.discussion.attribute('canViewNumber')) { - const views = this.props.discussion.viewCount(); + if(this.attrs.discussion.attribute('canViewNumber')) { + const views = this.attrs.discussion.viewCount(); var number = app.forum.attribute('mb-discussionviews.abbr_numbers') == 1 ? abbreviateNumber(views) : views; - items.add('discussion-views', number); + items.add('discussion-views', {number}); } }); @@ -57,10 +57,11 @@ export default function () { viewList.add('lastUser-' + key, listitem); }); - items.add('lastDiscussionViewers', FieldSet.component({ - label: app.translator.trans('michaelbelgium-discussion-views.forum.viewlist.title'), - className: 'LastDiscussionUsers', - children: viewList.toArray() - })); + items.add( + 'lastDiscussionViewers', +
+ {viewList.toArray()} +
+ ); }); } diff --git a/js/src/forum/components/ResetDiscussionViewsModal.js b/js/src/forum/components/ResetDiscussionViewsModal.js index 67fe914..e8c3f5a 100644 --- a/js/src/forum/components/ResetDiscussionViewsModal.js +++ b/js/src/forum/components/ResetDiscussionViewsModal.js @@ -2,11 +2,11 @@ import Modal from 'flarum/components/Modal'; import Button from 'flarum/components/Button'; export default class ResetDiscussionViewsModal extends Modal { - init() + oninit(vnode) { - super.init(); + super.oninit(vnode); - this.discussion = this.props.discussion; + this.discussion = this.attrs.discussion; this.currentViewsCount = this.discussion.viewCount(); } @@ -17,12 +17,14 @@ export default class ResetDiscussionViewsModal extends Modal {

{app.translator.transChoice('michaelbelgium-discussion-views.forum.modal_resetviews.label', this.currentViewsCount, {count: this.currentViewsCount })}

- {Button.component({ - className: 'Button Button--primary Button--block', - type: 'submit', - loading: this.loading, - children: app.translator.trans('michaelbelgium-discussion-views.forum.modal_resetviews.submit_button') - })} + {Button.component( + { + className: 'Button Button--primary Button--block', + type: 'submit', + loading: this.loading + }, + app.translator.trans('michaelbelgium-discussion-views.forum.modal_resetviews.submit_button') + )}
@@ -44,12 +46,10 @@ export default class ResetDiscussionViewsModal extends Modal { e.preventDefault(); this.loading = true; - this.props.discussion + this.attrs.discussion .save({ resetViews: true }) - .then(() => { m.redraw(); }) - .catch((reason) => { - this.loading = false; - console.log(reason) + .catch(() => { + this.loaded(); }); this.hide();