Merge pull request #4074 from dpalou/MOBILE-4470

Mobile 4470
main
Pau Ferrer Ocaña 2024-05-29 16:29:35 +02:00 committed by GitHub
commit 05e6bcb0b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 47 additions and 37 deletions

View File

@ -17,4 +17,4 @@
</ion-item>
</span>
<core-format-text *ngIf="displayMode && value && value.content" [text]="value.content" [filter]="false" />
<core-format-text *ngIf="displayMode && content" [text]="content" [filter]="false" />

View File

@ -25,6 +25,7 @@ import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-fiel
})
export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginBaseComponent {
content?: string;
options: {
key: string;
value: string;
@ -40,31 +41,32 @@ export class AddonModDataFieldCheckboxComponent extends AddonModDataFieldPluginB
return;
}
this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
const values: string[] = [];
if (this.editMode && this.value && this.value.content) {
this.value.content.split('##').forEach((value) => {
const x = this.options.findIndex((option) => value == option.key);
if (x >= 0) {
values.push(value);
}
});
}
if (this.searchMode) {
this.addControl('f_' + this.field.id + '_allreq');
}
this.addControl('f_' + this.field.id, values);
this.addControl('f_' + this.field.id, this.getValidValues(this.value));
}
/**
* @inheritdoc
*/
protected updateValue(value?: Partial<AddonModDataEntryField>): void {
this.value = value || {};
this.value.content = value?.content?.split('##').join('<br>');
super.updateValue(value);
this.content = this.getValidValues(value).join('<br>');
}
/**
* Get the list of valid values from current field value.
*
* @param value Field value.
* @returns List of valid values.
*/
protected getValidValues(value?: Partial<AddonModDataEntryField>): string[] {
this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
return value?.content?.split('##').filter((value) => this.options.some(option => value === option.key)) ?? [];
}
}

View File

@ -18,4 +18,4 @@
</ion-item>
</span>
<core-format-text *ngIf="displayMode && value && value.content" [text]="value.content" [filter]="false" />
<core-format-text *ngIf="displayMode && content" [text]="content" [filter]="false" />

View File

@ -25,6 +25,7 @@ import { AddonModDataFieldPluginBaseComponent } from '../../../classes/base-fiel
})
export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPluginBaseComponent {
content?: string;
options: {
key: string;
value: string;
@ -40,31 +41,32 @@ export class AddonModDataFieldMultimenuComponent extends AddonModDataFieldPlugin
return;
}
this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
const values: string[] = [];
if (this.editMode && this.value?.content) {
this.value.content.split('##').forEach((value) => {
const x = this.options.findIndex((option) => value == option.key);
if (x >= 0) {
values.push(value);
}
});
}
if (this.searchMode) {
this.addControl('f_' + this.field.id + '_allreq');
}
this.addControl('f_' + this.field.id, values);
this.addControl('f_' + this.field.id, this.getValidValues(this.value));
}
/**
* @inheritdoc
*/
protected updateValue(value?: Partial<AddonModDataEntryField>): void {
this.value = value || {};
this.value.content = value?.content && value.content.split('##').join('<br>');
super.updateValue(value);
this.content = this.getValidValues(value).join('<br>');
}
/**
* Get the list of valid values from current field value.
*
* @param value Field value.
* @returns List of valid values.
*/
protected getValidValues(value?: Partial<AddonModDataEntryField>): string[] {
this.options = this.field.param1.split(/\r?\n/).map((option) => ({ key: option, value: option }));
return value?.content?.split('##').filter((value) => this.options.some(option => value === option.key)) ?? [];
}
}

View File

@ -269,9 +269,14 @@ export class AddonModLessonHelperProvider {
if (option.checked || multiChoiceQuestion.multi) {
// Add the control.
const value = multiChoiceQuestion.multi ?
{ value: option.checked, disabled: option.disabled } : option.checked;
questionForm.addControl(option.name, this.formBuilder.control(value));
if (multiChoiceQuestion.multi) {
questionForm.addControl(
option.name,
this.formBuilder.control({ value: option.checked, disabled: option.disabled }),
);
} else {
questionForm.addControl(option.name, this.formBuilder.control(option.value));
}
controlAdded = true;
}
@ -464,7 +469,7 @@ export class AddonModLessonHelperProvider {
let input = element.querySelector<HTMLInputElement>('input[type="checkbox"][name*="answer"]');
if (input) {
// Truefalse or multichoice.
const successBadge = element.querySelector<HTMLElement>('.badge.badge-success');
const successBadge = element.querySelector<HTMLElement>('.badge.bg-success, .badge.badge-success');
const data: AddonModLessonCheckboxAnswerData = {
isCheckbox: true,
checked: !!input.checked,

View File

@ -83,7 +83,8 @@ html[dir=rtl] {
@each $color-name, $unused in $colors {
.text-#{$color-name},
p.text-#{$color-name} {
p.text-#{$color-name},
.text-#{$color-name} p {
color: var(--ion-color-#{$color-name}) !important;
}
}