diff --git a/src/addon/mod/data/components/action/action.ts b/src/addon/mod/data/components/action/action.ts
index dab8a35d0..32be60ec3 100644
--- a/src/addon/mod/data/components/action/action.ts
+++ b/src/addon/mod/data/components/action/action.ts
@@ -30,6 +30,7 @@ export class AddonModDataActionComponent implements OnInit {
@Input() action: string; // The field to render.
@Input() entry?: any; // The value of the field.
@Input() database: any; // Database object.
+ @Input() offset?: number; // Offset of the entry.
siteId: string;
rootUrl: string;
@@ -67,6 +68,9 @@ export class AddonModDataActionComponent implements OnInit {
switch (this.action) {
case 'more':
this.url = this.rootUrl + '/mod/data/view.php?d= ' + this.entry.dataid + '&rid=' + this.entry.id;
+ if (typeof this.offset == 'number') {
+ this.url += '&mode=single&page=' + this.offset;
+ }
break;
case 'edit':
this.url = this.rootUrl + '/mod/data/edit.php?d= ' + this.entry.dataid + '&rid=' + this.entry.id;
diff --git a/src/addon/mod/data/components/index/index.ts b/src/addon/mod/data/components/index/index.ts
index 9e32c7afb..9da9180fe 100644
--- a/src/addon/mod/data/components/index/index.ts
+++ b/src/addon/mod/data/components/index/index.ts
@@ -47,7 +47,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
timeAvailableToReadable: string | boolean;
isEmpty = false;
groupInfo: CoreGroupInfo;
- entries = {};
+ entries = [];
firstEntry = false;
canAdd = false;
canSearch = false;
@@ -317,6 +317,8 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
});
return Promise.all(promises).then((entries) => {
+ this.entries = entries;
+
let entriesHTML = this.data.listtemplateheader || '';
// Get first entry from the whole list.
@@ -326,12 +328,15 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
const template = this.data.listtemplate || this.dataHelper.getDefaultTemplate('list', this.fieldsArray);
- entries.forEach((entry) => {
- this.entries[entry.id] = entry;
+ const entriesById = {};
+ entries.forEach((entry, index) => {
+ entriesById[entry.id] = entry;
const actions = this.dataHelper.getActions(this.data, this.access, entry);
+ const offset = this.search.page * AddonModDataProvider.PER_PAGE + index;
- entriesHTML += this.dataHelper.displayShowFields(template, this.fieldsArray, entry, 'list', actions);
+ entriesHTML += this.dataHelper.displayShowFields(template, this.fieldsArray, entry, offset, 'list',
+ actions);
});
entriesHTML += this.data.listtemplatefooter || '';
@@ -340,7 +345,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
// Pass the input data to the component.
this.jsData = {
fields: this.fields,
- entries: this.entries,
+ entries: entriesById,
data: this.data,
gotoEntry: this.gotoEntry.bind(this)
};
@@ -440,9 +445,16 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
module: this.module,
courseId: this.courseId,
entryId: entryId,
- group: this.selectedGroup
+ group: this.selectedGroup,
+ offset: null
};
+ // Try to find page number and offset of the entry.
+ const pageXOffset = this.entries.findIndex((entry) => entry.id == entryId);
+ if (pageXOffset >= 0) {
+ params.offset = this.search.page * AddonModDataProvider.PER_PAGE + pageXOffset;
+ }
+
this.navCtrl.push('AddonModDataEntryPage', params);
}
diff --git a/src/addon/mod/data/pages/entry/entry.html b/src/addon/mod/data/pages/entry/entry.html
index c1d727795..a49acdf57 100644
--- a/src/addon/mod/data/pages/entry/entry.html
+++ b/src/addon/mod/data/pages/entry/entry.html
@@ -34,16 +34,16 @@
-
+
-
-