Adds input constraints to settings numeric fields
Improves user input validation for settings by: - Adding min/max range limits to numeric settings - Enforcing input type as number for better UX - Ensures settings inputs have appropriate constraints Validates timed count, delay, and note prompt settings with specific numeric ranges
This commit is contained in:
1 file changed
+32
-3
+32
-3
@@ -201,7 +201,16 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
|
||||
this.plugin.settings.timedCount = count;
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
}));
|
||||
}))
|
||||
.then(setting => {
|
||||
const input = setting.controlEl.querySelector('input');
|
||||
if (input) {
|
||||
input.setAttribute('type', 'number');
|
||||
input.setAttribute('min', '1');
|
||||
input.setAttribute('max', '50');
|
||||
input.setAttribute('step', '1');
|
||||
}
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Delay Between Prompts')
|
||||
@@ -215,7 +224,16 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
|
||||
this.plugin.settings.delaySeconds = delay;
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
}));
|
||||
}))
|
||||
.then(setting => {
|
||||
const input = setting.controlEl.querySelector('input');
|
||||
if (input) {
|
||||
input.setAttribute('type', 'number');
|
||||
input.setAttribute('min', '1');
|
||||
input.setAttribute('max', '300');
|
||||
input.setAttribute('step', '1');
|
||||
}
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Note Prompts Count')
|
||||
@@ -229,7 +247,16 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
|
||||
this.plugin.settings.noteCount = count;
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
}));
|
||||
}))
|
||||
.then(setting => {
|
||||
const input = setting.controlEl.querySelector('input');
|
||||
if (input) {
|
||||
input.setAttribute('type', 'number');
|
||||
input.setAttribute('min', '1');
|
||||
input.setAttribute('max', '20');
|
||||
input.setAttribute('step', '1');
|
||||
}
|
||||
});
|
||||
|
||||
// MARK: - Prompt Customization
|
||||
|
||||
@@ -303,6 +330,8 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
|
||||
// Show a temporary notice
|
||||
const notice = new Notice('Model list cache cleared');
|
||||
setTimeout(() => notice.hide(), 2000);
|
||||
// Persist the cleared cache so it doesn't restore on restart
|
||||
void this.plugin.saveSettings();
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user