Browse Source

added field to userlistPage

main 0.1.2
Marco Colia 3 years ago
parent
commit
478a95a471
  1. 2
      js/dist/admin.js
  2. 2
      js/dist/admin.js.map
  3. 4
      js/dist/forum.js
  4. 2
      js/dist/forum.js.map
  5. 19
      js/src/admin/index.js
  6. 3
      js/src/forum/components/AddLocationComponent.js
  7. 17
      js/src/forum/index.js
  8. 1
      locale/en.yml

2
js/dist/admin.js vendored

@ -1,2 +1,2 @@
module.exports=function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=10)}({10:function(e,t,r){"use strict";r.r(t);var o=r(2),n=r.n(o);n.a.initializers.add("justoverclock/users-map-location",(function(){n.a.extensionData.for("justoverclock-users-map-location").registerSetting({setting:"justoverclock-users-map-location.mapBox-api-key",name:"justoverclock-users-map-location.mapBox-api-key",type:"text",label:n.a.translator.trans("justoverclock-users-map-location.admin.mapBox-api-key"),help:n.a.translator.trans("justoverclock-users-map-location.admin.mapBox-api-key-help")})}))},2:function(e,t){e.exports=flarum.core.compat["admin/app"]}}); module.exports=function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=11)}([,function(t,e){t.exports=flarum.core.compat["common/extend"]},function(t,e){t.exports=flarum.core.compat["admin/app"]},,,,,,function(t,e){t.exports=flarum.core.compat["admin/components/UserListPage"]},,,function(t,e,o){"use strict";o.r(e);var n=o(2),r=o.n(n),a=o(1),i=o(8),u=o.n(i);r.a.initializers.add("justoverclock/users-map-location",(function(){r.a.extensionData.for("justoverclock-users-map-location").registerSetting({setting:"justoverclock-users-map-location.mapBox-api-key",name:"justoverclock-users-map-location.mapBox-api-key",type:"text",label:r.a.translator.trans("justoverclock-users-map-location.admin.mapBox-api-key"),help:r.a.translator.trans("justoverclock-users-map-location.admin.mapBox-api-key-help")}),Object(a.extend)(u.a.prototype,"columns",(function(t){t.add("location",{name:r.a.translator.trans("justoverclock-users-map-location.admin.adminLocationField"),content:function(t){return m("div",null,t.data.attributes.location)}},-50)}))}))}]);
//# sourceMappingURL=admin.js.map //# sourceMappingURL=admin.js.map

2
js/dist/admin.js.map vendored

File diff suppressed because one or more lines are too long

4
js/dist/forum.js vendored

File diff suppressed because one or more lines are too long

2
js/dist/forum.js.map vendored

File diff suppressed because one or more lines are too long

19
js/src/admin/index.js

@ -1,13 +1,26 @@
import app from 'flarum/admin/app'; import app from 'flarum/admin/app';
import { extend } from 'flarum/common/extend';
import UserListPage from 'flarum/admin/components/UserListPage';
app.initializers.add('justoverclock/users-map-location', () => { app.initializers.add('justoverclock/users-map-location', () => {
app.extensionData app.extensionData.for('justoverclock-users-map-location').registerSetting({
.for('justoverclock-users-map-location')
.registerSetting({
setting: 'justoverclock-users-map-location.mapBox-api-key', setting: 'justoverclock-users-map-location.mapBox-api-key',
name: 'justoverclock-users-map-location.mapBox-api-key', name: 'justoverclock-users-map-location.mapBox-api-key',
type: 'text', type: 'text',
label: app.translator.trans('justoverclock-users-map-location.admin.mapBox-api-key'), label: app.translator.trans('justoverclock-users-map-location.admin.mapBox-api-key'),
help: app.translator.trans('justoverclock-users-map-location.admin.mapBox-api-key-help'), help: app.translator.trans('justoverclock-users-map-location.admin.mapBox-api-key-help'),
}); });
extend(UserListPage.prototype, 'columns', function (items) {
items.add(
'location',
{
name: app.translator.trans('justoverclock-users-map-location.admin.adminLocationField'),
content: (user) => {
return <div>{user.data.attributes.location}</div>;
},
},
-50
);
});
}); });

