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,6 +163,7 @@
<div> <div>
{% if v and v.id != u.id %} {% if v and v.id != u.id %}
<div id="profile--actionbtns"> <div id="profile--actionbtns">
<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-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>
@ -177,8 +178,9 @@
{%- 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>
{% endif %}
{% elif v and v.id == u.id %} <div class="actionbtns">
{% if v and v.id == u.id %}
<a href="/settings/profile" class="btn btn-secondary">Edit profile</a> <a href="/settings/profile" class="btn btn-secondary">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</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) %} {% 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> <button type="button" class="btn btn-secondary" onclick="toggle()">Toggle anthem</button>
</span>
{% endif %} {% 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,19 +401,24 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
<div class="actionbtns">
{% if v and v.id == u.id %} {% if v and v.id == u.id %}
<a href="/settings/profile" class="btn btn-secondary ">Edit profile</a> <a href="/settings/profile" class="btn btn-secondary ">Edit profile</a>
<a href="/views" class="btn btn-secondary">Profile views</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) %} {% 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> <button type="button" class="btn btn-secondary" onclick="toggle()">Toggle anthem</button>
</span>
{% endif %} {% endif %}
{% 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> <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" 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> <button type="button" class="btn btn-primary" onclick="toggleElement('message-mobile', 'input-message-mobile')">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>
@ -419,8 +429,11 @@
{%- 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>
{% endif %}
</div>
{{userpage_admintools.userAdminToolsUpper('mobile')}} {% if v and v.id != u.id %}
{{userpage_admintools.userAdminTools('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>
@ -445,10 +458,8 @@
<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,6 +88,18 @@
</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 %}
<div class="actionbtns mt-3">
{% 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 %}
{% if v.admin_level >= PERMS['USER_BAN'] %} {% 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> <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>
<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> <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>
@ -124,5 +121,6 @@
<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> <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 %} {% endif %}
</div> </div>
</div>
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}