-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the UI to switch user aka become user
- Rename to "switch user" - Can switch from the user menu - Switch to choices.js from Select2 - Update the hijacked view, so an alert at the top
- Loading branch information
Showing
11 changed files
with
186 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{% load i18n static %} | ||
|
||
{% modal_title %}{% trans "Switch to User..." %}{% endmodal_title %} | ||
|
||
<form class="p-4 form" action="{{ request.path }}" method="post"> | ||
{% csrf_token %} | ||
{% if next %} | ||
<input type="hidden" name="next" value="{{ next }}" /> | ||
{% endif %} | ||
|
||
<label for="id_user_pk" class="block text-sm font-semibold text-fg-muted mb-2"> | ||
{% trans "Select User:" %} | ||
</label> | ||
|
||
{{ form.user_pk }} | ||
|
||
<p class="m-0 pt-2 text-fg-muted text-sm"> | ||
{{ form.user_pk.help_text }} | ||
</p> | ||
|
||
<div class="mt-5 sm:gap-4 sm:mt-4 sm:flex sm:flex-row-reverse"> | ||
<button | ||
class="button button--warning w-full sm:w-auto" | ||
type="submit" | ||
> | ||
{% trans "Switch User" %} | ||
</button> | ||
|
||
<button | ||
type="button" | ||
class="inline-flex items-center justify-center w-full px-3 py-2 mt-3 text-sm font-semibold text-gray-900 bg-white rounded-sm shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto" | ||
@click="show = false" | ||
>{% trans "Cancel" %}</button> | ||
</div> | ||
</i> | ||
|
||
<script type="module"> | ||
import Choices from "{% static 'js/esm/choices.js-10-2-0.js' %}"; | ||
|
||
const selectElements = document.querySelectorAll('select#id_user_pk'); | ||
|
||
// add choices to all select elements | ||
selectElements.forEach((selectElement) => { | ||
new Choices(selectElement, { | ||
allowHTML: true | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{% load i18n heroicons %} | ||
|
||
<form action="{% url 'hijack:release' %}" | ||
method="POST" | ||
class="bg-yellow-500 text-black px-4 py-2 border-t-4 border-warning border-stripe text-center" | ||
> | ||
{% csrf_token %} | ||
<input type="hidden" name="next" value="{{ request.path }}"> | ||
<span> | ||
|
||
{% heroicon_micro "exclamation-triangle" size=18 class="inline align-text-bottom" aria_hidden=true %} | ||
|
||
{% blocktrans trimmed with user=request.user %} | ||
You are currently working on behalf of <strong class="font-bold">{{ user }}</strong> | ||
{% endblocktrans %} | ||
<{{ request.user.email }}> | ||
{% for role in request.user.get_role_names %} | ||
<span class="inline-block bg-gray-200 text-gray-800 text-xs font-semibold px-2 rounded-full uppercase"> | ||
{{ role }} | ||
</span> | ||
{% endfor %} | ||
|
||
|
||
</span> | ||
|
||
<button class="button button--link underline ms-2 font-semibold uppercase" type="submit"> | ||
{% translate 'Release' %} | ||
</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters