small refactor to buttons on userpages

master
Aevann1 2022-11-01 00:43:18 +02:00
parent fa43317ee2
commit ce2d90a212
3 changed files with 101 additions and 83 deletions

View File

@ -6310,3 +6310,12 @@ div.markdown {
.comment-actions *:hover { .comment-actions *:hover {
color: var(--black); color: var(--black);
} }
.actionbtns > *:not(.d-none) {
display: inline !important;
margin-bottom: 10px !important;
margin-right: 5px !important;
}
.actionbtns > form > * {
margin-bottom: 10px !important;
}

View File

@ -163,22 +163,24 @@
<div> <div>
{% if v and v.id != u.id %} {% if v and v.id != u.id %}
<div id="profile--actionbtns"> <div id="profile--actionbtns">
<button type="button" id="button-unsub" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" onclick="postToast(this,'/unfollow/{{u.username}}','button-unsub','button-sub','d-none')">Unfollow</button> <div class="actionbtns mb-3">
<button type="button" id="button-unsub" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" onclick="postToast(this,'/unfollow/{{u.username}}','button-unsub','button-sub','d-none')">Unfollow</button>
<button type="button" id="button-sub" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" onclick="postToast(this,'/follow/{{u.username}}','button-unsub','button-sub','d-none')">Follow</button> <button type="button" id="button-sub" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" onclick="postToast(this,'/follow/{{u.username}}','button-unsub','button-sub','d-none')">Follow</button>
<button type="button" class="btn btn-primary" onclick="toggleElement('message', 'input-message')">Message</button> <button type="button" class="btn btn-primary" onclick="toggleElement('message', 'input-message')">Message</button>
{% if FEATURES['USERS_SUICIDE'] -%} {% if FEATURES['USERS_SUICIDE'] -%}
<button type="button" class="btn btn-primary" onclick="postToast(this,'/@{{u.username}}/suicide')">Get Them Help</button> <button type="button" class="btn btn-primary" onclick="postToast(this,'/@{{u.username}}/suicide')">Get Them Help</button>
{%- endif %} {%- endif %}
<button type="button" class="btn btn-primary" onclick="toggleElement('coin-transfer', 'coin-transfer-amount')">Gift Coins</button> <button type="button" class="btn btn-primary" onclick="toggleElement('coin-transfer', 'coin-transfer-amount')">Gift Coins</button>
{% if FEATURES['PROCOINS'] -%} {% if FEATURES['PROCOINS'] -%}
<button type="button" class="btn btn-primary" onclick="toggleElement('bux-transfer', 'bux-transfer-amount')">Gift Marseybux</button> <button type="button" class="btn btn-primary" onclick="toggleElement('bux-transfer', 'bux-transfer-amount')">Gift Marseybux</button>
{%- endif %} {%- endif %}
<button type="button" class="btn btn-primary" onclick="postToast(this,'/settings/block?username={{u.username}}',true)">Block</button> <button type="button" class="btn btn-primary" onclick="postToast(this,'/settings/block?username={{u.username}}',true)">Block</button>
</div>
{{userpage_admintools.userAdminToolsUpper('desktop')}} {{userpage_admintools.userAdminTools('desktop')}}
</div> </div>
<form class="d-none toggleable" id="message" action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)"> <form class="d-none toggleable" id="message" action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
@ -203,19 +205,22 @@
<div>{{u.username}} will receive <span id="bux-transfer-taxed">0</span> marseybux</div> <div>{{u.username}} will receive <span id="bux-transfer-taxed">0</span> marseybux</div>
<button type="button" class="btn btn-primary mt-3" onclick="transferBux()">Gift</button> <button type="button" class="btn btn-primary mt-3" onclick="transferBux()">Gift</button>
</div> </div>
{% elif v and v.id == u.id %}
<a href="/settings/profile" class="btn btn-secondary">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</a>
{% endif %} {% endif %}
{% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %} <div class="actionbtns">
<button type="button" class="btn btn-secondary" onclick="toggle()">Toggle anthem</button> {% if v and v.id == u.id %}
{% endif %} <a href="/settings/profile" class="btn btn-secondary">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</a>
{% endif %}
{% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %}
<span>
<button type="button" class="btn btn-secondary" onclick="toggle()">Toggle anthem</button>
</span>
{% endif %}
</div>
{{userpage_admintools.userAdminToolsLower('desktop')}} <div class="mt-2" id="profile--info">
<div class="mt-1" id="profile--info">
<p id="profile--info--id">User ID: {{u.id}}</p> <p id="profile--info--id">User ID: {{u.id}}</p>
<p id="profile--info--spent">Coins spent: {{u.coins_spent}}</p> <p id="profile--info--spent">Coins spent: {{u.coins_spent}}</p>
<p id="profile--info--truescore">True score: {{u.truecoins}}</p> <p id="profile--info--truescore">True score: {{u.truecoins}}</p>
@ -396,31 +401,39 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% if v and v.id == u.id %}
<a href="/settings/profile" class="btn btn-secondary ">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</a>
{% endif %}
{% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %} <div class="actionbtns">
<button type="button" class="btn btn-secondary" onclick="toggle()">Toggle anthem</button> {% if v and v.id == u.id %}
{% endif %} <a href="/settings/profile" class="btn btn-secondary ">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</a>
{% endif %}
{% if FEATURES['USERS_PROFILE_SONG'] and u.song and v and (v.id == u.id or v.mute and not u.unmutable) %}
<span>
<button type="button" class="btn btn-secondary" onclick="toggle()">Toggle anthem</button>
</span>
{% endif %}
{% if v and v.id != u.id %}
<button type="button" id="button-unsub2" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" onclick="postToast(this,'/unfollow/{{u.username}}','button-unsub2','button-sub2','d-none')">Unfollow</button>
<button type="button" id="button-sub2" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" onclick="postToast(this,'/follow/{{u.username}}','button-unsub2','button-sub2','d-none')">Follow</button>
<button type="button" class="btn btn-primary" onclick="toggleElement('message-mobile', 'input-message-mobile')">Message</button>
{% if FEATURES['USERS_SUICIDE'] -%}
<button type="button" class="btn btn-primary" onclick="postToast(this,'/@{{u.username}}/suicide')">Get Them Help</button>
{%- endif %}
<button type="button" class="btn btn-primary" onclick="toggleElement('coin-transfer-mobile', 'coin-transfer-amount-mobile')">Gift Coins</button>
{% if FEATURES['PROCOINS'] -%}
<button type="button" class="btn btn-primary" onclick="toggleElement('bux-transfer-mobile', 'bux-transfer-amount-mobile')">Gift Marseybux</button>
{%- endif %}
<button type="button" class="btn btn-primary" onclick="postToast(this,'/settings/block?username={{u.username}}',true)">Block</button>
{% endif %}
</div>
{% if v and v.id != u.id %} {% if v and v.id != u.id %}
<button type="button" id="button-unsub2" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" onclick="postToast(this,'/unfollow/{{u.username}}','button-unsub2','button-sub2','d-none')">Unfollow</button> {{userpage_admintools.userAdminTools('mobile')}}
<button type="button" id="button-sub2" class="btn btn-primary {% if is_following or u.is_nofollow or u.is_blocked %}d-none{% endif %}" onclick="postToast(this,'/follow/{{u.username}}','button-unsub2','button-sub2','d-none')">Follow</button>
<button type="button" class="btn btn-primary" onclick="toggleElement('message-mobile', 'input-message-mobile')">Message</button>
{% if FEATURES['USERS_SUICIDE'] -%}
<button type="button" class="btn btn-primary" onclick="postToast(this,'/@{{u.username}}/suicide')">Get Them Help</button>
{%- endif %}
<button type="button" class="btn btn-primary" onclick="toggleElement('coin-transfer-mobile', 'coin-transfer-amount-mobile')">Gift Coins</button>
{% if FEATURES['PROCOINS'] -%}
<button type="button" class="btn btn-primary" onclick="toggleElement('bux-transfer-mobile', 'bux-transfer-amount-mobile')">Gift Marseybux</button>
{%- endif %}
<button type="button" class="btn btn-primary" onclick="postToast(this,'/settings/block?username={{u.username}}',true)">Block</button>
{{userpage_admintools.userAdminToolsUpper('mobile')}}
<form class="d-none toggleable" id='message-mobile' action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)"> <form class="d-none toggleable" id='message-mobile' action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)">
<input class="mt-1" type="hidden" name="formkey" value="{{v.formkey}}"> <input class="mt-1" type="hidden" name="formkey" value="{{v.formkey}}">
<textarea autocomplete="off" id="input-message-mobile" form="message-mobile" name="message" rows="3" minlength="1" maxlength="10000" class="form-control" data-preview="message-preview-mobile" oninput="markdown(this)" required></textarea> <textarea autocomplete="off" id="input-message-mobile" form="message-mobile" name="message" rows="3" minlength="1" maxlength="10000" class="form-control" data-preview="message-preview-mobile" oninput="markdown(this)" required></textarea>
@ -444,11 +457,9 @@
<div>{{u.username}} will receive <span id="bux-transfer-taxed-mobile">0</span> marseybux</div> <div>{{u.username}} will receive <span id="bux-transfer-taxed-mobile">0</span> marseybux</div>
<button type="button" class="btn btn-primary mt-2 mb-3" onclick="transferBux(true)">Gift</button> <button type="button" class="btn btn-primary mt-2 mb-3" onclick="transferBux(true)">Gift</button>
</div> </div>
{{userpage_admintools.userAdminToolsLower('mobile')}}
{% endif %} {% endif %}
<div class="mt-1" id="profile-mobile--info"> <div class="mt-2" id="profile-mobile--info">
<p id="profile-mobile--info--id">User ID: {{u.id}}</p> <p id="profile-mobile--info--id">User ID: {{u.id}}</p>
<p id="profile-mobile--info--spent">Coins spent: {{u.coins_spent}}</p> <p id="profile-mobile--info--spent">Coins spent: {{u.coins_spent}}</p>
<p id="profile-mobile--info--truescore">True score: {{u.truecoins}}</p> <p id="profile-mobile--info--truescore">True score: {{u.truecoins}}</p>

