Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library message box is not themed. #7811

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/question_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ export class QuestionFileModel extends QuestionFileModelBase {
}
doClean = () => {
if (this.needConfirmRemoveFile) {
confirmActionAsync(this.confirmRemoveAllMessage, () => { this.clearFilesCore(); }, undefined, this.getLocale());
confirmActionAsync(this.confirmRemoveAllMessage, () => { this.clearFilesCore(); }, undefined, this.getLocale(), this.survey.rootElement);
return;
}
this.clearFilesCore();
Expand All @@ -1037,7 +1037,7 @@ export class QuestionFileModel extends QuestionFileModelBase {
}
doRemoveFile(data: any) {
if (this.needConfirmRemoveFile) {
confirmActionAsync(this.getConfirmRemoveMessage(data.name), () => { this.removeFileCore(data); }, undefined, this.getLocale());
confirmActionAsync(this.getConfirmRemoveMessage(data.name), () => { this.removeFileCore(data); }, undefined, this.getLocale(), this.survey.rootElement);
return;
}
this.removeFileCore(data);
Expand Down
2 changes: 1 addition & 1 deletion src/question_matrixdynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ export class QuestionMatrixDynamicModel extends QuestionMatrixDropdownModelBase
confirmDelete = this.isRequireConfirmOnRowDelete(index);
}
if (confirmDelete) {
confirmActionAsync(this.confirmDeleteText, () => { this.removeRowAsync(index, row); }, undefined, this.getLocale());
confirmActionAsync(this.confirmDeleteText, () => { this.removeRowAsync(index, row); }, undefined, this.getLocale(), this.survey.rootElement);
return;
}
this.removeRowAsync(index, row);
Expand Down
2 changes: 1 addition & 1 deletion src/question_paneldynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ export class QuestionPanelDynamicModel extends Question
public removePanelUI(value: any): void {
if (!this.canRemovePanel) return;
if(this.isRequireConfirmOnDelete(value)) {
confirmActionAsync(this.confirmDeleteText, () => { this.removePanel(value); }, undefined, this.getLocale());
confirmActionAsync(this.confirmDeleteText, () => { this.removePanel(value); }, undefined, this.getLocale(), this.survey.rootElement);
} else {
this.removePanel(value);
}
Expand Down
4 changes: 2 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ export var settings = {
* @param message A message to be displayed in the confirm dialog window.
* @param callback A callback function that should be called with `true` if a user confirms an action or `false` otherwise.
*/
confirmActionAsync: function (message: string, callback: (res: boolean) => void, applyTitle?: string, locale?: string): boolean {
return showConfirmDialog(message, callback, applyTitle, locale);
confirmActionAsync: function (message: string, callback: (res: boolean) => void, applyTitle?: string, locale?: string, rootElement?: HTMLElement): boolean {
return showConfirmDialog(message, callback, applyTitle, locale, rootElement);
},
/**
* A minimum width value for all survey elements.
Expand Down
8 changes: 4 additions & 4 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ function confirmAction(message: string): boolean {
return confirm(message);
}

function confirmActionAsync(message: string, funcOnYes: () => void, funcOnNo?: () => void, locale?: string): void {
function confirmActionAsync(message: string, funcOnYes: () => void, funcOnNo?: () => void, locale?: string, rootElement?: HTMLElement): void {
const callbackFunc = (res: boolean): void => {
if (res) funcOnYes();
else if (!!funcOnNo) funcOnNo();
};

if (!!settings && !!settings.confirmActionAsync) {
if (settings.confirmActionAsync(message, callbackFunc, undefined, locale)) return;
if (settings.confirmActionAsync(message, callbackFunc, undefined, locale, rootElement)) return;
}

callbackFunc(confirmAction(message));
Expand Down Expand Up @@ -412,7 +412,7 @@ export class Logger {
}
}

export function showConfirmDialog(message: string, callback: (res: boolean) => void, applyTitle?: string, locale?: string): boolean {
export function showConfirmDialog(message: string, callback: (res: boolean) => void, applyTitle?: string, locale?: string, rootElement?: HTMLElement): boolean {
const locStr = new LocalizableString(undefined);
const popupViewModel: PopupBaseViewModel = settings.showDialog(<IDialogOptions>{
componentName: "sv-string-viewer",
Expand All @@ -429,7 +429,7 @@ export function showConfirmDialog(message: string, callback: (res: boolean) => v
displayMode: "popup",
isFocusedContent: false,
cssClass: "sv-popup--confirm-delete"
}, /*settings.rootElement*/document.body); //TODO survey root
}, rootElement);
const toolbar = popupViewModel.footerToolbar;
const applyBtn = toolbar.getActionById("apply");
const cancelBtn = toolbar.getActionById("cancel");
Expand Down
Loading