diff --git a/src/itemvalue.ts b/src/itemvalue.ts index cee287a340..92dfa4f40f 100644 --- a/src/itemvalue.ts +++ b/src/itemvalue.ts @@ -63,13 +63,13 @@ export class ItemValue { items[i].locText.onChanged(); } } - private static itemValueProp = [ "text", "value", "hasText", "locOwner", "locText"]; + private static itemValueProp = [ "text", "value", "hasText", "locOwner", "locText", "isValueEmpty"]; private itemValue: any; private locTextValue: LocalizableString; constructor(value: any, text: string = null) { this.locTextValue = new LocalizableString(null, true); var self = this; - this.locTextValue.onGetTextCallback = function(text) { return text ? text : (self.value ? self.value.toString() : null); } + this.locTextValue.onGetTextCallback = function(text) { return text ? text : (!self.isValueEmpty ? self.value.toString() : null); } if(text) this.locText.text = text; this.value = value; } @@ -106,7 +106,8 @@ export class ItemValue { this.value = value; } } - private isObjItemValue(obj: any) { return typeof (obj.getType) !== 'undefined' && obj.getType() == 'itemvalue'} + private get isValueEmpty() { return !this.itemValue && this.itemValue !== 0 && this.itemValue !== false; } + private isObjItemValue(obj: any) { return typeof (obj.getType) !== 'undefined' && obj.getType() == 'itemvalue';} private copyAttributes(src: any, exceptons: Array) { for (var key in src) { if ((typeof src[key] == 'function')) continue; diff --git a/tests/localizablestringtests.ts b/tests/localizablestringtests.ts index 89b3c3c68c..cdbe24bc34 100644 --- a/tests/localizablestringtests.ts +++ b/tests/localizablestringtests.ts @@ -127,6 +127,13 @@ QUnit.test("Array localization", function (assert) { items[0].locText.setLocaleText("", null); assert.equal(items[0].text, "val1", "Check6, use value"); }); +QUnit.test("ItemValue.value = 0, #538", function (assert) { + var owner = new LocalizableOwnerTester(""); + var items = ItemValue.createArray(owner); + + items.push(new ItemValue(0)); + assert.equal(items[0].locText.textOrHtml, "0", "value 0, text should be '0'") +}); QUnit.test("Array localization serialize", function (assert) { var owner = new LocalizableOwnerTester(""); diff --git a/tests/surveypaneldynamictests.ts b/tests/surveypaneldynamictests.ts index 11635c210f..606bf1ff37 100644 --- a/tests/surveypaneldynamictests.ts +++ b/tests/surveypaneldynamictests.ts @@ -195,3 +195,18 @@ QUnit.test("PanelDynamic in design time", function (assert) { assert.equal(question.panels.length, 1, "Only one panel at design time"); assert.equal(question.panels[0].id, question.template.id, "The template panel should be shown"); }); + +/* Think about this- +QUnit.test("PanelDynamic survey.getPageByQuestion/Element", function (assert) { + var survey = new SurveyModel(); + survey.setDesignMode(true); + survey.addNewPage("p"); + var question = new QuestionPanelDynamicModel("q"); + survey.pages[0].addQuestion(question); + question.template.addNewQuestion("text", "q1"); + question.template.addNewQuestion("text", "q2"); + question.panelCount = 2; + assert.equal(survey.getPageByQuestion(question.template.questions[0]).name, "p", "Template question page is found"); + assert.equal(survey.getPageByQuestion(question.panels[0].questions[0]).name, "p", "Nested question page is found"); +}); +*/ \ No newline at end of file diff --git a/tests/surveyquestiontests.ts b/tests/surveyquestiontests.ts index 3237b5a700..6b43115ef6 100644 --- a/tests/surveyquestiontests.ts +++ b/tests/surveyquestiontests.ts @@ -761,7 +761,6 @@ QUnit.test("Matrixdynamic column.visibleIf, load from json and add item", functi assert.equal(q_1_1.visible, false, "Initial the question in the added row is invisible"); }); - QUnit.test("Text inputType=number", function (assert) { var question = new QuestionTextModel("text"); question.inputType = "number";