Skip to content

Commit 243881e

Browse files
committed
settings cleanup
1 parent 6809110 commit 243881e

File tree

2 files changed

+75
-28
lines changed

2 files changed

+75
-28
lines changed

src/settings/ICSSettingsTab.ts

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ export default class ICSSettingsTab extends PluginSettingTab {
9090

9191
// Add field section management
9292
new Setting(patternsContainer)
93-
.setName("Create Field Section")
94-
.setDesc("Create a new field section to group related patterns")
93+
.setName("Add new")
94+
.setDesc("Add a new field section")
9595
.addButton((button: ButtonComponent): ButtonComponent => {
96-
return button
97-
.setTooltip("Create Field Section")
98-
.setButtonText("+ Field Section")
96+
const b = button
97+
.setTooltip("Add Additional")
98+
.setButtonText("+")
9999
.onClick(async () => {
100100
const modal = new FieldSectionModal(this.app, this.plugin);
101101
modal.onClose = async () => {
@@ -106,24 +106,8 @@ export default class ICSSettingsTab extends PluginSettingTab {
106106
};
107107
modal.open();
108108
});
109-
});
110109

111-
// Reset to defaults button
112-
new Setting(patternsContainer)
113-
.setName("Reset to Defaults")
114-
.setDesc("Reset all patterns to default video call providers")
115-
.addButton((button: ButtonComponent): ButtonComponent => {
116-
return button
117-
.setButtonText("Reset")
118-
.setWarning()
119-
.onClick(async () => {
120-
const confirmed = confirm("Are you sure you want to reset all field extraction patterns to defaults? This will delete all your custom patterns and cannot be undone.");
121-
if (confirmed) {
122-
this.plugin.data.fieldExtraction.patterns = [...DEFAULT_FIELD_EXTRACTION_PATTERNS];
123-
await this.plugin.saveSettings();
124-
this.display();
125-
}
126-
});
110+
return b;
127111
});
128112

129113
// Group patterns by field name and display them as manageable sections
@@ -143,8 +127,8 @@ export default class ICSSettingsTab extends PluginSettingTab {
143127
for (const [fieldName, fieldPatterns] of groupedPatterns) {
144128
// Field section header with management buttons
145129
const fieldHeader = new Setting(patternsContainer)
146-
.setHeading()
147130
.setName(`${fieldName} (${fieldPatterns.length} pattern${fieldPatterns.length === 1 ? '' : 's'})`)
131+
.setClass('field-section-header')
148132
.addExtraButton((b) => {
149133
b.setIcon("plus")
150134
.setTooltip("Add Pattern to this Field")
@@ -270,6 +254,26 @@ export default class ICSSettingsTab extends PluginSettingTab {
270254
}
271255
}
272256

257+
private displayFieldExtractionReset(containerEl: HTMLElement) {
258+
// Reset to defaults button - positioned outside patterns to show it affects all patterns
259+
new Setting(containerEl)
260+
.setName("Reset to Defaults")
261+
.setDesc("Reset all field extraction patterns to default video call providers")
262+
.addButton((button: ButtonComponent): ButtonComponent => {
263+
return button
264+
.setButtonText("Reset All")
265+
.setWarning()
266+
.onClick(async () => {
267+
const confirmed = confirm("Are you sure you want to reset all field extraction patterns to defaults? This will delete all your custom patterns and cannot be undone.");
268+
if (confirmed) {
269+
this.plugin.data.fieldExtraction.patterns = [...DEFAULT_FIELD_EXTRACTION_PATTERNS];
270+
await this.plugin.saveSettings();
271+
this.display();
272+
}
273+
});
274+
});
275+
}
276+
273277
private dataViewSyntaxDescription(): DocumentFragment {
274278
const descEl = document.createDocumentFragment();
275279
descEl.appendText('Enable this option if you use the DataView plugin to query event start and end times.');
@@ -463,6 +467,10 @@ export default class ICSSettingsTab extends PluginSettingTab {
463467
containerEl.createDiv().style.marginBottom = '20px';
464468

465469
this.displayFieldExtractionPatterns(containerEl);
470+
471+
// Add visual separation and reset button
472+
containerEl.createDiv().style.marginTop = '20px';
473+
this.displayFieldExtractionReset(containerEl);
466474
}
467475
}
468476

@@ -807,7 +815,7 @@ class FieldExtractionPatternModal extends Modal {
807815
pattern: "",
808816
matchType: "contains",
809817
priority: maxPriority + 1,
810-
extractedFieldName: defaultFieldName || "Video Call URL"
818+
extractedFieldName: defaultFieldName || "Video Call URLs"
811819
};
812820
}
813821
}
@@ -818,6 +826,14 @@ class FieldExtractionPatternModal extends Modal {
818826

819827
const settingDiv = contentEl.createDiv({ cls: 'video-call-pattern-settings' });
820828

829+
// Add Esc key handling to close modal
830+
contentEl.addEventListener('keydown', (e) => {
831+
if (e.key === 'Escape') {
832+
e.preventDefault();
833+
this.close();
834+
}
835+
});
836+
821837
// Pattern name
822838
let nameText: TextComponent;
823839
new Setting(settingDiv)
@@ -874,6 +890,16 @@ class FieldExtractionPatternModal extends Modal {
874890
this.hasChanges = true;
875891
}
876892
});
893+
priorityText.inputEl.addEventListener('keydown', (e) => {
894+
if (e.key === 'Enter') {
895+
e.preventDefault();
896+
if (this.validateForm()) {
897+
this.saved = true;
898+
this.hasChanges = false;
899+
this.close();
900+
}
901+
}
902+
});
877903
});
878904

879905
// Footer buttons
@@ -921,9 +947,6 @@ class FieldExtractionPatternModal extends Modal {
921947
if (!this.pattern.name.trim()) {
922948
return false;
923949
}
924-
if (!this.pattern.extractedFieldName.trim()) {
925-
return false;
926-
}
927950
if (!this.pattern.pattern.trim()) {
928951
return false;
929952
}
@@ -975,6 +998,14 @@ class FieldSectionModal extends Modal {
975998
const { contentEl } = this;
976999
contentEl.empty();
9771000

1001+
// Add Esc key handling to close modal
1002+
contentEl.addEventListener('keydown', (e) => {
1003+
if (e.key === 'Escape') {
1004+
e.preventDefault();
1005+
this.close();
1006+
}
1007+
});
1008+
9781009
// Modal title at the top
9791010
const titleEl = contentEl.createEl('h3', { cls: 'modal-title' });
9801011
titleEl.textContent = this.isEditing ? 'Edit Field Section' : 'Create Field Section';

styles.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@ padding-top: 2em;
55
}
66

77

8-
/* Field extraction pattern grouping */
8+
/* Field section headers - smaller than main headings */
9+
.field-extraction-patterns .field-section-header {
10+
margin-top: 16px;
11+
margin-bottom: 8px;
12+
}
13+
14+
.field-extraction-patterns .field-section-header:first-child {
15+
margin-top: 8px;
16+
}
17+
18+
.field-extraction-patterns .field-section-header .setting-item-name {
19+
color: var(--text-accent);
20+
font-weight: var(--font-medium);
21+
font-size: var(--font-ui-medium);
22+
}
23+
24+
/* Legacy field extraction pattern grouping (keeping for compatibility) */
925
.field-extraction-patterns .setting-item.mod-heading {
1026
margin-top: 20px;
1127
margin-bottom: 8px;

0 commit comments

Comments
 (0)