Presets: show warning dialog when preset options list has not been opened

10.8-maintenance
Ivan Efimov 2022-01-25 04:13:41 -06:00
parent 83b2846a1d
commit 43b7a8b0d9
4 changed files with 40 additions and 2 deletions

View File

@ -6589,5 +6589,9 @@
"presetsVersionMismatch": { "presetsVersionMismatch": {
"message": "Preset source version mismatch.<br/>Required version: {{versionRequired}}<br/>Preset source version: {{versionSource}}<br/>Using this preset source could be dangerous.<br/>Do you want to continue?", "message": "Preset source version mismatch.<br/>Required version: {{versionRequired}}<br/>Preset source version: {{versionSource}}<br/>Using this preset source could be dangerous.<br/>Do you want to continue?",
"description": "Placeholder for the options list dropdown" "description": "Placeholder for the options list dropdown"
},
"presetsReviewOptionsWarning": {
"message": "Please, review the list of options before picking this preset.",
"description": "Dialog text to prompt user to review options for the preset"
} }
} }

View File

@ -9,6 +9,11 @@
margin-bottom: 2ex; margin-bottom: 2ex;
} }
/* multiple select for options - force placeholder color to black/white */
#presets_detailed_dialog_content_wrapper .ms-choice>span.placeholder {
color: var(--defaultText);
}
.presets-detailed-dialog-property-table { .presets-detailed-dialog-property-table {
margin-top: 10px; margin-top: 10px;
margin-bottom: 10px; margin-bottom: 10px;

View File

@ -23,6 +23,7 @@ class PresetsDetailedDialog {
this._preset = preset; this._preset = preset;
this._setLoadingState(true); this._setLoadingState(true);
this._domDialog[0].showModal(); this._domDialog[0].showModal();
this._optionsShowedAtLeastOnce = false;
this._presetsRepo.loadPreset(this._preset) this._presetsRepo.loadPreset(this._preset)
.then(() => { .then(() => {
@ -139,6 +140,7 @@ class PresetsDetailedDialog {
onClick: () => this._optionsSelectionChanged(), onClick: () => this._optionsSelectionChanged(),
onCheckAll: () => this._optionsSelectionChanged(), onCheckAll: () => this._optionsSelectionChanged(),
onUncheckAll: () => this._optionsSelectionChanged(), onUncheckAll: () => this._optionsSelectionChanged(),
onOpen: () => this._optionsOpened(),
hideOptgroupCheckboxes: true, hideOptgroupCheckboxes: true,
singleRadio: true, singleRadio: true,
selectAll: false, selectAll: false,
@ -154,6 +156,10 @@ class PresetsDetailedDialog {
}); });
} }
_optionsOpened() {
this._optionsShowedAtLeastOnce = true;
}
_addOptionGroup(parentElement, optionGroup) { _addOptionGroup(parentElement, optionGroup) {
const optionGroupElement = $(`<optgroup label="${optionGroup.name}"></optgroup>`); const optionGroupElement = $(`<optgroup label="${optionGroup.name}"></optgroup>`);
@ -210,7 +216,14 @@ class PresetsDetailedDialog {
} }
_onApplyButtonClicked() { _onApplyButtonClicked() {
if (!this._preset.completeWarning) { if (this._preset.force_options_review && !this._optionsShowedAtLeastOnce) {
const dialogOptions = {
title: i18n.getMessage("warningTitle"),
text: i18n.getMessage("presetsReviewOptionsWarning"),
buttonConfirmText: i18n.getMessage("close"),
};
GUI.showInformationDialog(dialogOptions);
} else if (!this._preset.completeWarning) {
this._pickPresetFwVersionCheck(); this._pickPresetFwVersionCheck();
} else { } else {
GUI.showYesNoDialog(this._finalDialogYesNoSettings); GUI.showYesNoDialog(this._finalDialogYesNoSettings);

View File

@ -6,7 +6,7 @@ class PresetParser {
} }
readPresetProperties(preset, strings) { readPresetProperties(preset, strings) {
const propertiesToRead = ["description", "discussion", "warning", "disclaimer", "include_warning", "include_disclaimer", "discussion"]; const propertiesToRead = ["description", "discussion", "warning", "disclaimer", "include_warning", "include_disclaimer", "discussion", "force_options_review"];
const propertiesMetadata = {}; const propertiesMetadata = {};
preset.options = []; preset.options = [];
@ -110,11 +110,27 @@ class PresetParser {
case this._settings.MetadataTypes.FILE_PATH_ARRAY: case this._settings.MetadataTypes.FILE_PATH_ARRAY:
this._processArrayProperty(preset, line, propertyName); this._processArrayProperty(preset, line, propertyName);
break; break;
case this._settings.MetadataTypes.BOOLEAN:
this._processBooleanProperty(preset, line, propertyName);
break;
default: default:
this.console.err(`Parcing preset: unknown property type '${this._settings.presetsFileMetadata[property].type}' for the property '${propertyName}'`); this.console.err(`Parcing preset: unknown property type '${this._settings.presetsFileMetadata[property].type}' for the property '${propertyName}'`);
} }
} }
_processBooleanProperty(preset, line, propertyName) {
const trueValues = ["true", "yes"];
const lineLowCase = line.toLowerCase();
let result = false;
if (trueValues.includes(lineLowCase)) {
result = true;
}
preset[propertyName] = result;
}
_processArrayProperty(preset, line, propertyName) { _processArrayProperty(preset, line, propertyName) {
if (!preset[propertyName]) { if (!preset[propertyName]) {
preset[propertyName] = []; preset[propertyName] = [];