From 9d6c8312e81d632e9d93e4ac8ddb165d919b27b7 Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Wed, 17 Oct 2018 14:23:50 +0200 Subject: [PATCH] MOBILE-2693 data: Fix options of checkbox/multimenu fields --- src/addon/mod/data/fields/checkbox/component/checkbox.ts | 4 ++-- src/addon/mod/data/fields/multimenu/component/multimenu.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/addon/mod/data/fields/checkbox/component/checkbox.ts b/src/addon/mod/data/fields/checkbox/component/checkbox.ts index 98cbe5cc7..2db02302a 100644 --- a/src/addon/mod/data/fields/checkbox/component/checkbox.ts +++ b/src/addon/mod/data/fields/checkbox/component/checkbox.ts @@ -40,7 +40,7 @@ export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginC return; } - this.options = this.field.param1.split('\n').map((option) => { + this.options = this.field.param1.split(/\r?\n/).map((option) => { return { key: option, value: option }; }); @@ -67,7 +67,7 @@ export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginC * @param {any} value New value to be set. */ protected updateValue(value: any): void { - this.value = value; + this.value = value || {}; this.value.content = value && value.content && value.content.split('##').join('
'); } } diff --git a/src/addon/mod/data/fields/multimenu/component/multimenu.ts b/src/addon/mod/data/fields/multimenu/component/multimenu.ts index c642895f9..b31800229 100644 --- a/src/addon/mod/data/fields/multimenu/component/multimenu.ts +++ b/src/addon/mod/data/fields/multimenu/component/multimenu.ts @@ -40,7 +40,7 @@ export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPlugin return; } - this.options = this.field.param1.split('\n').map((option) => { + this.options = this.field.param1.split(/\r?\n/).map((option) => { return { key: option, value: option }; }); @@ -67,7 +67,7 @@ export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPlugin * @param {any} value New value to be set. */ protected updateValue(value: any): void { - this.value = value; + this.value = value || {}; this.value.content = value && value.content && value.content.split('##').join('
'); } }