3
js/src/forum/components/AddLocationComponent.js

@ -20,7 +20,8 @@ export default class AddLocationComponent extends Component {
saveValue(e) { saveValue(e) {
const user = app.session.user; const user = app.session.user;
user.save({ user
.save({
location: e.target.value, location: e.target.value,
}) })
.then(app.alerts.show({ type: 'success' }, app.translator.trans('justoverclock-users-map-location.forum.locationSaved'))); .then(app.alerts.show({ type: 'success' }, app.translator.trans('justoverclock-users-map-location.forum.locationSaved')));

17
js/src/forum/index.js

@ -9,8 +9,8 @@ import Leaflet from 'leaflet';
app.initializers.add('justoverclock/users-map-location', () => { app.initializers.add('justoverclock/users-map-location', () => {
User.prototype.location = Model.attribute('location'); User.prototype.location = Model.attribute('location');
extend(UserCard.prototype, 'oncreate', function () {
extend(UserCard.prototype, 'oncreate', function () {
const user = this.attrs.user; const user = this.attrs.user;
let UserLocation = user.location(); let UserLocation = user.location();
const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key'); const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key');
@ -29,7 +29,7 @@ app.initializers.add('justoverclock/users-map-location', () => {
let markerIcon = L.icon({ let markerIcon = L.icon({
iconUrl: markerIconPath, iconUrl: markerIconPath,
iconSize: [28, 45], // size of the icon iconSize: [28, 45], // size of the icon
}) });
let map2 = L.map('map2').setView([this.latitude, this.longitude], 13); let map2 = L.map('map2').setView([this.latitude, this.longitude], 13);
let layerUserCard = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', { let layerUserCard = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
@ -41,8 +41,8 @@ app.initializers.add('justoverclock/users-map-location', () => {
zoomOffset: -1, zoomOffset: -1,
accessToken: publicToken, accessToken: publicToken,
}).addTo(map2); }).addTo(map2);
}) });
}) });
extend(SettingsPage.prototype, 'oncreate', function () { extend(SettingsPage.prototype, 'oncreate', function () {
const location = app.session.user.location(); const location = app.session.user.location();
const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key'); const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key');
@ -76,7 +76,7 @@ app.initializers.add('justoverclock/users-map-location', () => {
zoomOffset: -1, zoomOffset: -1,
accessToken: publicToken, accessToken: publicToken,
}).addTo(map); }).addTo(map);
}) });
}); });
extend(SettingsPage.prototype, 'settingsItems', function (items) { extend(SettingsPage.prototype, 'settingsItems', function (items) {
items.add('location', <AddLocationComponent />); items.add('location', <AddLocationComponent />);
@ -86,9 +86,6 @@ app.initializers.add('justoverclock/users-map-location', () => {
const user = this.attrs.user; const user = this.attrs.user;
let UserLocation = user.location(); let UserLocation = user.location();
if (UserLocation === '') return; if (UserLocation === '') return;
items.add( items.add('mapLocation', <div className="map-div" id="map2" />, -100);
'mapLocation', });
<div className="map-div" id="map2" />, -100
)
})
}); });

1
locale/en.yml

@ -1,5 +1,6 @@
justoverclock-users-map-location: justoverclock-users-map-location:
admin: admin:
adminLocationField: Location
mapBox-api-key: MapBox Public Token mapBox-api-key: MapBox Public Token
mapBox-api-key-help: "retrieve your free public token on <a>https://account.mapbox.com/</a>" mapBox-api-key-help: "retrieve your free public token on <a>https://account.mapbox.com/</a>"
forum: forum:

Loading…
Cancel
Save