diff --git a/package-lock.json b/package-lock.json index fda55e18..3620223c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "ignore-loader": "^0.1.2", "lodash.clonedeep": "^4.5.0", "lodash.defaultsdeep": "^4.6.1", + "node-gzip": "^1.1.2", "reflect-metadata": "^0.1.13", "style-loader": "^3.3.1", "ts-loader": "^9.2.6", diff --git a/package.json b/package.json index 898eb52b..7d322526 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "basiscore", - "version": "2.34.1", + "version": "2.34.2", "description": "Client side and light version of BasisCore web programming language", "main": "dist/basiscore.js", "types": "dist/basiscore.d.ts", @@ -58,4 +58,4 @@ "pako": "^2.1.0", "tsyringe": "^4.6.0" } -} \ No newline at end of file +} diff --git a/src/component/renderable/schema/part-control/html/HTMLFieldType.ts b/src/component/renderable/schema/part-control/html/HTMLFieldType.ts index 58048922..8219ffc6 100644 --- a/src/component/renderable/schema/part-control/html/HTMLFieldType.ts +++ b/src/component/renderable/schema/part-control/html/HTMLFieldType.ts @@ -11,8 +11,9 @@ import { IQuestionPart } from "../../IQuestionSchema"; export default class HTMLFieldType extends QuestionPart { private valueInput: HTMLInputElement; - private value: IUserActionPart; + public value: IUserActionPart | string; private modalElement: HTMLElement; + public answer; constructor(part: IQuestionPart, owner: Question, answer: IPartCollection) { super(part, layout, owner, answer); this.modalElement = Util.parse(HTMLLayout).querySelector( @@ -51,7 +52,7 @@ export default class HTMLFieldType extends QuestionPart { let data; try { data = JSON.parse(e.data); - } catch { } + } catch {} if (data) { if (Object.keys(data).find((e) => e == "isLoaded")) { if (data.isLoaded) { @@ -92,7 +93,7 @@ export default class HTMLFieldType extends QuestionPart { iframe.onload = (e) => { if (this.value) { iframe.contentWindow.postMessage( - JSON.stringify({ ...this.value, mode: "edit" }) + JSON.stringify({ ...(this.value as IUserActionPart), mode: "edit" }) ); } else { iframe.contentWindow.postMessage(JSON.stringify({ mode: "new" })); @@ -111,6 +112,8 @@ export default class HTMLFieldType extends QuestionPart { } public getAddedAsync(): Promise { let retVal = null; + + if (!this.answer) { if (this.value) { retVal = { @@ -130,6 +133,7 @@ export default class HTMLFieldType extends QuestionPart { } public getEditedAsync(): Promise { let retVal = null; + if (this.answer) { const changed = this.value != this.answer.values[0].value; if (changed) { @@ -149,7 +153,6 @@ export default class HTMLFieldType extends QuestionPart { public getDeletedAsync(): Promise { let retVal = null; - if (this.answer && Object.keys(this.value).length == 0) { const changed = this.value != this.answer.values[0].value; if (changed) { @@ -168,6 +171,6 @@ export default class HTMLFieldType extends QuestionPart { } public getValuesAsync(): Promise { - return Promise.resolve(this.value); + return Promise.resolve(this.value as IUserActionPart); } } diff --git a/src/component/renderable/schema/question-container/QuestionContainer.ts b/src/component/renderable/schema/question-container/QuestionContainer.ts index 119d0982..4b40d7c6 100644 --- a/src/component/renderable/schema/question-container/QuestionContainer.ts +++ b/src/component/renderable/schema/question-container/QuestionContainer.ts @@ -8,6 +8,7 @@ import { IAnswerProperty, IAnswerPart } from "../IAnswerSchema"; import { IQuestion } from "../IQuestionSchema"; import IQuestionCellManager from "../IQuestionCellManager"; import QuestionPart from "../question-part/QuestionPart"; +import HTMLFieldType from "../part-control/html/HTMLFieldType"; export default class QuestionContainer { public readonly QuestionSchema: IQuestion; @@ -40,7 +41,9 @@ export default class QuestionContainer { if (!questionSchema.help) { uiElement.querySelector("[data-bc-help-btn]").remove(); } else { - uiElement.querySelector("[data-bc-help-btn]").setAttribute("data-bc-help-tooltip", questionSchema.help); + uiElement + .querySelector("[data-bc-help-btn]") + .setAttribute("data-bc-help-tooltip", questionSchema.help); } const headerContainer = uiElement.querySelector( "[data-bc-answer-title-container]" @@ -123,12 +126,16 @@ export default class QuestionContainer { public onQuestionRemove(question: Question) { const index = this._questions.indexOf(question); - this._questions.splice(index, 1); - if (question.answer?.id) { - if (!this._removedQuestions) { - this._removedQuestions = []; + if (question.question.parts[0].viewType == "html") { + (question._parts[0] as HTMLFieldType).value =""; + } else { + this._questions.splice(index, 1); + if (question.answer?.id) { + if (!this._removedQuestions) { + this._removedQuestions = []; + } + this._removedQuestions.push(question.answer.id); } - this._removedQuestions.push(question.answer.id); } } diff --git a/src/component/renderable/schema/question/Question.ts b/src/component/renderable/schema/question/Question.ts index 9549b7a8..6f3aab27 100644 --- a/src/component/renderable/schema/question/Question.ts +++ b/src/component/renderable/schema/question/Question.ts @@ -21,7 +21,7 @@ export default class Question { private _addButton: HTMLButtonElement; private _pairBtnContainer: HTMLDivElement; readonly owner: QuestionContainer; - readonly answer: IAnswerPart; + answer: IAnswerPart; private readonly _ui: HTMLElement; private _onAddClick: AddRemoveCallback; private _onRemoveClick: AddRemoveCallback; @@ -49,10 +49,11 @@ export default class Question { this.button.addEventListener("click", this.onBtnClick.bind(this)); this._removeButton.addEventListener("click", (e) => { + e.preventDefault; this.owner.onQuestionRemove(this); this._ui.remove(); - this.owner.addQuestion(null); + this.owner.addQuestion(null); }); this._addButton.addEventListener("click", () => this._onAddClick()); this._onAddClick = () => { @@ -181,6 +182,9 @@ export default class Question { } : null; } + public clearAnswer(){ + this.answer =null + } } declare type AddRemoveCallback = () => void; diff --git a/src/index.ts b/src/index.ts index fcb73450..e56e3728 100644 --- a/src/index.ts +++ b/src/index.ts @@ -44,7 +44,7 @@ ______ _ _ _ _ follow us on https://BasisCore.com/ -version:2.34.1`, +version:2.34.2`, " background: yellow;color: #0078C1; font-size: 2rem; font-family: Arial; font-weight: bolder", "color: #0078C1; font-size: 1rem; font-family: Arial;" diff --git a/src/options/connection-options/ChunkBasedConnectionOptions.ts b/src/options/connection-options/ChunkBasedConnectionOptions.ts index 62d051b8..5a397f18 100644 --- a/src/options/connection-options/ChunkBasedConnectionOptions.ts +++ b/src/options/connection-options/ChunkBasedConnectionOptions.ts @@ -4,6 +4,7 @@ import { EventHandlerWithReturn } from "../../event/EventHandlerWithReturn"; import IDictionary from "../../IDictionary"; import ConnectionOptions from "./ConnectionOptions"; import StreamPromise from "./StreamPromise"; +//@ts-ignore import pako from "pako"; enum HttpMethod {