MOBILE-2430 data: Fix add entry offline

main
Pau Ferrer Ocaña 2018-06-21 17:45:30 +02:00
parent 9f3b03cbde
commit 49ae499481
3 changed files with 14 additions and 11 deletions

View File

@ -28,7 +28,7 @@
<span *ngIf="action == 'timemodified'">{{ entry.timemodified * 1000 | coreFormatDate:"dffulldate" }}</span>
<a *ngIf="action == 'userpicture'" core-user-link [courseId]="database.courseid" [userId]="entry.userid" [title]="entry.fullname">
<img class="avatar-round" [src]="userPicture" [alt]="'core.pictureof' | translate:{$a: user.fullname}" core-external-content onError="this.src='assets/img/user-avatar.png'" role="presentation">
<img class="avatar-round" [src]="userPicture" [alt]="'core.pictureof' | translate:{$a: entry.fullname}" core-external-content onError="this.src='assets/img/user-avatar.png'" role="presentation">
</a>
<a *ngIf="action == 'user'" core-user-link [courseId]="database.courseid" [userId]="entry.userid" [title]="entry.fullname">{{entry.fullname}}</a>
<a *ngIf="action == 'user' && entry" core-user-link [courseId]="database.courseid" [userId]="entry.userid" [title]="entry.fullname">{{entry.fullname}}</a>

View File

@ -253,12 +253,14 @@ export class AddonModDataEditPage {
});
} else {
this.errors = {};
result.fieldnotifications.forEach((fieldNotif) => {
const field = this.fieldsArray.find((field) => field.name == fieldNotif.fieldname);
if (field) {
this.errors[field.id] = fieldNotif.notification;
}
});
if (result.fieldnotifications) {
result.fieldnotifications.forEach((fieldNotif) => {
const field = this.fieldsArray.find((field) => field.name == fieldNotif.fieldname);
if (field) {
this.errors[field.id] = fieldNotif.notification;
}
});
}
this.jsData['errors'] = this.errors;
setTimeout(() => {

View File

@ -62,7 +62,7 @@ export class AddonModDataProvider {
.then((entry) => {
return {
// Return provissional entry Id.
newentryid: entry[1]
newentryid: entry
};
});
};
@ -194,8 +194,9 @@ export class AddonModDataProvider {
});
// App is offline, check required fields.
fields.forEach((field) => {
const notification = this.fieldsDelegate.getFieldsNotifications(field, contentsIndexed[field.id]);
Object.keys(fields).forEach((key) => {
const field = fields[key],
notification = this.fieldsDelegate.getFieldsNotifications(field, contentsIndexed[field.id]);
if (notification) {
notifications.push({
fieldname: field.name,