Added more clarity
When searching for seasons the modal specifies that you must select only one series to proceed to the season selection screen
This commit is contained in:
parent
59919f9461
commit
d748d9840e
4 changed files with 26 additions and 11 deletions
20
src/main.ts
20
src/main.ts
|
|
@ -221,14 +221,26 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
while (!proceed) {
|
while (!proceed) {
|
||||||
if (types.length === 1 && types[0] === 'season') {
|
if (types.length === 1 && types[0] === 'season') {
|
||||||
selectResults =
|
selectResults =
|
||||||
(await this.modalHelper.openSelectModal({ elements: apiSearchResults }, async selectModalData => {
|
(await this.modalHelper.openSelectModal(
|
||||||
|
{
|
||||||
|
elements: apiSearchResults,
|
||||||
|
description: 'Select one search result to proceed.',
|
||||||
|
submitButtonText: 'Ok',
|
||||||
|
},
|
||||||
|
async selectModalData => {
|
||||||
return selectModalData.selected;
|
return selectModalData.selected;
|
||||||
})) ?? [];
|
},
|
||||||
|
)) ?? [];
|
||||||
} else {
|
} else {
|
||||||
selectResults =
|
selectResults =
|
||||||
(await this.modalHelper.openSelectModal({ elements: apiSearchResults }, async selectModalData => {
|
(await this.modalHelper.openSelectModal(
|
||||||
|
{
|
||||||
|
elements: apiSearchResults,
|
||||||
|
},
|
||||||
|
async selectModalData => {
|
||||||
return await this.queryDetails(selectModalData.selected);
|
return await this.queryDetails(selectModalData.selected);
|
||||||
})) ?? [];
|
},
|
||||||
|
)) ?? [];
|
||||||
}
|
}
|
||||||
if (!selectResults || selectResults.length < 1) {
|
if (!selectResults || selectResults.length < 1) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ export class MediaDbSearchResultModal extends SelectModal<MediaTypeModel> {
|
||||||
super(plugin.app, selectModalOptions.elements ?? [], selectModalOptions.multiSelect);
|
super(plugin.app, selectModalOptions.elements ?? [], selectModalOptions.multiSelect);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.title = selectModalOptions.modalTitle ?? '';
|
this.title = selectModalOptions.modalTitle ?? '';
|
||||||
this.description = 'Select one or multiple search results.';
|
this.description = selectModalOptions.description ?? 'Select one or multiple search results.';
|
||||||
this.addSkipButton = selectModalOptions.skipButton ?? false;
|
this.addSkipButton = selectModalOptions.skipButton ?? false;
|
||||||
this.submitButtonText = 'Ok';
|
this.submitButtonText = selectModalOptions.submitButtonText ?? 'Ok';
|
||||||
this.busy = false;
|
this.busy = false;
|
||||||
this.sendCallback = false;
|
this.sendCallback = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ export abstract class SelectModal<T> extends Modal {
|
||||||
this.skipButton = btn;
|
this.skipButton = btn;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
bottomSettingRow.addButton((btn) => {
|
bottomSettingRow.addButton(btn => {
|
||||||
btn.setButtonText(this.submitButtonText);
|
btn.setButtonText(this.submitButtonText);
|
||||||
btn.setCta();
|
btn.setCta();
|
||||||
btn.onClick(() => this.submit());
|
btn.onClick(() => this.submit());
|
||||||
|
|
|
||||||
|
|
@ -159,12 +159,13 @@ export interface IdSearchModalOptions {
|
||||||
* - skipButton: whether to add a skip button to the modal
|
* - skipButton: whether to add a skip button to the modal
|
||||||
*/
|
*/
|
||||||
export interface SelectModalOptions {
|
export interface SelectModalOptions {
|
||||||
modalTitle?: string;
|
|
||||||
elements?: MediaTypeModel[];
|
elements?: MediaTypeModel[];
|
||||||
multiSelect?: boolean;
|
multiSelect?: boolean;
|
||||||
|
modalTitle?: string;
|
||||||
skipButton?: boolean;
|
skipButton?: boolean;
|
||||||
|
description?: string; // Add this
|
||||||
|
submitButtonText?: string; // Add this too
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for the preview modal.
|
* Options for the preview modal.
|
||||||
* - modalTitle: the title of the modal
|
* - modalTitle: the title of the modal
|
||||||
|
|
@ -210,6 +211,8 @@ export const SELECTMODALOPTIONSDEFAULT: SelectModalOptions = {
|
||||||
multiSelect: true,
|
multiSelect: true,
|
||||||
modalTitle: '',
|
modalTitle: '',
|
||||||
skipButton: false,
|
skipButton: false,
|
||||||
|
description: 'Select one or multiple search results.',
|
||||||
|
submitButtonText: 'Ok',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue