Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/consolidating edit menu #442

Merged
merged 13 commits into from
Jun 18, 2024
8 changes: 8 additions & 0 deletions src/rard/static/css/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ button.insert {
background-color: #ffff00;
}

.lock-duration {
display: none;
}

.lock-options:hover .lock-duration {
display: block;
}

/* editor related */
.ql-editor {
background-color: white !important;
Expand Down
39 changes: 2 additions & 37 deletions src/rard/templates/research/anonymousfragment_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,8 @@
{% block action %}
{% with request.user|has_lock:object as has_object_lock %}

{% include 'research/partials/render_locked_info.html' %}

{% if has_object_lock %}
<div class='d-flex flex-column justify-content-end'>
{% if perms.research.delete_anonymousfragment %}
<form novalidate style='margin-left:auto' class='form-inline' action='{% url "anonymous_fragment:delete" object.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-danger {% if object.mentioned_in.all %}confirm-delete-mentions {% else %} confirm-delete {% endif %} p-0 ml-2'
data-what='anonymous fragment'>{% trans 'Delete' %}</button>
</div>
</form>
{% endif %}
{% if perms.research.change_anonymousfragment %}
<form novalidate style='margin-left:auto' class='form-inline' action='{% url "anonymous_fragment:convert_to_fragment" object.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button
type='submit'
class='
{% if object.get_all_links %}has-links{% endif %}
btn btn-link text-danger confirm-convert p-0 ml-2
'
data-what='anonymous fragment'
>{% trans 'Make non-anonymous' %}</button>
</div>
</form>
<form novalidate style='margin-left:auto' class='form-inline' action='{% url "anonymous_fragment:duplicate" object.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-info p-0 ml-2'
data-what='anonymous fragment'>{% trans 'Duplicate' %}</button>
</div>
</form>
{% endif %}
</div>
{% endif %}
{% include 'research/partials/render_locked_info.html' with is_anonymousfragment="anonymous fragment" %}

{% endwith %}
{% endblock %}

Expand Down
17 changes: 2 additions & 15 deletions src/rard/templates/research/antiquarian_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,8 @@

{% with request.user|has_lock:object as has_object_lock %}

{% include 'research/partials/render_locked_info.html' %}

<div class='d-flex justify-content-end'>
{% if has_object_lock %}
{% if perms.research.delete_antiquarian %}
<form novalidate class='form-inline' action='{% url "antiquarian:delete" antiquarian.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-danger confirm-delete p-0 ml-2'
data-what='antiquarian'>{% trans 'Delete' %}</button>
</div>
</form>
{% endif %}
{% endif %}
</div>
{% include 'research/partials/render_locked_info.html' with is_antiquarian="antiquarian" %}

{% endwith %}

{% endblock %}
Expand Down
39 changes: 1 addition & 38 deletions src/rard/templates/research/fragment_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,8 @@
{% block action %}
{% with request.user|has_lock:object as has_object_lock %}

{% include 'research/partials/render_locked_info.html' %}
{% include 'research/partials/render_locked_info.html' with is_fragment="fragment" %}

{% if has_object_lock %}
<div class='d-flex flex-column justify-content-end'>
{% if perms.research.delete_fragment %}
<form novalidate style='margin-left:auto' class='form-inline' action='{% url "fragment:delete" fragment.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-danger {% if object.mentioned_in.all %}confirm-delete-mentions {% else %} confirm-delete {% endif %} p-0 ml-2'
data-what='fragment'>{% trans 'Delete' %}</button>
</div>
</form>
{% endif %}
{% if perms.research.change_fragment and object.is_unlinked %}
<form novalidate style='margin-left:auto' class='form-inline' action='{% url "fragment:convert_to_anonymous" fragment.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-danger confirm-convert p-0 ml-2'
data-what='fragment'>{% trans 'Make anonymous' %}</button>
</div>
</form>
{% endif %}
<form novalidate style='margin-left:auto' class='form-inline' action='{% url "fragment:duplicate" fragment.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-info p-0 ml-2'
data-what='fragment'>{% trans 'Duplicate' %}</button>
</div>
</form>

</div>
{% endif %}
{% endwith %}
{% endblock %}

Expand All @@ -58,13 +28,6 @@
<div>
<h5>{% trans 'Details' %}</h5>
</div>
<div>
{% comment %}
{% if perms.research.change_fragment and has_object_lock %}
<a href='{% url "fragment:update" object.pk %}'>{% trans 'Edit' %}</a>
{% endif %}
{% endcomment %}
</div>
</div>

<dl class="row mb-0">
Expand Down
99 changes: 74 additions & 25 deletions src/rard/templates/research/partials/render_locked_info.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{# Assumes a context object named 'object' which is a LockableModel instance #}

{% load humanize object_lock %}
{% load humanize object_lock i18n %}

<div class='d-flex justify-content-between align-items-center mb-2'>
<div class='d-flex align-items-center mb-2'>
<div class='mr-3'>

{% include 'research/partials/render_locked_icons.html' %}
Expand All @@ -12,32 +12,81 @@
<form novalidate enctype="multipart/form-data" autocomplete='off' action='{{ request.path }}' class="form"
method='POST'>
{% csrf_token %}
{% if object.locked_by == request.user %}
<button type='submit' class='btn btn-primary btn-sm' name='unlock'>Finish&nbsp;Editing</button>
{% else %}
{% if object.is_locked %}
<button type='submit' class='btn btn-warning btn-sm' name='request'>Request Item</button>
{% if request.user.can_break_locks %}
<button title='You can break this lock' type='submit' class='btn btn-danger btn-sm' name='break'><i class='fa fa-unlock'></i> Unlock</button>
<div class="dropdown show">
<a class="btn btn-primary btn-sm dropdown-toggle" name='lock' href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Actions
</a>

<div class="dropdown-menu text-center p-2" aria-labelledby="dropdownMenuLink">
<form novalidate class='form-group' action='{% if is_testimonium %}{% url "testimonium:delete" testimonium.pk %} {% elif is_work %}{% url "work:delete" work.pk %} {% elif is_antiquarian %}{% url "antiquarian:delete" antiquarian.pk %}{% elif is_anonymousfragment %}{% url "anonymous_fragment:delete" object.pk %}% elif is_fragment %}{% url "fragment:delete" object.pk %}
{% endif %}'
method='POST'>
{% csrf_token %}
<button type='submit' class='btn btn-link text-danger {% if object.mentioned_in.all %}confirm-delete-mentions {% else %} confirm-delete {% endif %}'
data-what='{{is_testimonium}}{{is_work}}{{is_antiquarian}}{{is_anonymousfragment}}{{is_fragment}}'>{% trans 'Delete' %}</button>
</form>

{% if is_anonymousfragment %}
<form novalidate class='form-group mb-0' action='{% url "anonymous_fragment:convert_to_fragment" object.pk %}' method='POST'>
{% csrf_token %}
<button
type='submit'
class='
{% if object.get_all_links %}has-links{% endif %}
btn btn-link text-danger confirm-convert p-1 text-nowrap
'
data-what='anonymous fragment'
>{% trans 'Make non-anonymous' %}</button>
</form>
<form novalidate class='form-group mb-0' action='{% url "anonymous_fragment:duplicate" object.pk %}' method='POST'>
{% csrf_token %}
<button type='submit' class='btn btn-link text-info'
data-what='anonymous fragment'>{% trans 'Duplicate' %}</button>
</form>

{% elif is_fragment %}
{% if object.is_unlinked %}
<form novalidate class='form-group mb-0' action='{% url "fragment:convert_to_anonymous" fragment.pk %}' method='POST'>
{% csrf_token %}
<button type='submit' class='btn btn-link text-danger text-nowrap confirm-convert'
data-what='fragment'>{% trans 'Make anonymous' %}</button>
</form>
{% endif %}
<form novalidate class='form-group mb-0' action='{% url "fragment:duplicate" object.pk %}' method='POST'>
{% csrf_token %}
<button type='submit' class='btn btn-link text-info'
data-what='fragment'>{% trans 'Duplicate' %}</button>
</form>

{% endif %}

<hr class="m-1">

{% if object.locked_by == request.user %}
<button type='submit' class='btn btn-link text-primary' name='unlock'>Finish Editing</button>

{% else %}
{% if object.is_locked %}
<button type='submit' class='btn btn-link text-warning' name='request'>Request Item</button>
{% if request.user.can_break_locks %}
<button title='You can break this lock' type='submit' class='btn btn-link text-danger' name='break'><i class='fa fa-unlock'></i> Unlock</button>
{% endif %}

{% elif not object.is_locked %}
<div class="lock-options">
<button type='button' name='lock' class='dropdown-toggle btn btn-link text-primary w-100 p-1 m-1'>Edit</button>
<div class="lock-duration form-group">
<button type='submit' name='days' value='1' class='dropdown-item'>for 1 day</button>
<button type='submit' name='days' value='2' class='dropdown-item'>for 2 days</button>
<button type='submit' name='days' value='7' class='dropdown-item'>for a week</button>
<button type='submit' name='lock' class='dropdown-item text-danger'>until I unlock</button>
</div>
</div>
{% endif %}
{% endif %}
{% elif not object.is_locked %}

<div class="dropdown show">
<a class="btn btn-primary btn-sm dropdown-toggle" name='lock' href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Edit
</a>

<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<button type='submit' name='days' value='1' class='dropdown-item'>for 1 day</button>
<button type='submit' name='days' value='2' class='dropdown-item'>for 2 days</button>
<button type='submit' name='days' value='5' class='dropdown-item'>for 5 days</button>
<button type='submit' name='days' value='7' class='dropdown-item'>for a week</button>
<button type='submit' name='lock' class='dropdown-item'>until I unlock</button>
</div>
</div>
{% endif %}
</div>

{% endif %}
</form>
</div>
</div>
Expand Down
24 changes: 2 additions & 22 deletions src/rard/templates/research/testimonium_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,8 @@
{% block action %}
{% with request.user|has_lock:object as has_object_lock %}

{% include 'research/partials/render_locked_info.html' %}

<div class='d-flex justify-content-end'>
{% if has_object_lock %}
{% if perms.research.delete_testimonium %}
<form novalidate class='form-inline' action='{% url "testimonium:delete" testimonium.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-danger {% if object.mentioned_in.all %}confirm-delete-mentions {% else %} confirm-delete {% endif %} p-0 ml-2'
data-what='testimonium'>{% trans 'Delete' %}</button>
</div>
</form>
{% endif %}
{% endif %}
</div>
{% include 'research/partials/render_locked_info.html' with is_testimonium="testimonium" %}

{% endwith %}
{% endblock %}

Expand All @@ -40,13 +27,6 @@
<div>
<h5>{% trans 'Details' %}</h5>
</div>
<div>
{% comment %}
{% if perms.research.change_testimonium and has_object_lock %}
<a href='{% url "testimonium:update" object.pk %}'>{% trans 'Edit' %}</a>
{% endif %}
{% endcomment %}
</div>
</div>

<dl class="row mb-0">
Expand Down
17 changes: 2 additions & 15 deletions src/rard/templates/research/work_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,8 @@

{% with request.user|has_lock:object as has_object_lock %}

{% include 'research/partials/render_locked_info.html' %}

<div class='d-flex justify-content-end'>
{% if has_object_lock %}
{% if perms.research.delete_work %}
<form novalidate class='form-inline' action='{% url "work:delete" work.pk %}' method='POST'>
{% csrf_token %}
<div class='form-group'>
<button type='submit' class='btn btn-link text-danger confirm-delete p-0 ml-2'
data-what='work'>{% trans 'Delete' %}</button>
</div>
</form>
{% endif %}
{% endif %}
</div>
{% include 'research/partials/render_locked_info.html' with is_work="work" %}

{% endwith %}
{% endblock %}

Expand Down
Loading