Fix checkbox state not updating + ran prettier

Forgot a comma and to load back the wikilink with new properties
This commit is contained in:
ltctceplrm 2025-12-09 21:07:45 +01:00
parent 95035e5eac
commit f8b6ae8761
6 changed files with 18 additions and 16 deletions

View file

@ -584,7 +584,9 @@ export default class MediaDbPlugin extends Plugin {
newProperties.push(defaultProperty); newProperties.push(defaultProperty);
} else { } else {
// newProperty is just an object and take locked status from default property // newProperty is just an object and take locked status from default property
newProperties.push(new PropertyMapping(newProperty.property, newProperty.newProperty, newProperty.mapping, defaultProperty.locked)); newProperties.push(
new PropertyMapping(newProperty.property, newProperty.newProperty, newProperty.mapping, defaultProperty.locked, newProperty.wikilink ?? false),
);
} }
} }

View file

@ -40,9 +40,7 @@ export class PropertyMapper {
if (typeof value === 'string') { if (typeof value === 'string') {
finalValue = `[[${value}]]`; finalValue = `[[${value}]]`;
} else if (Array.isArray(value)) { } else if (Array.isArray(value)) {
finalValue = value.map(v => finalValue = value.map(v => (typeof v === 'string' ? `[[${v}]]` : v));
typeof v === 'string' ? `[[${v}]]` : v
);
} }
} }
if (propertyMapping.mapping === PropertyMappingOption.Map) { if (propertyMapping.mapping === PropertyMappingOption.Map) {

View file

@ -71,11 +71,11 @@
</div> </div>
<style> <style>
.media-db-plugin-property-mapping-wikilink-label { .media-db-plugin-property-mapping-wikilink-label {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
font-size: 0.95em; font-size: 0.95em;
cursor: pointer; cursor: pointer;
} }
</style> </style>

View file

@ -162,7 +162,7 @@ export function getDefaultSettings(plugin: MediaDbPlugin): MediaDbPluginSettings
PropertyMappingOption.Default, PropertyMappingOption.Default,
lockedPropertyMappings.contains(key), lockedPropertyMappings.contains(key),
false, // wikilink default false, // wikilink default
) ),
); );
} }
@ -817,8 +817,8 @@ export class MediaDbSettingTab extends PluginSettingTab {
cb.setPlaceholder(`Example: ${DEFAULT_SETTINGS.boardgameFileNameTemplate}`) cb.setPlaceholder(`Example: ${DEFAULT_SETTINGS.boardgameFileNameTemplate}`)
.setValue(this.plugin.settings.boardgameFileNameTemplate) .setValue(this.plugin.settings.boardgameFileNameTemplate)
.onChange(data => { .onChange(data => {
this.plugin.settings.boardgameFileNameTemplate = data; this.plugin.settings.boardgameFileNameTemplate = data;
void this.plugin.saveSettings(); void this.plugin.saveSettings();
}); });
}); });

View file

@ -5,7 +5,8 @@ export class FileSuggest extends AbstractInputSuggest<TFile> {
const lowerCaseInputStr = query.toLowerCase(); const lowerCaseInputStr = query.toLowerCase();
// we do two filters because otherwise TS type inference does convert the array to TFile[] // we do two filters because otherwise TS type inference does convert the array to TFile[]
return this.app.vault.getAllLoadedFiles() return this.app.vault
.getAllLoadedFiles()
.filter(file => file instanceof TFile) .filter(file => file instanceof TFile)
.filter(file => file.path.toLowerCase().contains(lowerCaseInputStr)); .filter(file => file.path.toLowerCase().contains(lowerCaseInputStr));
} }

View file

@ -5,7 +5,8 @@ export class FolderSuggest extends AbstractInputSuggest<TFolder> {
const lowerCaseInputStr = query.toLowerCase(); const lowerCaseInputStr = query.toLowerCase();
// we do two filters because otherwise TS type inference does convert the array to TFolder[] // we do two filters because otherwise TS type inference does convert the array to TFolder[]
return this.app.vault.getAllLoadedFiles() return this.app.vault
.getAllLoadedFiles()
.filter(file => file instanceof TFolder) .filter(file => file instanceof TFolder)
.filter(file => file.path.toLowerCase().contains(lowerCaseInputStr)); .filter(file => file.path.toLowerCase().contains(lowerCaseInputStr));
} }