Skip to content

Commit

Permalink
resolve #7770 Library message box is not themed. (#7811)
Browse files Browse the repository at this point in the history
Co-authored-by: OlgaLarina <olga.larina.dev@gmail.com>
  • Loading branch information
OlgaLarina and OlgaLarina committed Feb 6, 2024
1 parent 6524355 commit 61b200d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/question_file.ts
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
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
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
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
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

0 comments on commit 61b200d

Please sign in to comment.