forked from enviPath/enviPy
This PR moves all the collection pages into the new UI in a rough push. I did not put the same amount of care into these as into search, index, and predict. ## Major changes - All modals are now migrated to a state based alpine.js implementation. - jQuery is no longer present in the base layout; ajax is replace by native fetch api - most of the pps.js is now obsolte (as I understand it; the code is not referenced any more @jebus please double check) - in-memory pagination for large result lists (set to 50; we can make that configurable later; performance degrades at around 1k) stukk a bit rough tracked in #235 ## Minor things - Sarch and index also use alpine now - The loading spinner is now CSS animated (not sure if it currently gets correctly called) ## Not done - Ihave not even cheked the admin pages. Not sure If these need migrations - The temporary migration pages still use the old template. Not sure what is supposed to happen with those? @jebus ## What I did to test - opend all pages in browse, and user ; plus all pages reachable from there. - Interacted and tested the functionality of each modal superfically with exception of the API key modal (no functional test). --- This PR is massive sorry for that; just did not want to push half-brokenn state. @jebus @liambrydon I would be glad if you could click around and try to break it :) Finally closes #133 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#236 Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-committed-by: Tobias O <tobias.olenyi@envipath.com>
182 lines
5.2 KiB
HTML
182 lines
5.2 KiB
HTML
{% load static %}
|
|
<dialog
|
|
id="add_pathway_edge_modal"
|
|
class="modal"
|
|
x-data="{
|
|
isSubmitting: false,
|
|
reactionImageUrl: '',
|
|
|
|
reset() {
|
|
this.isSubmitting = false;
|
|
this.reactionImageUrl = '';
|
|
},
|
|
|
|
updateReactionImage() {
|
|
const substratesSelect = document.getElementById('add_pathway_edge_substrates');
|
|
const productsSelect = document.getElementById('add_pathway_edge_products');
|
|
|
|
const substrates = [];
|
|
for (const option of substratesSelect.selectedOptions) {
|
|
substrates.push(option.dataset.smiles);
|
|
}
|
|
|
|
const products = [];
|
|
for (const option of productsSelect.selectedOptions) {
|
|
products.push(option.dataset.smiles);
|
|
}
|
|
|
|
if (substrates.length > 0 && products.length > 0) {
|
|
const reaction = substrates.join('.') + '>>' + products.join('.');
|
|
this.reactionImageUrl = '{% url "depict" %}?smirks=' + encodeURIComponent(reaction);
|
|
} else {
|
|
this.reactionImageUrl = '';
|
|
}
|
|
},
|
|
|
|
submit() {
|
|
this.isSubmitting = true;
|
|
document.getElementById('add_pathway_edge_modal_form').submit();
|
|
}
|
|
}"
|
|
@close="reset()"
|
|
>
|
|
<div class="modal-box max-w-4xl">
|
|
<!-- Header -->
|
|
<h3 class="text-lg font-bold">Add a Reaction</h3>
|
|
|
|
<!-- Close button (X) -->
|
|
<form method="dialog">
|
|
<button
|
|
class="btn btn-sm btn-circle btn-ghost absolute top-2 right-2"
|
|
:disabled="isSubmitting"
|
|
>
|
|
✕
|
|
</button>
|
|
</form>
|
|
|
|
<!-- Body -->
|
|
<div class="py-4">
|
|
<form
|
|
id="add_pathway_edge_modal_form"
|
|
accept-charset="UTF-8"
|
|
action="{% url 'package pathway edge list' meta.current_package.uuid pathway.uuid %}"
|
|
data-remote="true"
|
|
method="post"
|
|
>
|
|
{% csrf_token %}
|
|
<div class="form-control mb-3">
|
|
<label class="label" for="edge-name">
|
|
<span class="label-text">Name</span>
|
|
</label>
|
|
<input
|
|
id="edge-name"
|
|
type="text"
|
|
class="input input-bordered w-full"
|
|
name="edge-name"
|
|
placeholder="Name"
|
|
/>
|
|
</div>
|
|
|
|
<div class="form-control mb-3">
|
|
<label class="label" for="edge-description">
|
|
<span class="label-text">Description</span>
|
|
</label>
|
|
<input
|
|
id="edge-description"
|
|
type="text"
|
|
class="input input-bordered w-full"
|
|
name="edge-description"
|
|
placeholder="Description"
|
|
/>
|
|
</div>
|
|
|
|
<div class="mb-3 grid grid-cols-11 gap-2">
|
|
<div class="col-span-5">
|
|
<div class="form-control">
|
|
<label class="label">
|
|
<span class="label-text font-semibold">Substrate(s)</span>
|
|
</label>
|
|
<select
|
|
id="add_pathway_edge_substrates"
|
|
name="edge-substrates"
|
|
class="select select-bordered h-32 w-full"
|
|
multiple
|
|
@change="updateReactionImage()"
|
|
>
|
|
{% for n in pathway.nodes %}
|
|
<option
|
|
data-smiles="{{ n.default_node_label.smiles }}"
|
|
value="{{ n.url }}"
|
|
>
|
|
{{ n.default_node_label.name|safe }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="col-span-1 flex items-center justify-center">
|
|
<span class="text-2xl">→</span>
|
|
</div>
|
|
<div class="col-span-5">
|
|
<div class="form-control">
|
|
<label class="label">
|
|
<span class="label-text font-semibold">Product(s)</span>
|
|
</label>
|
|
<select
|
|
id="add_pathway_edge_products"
|
|
name="edge-products"
|
|
class="select select-bordered h-32 w-full"
|
|
multiple
|
|
@change="updateReactionImage()"
|
|
>
|
|
{% for n in pathway.nodes %}
|
|
<option
|
|
data-smiles="{{ n.default_node_label.smiles }}"
|
|
value="{{ n.url }}"
|
|
>
|
|
{{ n.default_node_label.name|safe }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3" x-show="reactionImageUrl" x-cloak>
|
|
<img :src="reactionImageUrl" class="w-full" alt="Reaction preview" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Footer -->
|
|
<div class="modal-action">
|
|
<button
|
|
type="button"
|
|
class="btn"
|
|
onclick="this.closest('dialog').close()"
|
|
:disabled="isSubmitting"
|
|
>
|
|
Close
|
|
</button>
|
|
<button
|
|
type="button"
|
|
class="btn btn-primary"
|
|
@click="submit()"
|
|
:disabled="isSubmitting"
|
|
>
|
|
<span x-show="!isSubmitting">Submit</span>
|
|
<span
|
|
x-show="isSubmitting"
|
|
class="loading loading-spinner loading-sm"
|
|
></span>
|
|
<span x-show="isSubmitting">Submitting...</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Backdrop -->
|
|
<form method="dialog" class="modal-backdrop">
|
|
<button :disabled="isSubmitting">close</button>
|
|
</form>
|
|
</dialog>
|