Browse Source

fix infinitescroll to work off correct ID

kb/add-usage-guide
Trent Larson 1 year ago
parent
commit
42bf34f549
  1. 25
      src/views/ProjectsView.vue

25
src/views/ProjectsView.vue

@ -117,7 +117,12 @@ import InfiniteScroll from "@/components/InfiniteScroll";
})
export default class ProjectsView extends Vue {
apiServer = "";
projects: { handleId: string; name: string; description: string }[] = [];
projects: {
handleId: string;
name: string;
description: string;
rowid: number;
}[] = [];
current: IIdentifier;
isDataLoaded = false;
@ -126,20 +131,10 @@ export default class ProjectsView extends Vue {
console.log(payload);
if (this.projects.length > 0) {
console.log(this.projects[this.projects.length - 1]);
const afterurl = this.projects[this.projects.length - 1]["handleId"];
const regex = /([0-9A-Z]+)$/; // Regular expression to match one or more digits at the end
const matches = afterurl.match(regex);
let afterId = "";
if (matches && matches.length > 1) {
afterId = matches[1];
console.log(afterId); // Output: 01H3HBVZGH3YE0K27X35S15QT1
} else {
console.log("No digits found at the end of the URL.");
return;
}
const oldestId = this.projects[this.projects.length - 1]["rowid"];
const url =
this.apiServer + "/api/v2/report/plansByIssuer?afterId=" + afterId;
this.apiServer + "/api/v2/report/plansByIssuer?beforeId=" + oldestId;
const token = await accessToken(this.current);
const headers = {
"Content-Type": "application/json",
@ -158,6 +153,7 @@ export default class ProjectsView extends Vue {
// handleId is new in server v release-1.6.0; remove fullIri when that
// version shows up here: https://endorser.ch:3000/api-docs/
handleId: plan.handleId || plan.fullIri,
rowid: plan.rowid,
};
this.projects.push(data);
}
@ -197,6 +193,7 @@ export default class ProjectsView extends Vue {
// handleId is new in server v release-1.6.0; remove fullIri when that
// version shows up here: https://endorser.ch:3000/api-docs/
handleId: plan.handleId || plan.fullIri,
rowid: plan.rowid,
};
this.projects.push(data);
}

Loading…
Cancel
Save