diff --git a/cypress/e2e/table.cy.js b/cypress/e2e/table.cy.js
index af869c6..a308d32 100644
--- a/cypress/e2e/table.cy.js
+++ b/cypress/e2e/table.cy.js
@@ -38,6 +38,45 @@ context("table element", function() {
});
});
+ describe("when element have data-os-results-per-page attribute", () => {
+ beforeEach(() => {
+ cy.visit("/").then(() => {
+ cy.request("/").then((response) => {
+ const body = `
+
+
+
+ `;
+
+ const modifiedHtml = response.body.replace(
+ /[\s\S]*<\/body>/,
+ body,
+ );
+
+ cy.intercept("/", modifiedHtml);
+ });
+ });
+ });
+
+ it("calls response views items endpoint with rows_per_page param", function() {
+ cy.intercept(
+ "GET",
+ "**/api/v1/response_views/view_uuid/items*",
+ {
+ data: [],
+ },
+ ).as("responseViewsItems");
+
+ cy.visit("/");
+
+ cy.wait("@responseViewsItems").then((interceptor) => {
+ expect(interceptor.request.url).to.match(
+ /response_views\/view_uuid\/items\?rows_per_page\=100/,
+ );
+ });
+ });
+ });
+
describe("when response view have items", () => {
it("renders table with data", function() {
cy.intercept(
diff --git a/src/components/table.js b/src/components/table.js
index bec8fa5..76f025b 100644
--- a/src/components/table.js
+++ b/src/components/table.js
@@ -11,6 +11,11 @@ export class OSTable extends HTMLElement {
if (haveLoopAttribute) {
const responseViewUuid = this.getAttribute("data-os-view");
+ const resultsPerPage = this.getAttribute("data-os-results-per-page");
+ let params = '';
+ if (resultsPerPage) {
+ params = `?rows_per_page=${resultsPerPage}`;
+ }
if (responseViewUuid) {
const emptyElement = document.createElement("div");
emptyElement.innerText = "No data found";
@@ -21,7 +26,7 @@ export class OSTable extends HTMLElement {
this.dispatchLoadingEvent(true);
fetch(
- `${requestHost}/api/v1/response_views/${responseViewUuid}/items`,
+ `${requestHost}/api/v1/response_views/${responseViewUuid}/items${params}`,
{
credentials: "include",
headers: {