Skip to content
Open
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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -58,4 +58,4 @@
"pako": "^2.1.0",
"tsyringe": "^4.6.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { IQuestionPart } from "../../IQuestionSchema";

export default class HTMLFieldType extends QuestionPart {
private valueInput: HTMLInputElement;
private value: IUserActionPart;
public value: IUserActionPart | string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

private modalElement: HTMLElement;
public answer;
constructor(part: IQuestionPart, owner: Question, answer: IPartCollection) {
super(part, layout, owner, answer);
this.modalElement = Util.parse(HTMLLayout).querySelector(
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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" }));
Expand All @@ -111,6 +112,8 @@ export default class HTMLFieldType extends QuestionPart {
}
public getAddedAsync(): Promise<IUserActionPart> {
let retVal = null;


if (!this.answer) {
if (this.value) {
retVal = {
Expand All @@ -130,6 +133,7 @@ export default class HTMLFieldType extends QuestionPart {
}
public getEditedAsync(): Promise<IUserActionPart> {
let retVal = null;

if (this.answer) {
const changed = this.value != this.answer.values[0].value;
if (changed) {
Expand All @@ -149,7 +153,6 @@ export default class HTMLFieldType extends QuestionPart {

public getDeletedAsync(): Promise<IUserActionPart> {
let retVal = null;

if (this.answer && Object.keys(this.value).length == 0) {
const changed = this.value != this.answer.values[0].value;
if (changed) {
Expand All @@ -168,6 +171,6 @@ export default class HTMLFieldType extends QuestionPart {
}

public getValuesAsync(): Promise<IUserActionPart> {
return Promise.resolve(this.value);
return Promise.resolve(this.value as IUserActionPart);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]"
Expand Down Expand Up @@ -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);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/component/renderable/schema/question/Question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Question {
private _addButton: HTMLButtonElement;
private _pairBtnContainer: HTMLDivElement;
readonly owner: QuestionContainer;
readonly answer: IAnswerPart;
answer: IAnswerPart;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer must be read-only and only set once in edit mode!

private readonly _ui: HTMLElement;
private _onAddClick: AddRemoveCallback;
private _onRemoveClick: AddRemoveCallback;
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -181,6 +182,9 @@ export default class Question {
}
: null;
}
public clearAnswer(){
this.answer =null
}
Comment on lines +185 to +187
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For adding support of clear, please use another method!

}

declare type AddRemoveCallback = () => void;
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EventHandlerWithReturn } from "../../event/EventHandlerWithReturn";
import IDictionary from "../../IDictionary";
import ConnectionOptions from "./ConnectionOptions";
import StreamPromise from "./StreamPromise";
//@ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible please remove it.

import pako from "pako";

enum HttpMethod {
Expand Down