forked from MarseyWorld/MarseyWorld
better UI for ping groups
parent
8be4e6adc2
commit
63ff0d8511
|
@ -3131,6 +3131,9 @@ a.bg-light:hover, a.bg-light:focus, button.bg-light:hover, button.bg-light:focus
|
|||
.mb-md-5 {
|
||||
margin-bottom: 3rem !important;
|
||||
}
|
||||
.mb-md-5 {
|
||||
margin-bottom: 5rem !important;
|
||||
}
|
||||
.mb-md-auto {
|
||||
margin-bottom: auto !important;
|
||||
}
|
||||
|
@ -3152,6 +3155,9 @@ a.bg-light:hover, a.bg-light:focus, button.bg-light:hover, button.bg-light:focus
|
|||
.ml-md-5 {
|
||||
margin-left: 3rem !important;
|
||||
}
|
||||
.ml-md-6 {
|
||||
margin-left: 5rem !important;
|
||||
}
|
||||
.ml-md-auto {
|
||||
margin-left: auto !important;
|
||||
}
|
||||
|
@ -5988,12 +5994,12 @@ li > .sidebar {
|
|||
|
||||
@media (max-width: 768px) {
|
||||
.table th {
|
||||
padding-left: 0.5rem !important;
|
||||
padding-right: 0.5rem !important;
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
.table td {
|
||||
padding-left: 0.5rem !important;
|
||||
padding-right: 0.5rem !important;
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.marseybux {
|
||||
|
@ -7186,7 +7192,20 @@ input[type=number] {
|
|||
|
||||
@media (max-width: 768px) {
|
||||
.award-tab {
|
||||
font-size: 10px;
|
||||
letter-spacing: 1px;
|
||||
font-size: 10px !important;
|
||||
letter-spacing: 1px !important;
|
||||
}
|
||||
|
||||
.ping-groups * {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
.ping-groups .btn {
|
||||
font-size: 10px !important;
|
||||
padding: 5px !important;
|
||||
}
|
||||
|
||||
#ping-groups .members {
|
||||
padding-right: 3.7rem !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
function approve_membership(t, url) {
|
||||
const members_tbody = document.getElementById('Members_tbody')
|
||||
|
||||
function approve_membership(t, url, uid) {
|
||||
postToast(t, url,
|
||||
{
|
||||
},
|
||||
() => {
|
||||
t.parentElement.nextElementSibling.classList.remove('d-none');
|
||||
t.parentElement.innerHTML = formatDate(new Date());
|
||||
document.getElementById(`kick-${uid}`).classList.remove('d-none')
|
||||
document.getElementById(`time-${uid}`).innerHTML = formatDate(new Date());
|
||||
document.getElementById(`counter-${uid}`).innerHTML = parseInt(members_tbody.lastElementChild.firstElementChild.innerHTML) + 1
|
||||
|
||||
members_tbody.append(document.getElementById(uid));
|
||||
t.parentElement.remove()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -14,7 +20,7 @@ function reject_membership(t, url) {
|
|||
{
|
||||
},
|
||||
() => {
|
||||
t.parentElement.parentElement.remove();
|
||||
t.parentElement.parentElement.parentElement.remove();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@ def leave_group(v:User, group_name):
|
|||
|
||||
send_notification(group.owner.id, text)
|
||||
g.db.delete(existing)
|
||||
|
||||
return {"message": msg}
|
||||
|
||||
return {"message": ''}
|
||||
|
||||
|
@ -93,12 +95,17 @@ def memberships(v:User, group_name):
|
|||
group = g.db.get(Group, group_name)
|
||||
if not group: abort(404)
|
||||
|
||||
memberships = g.db.query(GroupMembership).filter_by(group_name=group_name).order_by(
|
||||
GroupMembership.approved_utc.desc(),
|
||||
GroupMembership.created_utc.desc(),
|
||||
).all()
|
||||
members = g.db.query(GroupMembership).filter(
|
||||
GroupMembership.group_name == group_name,
|
||||
GroupMembership.approved_utc != None
|
||||
).order_by(GroupMembership.approved_utc).all()
|
||||
|
||||
return render_template('group_memberships.html', v=v, group=group, memberships=memberships)
|
||||
applications = g.db.query(GroupMembership).filter(
|
||||
GroupMembership.group_name == group_name,
|
||||
GroupMembership.approved_utc == None
|
||||
).order_by(GroupMembership.created_utc).all()
|
||||
|
||||
return render_template('group_memberships.html', v=v, group=group, members=members, applications=applications)
|
||||
|
||||
@app.post("/!<group_name>/<user_id>/approve")
|
||||
@limiter.limit(DEFAULT_RATELIMIT_SLOWER, key_func=get_ID)
|
||||
|
|
|
@ -1,46 +1,66 @@
|
|||
{% extends "default.html" %}
|
||||
{% block pagetitle %}!{{group}} Members{% endblock %}
|
||||
{% block content %}
|
||||
<h5 class="my-3">!{{group}} Members</h5>
|
||||
<div class="overflow-x-auto mt-1"><table class="table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Approved on</th>
|
||||
{% if v.id == group.owner.id %}
|
||||
<th class="disable-sort-click"></th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for membership in memberships %}
|
||||
<tr>
|
||||
<td>
|
||||
{% with user=membership.user %}
|
||||
{% include "user_in_table.html" %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
|
||||
{% if membership.approved_utc %}
|
||||
<td data-time="{{membership.approved_utc}}"></td>
|
||||
{% elif v.id == group.owner.id %}
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="approve_membership(this,'/!{{group}}/{{membership.user_id}}/approve')">Approve</button>
|
||||
<button type="button" class="btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="reject_membership(this,'/!{{group}}/{{membership.user_id}}/reject')">Reject</button>
|
||||
</td>
|
||||
{% else %}
|
||||
<td></td>
|
||||
{% endif %}
|
||||
|
||||
{% if v.id == group.owner.id %}
|
||||
<td class="{% if not membership.approved_utc %}d-none{% endif %}">
|
||||
<button type="button" class="btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="reject_membership(this,'/!{{group}}/{{membership.user_id}}/reject')">Kick</button>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
{% macro process_memberships(memberships, name) %}
|
||||
<h5 class="my-3">!{{group}} {{name}}</h5>
|
||||
<div class="overflow-x-auto mt-1">
|
||||
<table class="table table-striped mb-5 ping-groups">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Name</th>
|
||||
|
||||
{% if name == 'Members' %}
|
||||
<th>Approved on</th>
|
||||
{% else %}
|
||||
<th>Applied on</th>
|
||||
{% endif %}
|
||||
|
||||
{% if v.id == group.owner.id %}
|
||||
<th class="disable-sort-click"></th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="{{name}}_tbody">
|
||||
{% for membership in memberships %}
|
||||
<tr id="{{membership.user_id}}">
|
||||
<td id="counter-{{membership.user_id}}">{{loop.index}}</td>
|
||||
<td>
|
||||
{% with user=membership.user %}
|
||||
{% include "user_in_table.html" %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
|
||||
{% if name == 'Members' %}
|
||||
<td id="time-{{membership.user_id}}" data-time="{{membership.approved_utc}}"></td>
|
||||
{% else %}
|
||||
<td id="time-{{membership.user_id}}" data-time="{{membership.created_utc}}"></td>
|
||||
{% endif %}
|
||||
|
||||
{% if v.id == group.owner.id %}
|
||||
<td>
|
||||
<div id="kick-{{membership.user_id}}" {% if name == 'Applications' %}class="d-none"{% endif %}>
|
||||
<button type="button" class="btn btn-primary btn-block" data-nonce="{{g.nonce}}" data-onclick="reject_membership(this,'/!{{group}}/{{membership.user_id}}/reject')">Kick</button>
|
||||
</div>
|
||||
|
||||
<div {% if name == 'Members' %}class="d-none"{% endif %}>
|
||||
<button type="button" class="btn btn-primary btn-block" data-nonce="{{g.nonce}}" data-onclick="approve_membership(this,'/!{{group}}/{{membership.user_id}}/approve','{{membership.user_id}}')">Approve</button>
|
||||
<button type="button" class="btn btn-primary btn-block" data-nonce="{{g.nonce}}" data-onclick="reject_membership(this,'/!{{group}}/{{membership.user_id}}/reject','{{membership.user_id}}')">Reject</button>
|
||||
</div>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{{process_memberships(members, 'Members')}}
|
||||
|
||||
{{process_memberships(applications, 'Applications')}}
|
||||
|
||||
{% if v.id == group.owner.id %}
|
||||
<script defer src="{{'js/group_members_owner.js' | asset}}"></script>
|
||||
|
|
|
@ -6,13 +6,12 @@
|
|||
<div class="px-3">
|
||||
<h3 class="my-3">Ping Groups</h3>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-striped mb-5">
|
||||
<table class="ping-groups table table-striped mb-5">
|
||||
<thead class="bg-primary text-white">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th>Members</th>
|
||||
<th class="disable-sort-click"></th>
|
||||
<th class="members">Members</th>
|
||||
<th>Created on</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -21,10 +20,10 @@
|
|||
<tr>
|
||||
<td>{{loop.index}}</td>
|
||||
<td>{{group.name}}</td>
|
||||
<td><a href="/!{{group}}/members">{{group.member_ids | length}}</a></td>
|
||||
<td>
|
||||
<td class="unbreakable">
|
||||
<a href="/!{{group}}/members">{{group.member_ids | length}}</a>
|
||||
{% if v.id != group.owner.id %}
|
||||
<button id="leave-{{group}}" type="button" class="btn btn-primary {% if v.id not in group.membership_user_ids %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/leave','leave-{{group}}','apply-{{group}}','d-none')">
|
||||
<button id="leave-{{group}}" type="button" class="ml-3 ml-md-5 btn btn-primary {% if v.id not in group.membership_user_ids %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/leave','leave-{{group}}','apply-{{group}}','d-none')">
|
||||
{%- if v.id in group.member_ids -%}
|
||||
Leave
|
||||
{%- else -%}
|
||||
|
@ -32,7 +31,7 @@
|
|||
{%- endif -%}
|
||||
</button>
|
||||
|
||||
<button id="apply-{{group}}" type="button" class="{% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">Apply to Join</button>
|
||||
<button id="apply-{{group}}" type="button" class="ml-3 ml-md-5 {% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">Apply to Join</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td data-time="{{group.created_utc}}"></td>
|
||||
|
@ -43,7 +42,7 @@
|
|||
|
||||
<h3 class="my-3">Create Ping Group</h3>
|
||||
<form class="mt-3" action="/create_group" method="post">
|
||||
<div class="container">
|
||||
<div class="container pb-0">
|
||||
<div class="row mb-4 pb-6">
|
||||
<div class="col col-md-6 px-0 py-3 py-md-0">
|
||||
<div class="body">
|
||||
|
|
Loading…
Reference in New Issue