UI: fixes based on Actionable Feedback from devtalk and frontend changes #40
@ -7,13 +7,29 @@ const formsetPrefix = 'form';
|
||||
const inputTotalForms = document.getElementById(`id_${formsetPrefix}-TOTAL_FORMS`);
|
||||
const tagInput = document.getElementById('id_tags');
|
||||
|
||||
// Create function addImgUploadFormClasses
|
||||
function addImgUploadFormClasses() {
|
||||
// Function intializes img upload widgets' custom classes for js manage
|
||||
const inputImgHelper = document.querySelector('.js-input-img-helper');
|
||||
const inputImgCaptionHelper = document.querySelector('.js-input-img-caption-helper');
|
||||
|
||||
inputImgHelper.querySelector('input')
|
||||
.classList.add('js-input-img');
|
||||
|
||||
inputImgHelper.querySelector('label')
|
||||
.classList.add('d-none');
|
||||
|
||||
inputImgCaptionHelper.querySelector('input')
|
||||
.classList.add('js-input-img-caption');
|
||||
}
|
||||
|
||||
function appendImageUploadForm() {
|
||||
const i = inputTotalForms.value;
|
||||
const formRow = document.createElement('div');
|
||||
const newFormHTML = `
|
||||
<div class="previews-list-item">
|
||||
<div class="align-items-center d-flex previews-list-item-thumbnail pl-3">
|
||||
<div class="js-input-img-thumbnail previews-list-item-thumbnail-img"" title="Preview">
|
||||
<div class="js-input-img-thumbnail previews-list-item-thumbnail-img" title="Preview">
|
||||
<div class="align-items-center d-flex js-input-img-thumbnail-icon justify-content-center">
|
||||
<i class="i-image"></i>
|
||||
</div>
|
||||
@ -83,6 +99,7 @@ function removeImgUploadForm() {
|
||||
}
|
||||
|
||||
// Create function resetImgUploadForm
|
||||
// TODO: fix function resetImgUploadForm on pageload
|
||||
function resetImgUploadForm() {
|
||||
const btnResetImgUploadForm = document.querySelectorAll('.js-btn-reset-img-upload-form');
|
||||
|
||||
@ -153,6 +170,7 @@ function setImgUploadFormThumbnail() {
|
||||
|
||||
// Create function init
|
||||
function init() {
|
||||
addImgUploadFormClasses();
|
||||
resetImgUploadForm();
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,29 @@
|
||||
{{ add_preview_formset.non_form_errors }}
|
||||
{% for newform in add_preview_formset %}
|
||||
{% with inlineform=newform|add_form_classes %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{% include "common/components/field.html" with field=inlineform.source label='File' %}
|
||||
<button class="btn btn-link js-btn-reset-img-upload-form mt-1 pl-0 pr-2"><i class="i-refresh"></i> Reset</button>
|
||||
<div class="ext-edit-field-row js-ext-edit-field-row">
|
||||
<div class="previews-list-item">
|
||||
<div class="align-items-center d-flex previews-list-item-thumbnail pl-3">
|
||||
<div class="js-input-img-thumbnail previews-list-item-thumbnail-img" title="Preview">
|
||||
<div class="align-items-center d-flex js-input-img-thumbnail-icon justify-content-center">
|
||||
<i class="i-image"></i>
|
||||
</div>
|
||||
<div class="col">
|
||||
</div>
|
||||
</div>
|
||||
<div class="details flex-grow-1">
|
||||
<div class="js-input-img-caption-helper mb-2">
|
||||
{% include "common/components/field.html" with field=inlineform.caption label='Caption' %}
|
||||
</div>
|
||||
<div class="align-items-center d-flex js-input-img-helper justify-content-between">
|
||||
{% include "common/components/field.html" with field=inlineform.source label='File' %}
|
||||
<ul class="pt-0">
|
||||
<li>
|
||||
<button class="btn btn-link btn-sm js-btn-reset-img-upload-form pl-2 pr-0"><i class="i-refresh"></i> Reset</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ inlineform.non_form_errors }}
|
||||
{% endwith %}
|
||||
|
Loading…
Reference in New Issue
Block a user