From a1063161fb21829c3b37195614f42a703be2652b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 7 Dec 2024 11:58:32 +0330 Subject: [PATCH 1/2] add undefined checker --- package-lock.json | 4 +-- .../renderable/schema/SchemaComponent.ts | 28 ++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 888791fb..5504e2f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "basiscore", - "version": "2.35.0", + "version": "2.36.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "basiscore", - "version": "2.35.0", + "version": "2.36.2", "license": "ISC", "dependencies": { "@types/pako": "^2.0.3", diff --git a/src/component/renderable/schema/SchemaComponent.ts b/src/component/renderable/schema/SchemaComponent.ts index f0077210..041292d0 100644 --- a/src/component/renderable/schema/SchemaComponent.ts +++ b/src/component/renderable/schema/SchemaComponent.ts @@ -68,6 +68,10 @@ export default class SchemaComponent extends SourceBaseComponent { this.buttonSelector = await this.getAttributeValueAsync("button"); this.resultSourceIdToken = this.getAttributeToken("resultSourceId"); + console.log( + // await this.schemaUrlToken.getValueAsync(), + // await this.paramUrlToken.getValueAsync() + ) this.errorResultSourceIdToken = this.getAttributeToken( "errorResultSourceId" @@ -89,6 +93,7 @@ export default class SchemaComponent extends SourceBaseComponent { private onClick(e: MouseEvent) { e.preventDefault(); + console.log("ssssss"); if (this.getAnswersAndSetAsSource) { this.getAnswersAndSetAsSource(); } @@ -115,6 +120,7 @@ export default class SchemaComponent extends SourceBaseComponent { //schemaId = this._answer?.schemaId ?? schemaId; this._questions = new Array(); this.getAnswersAndSetAsSource = null; + console.log("dddd"); const container = document.createElement("div") as Element; container.setAttribute("data-bc-schema-main-container", ""); @@ -158,7 +164,7 @@ export default class SchemaComponent extends SourceBaseComponent { var schemaCallback: GetSchemaCallbackAsync = schemaCallbackStr ? eval(schemaCallbackStr) : null; - + console.log(schemaCallback, schemaCallbackStr); if (!schemaCallback) { schemaCallback = async (context, schemaUrl) => { // const url = Util.formatUrl(schemaUrlStr, null, { @@ -170,6 +176,7 @@ export default class SchemaComponent extends SourceBaseComponent { (schemaUrl?.length ?? 0) > 0 ? `${schemaUrlStr}${schemaUrl}` : schemaUrlStr; + console.log(url); const response = await Util.getDataAsync< IServerResponse >(url); @@ -211,11 +218,20 @@ export default class SchemaComponent extends SourceBaseComponent { getQueryStringParamsAsync: queryStringsMakerAsync, filesPath: filesPath, }; + // if (!this.getAnswersAndSetAsSource) { + // this.getAnswersAndSetAsSource = async () => { + // const answer = await this.getAnswersAsync(false); + // console.log("answerteterr", answer); + // this.context.setAsSource(resultSourceId, answer); + // console.log("ttt"); + // }; + // console.log("important", await this.getAnswersAndSetAsSource()); + // } this._schema = await schemaCallback(this.context, options.paramUrl); const optionName = await this.getAttributeValueAsync("options"); let option = optionName ? eval(optionName) : null; - const validationHandler = new ValidationHandler(this._schema.lid, option); - const schemaDirection = this._schema.direction ?? direction; + const validationHandler = new ValidationHandler(this._schema?.lid, option); + const schemaDirection = this._schema?.direction ?? direction; options["direction"] = schemaDirection; container.setAttribute("data-bc-schema-direction", schemaDirection); const sections = new Map(); @@ -267,7 +283,7 @@ export default class SchemaComponent extends SourceBaseComponent { options, cellManager, partAnswer, -validationHandler + validationHandler ) ); } @@ -279,8 +295,10 @@ validationHandler ) { this.getAnswersAndSetAsSource = async () => { const answer = await this.getAnswersAsync(false); + console.log("answer", answer); if (answer) { this.context.setAsSource(resultSourceId, answer); + console.log("ttt"); } }; } @@ -295,6 +313,7 @@ validationHandler let retVal: IUserActionResult = null; const errorResultSourceId = await this.errorResultSourceIdToken?.getValueAsync(); + console.log("errorResultSourceId",errorResultSourceId,this) for (const question of this._questions) { try { var actions = await question.getUserActionAsync(); @@ -320,6 +339,7 @@ validationHandler throw Error("invalid"); } else if (hasValidationError && errorResultSourceId) { this.context.setAsSource(errorResultSourceId, hasValidationError); + console.log("llll"); } if (!hasValidationError && userActionList.length > 0) { retVal = { From eb3449c270f9ea941c542f42a12a84620efd8a36 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 7 Dec 2024 12:31:24 +0330 Subject: [PATCH 2/2] remove logs --- .../renderable/schema/SchemaComponent.ts | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/component/renderable/schema/SchemaComponent.ts b/src/component/renderable/schema/SchemaComponent.ts index 041292d0..9a7cc480 100644 --- a/src/component/renderable/schema/SchemaComponent.ts +++ b/src/component/renderable/schema/SchemaComponent.ts @@ -68,10 +68,6 @@ export default class SchemaComponent extends SourceBaseComponent { this.buttonSelector = await this.getAttributeValueAsync("button"); this.resultSourceIdToken = this.getAttributeToken("resultSourceId"); - console.log( - // await this.schemaUrlToken.getValueAsync(), - // await this.paramUrlToken.getValueAsync() - ) this.errorResultSourceIdToken = this.getAttributeToken( "errorResultSourceId" @@ -93,7 +89,6 @@ export default class SchemaComponent extends SourceBaseComponent { private onClick(e: MouseEvent) { e.preventDefault(); - console.log("ssssss"); if (this.getAnswersAndSetAsSource) { this.getAnswersAndSetAsSource(); } @@ -120,7 +115,6 @@ export default class SchemaComponent extends SourceBaseComponent { //schemaId = this._answer?.schemaId ?? schemaId; this._questions = new Array(); this.getAnswersAndSetAsSource = null; - console.log("dddd"); const container = document.createElement("div") as Element; container.setAttribute("data-bc-schema-main-container", ""); @@ -164,7 +158,6 @@ export default class SchemaComponent extends SourceBaseComponent { var schemaCallback: GetSchemaCallbackAsync = schemaCallbackStr ? eval(schemaCallbackStr) : null; - console.log(schemaCallback, schemaCallbackStr); if (!schemaCallback) { schemaCallback = async (context, schemaUrl) => { // const url = Util.formatUrl(schemaUrlStr, null, { @@ -176,7 +169,6 @@ export default class SchemaComponent extends SourceBaseComponent { (schemaUrl?.length ?? 0) > 0 ? `${schemaUrlStr}${schemaUrl}` : schemaUrlStr; - console.log(url); const response = await Util.getDataAsync< IServerResponse >(url); @@ -218,15 +210,6 @@ export default class SchemaComponent extends SourceBaseComponent { getQueryStringParamsAsync: queryStringsMakerAsync, filesPath: filesPath, }; - // if (!this.getAnswersAndSetAsSource) { - // this.getAnswersAndSetAsSource = async () => { - // const answer = await this.getAnswersAsync(false); - // console.log("answerteterr", answer); - // this.context.setAsSource(resultSourceId, answer); - // console.log("ttt"); - // }; - // console.log("important", await this.getAnswersAndSetAsSource()); - // } this._schema = await schemaCallback(this.context, options.paramUrl); const optionName = await this.getAttributeValueAsync("options"); let option = optionName ? eval(optionName) : null; @@ -295,10 +278,8 @@ export default class SchemaComponent extends SourceBaseComponent { ) { this.getAnswersAndSetAsSource = async () => { const answer = await this.getAnswersAsync(false); - console.log("answer", answer); if (answer) { this.context.setAsSource(resultSourceId, answer); - console.log("ttt"); } }; } @@ -312,8 +293,7 @@ export default class SchemaComponent extends SourceBaseComponent { let hasValidationError = false; let retVal: IUserActionResult = null; const errorResultSourceId = - await this.errorResultSourceIdToken?.getValueAsync(); - console.log("errorResultSourceId",errorResultSourceId,this) + await this.errorResultSourceIdToken?.getValueAsync(); for (const question of this._questions) { try { var actions = await question.getUserActionAsync(); @@ -339,7 +319,6 @@ export default class SchemaComponent extends SourceBaseComponent { throw Error("invalid"); } else if (hasValidationError && errorResultSourceId) { this.context.setAsSource(errorResultSourceId, hasValidationError); - console.log("llll"); } if (!hasValidationError && userActionList.length > 0) { retVal = {