Adds confirm modal for loading data

This commit is contained in:
Mouse Reeve
2021-12-07 12:30:21 -08:00
parent 7dbb9b4b26
commit 4973e0a010
7 changed files with 63 additions and 27 deletions

View File

@ -70,63 +70,65 @@
<h2 class="title is-4">{% trans "External links" %}</h2>
<div class="box">
{% if author.wikipedia_link %}
<p>
<div>
<a itemprop="sameAs" href="{{ author.wikipedia_link }}" rel="noopener" target="_blank">
{% trans "Wikipedia" %}
</a>
</p>
</div>
{% endif %}
{% if author.isni %}
<p>
<div class="mt-1">
<a itemprop="sameAs" href="{{ author.isni_link }}" rel="noopener" target="_blank">
{% trans "View ISNI record" %}
</a>
</p>
</div>
{% endif %}
{% trans "Load data" as button_text %}
{% if author.openlibrary_key %}
<p>
<a itemprop="sameAs" href="{{ author.openlibrary_link }}" target="_blank" rel="noopener">
<div class="mt-1 is-flex">
<a class="mr-3" itemprop="sameAs" href="{{ author.openlibrary_link }}" target="_blank" rel="noopener">
{% trans "View on OpenLibrary" %}
</a>
{% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
<form name="ol-update" method="POST" action="{% url 'author-update-remote' author.id 'openlibrary.org' %}">
{% csrf_token %}
<button class="button is-small" type="submit">{% trans "Update from OpenLibrary" %}</button>
</form>
{% with controls_text="ol_sync" controls_uid=author.id %}
{% include 'snippets/toggle/toggle_button.html' with text=button_text focus="modal_title_ol_sync" class="is-small" icon_with_text="download" %}
{% include "author/sync_modal.html" with source="opnlibrary.org" source_name="OpenLibrary" %}
{% endwith %}
{% endif %}
</p>
</div>
{% endif %}
{% if author.inventaire_id %}
<p>
<a itemprop="sameAs" href="{{ author.inventaire_link }}" target="_blank" rel="noopener">
<div class="mt-1 is-flex">
<a class="mr-3" itemprop="sameAs" href="{{ author.inventaire_link }}" target="_blank" rel="noopener">
{% trans "View on Inventaire" %}
</a>
{% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
<form name="ol-update" method="POST" action="{% url 'author-update-remote' author.id 'inventaire.io' %}">
{% csrf_token %}
<button class="button is-small" type="submit">{% trans "Update from Inventaire" %}</button>
</form>
{% with controls_text="iv_sync" controls_uid=author.id %}
{% include 'snippets/toggle/toggle_button.html' with text=button_text focus="modal_title_iv_sync" class="is-small" icon_with_text="download" %}
{% include "author/sync_modal.html" with source="inventaire.io" source_name="Inventaire" %}
{% endwith %}
{% endif %}
</p>
</div>
{% endif %}
{% if author.librarything_key %}
<p>
<div class="mt-1">
<a itemprop="sameAs" href="https://www.librarything.com/author/{{ author.librarything_key }}" target="_blank" rel="noopener">
{% trans "View on LibraryThing" %}
</a>
</p>
</div>
{% endif %}
{% if author.goodreads_key %}
<p>
<div>
<a itemprop="sameAs" href="https://www.goodreads.com/author/show/{{ author.goodreads_key }}" target="_blank" rel="noopener">
{% trans "View on Goodreads" %}
</a>
</p>
</div>
{% endif %}
</div>
</section>

View File

@ -0,0 +1,30 @@
{% extends 'components/modal.html' %}
{% load i18n %}
{% block modal-title %}
{% trans "Load data" %}
{% endblock %}
{% block modal-form-open %}
<form name="{{ source }}-update" method="POST" action="{% url 'author-update-remote' author.id source %}">
{% csrf_token %}
{% endblock %}
{% block modal-body %}
<p>
{% blocktrans trimmed %}
Loading data will connect to <strong>{{ source_name }}</strong> and check for any metadata about this author which aren't present here. Existing metadata will not be overwritten.
{% endblocktrans %}
</p>
{% endblock %}
{% block modal-footer %}
<button class="button is-primary" type="submit">
<span>{% trans "Confirm" %}</span>
</button>
{% trans "Cancel" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with text=button_text %}
{% endblock %}
{% block modal-form-close %}</form>{% endblock %}