From 2fea2dde57a84a27b34765b50501cb257b13b405 Mon Sep 17 00:00:00 2001 From: Aleksey Novikov Date: Mon, 29 Jul 2024 19:17:11 +0300 Subject: [PATCH 1/3] #8575 The survey.onDownloadFile event is not raised for a Signature Pad question which stores signatures by their names/ids Fixes #8575 --- src/question_file.ts | 30 ++++++------ src/question_signaturepad.ts | 24 +++++++++- tests/question_signaturepadtests.ts | 44 ++++++++++++++++-- .../etalons/signature-data-load-preview.png | Bin 0 -> 7211 bytes .../tests/defaultV2/signaturepad.ts | 30 ++++++++++++ 5 files changed, 110 insertions(+), 18 deletions(-) create mode 100644 visualRegressionTests/tests/defaultV2/etalons/signature-data-load-preview.png diff --git a/src/question_file.ts b/src/question_file.ts index f7e5c54869..ac54cdb8e1 100644 --- a/src/question_file.ts +++ b/src/question_file.ts @@ -136,6 +136,14 @@ export class QuestionFileModelBase extends Question { }); } } + protected loadPreview(newValue: any): void { } + protected onChangeQuestionValue(newValue: any): void { + super.onChangeQuestionValue(newValue); + this.stateChanged(this.isEmpty() ? "empty" : "loaded"); + if (!this.isLoadingFromJson) { + this.loadPreview(newValue); + } + } } /** @@ -187,6 +195,13 @@ export class QuestionFileModel extends QuestionFileModelBase { public cleanAction: Action; public actionsContainer: ActionContainer; + private isFileLoadingValue: boolean; + protected get isFileLoading(): boolean { return this.isFileLoadingValue; } + protected set isFileLoading(val: boolean) { + this.isFileLoadingValue = val; + this.updateIsReady(); + } + get fileNavigatorVisible(): boolean { const isUploading = this.isUploading; const isPlayingVideo = this.isPlayingVideo; @@ -800,12 +815,6 @@ export class QuestionFileModel extends QuestionFileModelBase { } this.previewValueChanged(); } - private isFileLoadingValue: boolean; - protected get isFileLoading(): boolean { return this.isFileLoadingValue; } - protected set isFileLoading(val: boolean) { - this.isFileLoadingValue = val; - this.updateIsReady(); - } protected getIsQuestionReady(): boolean { return super.getIsQuestionReady() && !this.isFileLoading; } @@ -920,13 +929,6 @@ export class QuestionFileModel extends QuestionFileModelBase { this.loadFiles(files); } - protected onChangeQuestionValue(newValue: any): void { - super.onChangeQuestionValue(newValue); - this.stateChanged(this.isEmpty() ? "empty" : "loaded"); - if (!this.isLoadingFromJson) { - this.loadPreview(newValue); - } - } protected calcCssClasses(css: any): any { const classes = super.calcCssClasses(css); this.actionsContainer.cssClasses = css.actionBar; @@ -1127,7 +1129,7 @@ QuestionFactory.Instance.registerQuestion("file", (name) => { }); export class FileLoader { - constructor(private fileQuestion: QuestionFileModel, private callback: (status: string, files: any[]) => void) { + constructor(private fileQuestion: QuestionFileModelBase, private callback: (status: string, files: any[]) => void) { } loaded: any[] = []; load(files: Array): void { diff --git a/src/question_signaturepad.ts b/src/question_signaturepad.ts index 2b08da746d..5aaecd835e 100644 --- a/src/question_signaturepad.ts +++ b/src/question_signaturepad.ts @@ -5,7 +5,7 @@ import { CssClassBuilder } from "./utils/cssClassBuilder"; import { SurveyModel } from "./survey"; import { ConsoleWarnings } from "./console-warnings"; import { ITheme } from "./themes"; -import { dataUrl2File, QuestionFileModelBase } from "./question_file"; +import { dataUrl2File, FileLoader, QuestionFileModelBase } from "./question_file"; var defaultWidth = 300; var defaultHeight = 200; @@ -137,6 +137,28 @@ export class QuestionSignaturePadModel extends QuestionFileModelBase { this.refreshCanvas(); }; + protected loadPreview(newValue: any): void { + if (!this.storeDataAsText) { + var newValues = !!newValue ? [newValue] : []; + if (!!this._previewLoader) { + this._previewLoader.dispose(); + } + this.isFileLoading = true; + this._previewLoader = new FileLoader(this, (status, loaded) => { + this.isFileLoading = false; + if (loaded && loaded.length > 0) this.fromDataUrl(loaded[0].content); + this._previewLoader.dispose(); + this._previewLoader = undefined; + }); + this._previewLoader.load(newValues); + } + } + + public onSurveyLoad(): void { + super.onSurveyLoad(); + this.loadPreview(this.value); + } + initSignaturePad(el: HTMLElement) { var canvas: any = el.getElementsByTagName("canvas")[0]; this.canvas = canvas; diff --git a/tests/question_signaturepadtests.ts b/tests/question_signaturepadtests.ts index 4a4458ca27..5d7bd67914 100644 --- a/tests/question_signaturepadtests.ts +++ b/tests/question_signaturepadtests.ts @@ -390,7 +390,7 @@ QUnit.test("check rendered size properties", (assert) => { assert.equal(signaturepadQuestion.renderedCanvasWidth, "100%"); }); -QUnit.test("Question Signature upload files", function (assert) { +QUnit.skip("Question Signature upload files", function (assert) { var json = { questions: [ { @@ -453,7 +453,7 @@ QUnit.test("Question Signature upload files", function (assert) { }); }); -QUnit.test("Question Signature upload files - and complete", function (assert) { +QUnit.skip("Question Signature upload files - and complete", function (assert) { var json = { questions: [ { @@ -516,4 +516,42 @@ QUnit.test("Question Signature pad invisible - on complete", function (assert) { survey.getQuestionByName("text").value = "abc"; survey.doComplete(); assert.deepEqual(survey.data, { text: "abc" }); -}); \ No newline at end of file +}); + +QUnit.skip("Check signature download file event", (assert) => { + var el = document.createElement("div"); + var canv = document.createElement("canvas"); + el.appendChild(canv); + const survey = new SurveyModel({ + questions: [ + { + type: "signaturepad", + name: "signature", + "signatureWidth": 100, + "signatureHeight": 100, + "dataFormat": "svg", + storeDataAsText: false + } + ], + }); + var q: QuestionSignaturePadModel = survey.getQuestionByName("signature"); + q.initSignaturePad(el); + let log = ""; + survey.onDownloadFile.add((survey, options) => { + log += "->" + options.fileValue; + options.callback( + "success", + "" + ); + }); + + assert.equal(q.currentState, "empty", "Initial state is empty"); + survey.data = { + "signature": "file1.png" + }; + assert.equal(log, "->file1.png", "file should be loaded only once"); + assert.equal(q.currentState, "loaded", "The loaded state after data assigned"); + + canv.remove(); + el.remove(); +}); diff --git a/visualRegressionTests/tests/defaultV2/etalons/signature-data-load-preview.png b/visualRegressionTests/tests/defaultV2/etalons/signature-data-load-preview.png new file mode 100644 index 0000000000000000000000000000000000000000..09160a59b0ce5f51b8aa6a6ef17ed46c874799fc GIT binary patch literal 7211 zcmdsc^;?wDx4kGRA`A%9-QC^NjKBbbATlUODJU^?BO)ULf=Dx@l(Zn7g0zIRbR*p< zanAss@Av)#_lJ9*hv#MDocHW=_S$Q&^-iD`Oa%{z0_WPbYj{vq#f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!UT!U=K8RJH*`iF-4OaKd-Sy()L^r%U4qgny!Dg{fD@yg20O#@C40-Vl7 zjYqM|#?!dCxW8y~0%~ix#zPdy_EZHqIbc~|Rv#_Ie=jZVHR;dN-d!FD`tShcLKD#9&}>Hf(&ys0A9D25t_SS@m#%W)Ng8@nc&}f-#sqc?pov{rNK}*vBo9cC zw0EC#5w3efN1F%?S8-Vbt4n-QAv { await takeElementScreenshot("signature-data-loading.png", ".sd-question", t, comparer); }); }); + test("Signature loading preview", async (t) => { + await wrapVisualTest(t, async (t, comparer) => { + await t.resizeWindow(1920, 1080); + await initSurvey(framework, { + questions: [ + { + type: "signaturepad", + name: "signature", + "signatureWidth": 100, + "signatureHeight": 100, + "dataFormat": "svg", + storeDataAsText: false + } + ], + }); + await ClientFunction(() => { + window["survey"].onDownloadFile.add((survey, options) => { + options.callback( + "success", + "data:image/svg+xml,%3Csvg height='100' width='100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle r='45' cx='50' cy='50' fill='red'/%3E%3C/svg%3E" + ); + }); + window["survey"].data = { + "signature": "file1.png" + }; + })(); + + await takeElementScreenshot("signature-data-load-preview.png", ".sd-question", t, comparer); + }); + }); }); \ No newline at end of file From 4623f4856c525447b6f9eece6e8b1cc783f7a1d2 Mon Sep 17 00:00:00 2001 From: Aleksey Novikov Date: Mon, 29 Jul 2024 23:12:06 +0300 Subject: [PATCH 2/3] #8575 - fixed tests --- src/question_signaturepad.ts | 2 +- tests/question_signaturepadtests.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/question_signaturepad.ts b/src/question_signaturepad.ts index 5aaecd835e..e08a15477b 100644 --- a/src/question_signaturepad.ts +++ b/src/question_signaturepad.ts @@ -146,7 +146,7 @@ export class QuestionSignaturePadModel extends QuestionFileModelBase { this.isFileLoading = true; this._previewLoader = new FileLoader(this, (status, loaded) => { this.isFileLoading = false; - if (loaded && loaded.length > 0) this.fromDataUrl(loaded[0].content); + if (loaded && loaded.length > 0 && loaded[0].content) this.fromDataUrl(loaded[0].content); this._previewLoader.dispose(); this._previewLoader = undefined; }); diff --git a/tests/question_signaturepadtests.ts b/tests/question_signaturepadtests.ts index 5d7bd67914..a51c7d06de 100644 --- a/tests/question_signaturepadtests.ts +++ b/tests/question_signaturepadtests.ts @@ -390,7 +390,7 @@ QUnit.test("check rendered size properties", (assert) => { assert.equal(signaturepadQuestion.renderedCanvasWidth, "100%"); }); -QUnit.skip("Question Signature upload files", function (assert) { +QUnit.test("Question Signature upload files", function (assert) { var json = { questions: [ { @@ -425,7 +425,7 @@ QUnit.skip("Question Signature upload files", function (assert) { options.callback( "success", options.files.map((file) => { - return { file: file, content: file.name + "_url" }; + return { file: file, content: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='" + file.name + "'%3E%3C/svg%3E" }; }) ), 2 @@ -442,7 +442,7 @@ QUnit.skip("Question Signature upload files", function (assert) { q1.onBlur({ target: null } as any); survey.onValueChanged.add((survey, options) => { - assert.equal(q1.value, "signature.svg_url"); + assert.equal(q1.value, "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='signature.svg'%3E%3C/svg%3E"); assert.ok(eventFired); assert.ok(fileLoaded); @@ -453,7 +453,7 @@ QUnit.skip("Question Signature upload files", function (assert) { }); }); -QUnit.skip("Question Signature upload files - and complete", function (assert) { +QUnit.test("Question Signature upload files - and complete", function (assert) { var json = { questions: [ { @@ -475,7 +475,7 @@ QUnit.skip("Question Signature upload files - and complete", function (assert) { options.callback( "success", options.files.map((file) => { - return { file: file, content: file.name + "_url" }; + return { file: file, content: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='" + file.name + "'%3E%3C/svg%3E" }; }) ); }, @@ -518,7 +518,7 @@ QUnit.test("Question Signature pad invisible - on complete", function (assert) { assert.deepEqual(survey.data, { text: "abc" }); }); -QUnit.skip("Check signature download file event", (assert) => { +QUnit.test("Check signature download file event", (assert) => { var el = document.createElement("div"); var canv = document.createElement("canvas"); el.appendChild(canv); From e6ffcf1291833b8a960742867464f3e7bd27abc1 Mon Sep 17 00:00:00 2001 From: Aleksey Novikov Date: Tue, 30 Jul 2024 14:38:30 +0300 Subject: [PATCH 3/3] #8575 The survey.onDownloadFile event is not raised for a Signature Pad question which stores signatures by their names/ids Fixes #8575 --- src/question_file.ts | 6 +++--- src/question_signaturepad.ts | 2 +- src/survey.ts | 2 +- tests/question_signaturepadtests.ts | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/question_file.ts b/src/question_file.ts index ac54cdb8e1..18d24aa91f 100644 --- a/src/question_file.ts +++ b/src/question_file.ts @@ -801,7 +801,7 @@ export class QuestionFileModel extends QuestionFileModelBase { } this.isFileLoading = true; this._previewLoader = new FileLoader(this, (status, loaded) => { - if (status === "loaded") { + if (status !== "error") { loaded.forEach((val) => { this.previewValue.push(val); }); @@ -1141,7 +1141,7 @@ export class FileLoader { if (!this.fileQuestion || !this.callback) { return; } - if (status === "success") { + if (status !== "error") { this.loaded[index] = { content: data, name: value.name, @@ -1149,7 +1149,7 @@ export class FileLoader { }; downloadedCount++; if (downloadedCount === files.length) { - this.callback("loaded", this.loaded); + this.callback(status, this.loaded); } } else { this.callback("error", this.loaded); diff --git a/src/question_signaturepad.ts b/src/question_signaturepad.ts index e08a15477b..4c45f120e0 100644 --- a/src/question_signaturepad.ts +++ b/src/question_signaturepad.ts @@ -146,7 +146,7 @@ export class QuestionSignaturePadModel extends QuestionFileModelBase { this.isFileLoading = true; this._previewLoader = new FileLoader(this, (status, loaded) => { this.isFileLoading = false; - if (loaded && loaded.length > 0 && loaded[0].content) this.fromDataUrl(loaded[0].content); + if (loaded && loaded.length > 0 && loaded[0].content && status === "success") this.fromDataUrl(loaded[0].content); this._previewLoader.dispose(); this._previewLoader = undefined; }); diff --git a/src/survey.ts b/src/survey.ts index fe39cd02be..a1e29b556d 100644 --- a/src/survey.ts +++ b/src/survey.ts @@ -5329,7 +5329,7 @@ export class SurveyModel extends SurveyElementCore callback: (status: string, data: any) => any ): void { if (this.onDownloadFile.isEmpty) { - !!callback && callback("success", fileValue.content || fileValue); + !!callback && callback("skipped", fileValue.content || fileValue); } this.onDownloadFile.fire(this, { question: question, diff --git a/tests/question_signaturepadtests.ts b/tests/question_signaturepadtests.ts index a51c7d06de..20ee0c2885 100644 --- a/tests/question_signaturepadtests.ts +++ b/tests/question_signaturepadtests.ts @@ -425,7 +425,7 @@ QUnit.test("Question Signature upload files", function (assert) { options.callback( "success", options.files.map((file) => { - return { file: file, content: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='" + file.name + "'%3E%3C/svg%3E" }; + return { file: file, content: file.name + "_url" }; }) ), 2 @@ -442,7 +442,7 @@ QUnit.test("Question Signature upload files", function (assert) { q1.onBlur({ target: null } as any); survey.onValueChanged.add((survey, options) => { - assert.equal(q1.value, "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='signature.svg'%3E%3C/svg%3E"); + assert.equal(q1.value, "signature.svg_url"); assert.ok(eventFired); assert.ok(fileLoaded); @@ -475,7 +475,7 @@ QUnit.test("Question Signature upload files - and complete", function (assert) { options.callback( "success", options.files.map((file) => { - return { file: file, content: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' id='" + file.name + "'%3E%3C/svg%3E" }; + return { file: file, content: file.name + "_url" }; }) ); },