Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: popup option hiding logic refactoring #296

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main/resources/webapp/pdf-exporter/html/popupForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

<div class="flex-container">
<div class="flex-column">
<div class='property-wrapper'>
<div class='property-wrapper hidden visible-for-live-doc visible-for-test-run'>
<label for='popup-fit-to-page'>
<input id='popup-fit-to-page' type='checkbox'/>
Fit images and tables to page
Expand All @@ -104,7 +104,7 @@
Follow HTML presentational hints
</label>
</div>
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-enable-comments-rendering'>
<input id='popup-enable-comments-rendering' type='checkbox'/>
Comments rendering
Expand All @@ -118,13 +118,13 @@
</div>
</div>
<div class="flex-column">
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-cut-empty-chapters'>
<input id='popup-cut-empty-chapters' type='checkbox'/>
Cut empty chapters (any level)
</label>
</div>
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-cut-empty-wi-attributes'>
<input id='popup-cut-empty-wi-attributes' type='checkbox'/>
Cut empty Workitem attributes
Expand All @@ -136,7 +136,7 @@
Cut local Polarion URLs
</label>
</div>
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-mark-referenced-workitems'>
<input id='popup-mark-referenced-workitems' type='checkbox'/>
Mark referenced Workitems
Expand All @@ -147,14 +147,14 @@

<div class="flex-container">
<div class="flex-column">
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-custom-list-styles'>
<input id='popup-custom-list-styles' onchange='document.getElementById("popup-numbered-list-styles").style.visibility = this.checked ? "visible" : "hidden"' type='checkbox'/>
Custom styles of numbered lists
</label>
<input id='popup-numbered-list-styles' placeholder='eg. 1ai' style='width: 84px' type='text'/>
</div>
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-specific-chapters'>
<input id='popup-specific-chapters' onchange='document.getElementById("popup-chapters").style.visibility = this.checked ? "visible" : "hidden"' type='checkbox'/>
Specific higher level chapters
Expand All @@ -163,7 +163,7 @@
</div>
</div>
<div class="flex-column">
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-localization'>
<input id='popup-localization' onchange='document.getElementById("popup-language").style.visibility = this.checked ? "visible" : "hidden"' type='checkbox'/>
Localize enums
Expand All @@ -174,7 +174,7 @@
<option value='it'>Italiano</option>
</select>
</div>
<div class='property-wrapper only-live-doc'>
<div class='property-wrapper hidden visible-for-live-doc'>
<label for='popup-selected-roles' style="align-self: flex-start;">
<input id='popup-selected-roles' onchange='document.getElementById("popup-roles-selector").style.display = this.checked ? "inline-block" : "none"' type='checkbox'/>
Specific Workitem roles
Expand Down
20 changes: 14 additions & 6 deletions src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ const PdfExporter = {

this.hideAlerts();
this.loadFormData();
const documentContext = this.exportContext.getDocumentType() === ExportParams.DocumentType.LIVE_DOC;
document.querySelectorAll(".modal__container.pdf-exporter .property-wrapper.only-live-doc")
.forEach(propertyBlock => propertyBlock.style.display = (documentContext ? "flex" : "none"));
const mixedContext = this.exportContext.getDocumentType() === ExportParams.DocumentType.MIXED;
document.querySelectorAll(".modal__container.pdf-exporter .property-wrapper.not-mixed")
.forEach(propertyBlock => propertyBlock.style.display = (mixedContext ? "none" : "flex"));
switch (this.exportContext.getDocumentType()) {
case ExportParams.DocumentType.LIVE_DOC:
document.querySelectorAll(".modal__container.pdf-exporter .property-wrapper.visible-for-live-doc")
.forEach(propertyBlock => propertyBlock.style.display = "flex");
break;
case ExportParams.DocumentType.TEST_RUN:
document.querySelectorAll(".modal__container.pdf-exporter .property-wrapper.visible-for-test-run")
.forEach(propertyBlock => propertyBlock.style.display = "flex");
break;
case ExportParams.DocumentType.MIXED:
document.querySelectorAll(".modal__container.pdf-exporter .property-wrapper.not-mixed")
.forEach(propertyBlock => propertyBlock.style.display = "none");
break;
}
MicroModal.show(POPUP_ID);
},

Expand Down