forked from enviPath/enviPy
[Refactor] Large scale formatting/linting (#193)
All html files now prettier formatted and fixes for incompatible blocks applied Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#193 Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-committed-by: Tobias O <tobias.olenyi@envipath.com>
This commit is contained in:
@ -1,75 +1,109 @@
|
||||
|
||||
{% load static %}
|
||||
<!-- Copy Object -->
|
||||
<div id="generic_copy_object_modal" class="modal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Copy {{ object_type|capfirst }}</h3>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="generic-copy-object-modal-form" accept-charset="UTF-8" data-remote="true" method="post">
|
||||
{% csrf_token %}
|
||||
<label for="target-package">Select the Target Package you want to copy this {{ object_type }}
|
||||
into</label>
|
||||
<select id="target-package" name="target-package" data-actions-box='true' class="form-control"
|
||||
data-width='100%'>
|
||||
<option disabled selected>Select Target Package</option>
|
||||
{% for p in meta.writeable_packages %}
|
||||
<option value="{{ p.url }}">{{ p.name|safe }}</option>`
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="hidden" name="hidden" value="copy">
|
||||
</form>
|
||||
<div id="copy-object-error-message" class="alert alert-danger" role="alert" style="display: none">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="generic-copy-object-modal-form-submit">
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Copy {{ object_type|capfirst }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="close"
|
||||
data-dismiss="modal"
|
||||
aria-label="Close"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form
|
||||
id="generic-copy-object-modal-form"
|
||||
accept-charset="UTF-8"
|
||||
data-remote="true"
|
||||
method="post"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<label for="target-package"
|
||||
>Select the Target Package you want to copy this {{ object_type }}
|
||||
into</label
|
||||
>
|
||||
<select
|
||||
id="target-package"
|
||||
name="target-package"
|
||||
data-actions-box="true"
|
||||
class="form-control"
|
||||
data-width="100%"
|
||||
>
|
||||
<option disabled selected>Select Target Package</option>
|
||||
{% for p in meta.writeable_packages %}
|
||||
<option value="{{ p.url }}">{{ p.name|safe }}</option>
|
||||
`
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="hidden" name="hidden" value="copy" />
|
||||
</form>
|
||||
<div
|
||||
id="copy-object-error-message"
|
||||
class="alert alert-danger"
|
||||
role="alert"
|
||||
style="display: none"
|
||||
></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
id="generic-copy-object-modal-form-submit"
|
||||
>
|
||||
Copy
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
$(function () {
|
||||
$("#generic-copy-object-modal-form-submit").click(function (e) {
|
||||
e.preventDefault();
|
||||
$("#copy-object-error-message").hide();
|
||||
|
||||
$('#generic-copy-object-modal-form-submit').click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#copy-object-error-message').hide()
|
||||
const packageUrl = $("#target-package").find(":selected").val();
|
||||
|
||||
const packageUrl = $('#target-package').find(":selected").val();
|
||||
if (
|
||||
packageUrl === "Select Target Package" ||
|
||||
packageUrl === "" ||
|
||||
packageUrl === null ||
|
||||
packageUrl === undefined
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const formData = {
|
||||
hidden: "copy",
|
||||
object_to_copy: "{{ current_object.url }}",
|
||||
};
|
||||
|
||||
if (packageUrl === 'Select Target Package' || packageUrl === '' || packageUrl === null || packageUrl === undefined) {
|
||||
return;
|
||||
}
|
||||
const formData = {
|
||||
hidden: 'copy',
|
||||
object_to_copy: '{{ current_object.url }}',
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
data: formData,
|
||||
url: packageUrl,
|
||||
success: function (data, textStatus) {
|
||||
window.location.href = data.success;
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
if (jqXHR.responseJSON.error.indexOf('to the same package') > -1) {
|
||||
$('#copy-object-error-message').append('<p>The target Package is the same as the source Package. Please select another target!</p>');
|
||||
} else {
|
||||
$('#copy-object-error-message').append('<p>' + jqXHR.responseJSON.error + '</p>');
|
||||
}
|
||||
$('#copy-object-error-message').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
$.ajax({
|
||||
type: "post",
|
||||
data: formData,
|
||||
url: packageUrl,
|
||||
success: function (data, textStatus) {
|
||||
window.location.href = data.success;
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
if (jqXHR.responseJSON.error.indexOf("to the same package") > -1) {
|
||||
$("#copy-object-error-message").append(
|
||||
"<p>The target Package is the same as the source Package. Please select another target!</p>",
|
||||
);
|
||||
} else {
|
||||
$("#copy-object-error-message").append(
|
||||
"<p>" + jqXHR.responseJSON.error + "</p>",
|
||||
);
|
||||
}
|
||||
$("#copy-object-error-message").show();
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user