From dad188ad37699921f04341f8cc9d3ca1a0d39e93 Mon Sep 17 00:00:00 2001 From: mattoid Date: Fri, 1 Mar 2024 15:26:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E4=BB=96=E4=BA=BA=E8=B5=84=E9=87=91=E5=8E=86=E5=8F=B2=E6=9D=83?= =?UTF-8?q?=E9=99=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend.php | 5 +++++ js/dist/admin.js | 2 +- js/dist/admin.js.map | 2 +- js/dist/forum.js | 2 +- js/dist/forum.js.map | 2 +- js/src/admin/index.ts | 9 ++++++++- js/src/forum/index.ts | 8 +++++--- .../ListUserMoneyHistoryController.php | 10 +++++++--- src/Attributes/UserAttributes.php | 20 +++++++++++++++++++ 9 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 src/Attributes/UserAttributes.php diff --git a/extend.php b/extend.php index 259a1c9..1b18c6a 100644 --- a/extend.php +++ b/extend.php @@ -10,8 +10,10 @@ */ use Flarum\Extend; +use Flarum\Api\Serializer\BasicUserSerializer; use Mattoid\MoneyHistory\Api\Controller\ListUserMoneyHistoryController; +use Mattoid\MoneyHistory\Attributes\UserAttributes; use Mattoid\MoneyHistory\Event\MoneyAllHistoryEvent; use Mattoid\MoneyHistory\Listeners\MoneyAllHistoryListeners; use Mattoid\MoneyHistory\Listeners\MoneyHistoryListeners; @@ -27,6 +29,9 @@ ->css(__DIR__.'/less/admin.less'), new Extend\Locales(__DIR__.'/locale'), + (new Extend\ApiSerializer(BasicUserSerializer::class)) + ->attributes(UserAttributes::class), + (new Extend\Routes('api')) ->get('/users/{id}/money/history', 'user.money.history', ListUserMoneyHistoryController::class), diff --git a/js/dist/admin.js b/js/dist/admin.js index 3e7f04d..ac90351 100644 --- a/js/dist/admin.js +++ b/js/dist/admin.js @@ -1,2 +1,2 @@ -(()=>{var e={n:o=>{var t=o&&o.__esModule?()=>o.default:()=>o;return e.d(t,{a:t}),t},d:(o,t)=>{for(var r in t)e.o(t,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:t[r]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};(()=>{"use strict";e.r(o);const t=flarum.core.compat["admin/app"];e.n(t)().initializers.add("mattoid/flarum-ext-money-history",(function(){console.log("[mattoid/flarum-ext-money-history] Hello, forum and admin!")}))})(),module.exports=o})(); +(()=>{var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t);const o=flarum.core.compat["admin/app"];var r=e.n(o);r().initializers.add("mattoid/flarum-ext-money-history",(function(){r().extensionData.for("mattoid-money-history").registerPermission({icon:"fas fa-id-card",label:r().translator.trans("mattoid-money-history.admin.settings.query-others-history"),permission:"money-history.queryOthersMoneyHistory",allowGuest:!0},"view")}))})(),module.exports=t})(); //# 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 89cc934..2477b23 100644 --- a/js/dist/admin.js.map +++ b/js/dist/admin.js.map @@ -1 +1 @@ -{"version":3,"file":"admin.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,+BCL9D,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,a,MCExDC,GAAAA,aAAiBC,IAAI,oCAAoC,WACvDC,QAAQC,IAAI,6DACd,G","sources":["webpack://@mattoid/flarum-ext-money-history/webpack/bootstrap","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/compat get default export","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/define property getters","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/hasOwnProperty shorthand","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/make namespace object","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['admin/app']\"","webpack://@mattoid/flarum-ext-money-history/./src/admin/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['admin/app'];","import app from 'flarum/admin/app';\n\napp.initializers.add('mattoid/flarum-ext-money-history', () => {\n console.log('[mattoid/flarum-ext-money-history] Hello, forum and admin!');\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","app","add","console","log"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"admin.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,+BCL9D,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,a,aCExDC,IAAAA,aAAiBC,IAAI,oCAAoC,WACvDD,IAAAA,cAAiB,IAAK,yBACrBE,mBACC,CACEC,KAAM,iBACNC,MAAOJ,IAAAA,WAAeK,MAAM,6DAC5BC,WAAY,wCACZC,YAAY,GACX,OACP,G","sources":["webpack://@mattoid/flarum-ext-money-history/webpack/bootstrap","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/compat get default export","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/define property getters","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/hasOwnProperty shorthand","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/make namespace object","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['admin/app']\"","webpack://@mattoid/flarum-ext-money-history/./src/admin/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['admin/app'];","import app from 'flarum/admin/app';\n\napp.initializers.add('mattoid/flarum-ext-money-history', () => {\n app.extensionData.for(\"mattoid-money-history\")\n .registerPermission(\n {\n icon: 'fas fa-id-card',\n label: app.translator.trans('mattoid-money-history.admin.settings.query-others-history'),\n permission: 'money-history.queryOthersMoneyHistory',\n allowGuest: true\n }, 'view')\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","app","add","registerPermission","icon","label","trans","permission","allowGuest"],"sourceRoot":""} \ No newline at end of file diff --git a/js/dist/forum.js b/js/dist/forum.js index f3a0c74..f22cdf9 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -(()=>{var t={n:o=>{var e=o&&o.__esModule?()=>o.default:()=>o;return t.d(e,{a:e}),e},d:(o,e)=>{for(var r in e)t.o(e,r)&&!t.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:e[r]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o);const e=flarum.core.compat["forum/app"];var r=t.n(e);const n=flarum.core.compat["common/extend"],s=flarum.core.compat["forum/components/UserPage"];var a=t.n(s);const i=flarum.core.compat["common/components/LinkButton"];var u=t.n(i);function l(t,o){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},l(t,o)}function c(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,l(t,o)}const p=flarum.core.compat.Component;var y=t.n(p);const d=flarum.core.compat.app;var h=t.n(d);const f=flarum.core.compat["components/LoadingIndicator"];var v=t.n(f);const g=flarum.core.compat["components/Button"];var b=t.n(g);const M=flarum.core.compat["components/Link"];var x=t.n(M);const H=flarum.core.compat["helpers/avatar"];var O=t.n(H);const _=flarum.core.compat["helpers/username"];var R=t.n(_),j=function(t){function o(){return t.apply(this,arguments)||this}return c(o,t),o.prototype.view=function(){var t=this.attrs.userMoneyHistory,o=t.changeTime(),e=t.money(),r=t.sourceDesc(),n=t.id(),s=(t.user(),t.createUser()),a=t.balanceMoney(),i=t.lastMoney(),u=app.translator.trans("D"===t.type()?"mattoid-money-history.forum.record.money-out":"mattoid-money-history.forum.record.money-in"),l="D"===t.type()?"color:red":"color:green";return m("div",{className:"transferHistoryContainer"},m("div",{style:"padding-top: 5px;"},m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-type"),": "),m("span",{style:l},u)," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-assign-at"),": "),o),m("div",{style:"padding-top: 5px;"},m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-id"),": "),n," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-from-user"),": "),m(x(),{href:"#",className:"moneyHistoryUser",style:"color:var(--heading-color)"},O()(s)," ",R()(s))," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-amount"),": "),e," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-balance"),": "),a," → ",i," | ",m("span",null,m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-transfer-notes"),": "),r)))},o}(y()),P=function(t){function o(){return t.apply(this,arguments)||this}c(o,t);var e=o.prototype;return e.oninit=function(o){t.prototype.oninit.call(this,o),this.loading=!0,this.moreResults=!1,this.userMoneyHistory=[],this.user=this.attrs.params.user,this.loadResults()},e.view=function(){var t=this;return this.loading&&v().component({size:"large"}),m("div",null,m("div",{style:"padding-bottom:10px; font-size: 24px;font-weight: bold;"},h().translator.trans("mattoid-money-history.forum.title")),m("ul",{style:"margin: 0;padding: 0;list-style-type: none;position: relative;"},this.userMoneyHistory.map((function(t){return m("li",{style:"padding-top:5px",key:t.id,"data-id":t.id},j.component({userMoneyHistory:t}))}))),!this.loading&&0===this.userMoneyHistory.length&&m("div",null,m("div",{style:"font-size:1.4em;color: var(--muted-more-color);text-align: center;height: 300px;line-height: 100px;"},h().translator.trans("mattoid-money-history.forum.list-empty"))),this.hasMoreResults()&&m("div",{style:"text-align:center;padding:20px"},m(b(),{className:"Button Button--primary",disabled:this.loading,loading:this.loading,onclick:function(){return t.loadMore()}},h().translator.trans("mattoid-money-history.forum.money-list-load-more"))))},e.loadMore=function(){this.loading=!0,this.loadResults(this.userMoneyHistory.length)},e.parseResults=function(t){return this.moreResults=!!t.payload.links&&!!t.payload.links.next,[].push.apply(this.userMoneyHistory,t),this.loading=!1,m.redraw(),t},e.hasMoreResults=function(){return this.moreResults},e.loadResults=function(t){void 0===t&&(t=0);var o="/users/"+this.user.id()+"/money/history";return h().store.find(o,{filter:{user:this.user.id()},page:{offset:t}}).catch((function(){})).then(this.parseResults.bind(this))},o}(y()),k=function(t){function o(){return t.apply(this,arguments)||this}c(o,t);var e=o.prototype;return e.oninit=function(o){t.prototype.oninit.call(this,o),this.loadUser(m.route.param("username"))},e.content=function(){return m("div",{className:"Post-body"},P.component({params:{user:this.user}}))},o}(a());const U=flarum.core.compat["common/Model"];var w=t.n(U),S=function(t){function o(){return t.apply(this,arguments)||this}return c(o,t),o}(w());Object.assign(S.prototype,{type:w().attribute("type"),money:w().attribute("money"),sourceDesc:w().attribute("source_desc"),changeTime:w().attribute("change_time"),balanceMoney:w().attribute("balance_money"),lastMoney:w().attribute("last_money"),user:w().hasOne("user"),createUser:w().hasOne("createUser")}),r().initializers.add("flarum-ext-money-history",(function(){r().store.models.userMoneyHistory=S,r().routes.userMoneyHistory={path:"/u/:username/money/history",component:k},(0,n.extend)(a().prototype,"navItems",(function(t){r().session.user&&t.add("userMoneyHistory",u().component({href:r().route("userMoneyHistory",{username:r().session.user.username()}),icon:"fas fa-money-bill"},r().translator.trans("mattoid-money-history.forum.nav")))}))}))})(),module.exports=o})(); +(()=>{var t={n:o=>{var e=o&&o.__esModule?()=>o.default:()=>o;return t.d(e,{a:e}),e},d:(o,e)=>{for(var r in e)t.o(e,r)&&!t.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:e[r]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o);const e=flarum.core.compat["forum/app"];var r=t.n(e);const n=flarum.core.compat["common/extend"],s=flarum.core.compat["forum/components/UserPage"];var a=t.n(s);const i=flarum.core.compat["common/components/LinkButton"];var u=t.n(i);function l(t,o){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},l(t,o)}function c(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,l(t,o)}const y=flarum.core.compat.Component;var p=t.n(y);const d=flarum.core.compat.app;var h=t.n(d);const f=flarum.core.compat["components/LoadingIndicator"];var g=t.n(f);const v=flarum.core.compat["components/Button"];var b=t.n(v);const M=flarum.core.compat["components/Link"];var x=t.n(M);const H=flarum.core.compat["helpers/avatar"];var O=t.n(H);const _=flarum.core.compat["helpers/username"];var R=t.n(_),j=function(t){function o(){return t.apply(this,arguments)||this}return c(o,t),o.prototype.view=function(){var t=this.attrs.userMoneyHistory,o=t.changeTime(),e=t.money(),r=t.sourceDesc(),n=t.id(),s=(t.user(),t.createUser()),a=t.balanceMoney(),i=t.lastMoney(),u=app.translator.trans("D"===t.type()?"mattoid-money-history.forum.record.money-out":"mattoid-money-history.forum.record.money-in"),l="D"===t.type()?"color:red":"color:green";return m("div",{className:"transferHistoryContainer"},m("div",{style:"padding-top: 5px;"},m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-type"),": "),m("span",{style:l},u)," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-assign-at"),": "),o),m("div",{style:"padding-top: 5px;"},m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-id"),": "),n," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-from-user"),": "),m(x(),{href:"#",className:"moneyHistoryUser",style:"color:var(--heading-color)"},O()(s)," ",R()(s))," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-amount"),": "),e," | ",m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-balance"),": "),a," → ",i," | ",m("span",null,m("b",null,app.translator.trans("mattoid-money-history.forum.record.money-list-transfer-notes"),": "),r)))},o}(p()),P=function(t){function o(){return t.apply(this,arguments)||this}c(o,t);var e=o.prototype;return e.oninit=function(o){t.prototype.oninit.call(this,o),this.loading=!0,this.moreResults=!1,this.userMoneyHistory=[],this.user=this.attrs.params.user,this.loadResults()},e.view=function(){var t=this;return this.loading&&g().component({size:"large"}),m("div",null,m("div",{style:"padding-bottom:10px; font-size: 24px;font-weight: bold;"},h().translator.trans("mattoid-money-history.forum.title")),m("ul",{style:"margin: 0;padding: 0;list-style-type: none;position: relative;"},this.userMoneyHistory.map((function(t){return m("li",{style:"padding-top:5px",key:t.id,"data-id":t.id},j.component({userMoneyHistory:t}))}))),!this.loading&&0===this.userMoneyHistory.length&&m("div",null,m("div",{style:"font-size:1.4em;color: var(--muted-more-color);text-align: center;height: 300px;line-height: 100px;"},h().translator.trans("mattoid-money-history.forum.list-empty"))),this.hasMoreResults()&&m("div",{style:"text-align:center;padding:20px"},m(b(),{className:"Button Button--primary",disabled:this.loading,loading:this.loading,onclick:function(){return t.loadMore()}},h().translator.trans("mattoid-money-history.forum.money-list-load-more"))))},e.loadMore=function(){this.loading=!0,this.loadResults(this.userMoneyHistory.length)},e.parseResults=function(t){return this.moreResults=!!t.payload.links&&!!t.payload.links.next,[].push.apply(this.userMoneyHistory,t),this.loading=!1,m.redraw(),t},e.hasMoreResults=function(){return this.moreResults},e.loadResults=function(t){void 0===t&&(t=0);var o="/users/"+this.user.id()+"/money/history";return h().store.find(o,{filter:{user:this.user.id()},page:{offset:t}}).catch((function(){})).then(this.parseResults.bind(this))},o}(p()),k=function(t){function o(){return t.apply(this,arguments)||this}c(o,t);var e=o.prototype;return e.oninit=function(o){t.prototype.oninit.call(this,o),this.loadUser(m.route.param("username"))},e.content=function(){return m("div",{className:"Post-body"},P.component({params:{user:this.user}}))},o}(a());const U=flarum.core.compat["common/Model"];var w=t.n(U),S=function(t){function o(){return t.apply(this,arguments)||this}return c(o,t),o}(w());Object.assign(S.prototype,{type:w().attribute("type"),money:w().attribute("money"),sourceDesc:w().attribute("source_desc"),changeTime:w().attribute("change_time"),balanceMoney:w().attribute("balance_money"),lastMoney:w().attribute("last_money"),user:w().hasOne("user"),createUser:w().hasOne("createUser")}),r().initializers.add("flarum-ext-money-history",(function(){r().store.models.userMoneyHistory=S,r().routes.userMoneyHistory={path:"/u/:username/money/history",component:k},(0,n.extend)(a().prototype,"navItems",(function(t){(r().session.user.id()===this.user.id()||this.user&&this.user.attribute("canQueryOthersHistory"))&&t.add("userMoneyHistory",u().component({href:r().route("userMoneyHistory",{username:this.user.slug()}),icon:"fas fa-money-bill"},r().translator.trans("mattoid-money-history.forum.nav")))}))}))})(),module.exports=o})(); //# 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 5b1094f..2695336 100644 --- a/js/dist/forum.js.map +++ b/js/dist/forum.js.map @@ -1 +1 @@ -{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDR,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX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AUX,IAAAA,QAAYJ,KAAKe,aAE7BqD,KAAM,qBACLhE,IAAAA,WAAeE,MAAM,oCAC1B,GACF,G","sources":["webpack://@mattoid/flarum-ext-money-history/webpack/bootstrap","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/compat get default export","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/define property getters","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/hasOwnProperty shorthand","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/make namespace object","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['forum/app']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['common/extend']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['forum/components/UserPage']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['common/components/LinkButton']\"","webpack://@mattoid/flarum-ext-money-history/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@mattoid/flarum-ext-money-history/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['Component']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['app']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['components/LoadingIndicator']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['components/Button']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['components/Link']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['helpers/avatar']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['helpers/username']\"","webpack://@mattoid/flarum-ext-money-history/./src/forum/components/MoneyHistoryListItem.js","webpack://@mattoid/flarum-ext-money-history/./src/forum/components/MoneyHistoryList.js","webpack://@mattoid/flarum-ext-money-history/./src/forum/components/MoneyHistoryPage.js","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['common/Model']\"","webpack://@mattoid/flarum-ext-money-history/./src/forum/models/UserMoneyHistory.js","webpack://@mattoid/flarum-ext-money-history/./src/forum/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/LinkButton'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/LoadingIndicator'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Button'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Link'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/avatar'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/username'];","import Component from \"flarum/Component\";\nimport Link from \"flarum/components/Link\";\nimport avatar from \"flarum/helpers/avatar\";\nimport username from \"flarum/helpers/username\";\n\nexport default class TransferHistoryListItem extends Component {\n view() {\n const {userMoneyHistory} = this.attrs;\n const changeTime = userMoneyHistory.changeTime();\n const money = userMoneyHistory.money();\n const sourceDesc = userMoneyHistory.sourceDesc();\n const moneyID = userMoneyHistory.id();\n const moneyUser = userMoneyHistory.user();\n const createUser = userMoneyHistory.createUser();\n const balanceMoney = userMoneyHistory.balanceMoney();\n const lastMoney = userMoneyHistory.lastMoney();\n const moneyType = app.translator.trans(userMoneyHistory.type()==='D'?\"mattoid-money-history.forum.record.money-out\":\"mattoid-money-history.forum.record.money-in\");\n const moneyTypeStyle = userMoneyHistory.type()==='D'?\"color:red\":\"color:green\";\n\n return (\n
\n
\n {app.translator.trans('mattoid-money-history.forum.record.money-list-type')}: \n {moneyType} | \n\n {app.translator.trans('mattoid-money-history.forum.record.money-list-assign-at')}: \n {changeTime}\n
\n\n
\n {app.translator.trans('mattoid-money-history.forum.record.money-list-id')}: \n {moneyID} | \n {app.translator.trans('mattoid-money-history.forum.record.money-list-from-user')}: \n \n {avatar(createUser)} {username(createUser)}\n  | \n {app.translator.trans('mattoid-money-history.forum.record.money-list-amount')}: \n {money} | \n {app.translator.trans('mattoid-money-history.forum.record.money-list-balance')}: \n {balanceMoney} → {lastMoney} | \n \n {app.translator.trans('mattoid-money-history.forum.record.money-list-transfer-notes')}: \n {sourceDesc}\n \n
\n
\n );\n }\n}\n","import Component from \"flarum/Component\";\nimport app from \"flarum/app\";\nimport LoadingIndicator from \"flarum/components/LoadingIndicator\";\nimport Button from \"flarum/components/Button\";\n\nimport MoneyHistoryListItem from \"./MoneyHistoryListItem\";\n\nexport default class TransferHistoryList extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n this.loading = true;\n this.moreResults = false;\n this.userMoneyHistory = [];\n this.user = this.attrs.params.user;\n this.loadResults();\n }\n\n view() {\n let loading;\n\n if (this.loading) {\n loading = LoadingIndicator.component({ size: \"large\" });\n }\n\n return (\n
\n
\n {app.translator.trans(\"mattoid-money-history.forum.title\")}\n
\n \n\n {!this.loading && this.userMoneyHistory.length===0 && (\n
\n
{app.translator.trans(\"mattoid-money-history.forum.list-empty\")}
\n
\n )}\n\n {this.hasMoreResults() && (\n
\n \n
\n )}\n
\n );\n }\n\n loadMore() {\n this.loading = true;\n this.loadResults(this.userMoneyHistory.length);\n }\n\n parseResults(results) {\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n [].push.apply(this.userMoneyHistory, results);\n this.loading = false;\n m.redraw();\n\n return results;\n }\n\n hasMoreResults() {\n return this.moreResults;\n }\n\n loadResults(offset = 0) {\n let url = '/users/' + this.user.id() + '/money/history';\n return app.store\n .find(url, {\n filter: {\n user: this.user.id(),\n },\n page: {\n offset,\n },\n })\n .catch(() => {})\n .then(this.parseResults.bind(this));\n }\n}\n","import UserPage from 'flarum/forum/components/UserPage';\nimport MoneyHistoryList from \"./MoneyHistoryList\";\n\nexport default class MoneyHistoryPage extends UserPage {\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loadUser(m.route.param('username'));\n }\n\n content() {\n return (\n
\n {MoneyHistoryList.component({\n params: {\n user: this.user,\n },\n })}\n
\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Model'];","import Model from 'flarum/common/Model';\n\nexport default class UserMoneyHistory extends Model {}\nObject.assign(UserMoneyHistory.prototype, {\n type : Model.attribute('type'),\n money : Model.attribute('money'),\n sourceDesc : Model.attribute('source_desc'),\n changeTime : Model.attribute('change_time'),\n balanceMoney: Model.attribute('balance_money'),\n lastMoney: Model.attribute('last_money'),\n user : Model.hasOne('user'),\n createUser : Model.hasOne('createUser')\n})\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport LinkButton from 'flarum/common/components/LinkButton';\nimport MoneyHistoryPage from './components/MoneyHistoryPage';\nimport UserMoneyHistory from \"./models/UserMoneyHistory\";\n\napp.initializers.add('flarum-ext-money-history', () => {\n app.store.models.userMoneyHistory = UserMoneyHistory;\n\n app.routes.userMoneyHistory = {\n path: '/u/:username/money/history',\n component: MoneyHistoryPage,\n };\n\n extend(UserPage.prototype, 'navItems', function (items) {\n if (!app.session.user) {\n return;\n }\n\n\n items.add('userMoneyHistory', LinkButton.component({\n href: app.route('userMoneyHistory', {\n username: app.session.user.username(),\n }),\n icon: 'fas fa-money-bill',\n }, app.translator.trans('mattoid-money-history.forum.nav')));\n });\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","_inheritsLoose","subClass","superClass","create","constructor","TransferHistoryListItem","_Component","apply","arguments","view","userMoneyHistory","this","attrs","changeTime","money","sourceDesc","moneyID","id","createUser","user","balanceMoney","lastMoney","moneyType","app","translator","trans","type","moneyTypeStyle","m","className","style","Link","href","avatar","username","Component","TransferHistoryList","_proto","oninit","vnode","loading","moreResults","params","loadResults","_this","LoadingIndicator","size","map","MoneyHistoryListItem","component","length","hasMoreResults","Button","disabled","onclick","loadMore","parseResults","results","payload","links","next","push","redraw","offset","url","find","filter","page","then","MoneyHistoryPage","_UserPage","loadUser","route","param","content","MoneyHistoryList","UserPage","UserMoneyHistory","_Model","Model","assign","add","models","path","extend","items","LinkButton","icon"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"forum.js","mapp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iE,IAAAA,UAAgB,SACxBhE,WAAagE,IAAAA,UAAgB,eAC7BlE,WAAakE,IAAAA,UAAgB,eAC7B3D,aAAc2D,IAAAA,UAAgB,iBAC9B1D,UAAW0D,IAAAA,UAAgB,cAC3B5D,KAAO4D,IAAAA,OAAa,QACpB7D,WAAa6D,IAAAA,OAAa,gBCJ5BxD,IAAAA,aAAiB0D,IAAI,4BAA4B,WAC/C1D,IAAAA,MAAU2D,OAAOxE,iBAAmBmE,EAEpCtD,IAAAA,OAAWb,iBAAmB,CAC5ByE,KAAM,6BACNlC,UAAWoB,IAGbe,EAAAA,EAAAA,QAAOR,IAAAA,UAAoB,YAAY,SAAUS,IAC3C9D,IAAAA,QAAYJ,KAAKF,OAASN,KAAKQ,KAAKF,MACjCN,KAAKQ,MAASR,KAAKQ,KAAKmE,UAAU,2BAMzCD,EAAMJ,IAAI,mBAAoBM,IAAAA,UAAqB,CACjDvD,KAAMT,IAAAA,MAAU,mBAAoB,CAClCW,SAAUvB,KAAKQ,KAAKqE,SAEtBC,KAAM,qBACLlE,IAAAA,WAAeE,MAAM,oCAC1B,GACF,G","sources":["webpack://@mattoid/flarum-ext-money-history/webpack/bootstrap","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/compat get default export","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/define property getters","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/hasOwnProperty shorthand","webpack://@mattoid/flarum-ext-money-history/webpack/runtime/make namespace object","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['forum/app']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['common/extend']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['forum/components/UserPage']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['common/components/LinkButton']\"","webpack://@mattoid/flarum-ext-money-history/./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","webpack://@mattoid/flarum-ext-money-history/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['Component']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['app']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['components/LoadingIndicator']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['components/Button']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['components/Link']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['helpers/avatar']\"","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['helpers/username']\"","webpack://@mattoid/flarum-ext-money-history/./src/forum/components/MoneyHistoryListItem.js","webpack://@mattoid/flarum-ext-money-history/./src/forum/components/MoneyHistoryList.js","webpack://@mattoid/flarum-ext-money-history/./src/forum/components/MoneyHistoryPage.js","webpack://@mattoid/flarum-ext-money-history/external root \"flarum.core.compat['common/Model']\"","webpack://@mattoid/flarum-ext-money-history/./src/forum/models/UserMoneyHistory.js","webpack://@mattoid/flarum-ext-money-history/./src/forum/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/UserPage'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/components/LinkButton'];","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['Component'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/LoadingIndicator'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Button'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['components/Link'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/avatar'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['helpers/username'];","import Component from \"flarum/Component\";\nimport Link from \"flarum/components/Link\";\nimport avatar from \"flarum/helpers/avatar\";\nimport username from \"flarum/helpers/username\";\n\nexport default class TransferHistoryListItem extends Component {\n view() {\n const {userMoneyHistory} = this.attrs;\n const changeTime = userMoneyHistory.changeTime();\n const money = userMoneyHistory.money();\n const sourceDesc = userMoneyHistory.sourceDesc();\n const moneyID = userMoneyHistory.id();\n const moneyUser = userMoneyHistory.user();\n const createUser = userMoneyHistory.createUser();\n const balanceMoney = userMoneyHistory.balanceMoney();\n const lastMoney = userMoneyHistory.lastMoney();\n const moneyType = app.translator.trans(userMoneyHistory.type()==='D'?\"mattoid-money-history.forum.record.money-out\":\"mattoid-money-history.forum.record.money-in\");\n const moneyTypeStyle = userMoneyHistory.type()==='D'?\"color:red\":\"color:green\";\n\n return (\n
\n
\n {app.translator.trans('mattoid-money-history.forum.record.money-list-type')}: \n {moneyType} | \n\n {app.translator.trans('mattoid-money-history.forum.record.money-list-assign-at')}: \n {changeTime}\n
\n\n
\n {app.translator.trans('mattoid-money-history.forum.record.money-list-id')}: \n {moneyID} | \n {app.translator.trans('mattoid-money-history.forum.record.money-list-from-user')}: \n \n {avatar(createUser)} {username(createUser)}\n  | \n {app.translator.trans('mattoid-money-history.forum.record.money-list-amount')}: \n {money} | \n {app.translator.trans('mattoid-money-history.forum.record.money-list-balance')}: \n {balanceMoney} → {lastMoney} | \n \n {app.translator.trans('mattoid-money-history.forum.record.money-list-transfer-notes')}: \n {sourceDesc}\n \n
\n
\n );\n }\n}\n","import Component from \"flarum/Component\";\nimport app from \"flarum/app\";\nimport LoadingIndicator from \"flarum/components/LoadingIndicator\";\nimport Button from \"flarum/components/Button\";\n\nimport MoneyHistoryListItem from \"./MoneyHistoryListItem\";\n\nexport default class TransferHistoryList extends Component {\n oninit(vnode) {\n super.oninit(vnode);\n this.loading = true;\n this.moreResults = false;\n this.userMoneyHistory = [];\n this.user = this.attrs.params.user;\n this.loadResults();\n }\n\n view() {\n let loading;\n\n if (this.loading) {\n loading = LoadingIndicator.component({ size: \"large\" });\n }\n\n return (\n
\n
\n {app.translator.trans(\"mattoid-money-history.forum.title\")}\n
\n \n\n {!this.loading && this.userMoneyHistory.length===0 && (\n
\n
{app.translator.trans(\"mattoid-money-history.forum.list-empty\")}
\n
\n )}\n\n {this.hasMoreResults() && (\n
\n \n
\n )}\n
\n );\n }\n\n loadMore() {\n this.loading = true;\n this.loadResults(this.userMoneyHistory.length);\n }\n\n parseResults(results) {\n this.moreResults = !!results.payload.links && !!results.payload.links.next;\n [].push.apply(this.userMoneyHistory, results);\n this.loading = false;\n m.redraw();\n\n return results;\n }\n\n hasMoreResults() {\n return this.moreResults;\n }\n\n loadResults(offset = 0) {\n let url = '/users/' + this.user.id() + '/money/history';\n return app.store\n .find(url, {\n filter: {\n user: this.user.id(),\n },\n page: {\n offset,\n },\n })\n .catch(() => {})\n .then(this.parseResults.bind(this));\n }\n}\n","import UserPage from 'flarum/forum/components/UserPage';\nimport MoneyHistoryList from \"./MoneyHistoryList\";\n\nexport default class MoneyHistoryPage extends UserPage {\n\n oninit(vnode) {\n super.oninit(vnode);\n\n this.loadUser(m.route.param('username'));\n }\n\n content() {\n return (\n
\n {MoneyHistoryList.component({\n params: {\n user: this.user,\n },\n })}\n
\n );\n }\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/Model'];","import Model from 'flarum/common/Model';\n\nexport default class UserMoneyHistory extends Model {}\nObject.assign(UserMoneyHistory.prototype, {\n type : Model.attribute('type'),\n money : Model.attribute('money'),\n sourceDesc : Model.attribute('source_desc'),\n changeTime : Model.attribute('change_time'),\n balanceMoney: Model.attribute('balance_money'),\n lastMoney: Model.attribute('last_money'),\n user : Model.hasOne('user'),\n createUser : Model.hasOne('createUser')\n})\n","import app from 'flarum/forum/app';\nimport { extend } from 'flarum/common/extend';\nimport UserPage from 'flarum/forum/components/UserPage';\nimport LinkButton from 'flarum/common/components/LinkButton';\nimport MoneyHistoryPage from './components/MoneyHistoryPage';\nimport UserMoneyHistory from \"./models/UserMoneyHistory\";\n\napp.initializers.add('flarum-ext-money-history', () => {\n app.store.models.userMoneyHistory = UserMoneyHistory;\n\n app.routes.userMoneyHistory = {\n path: '/u/:username/money/history',\n component: MoneyHistoryPage,\n };\n\n extend(UserPage.prototype, 'navItems', function (items) {\n if (app.session.user.id() !== this.user.id()) {\n if (!this.user || !this.user.attribute('canQueryOthersHistory')) {\n return;\n }\n }\n\n\n items.add('userMoneyHistory', LinkButton.component({\n href: app.route('userMoneyHistory', {\n username: this.user.slug(),\n }),\n icon: 'fas fa-money-bill',\n }, app.translator.trans('mattoid-money-history.forum.nav')));\n });\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","_setPrototypeOf","p","setPrototypeOf","bind","__proto__","_inheritsLoose","subClass","superClass","create","constructor","TransferHistoryListItem","_Component","apply","arguments","view","userMoneyHistory","this","attrs","changeTime","money","sourceDesc","moneyID","id","createUser","user","balanceMoney","lastMoney","moneyType","app","translator","trans","type","moneyTypeStyle","m","className","style","Link","href","avatar","username","Component","TransferHistoryList","_proto","oninit","vnode","loading","moreResults","params","loadResults","_this","LoadingIndicator","size","map","MoneyHistoryListItem","component","length","hasMoreResults","Button","disabled","onclick","loadMore","parseResults","results","payload","links","next","push","redraw","offset","url","find","filter","page","then","MoneyHistoryPage","_UserPage","loadUser","route","param","content","MoneyHistoryList","UserPage","UserMoneyHistory","_Model","Model","assign","add","models","path","extend","items","attribute","LinkButton","slug","icon"],"sourceRoot":""} \ No newline at end of file diff --git a/js/src/admin/index.ts b/js/src/admin/index.ts index 98f04a5..eae615a 100644 --- a/js/src/admin/index.ts +++ b/js/src/admin/index.ts @@ -1,5 +1,12 @@ import app from 'flarum/admin/app'; app.initializers.add('mattoid/flarum-ext-money-history', () => { - console.log('[mattoid/flarum-ext-money-history] Hello, forum and admin!'); + app.extensionData.for("mattoid-money-history") + .registerPermission( + { + icon: 'fas fa-id-card', + label: app.translator.trans('mattoid-money-history.admin.settings.query-others-history'), + permission: 'money-history.queryOthersMoneyHistory', + allowGuest: true + }, 'view') }); diff --git a/js/src/forum/index.ts b/js/src/forum/index.ts index 69566f1..ba7909a 100644 --- a/js/src/forum/index.ts +++ b/js/src/forum/index.ts @@ -14,14 +14,16 @@ app.initializers.add('flarum-ext-money-history', () => { }; extend(UserPage.prototype, 'navItems', function (items) { - if (!app.session.user) { - return; + if (app.session.user.id() !== this.user.id()) { + if (!this.user || !this.user.attribute('canQueryOthersHistory')) { + return; + } } items.add('userMoneyHistory', LinkButton.component({ href: app.route('userMoneyHistory', { - username: app.session.user.username(), + username: this.user.slug(), }), icon: 'fas fa-money-bill', }, app.translator.trans('mattoid-money-history.forum.nav'))); diff --git a/src/Api/Controller/ListUserMoneyHistoryController.php b/src/Api/Controller/ListUserMoneyHistoryController.php index 3c8182e..a9968c2 100644 --- a/src/Api/Controller/ListUserMoneyHistoryController.php +++ b/src/Api/Controller/ListUserMoneyHistoryController.php @@ -7,6 +7,7 @@ use Mattoid\MoneyHistory\Api\Serializer\MoneyHistorySerializer; use Mattoid\MoneyHistory\model\UserMoneyHistory; use Psr\Http\Message\ServerRequestInterface; +use Illuminate\Support\Arr; use Tobscure\JsonApi\Document; use Flarum\Http\UrlGenerator; @@ -35,8 +36,11 @@ protected function data(ServerRequestInterface $request, Document $document) $limit = $this->extractLimit($request); $offset = $this->extractOffset($request); - $userID = $actor->id; - $moneyHistoryQuery = UserMoneyHistory::query()->where(["user_id"=>$userID]); + $userId = Arr::get($request->getQueryParams(), 'id'); + if (!$userId) { + $userId = $actor->id; + } + $moneyHistoryQuery = UserMoneyHistory::query()->where(["user_id"=>$userId]); $MoneyHistoryResult = $moneyHistoryQuery ->skip($offset) ->take($limit + 1) @@ -50,7 +54,7 @@ protected function data(ServerRequestInterface $request, Document $document) } $document->addPaginationLinks( - $this->url->to('api')->route('user.money.history', ['id' => $userID]), + $this->url->to('api')->route('user.money.history', ['id' => $userId]), $params, $offset, $limit, diff --git a/src/Attributes/UserAttributes.php b/src/Attributes/UserAttributes.php new file mode 100644 index 0000000..67de0ab --- /dev/null +++ b/src/Attributes/UserAttributes.php @@ -0,0 +1,20 @@ +getActor()->cannot('queryOthersMoneyHistory', $user)) { + return []; + } + + return [ + 'canQueryOthersMoneyHistory' => true, + ]; + } +}