Skip to content

Commit

Permalink
Update sheet selection dialog UI:
Browse files Browse the repository at this point in the history
- Change the label from "Close" to "OK".
- Disable the OK button until at least one checkbox is selected.
- Add a heading "Show sheets" above the checkboxes.

Signed-off-by: Parth Raiyani <[email protected]>
Change-Id: I8fdabce9508296052f6c2e7741be651ef45df9f8
  • Loading branch information
rparth07 committed Dec 3, 2024
1 parent 7168663 commit dc21220
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions browser/src/control/Parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,11 @@ L.Map.include({
showPage: function () {
if (this.getDocType() === 'spreadsheet' && app.calc.isAnyPartHidden()) {
var hiddenParts = app.calc.getHiddenPartNameArray();

if (app.calc.isAnyPartHidden()) {
var container = document.createElement('div');
container.style.maxHeight = '300px';
container.style.overflowY = 'auto';
container.style.overflowY = 'auto';
for (var i = 0; i < hiddenParts.length; i++) {
var checkbox = document.createElement('input');
checkbox.type = 'checkbox';
Expand All @@ -475,7 +475,7 @@ L.Map.include({
container.appendChild(newLine);
}
}

var callback = function() {
var checkboxList = document.querySelectorAll('input[id^="hidden-part-checkbox"]');
for (var i = 0; i < checkboxList.length; i++) {
Expand All @@ -486,12 +486,29 @@ L.Map.include({
}
}
};

this.uiManager.showInfoModal('show-sheets-modal', '', ' ', ' ', _('Close'), callback, true, 'show-sheets-modal-response');
this.uiManager.showInfoModal('show-sheets-modal', 'Show sheets', ' ', ' ', _('OK'), callback, true, 'show-sheets-modal-response');
const modal = document.getElementById('show-sheets-modal');
modal.insertBefore(container, modal.children[0]);

var okButton = document.getElementById('show-sheets-modal-response');
var checkboxes = document.querySelectorAll('#show-sheets-modal input[type="checkbox"]');

okButton.disabled = true;

checkboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', function() {
var anyChecked = false;
checkboxes.forEach(function(checkbox) {
if (checkbox.checked) {
anyChecked = true;
}
});
okButton.disabled = !anyChecked;
});
});
}
},
},

hidePage: function (tabNumber) {
if (this.getDocType() === 'spreadsheet' && app.calc.getVisiblePartCount() > 1) {
Expand Down

0 comments on commit dc21220

Please sign in to comment.