View File

@ -20,24 +20,9 @@
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro userAdminToolsUpper(deviceType) %} {% macro userAdminTools(deviceType) %}
{% if v and v.id != u.id and v.admin_level >= PERMS['USER_MODERATION_TOOLS_VISIBLE'] %}
{% if v.admin_level >= PERMS['ADMIN_ADD'] %}
<button type="button" id="add-admin-{{deviceType}}" class="{% if u.admin_level >= PERMS['ADMIN_ADD_PERM_LEVEL'] %}d-none{% endif %} btn btn-primary" onclick="postToast(this,'/@{{u.username}}/make_admin','add-admin-{{deviceType}}','remove-admin-{{deviceType}}','d-none')">Make admin</button>
{% endif %}
{% if v.admin_level >= PERMS['ADMIN_REMOVE'] %}
<button type="button" id="remove-admin-{{deviceType}}" class="{% if u.admin_level < 1 %}d-none{% endif %} btn btn-danger" onclick="postToast(this,'/@{{u.username}}/remove_admin','add-admin-{{deviceType}}','remove-admin-{{deviceType}}','d-none')">Remove admin</button>
{% endif %}
{% if v.admin_level >= PERMS['ADMIN_ACTIONS_REVERT'] and u.admin_level %}
<button type="button" class="btn btn-danger" data-click="postToast(this,'/@{{u.username}}/revert_actions')" onclick="areyousure(this)">Revert admin actions</button>
{% endif %}
{% endif %}
{% endmacro %}
{% macro userAdminToolsLower(deviceType) -%}
{% if v and v.id != u.id and v.admin_level >= PERMS['USER_MODERATION_TOOLS_VISIBLE'] %} {% if v and v.id != u.id and v.admin_level >= PERMS['USER_MODERATION_TOOLS_VISIBLE'] %}
<div class="admintools-user-lower-{{deviceType}}"> <div class="admintools-user-lower-{{deviceType}}">
<br><br>
{% if v.admin_level >= PERMS['USER_TITLE_CHANGE'] %} {% if v.admin_level >= PERMS['USER_TITLE_CHANGE'] %}
<div class="body d-lg-flex border-bottom mb-2"> <div class="body d-lg-flex border-bottom mb-2">
<div class="w-lg-100"> <div class="w-lg-100">
@ -103,26 +88,39 @@
</form> </form>
<button type="button" id="unagendaposter-{{deviceType}}" class="mt-1 {% if not u.agendaposter %}d-none{% endif %} btn btn-success" onclick="postToast(this,'/unagendaposter/{{u.id}}','agendaposter-{{deviceType}}','unagendaposter-{{deviceType}}','d-none')">Disable Chud Theme</button> <button type="button" id="unagendaposter-{{deviceType}}" class="mt-1 {% if not u.agendaposter %}d-none{% endif %} btn btn-success" onclick="postToast(this,'/unagendaposter/{{u.id}}','agendaposter-{{deviceType}}','unagendaposter-{{deviceType}}','d-none')">Disable Chud Theme</button>
{% endif %} {% endif %}
{% if v.admin_level >= PERMS['USER_BAN'] %}
<button type="button" id="mute-user-{{deviceType}}" class="{% if u.is_muted %}d-none{% endif %} btn btn-danger" onclick="postToast(this,'/mute_user/{{u.id}}/1','mute-user-{{deviceType}}','unmute-user-{{deviceType}}','d-none')">Mute</button> <div class="actionbtns mt-3">
<button type="button" id="unmute-user-{{deviceType}}" class="mb-1 {% if not u.is_muted %}d-none{% endif %} btn btn-success" onclick="postToast(this,'/mute_user/{{u.id}}/0','mute-user-{{deviceType}}','unmute-user-{{deviceType}}','d-none')">Unmute</button> {% if v.admin_level >= PERMS['ADMIN_ADD'] %}
{% endif %} <button type="button" id="add-admin-{{deviceType}}" class="{% if u.admin_level >= PERMS['ADMIN_ADD_PERM_LEVEL'] %}d-none{% endif %} btn btn-primary" onclick="postToast(this,'/@{{u.username}}/make_admin','add-admin-{{deviceType}}','remove-admin-{{deviceType}}','d-none')">Make admin</button>
{% if v and v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %} {% endif %}
<form action="/admin/unnuke_user" method="post"> {% if v.admin_level >= PERMS['ADMIN_REMOVE'] %}
<input type="hidden" name="formkey", value="{{v.formkey}}"> <button type="button" id="remove-admin-{{deviceType}}" class="{% if u.admin_level < 1 %}d-none{% endif %} btn btn-danger" onclick="postToast(this,'/@{{u.username}}/remove_admin','add-admin-{{deviceType}}','remove-admin-{{deviceType}}','d-none')">Remove admin</button>
<input type="hidden" name="user" value="{{u.username}}"> {% endif %}
<input type="submit" onclick="disable(this)" class="btn btn-success" value="Approve User's Content"> {% if v.admin_level >= PERMS['ADMIN_ACTIONS_REVERT'] and u.admin_level %}
</form> <button type="button" class="btn btn-danger" data-click="postToast(this,'/@{{u.username}}/revert_actions')" onclick="areyousure(this)">Revert admin actions</button>
<form class="mt-1" action="/admin/nuke_user" method="post"> {% endif %}
<input type="hidden" name="formkey", value="{{v.formkey}}">
<input type="hidden" name="user" value="{{u.username}}"> {% if v.admin_level >= PERMS['USER_BAN'] %}
<input type="submit" onclick="disable(this)" class="btn btn-danger" value="Remove User's Content"> <button type="button" id="mute-user-{{deviceType}}" class="{% if u.is_muted %}d-none{% endif %} btn btn-danger" onclick="postToast(this,'/mute_user/{{u.id}}/1','mute-user-{{deviceType}}','unmute-user-{{deviceType}}','d-none')">Mute</button>
</form> <button type="button" id="unmute-user-{{deviceType}}" class="mb-1 {% if not u.is_muted %}d-none{% endif %} btn btn-success" onclick="postToast(this,'/mute_user/{{u.id}}/0','mute-user-{{deviceType}}','unmute-user-{{deviceType}}','d-none')">Unmute</button>
{% endif %} {% endif %}
{% if FEATURES['COUNTRY_CLUB'] and v and v.admin_level >= PERMS['USER_CLUB_ALLOW_BAN'] %} {% if v and v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
<button type="button" id="grant-{{device}}" class="mt-1 {% if u.paid_dues %}d-none{% endif %} btn btn-success" onclick="postToast(this,'/@{{u.username}}/club_allow','grant-{{device}}','bar-{{device}}','d-none')">Grant club access</button> <form action="/admin/unnuke_user" method="post">
<button type="button" id="bar-{{device}}" class="{% if u.club_allowed == False %}d-none{% endif %} btn btn-danger" onclick="postToast(this,'/@{{u.username}}/club_ban','grant-{{device}}','bar-{{device}}','d-none')">Bar from club</button> <input type="hidden" name="formkey", value="{{v.formkey}}">
{% endif %} <input type="hidden" name="user" value="{{u.username}}">
<input type="submit" onclick="disable(this)" class="btn btn-success" value="Approve User's Content">
</form>
<form class="mt-1" action="/admin/nuke_user" method="post">
<input type="hidden" name="formkey", value="{{v.formkey}}">
<input type="hidden" name="user" value="{{u.username}}">
<input type="submit" onclick="disable(this)" class="btn btn-danger" value="Remove User's Content">
</form>
{% endif %}
{% if FEATURES['COUNTRY_CLUB'] and v and v.admin_level >= PERMS['USER_CLUB_ALLOW_BAN'] %}
<button type="button" id="grant-{{device}}" class="mt-1 {% if u.paid_dues %}d-none{% endif %} btn btn-success" onclick="postToast(this,'/@{{u.username}}/club_allow','grant-{{device}}','bar-{{device}}','d-none')">Grant club access</button>
<button type="button" id="bar-{{device}}" class="{% if u.club_allowed == False %}d-none{% endif %} btn btn-danger" onclick="postToast(this,'/@{{u.username}}/club_ban','grant-{{device}}','bar-{{device}}','d-none')">Bar from club</button>
{% endif %}
</div>
</div> </div>
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}