UI: fixes based on Actionable Feedback from devtalk and frontend changes #40

Merged
Pablo Vazquez merged 15 commits from martonlente/extensions-website:ui-alpha-launch-actionable-feedback into main 2024-02-27 16:05:54 +01:00
2 changed files with 41 additions and 8 deletions
Showing only changes of commit 235874265c - Show all commits

View File

@ -7,13 +7,29 @@ const formsetPrefix = 'form';
const inputTotalForms = document.getElementById(`id_${formsetPrefix}-TOTAL_FORMS`); const inputTotalForms = document.getElementById(`id_${formsetPrefix}-TOTAL_FORMS`);
const tagInput = document.getElementById('id_tags'); 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() { function appendImageUploadForm() {
const i = inputTotalForms.value; const i = inputTotalForms.value;
const formRow = document.createElement('div'); const formRow = document.createElement('div');
const newFormHTML = ` const newFormHTML = `
<div class="previews-list-item"> <div class="previews-list-item">
<div class="align-items-center d-flex previews-list-item-thumbnail pl-3"> <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"> <div class="align-items-center d-flex js-input-img-thumbnail-icon justify-content-center">
<i class="i-image"></i> <i class="i-image"></i>
</div> </div>
@ -83,6 +99,7 @@ function removeImgUploadForm() {
} }
// Create function resetImgUploadForm // Create function resetImgUploadForm
// TODO: fix function resetImgUploadForm on pageload
function resetImgUploadForm() { function resetImgUploadForm() {
const btnResetImgUploadForm = document.querySelectorAll('.js-btn-reset-img-upload-form'); const btnResetImgUploadForm = document.querySelectorAll('.js-btn-reset-img-upload-form');
@ -153,6 +170,7 @@ function setImgUploadFormThumbnail() {
// Create function init // Create function init
function init() { function init() {
addImgUploadFormClasses();
resetImgUploadForm(); resetImgUploadForm();
} }

View File

@ -7,14 +7,29 @@
{{ add_preview_formset.non_form_errors }} {{ add_preview_formset.non_form_errors }}
{% for newform in add_preview_formset %} {% for newform in add_preview_formset %}
{% with inlineform=newform|add_form_classes %} {% with inlineform=newform|add_form_classes %}
<div class="row"> <div class="ext-edit-field-row js-ext-edit-field-row">
<div class="col"> <div class="previews-list-item">
{% include "common/components/field.html" with field=inlineform.source label='File' %} <div class="align-items-center d-flex previews-list-item-thumbnail pl-3">
<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="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>
<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' %} {% include "common/components/field.html" with field=inlineform.caption label='Caption' %}
</div> </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> </div>
{{ inlineform.non_form_errors }} {{ inlineform.non_form_errors }}
{% endwith %} {% endwith %}