Commit 5682085c authored by Charlie's avatar Charlie

More fixes

parent 08d16d99
......@@ -77,7 +77,7 @@ System.register('Reflar/UserManagement/components/AdminStrikeModal', ['flarum/co
}).then(function (response) {
_this2.strikes = response.data;
_this2.flatstrikes = [];
for (i = 0; i < _this2.user.data.attributes.strikes; i++) {
for (i = 0; i < _this2.strikes.length; i++) {
_this2.flatstrikes[i] = [];
_this2.flatstrikes[i]['index'] = i + 1;
_this2.flatstrikes[i]['id'] = _this2.strikes[i].attributes['id'];
......@@ -86,7 +86,7 @@ System.register('Reflar/UserManagement/components/AdminStrikeModal', ['flarum/co
_this2.flatstrikes[i]['post'] = _this2.strikes[i].attributes['post'];
_this2.flatstrikes[i]['time'] = new Date(_this2.strikes[i].attributes['time']);
}
if (_this2.user.data.attributes.strikes == 0) {
if (_this2.strikes.length == 0) {
_this2.strikes = undefined;
}
m.redraw();
......@@ -97,9 +97,9 @@ System.register('Reflar/UserManagement/components/AdminStrikeModal', ['flarum/co
key: 'className',
value: function className() {
if (this.strikes !== undefined) {
return 'ModStrikeModal Modal';
return 'AdminStrikeModal Modal';
} else {
return 'Modal Modal--small';
return 'NoStrikeModal Modal Modal--small';
}
}
}, {
......@@ -115,15 +115,15 @@ System.register('Reflar/UserManagement/components/AdminStrikeModal', ['flarum/co
return m('div', { className: 'Modal-body' }, [m('div', { className: 'Form Form--centered' }, [FieldSet.component({
className: 'AdminStrikeModal--fieldset',
children: [this.strikes !== undefined ? m('table', { className: "NotificationGrid" }, [m('thead', [m('tr', [m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.number')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.reason')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.content')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.actor')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.time')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.remove')])])]), m('tbody', [this.flatstrikes.map(function (strike) {
return [m('tr', [m('td', [strike['index']]), m('td', [strike['reason']]), m('td', [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post'] }, [app.translator.trans('reflar-usermanagement.admin.modal.view.link')])]), m('td', [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor'] }, [strike['actor']])]), m('td', [humanTime(strike['time'])]), m('td', [m('a', { className: "icon fa fa-fw fa-times", onclick: function onclick() {
_this3.deleteStrike(strike['id']);
children: [this.strikes !== undefined ? m('table', { className: "NotificationGrid" }, [m('thead', [m('tr', [m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.number')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.reason')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.content')]), m('td', { className: "HideOnMobile" }, [app.translator.trans('reflar-usermanagement.admin.modal.view.actor')]), m('td', { className: "HideOnMobile" }, [app.translator.trans('reflar-usermanagement.admin.modal.view.time')]), m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.remove')])])]), m('tbody', [this.flatstrikes.map(function (strike) {
return [m('tr', [m('td', [strike['index']]), m('td', [strike['reason']]), m('td', [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post'] }, [app.translator.trans('reflar-usermanagement.admin.modal.view.link')])]), m('td', { className: "HideOnMobile" }, [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor'] }, [strike['actor']])]), m('td', { className: "HideOnMobile" }, [humanTime(strike['time'])]), m('td', [m('a', { className: "icon fa fa-fw fa-times", onclick: function onclick() {
_this3.deleteStrike(strike['id'], strike['index']);
} })])])];
})])]) : m('tr', [m('td', [app.translator.trans('reflar-usermanagement.admin.modal.view.no_strikes')])])] })])]);
}
}, {
key: 'deleteStrike',
value: function deleteStrike(id) {
value: function deleteStrike(id, index) {
if (this.loading) return;
......@@ -132,7 +132,7 @@ System.register('Reflar/UserManagement/components/AdminStrikeModal', ['flarum/co
app.request({
method: 'Delete',
url: app.forum.attribute('apiUrl') + '/strike/' + id
}).then(app.modal.close(), this.loaded.bind(this));
}).then(this.flatstrikes.splice(index - 1, 1));
}
}]);
return AdminStrikeModal;
......@@ -234,7 +234,6 @@ System.register('Reflar/UserManagement/components/MemberPage', ['flarum/app', 'f
value: function view() {
var _this2 = this;
console.log(this.users);
var loading = void 0;
if (this.loading) {
......@@ -246,7 +245,7 @@ System.register('Reflar/UserManagement/components/MemberPage', ['flarum/app', 'f
onclick: this.loadMore.bind(this)
});
}
console.log(this.users);
return [m('div', { className: 'MemberListPage' }, [m('div', { className: 'MemberList-header' }, [m('div', { className: 'container' }, [m('p', {}, app.translator.trans('reflar-usermanagement.admin.page.about_text')), m(
'div',
{ className: 'Form-group' },
......
......@@ -17,7 +17,7 @@ export default class AdminStrikeModal extends Modal {
response => {
this.strikes = response.data;
this.flatstrikes = [];
for(i = 0; i < this.user.data.attributes.strikes; i++) {
for(i = 0; i < this.strikes.length; i++) {
this.flatstrikes[i] = [];
this.flatstrikes[i]['index'] = i+1;
this.flatstrikes[i]['id'] = this.strikes[i].attributes['id'];
......@@ -26,7 +26,7 @@ export default class AdminStrikeModal extends Modal {
this.flatstrikes[i]['post'] = this.strikes[i].attributes['post'];
this.flatstrikes[i]['time'] = new Date(this.strikes[i].attributes['time']);
}
if (this.user.data.attributes.strikes == 0) {
if (this.strikes.length == 0) {
this.strikes = undefined;
}
m.redraw();
......@@ -36,9 +36,9 @@ export default class AdminStrikeModal extends Modal {
className() {
if (this.strikes !== undefined) {
return 'ModStrikeModal Modal';
return 'AdminStrikeModal Modal';
} else {
return 'Modal Modal--small'
return 'NoStrikeModal Modal Modal--small'
}
}
......@@ -55,10 +55,10 @@ export default class AdminStrikeModal extends Modal {
className: 'AdminStrikeModal--fieldset',
children: [
(this.strikes !== undefined ?
m('table', {className: "NotificationGrid"}, [m('thead', [m('tr', [m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.number')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.reason')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.content')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.actor')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.time')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.remove')])])]),m('tbody',[
m('table', {className: "NotificationGrid"}, [m('thead', [m('tr', [m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.number')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.reason')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.content')]),m('td', {className: "HideOnMobile"}, [app.translator.trans('reflar-usermanagement.admin.modal.view.actor')]),m('td', {className: "HideOnMobile"}, [app.translator.trans('reflar-usermanagement.admin.modal.view.time')]),m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.remove')])])]),m('tbody',[
this.flatstrikes.map((strike) => {
return [
m('tr', [m('td',[strike['index']]),m('td',[strike['reason']]),m('td',[m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post']},[app.translator.trans('reflar-usermanagement.admin.modal.view.link')])]),m('td',[m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor']},[strike['actor']])]),m('td',[humanTime(strike['time'])]),m('td',[m('a', {className: "icon fa fa-fw fa-times", onclick: ()=>{this.deleteStrike(strike['id'])}})])])
m('tr', [m('td',[strike['index']]),m('td',[strike['reason']]),m('td',[m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post']},[app.translator.trans('reflar-usermanagement.admin.modal.view.link')])]),m('td', {className: "HideOnMobile"}, [m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor']},[strike['actor']])]),m('td', {className: "HideOnMobile"}, [humanTime(strike['time'])]),m('td',[m('a', {className: "icon fa fa-fw fa-times", onclick: ()=>{this.deleteStrike(strike['id'], strike['index'])}})])])
]})])])
: m('tr', [m('td',[app.translator.trans('reflar-usermanagement.admin.modal.view.no_strikes')])])),
]})
......@@ -67,17 +67,16 @@ export default class AdminStrikeModal extends Modal {
)
)}
deleteStrike(id) {
deleteStrike(id, index) {
if (this.loading) return;
this.loading = true;
app.request({
app.request({
method: 'Delete',
url: app.forum.attribute('apiUrl') + '/strike/'+id
}).then(app.modal.close(),
this.loaded.bind(this)
}).then(this.flatstrikes.splice(index - 1, 1)
);
}
}
\ No newline at end of file
......@@ -252,9 +252,10 @@ System.register('Reflar/UserManagement/components/ModStrikeModal', ['flarum/comp
method: 'GET',
url: app.forum.attribute('apiUrl') + '/strike/' + this.user.data.id
}).then(function (response) {
;
_this2.strikes = response.data;
_this2.flatstrikes = [];
for (i = 0; i < _this2.user.data.attributes.strikes; i++) {
for (i = 0; i < _this2.strikes.length; i++) {
_this2.flatstrikes[i] = [];
_this2.flatstrikes[i]['index'] = i + 1;
_this2.flatstrikes[i]['id'] = _this2.strikes[i].attributes['id'];
......@@ -263,7 +264,7 @@ System.register('Reflar/UserManagement/components/ModStrikeModal', ['flarum/comp
_this2.flatstrikes[i]['post'] = _this2.strikes[i].attributes['post'];
_this2.flatstrikes[i]['time'] = new Date(_this2.strikes[i].attributes['time']);
}
if (_this2.user.data.attributes.strikes == 0) {
if (_this2.strikes.length == 0) {
_this2.strikes = undefined;
}
m.redraw();
......@@ -276,7 +277,7 @@ System.register('Reflar/UserManagement/components/ModStrikeModal', ['flarum/comp
if (this.strikes !== undefined) {
return 'ModStrikeModal Modal';
} else {
return 'NoStrikeModa Modal Modal--small';
return 'NoStrikeModal Modal Modal--small';
}
}
}, {
......@@ -291,11 +292,11 @@ System.register('Reflar/UserManagement/components/ModStrikeModal', ['flarum/comp
return m('div', { className: 'Modal-body' }, [m('div', { className: 'Form Form--centered' }, [FieldSet.component({
className: 'ModStrikeModal--fieldset',
children: [this.strikes !== undefined ? m('table', { className: "NotificationGrid" }, [m('thead', [m('tr', [m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.number')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.reason')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.content')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.actor')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.time')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.remove')])])]), m('tbody', [this.flatstrikes.map(function (strike) {
return [m('tr', [m('td', [strike['index']]), m('td', [strike['reason']]), m('td', [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post'] }, [app.translator.trans('reflar-usermanagement.forum.modal.view.link')])]), m('td', [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor'] }, [strike['actor']])]), m('td', [humanTime(strike['time'])]), m('td', [m('a', { className: "icon fa fa-fw fa-times", onclick: function onclick() {
children: [this.strikes !== undefined ? m('table', { className: "NotificationGrid StrikeTable" }, [m('thead', [m('tr', [m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.number')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.reason')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.content')]), m('td', { className: "HideOnMobile" }, [app.translator.trans('reflar-usermanagement.forum.modal.view.actor')]), m('td', { className: "HideOnMobile" }, [app.translator.trans('reflar-usermanagement.forum.modal.view.time')]), m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.remove')])])]), m('tbody', [this.flatstrikes.map(function (strike) {
return [m('tr', [m('td', [strike['index']]), m('td', [strike['reason']]), m('td', [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post'] }, [app.translator.trans('reflar-usermanagement.forum.modal.view.link')])]), m('td', { className: "HideOnMobile" }, [m('a', { target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor'] }, [strike['actor']])]), m('td', { className: "HideOnMobile" }, [humanTime(strike['time'])]), m('td', [m('a', { className: "icon fa fa-fw fa-times", onclick: function onclick() {
_this3.deleteStrike(strike['id'], strike['index']);
} })])])];
})])]) : m('tr', [m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.no_strikes')])])] })])]);
})])]) : m('tr', { className: "Test" }, [m('td', [app.translator.trans('reflar-usermanagement.forum.modal.view.no_strikes')])])] })])]);
}
}, {
key: 'deleteStrike',
......@@ -308,7 +309,7 @@ System.register('Reflar/UserManagement/components/ModStrikeModal', ['flarum/comp
app.request({
method: 'Delete',
url: app.forum.attribute('apiUrl') + '/strike/' + id
}).then(this.flatstrikes.splice(index - 1, 1), m.redraw(), this.loaded.bind(this));
}).then(this.flatstrikes.splice(index - 1, 1), app.modal.close());
}
}]);
return ModStrikeModal;
......
......@@ -17,15 +17,15 @@ export default class ModStrikeModal extends Modal {
var username = this.user.data.attributes.username;
this.title = m.prop(app.translator.trans('reflar-usermanagement.forum.user.controls.modal', {username}));
}
app.request({
method: 'GET',
url: app.forum.attribute('apiUrl') + '/strike/'+this.user.data.id,
method: 'GET',
url: app.forum.attribute('apiUrl') + '/strike/'+this.user.data.id,
}).then(
response => {
response => {;
this.strikes = response.data;
this.flatstrikes = [];
for(i = 0; i < this.user.data.attributes.strikes; i++) {
for(i = 0; i < this.strikes.length; i++) {
this.flatstrikes[i] = [];
this.flatstrikes[i]['index'] = i+1;
this.flatstrikes[i]['id'] = this.strikes[i].attributes['id'];
......@@ -34,7 +34,7 @@ export default class ModStrikeModal extends Modal {
this.flatstrikes[i]['post'] = this.strikes[i].attributes['post'];
this.flatstrikes[i]['time'] = new Date(this.strikes[i].attributes['time']);
}
if (this.user.data.attributes.strikes == 0) {
if (this.strikes.length == 0) {
this.strikes = undefined;
}
m.redraw();
......@@ -46,13 +46,14 @@ export default class ModStrikeModal extends Modal {
if (this.strikes !== undefined) {
return 'ModStrikeModal Modal';
} else {
return 'NoStrikeModa Modal Modal--small'
return 'NoStrikeModal Modal Modal--small'
}
}
title() {
return this.title;
}
content() {
......@@ -63,12 +64,12 @@ export default class ModStrikeModal extends Modal {
className: 'ModStrikeModal--fieldset',
children: [
(this.strikes !== undefined ?
m('table', {className: "NotificationGrid"}, [m('thead', [m('tr', [m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.number')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.reason')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.content')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.actor')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.time')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.remove')])])]),m('tbody',[
m('table', {className: "NotificationGrid StrikeTable"}, [m('thead', [m('tr', [m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.number')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.reason')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.content')]),m('td', {className: "HideOnMobile"}, [app.translator.trans('reflar-usermanagement.forum.modal.view.actor')]),m('td', {className: "HideOnMobile"}, [app.translator.trans('reflar-usermanagement.forum.modal.view.time')]),m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.remove')])])]),m('tbody',[
this.flatstrikes.map((strike) => {
return [
m('tr', [m('td',[strike['index']]),m('td',[strike['reason']]),m('td',[m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post']},[app.translator.trans('reflar-usermanagement.forum.modal.view.link')])]),m('td',[m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor']},[strike['actor']])]),m('td',[humanTime(strike['time'])]),m('td',[m('a', {className: "icon fa fa-fw fa-times", onclick: ()=>{this.deleteStrike(strike['id'], strike['index'])}})])])
m('tr', [m('td',[strike['index']]),m('td',[strike['reason']]),m('td',[m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/d/' + strike['post']},[app.translator.trans('reflar-usermanagement.forum.modal.view.link')])]),m('td', {className: "HideOnMobile"}, [m('a', {target: "_blank", href: app.forum.attribute('baseUrl') + '/u/' + strike['actor']},[strike['actor']])]),m('td', {className: "HideOnMobile"}, [humanTime(strike['time'])]),m('td',[m('a', {className: "icon fa fa-fw fa-times", onclick: ()=>{this.deleteStrike(strike['id'], strike['index'])}})])])
]})])])
: m('tr', [m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.no_strikes')])])),
: m('tr', {className: "Test"}, [m('td',[app.translator.trans('reflar-usermanagement.forum.modal.view.no_strikes')])])),
]})
]
)]
......@@ -85,8 +86,7 @@ export default class ModStrikeModal extends Modal {
method: 'Delete',
url: app.forum.attribute('apiUrl') + '/strike/'+id
}).then(this.flatstrikes.splice(index - 1, 1),
m.redraw(),
this.loaded.bind(this)
app.modal.close()
);
}
}
\ No newline at end of file
......@@ -8,27 +8,31 @@
text-align: center !important;
margin: auto !important;
li {
list-style-type: none;
> ul {
list-style: none;
}
}
@media only screen and (max-width: 767px) {
.HideOnMobile {
display: none;
}
}
}
.NoStrikeModal {
.ModStrikeModal--fieldset
.AdminStrikeModal--fieldset
{
text-align: center !important;
margin: auto !important;
li {
list-style-type: none;
> ul {
list-style: none;
}
}
}
.NotificationGrid {
background: #eaeef0;
border-radius: 4px
}
......
......@@ -6,9 +6,19 @@
text-align: center !important;
margin: auto !important;
li {
> ul {
list-style-type: none;
padding: 0px;
}
.StrikeTable {
margin: auto;
}
@media only screen and (max-width: 767px) {
.HideOnMobile {
display: none;
}
}
}
}
......@@ -19,8 +29,8 @@
text-align: center !important;
margin: auto !important;
li {
list-style-type: none;
> ul {
list-style: none;
}
}
}
......
......@@ -15,7 +15,7 @@ reflar-usermanagement:
time: Time
reason: Reason
link: Link
remove: remove
remove: Remove
title : "{username}'s Strikes"
settings_title: Settings
email_switch: Disable email registration
......@@ -65,4 +65,4 @@ reflar-usermanagement:
time: Time
reason: Reason
link: Link
remove: remove
remove: Remove
......@@ -10,7 +10,7 @@
namespace Reflar\UserManagement\Api\Controllers;
use Flarum\Api\Controller\AbstractCollectionControlle
use Flarum\Api\Controller\AbstractCollectionController;
use Flarum\Core\Access\AssertPermissionTrait;
use Psr\Http\Message\ServerRequestInterface;
use Reflar\UserManagement\Api\Serializers\StrikeSerializer;
......@@ -39,6 +39,6 @@ class DeleteStrikeController extends AbstractCollectionController
$this->assertCan($request->getAttribute('actor'), 'user.strike');
$id = array_get($request->getQueryParams(), 'id');
return $this->strikes->deleteStrike($id, $actor);
$this->strikes->deleteStrike($id, $actor);
}
}
......@@ -79,7 +79,6 @@ class AddApiAttributes
if ($event->isSerializer(UserSerializer::class)) {
$event->attributes['canActivate'] = $event->actor->can('activate', $event->model);
$event->attributes['canViewStrike'] = $event->actor->can('strike', $event->model);
$event->attributes['strikes'] = $event->model->strikes;
$event->attributes['gender'] = $event->model->gender;
$event->attributes['age'] = $event->model->age;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment