Skip to content

Commit

Permalink
Merged in r2-3072-click-back-error (pull request #7060)
Browse files Browse the repository at this point in the history
R2-3072 - Clicking back to "cases to assign" list gives error

Approved-by: Joshua Toliver
  • Loading branch information
dhernandez-quoin authored and jtoliver-quoin committed Feb 18, 2025
2 parents b5fe984 + 366242d commit dc10f25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/javascript/components/record-list/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getAppliedFilters = (state, namespace) =>
export const getAppliedFiltersAsQueryString = (state, namespace) => {
const filters = filtersToQueryString(getAppliedFilters(state, namespace));

return new URLSearchParams(filters).toString();
return filters;
};

export const getLoading = (state, namespace) => state.getIn(getNamespacePath(namespace).concat("loading"), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const paramQueryString = (key, value) => {
}, "");
}

return `${key}=${value}`;
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
};

export default filters =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,32 @@ import filtersToQueryString from "./filters-to-query-string";
describe("<RecordList />/utils - filtersToQueryString", () => {
it("returns a query string for the filters object", () => {
expect(filtersToQueryString(fromJS({ record_state: [true], status: ["open"] }))).to.equals(
"record_state[0]=true&status[0]=open"
"record_state%5B0%5D=true&status%5B0%5D=open"
);
});

it("returns a query string with a value for each element in the array of the filter", () => {
expect(filtersToQueryString(fromJS({ status: ["open", "closed"] }))).to.equals("status[0]=open&status[1]=closed");
expect(filtersToQueryString(fromJS({ status: ["open", "closed"] }))).to.equals(
"status%5B0%5D=open&status%5B1%5D=closed"
);
});

it("returns a query string with a value for each element in the map of the filter", () => {
expect(filtersToQueryString(fromJS({ date: { from: "2010-01-05", to: "2010-01-08" } }))).to.equals(
"date[from]=2010-01-05&date[to]=2010-01-08"
"date%5Bfrom%5D=2010-01-05&date%5Bto%5D=2010-01-08"
);
});

it("returns a query string for a hash with a nested list", () => {
expect(filtersToQueryString(fromJS({ not: { last_updated_by: ["user1", "user2"] }, status: ["open"] }))).to.equals(
"not[last_updated_by][0]=user1&not[last_updated_by][1]=user2&status[0]=open"
"not%5Blast_updated_by%5D%5B0%5D=user1&not%5Blast_updated_by%5D%5B1%5D=user2&status%5B0%5D=open"
);
});

it("returns a query string for a list with hashes", () => {
expect(
filtersToQueryString(fromJS({ not: [{ user_name: "user1" }, { user_name: "user2" }], status: ["open"] }))
).to.equals("not[0][user_name]=user1&not[1][user_name]=user2&status[0]=open");
).to.equals("not%5B0%5D%5Buser_name%5D=user1&not%5B1%5D%5Buser_name%5D=user2&status%5B0%5D=open");
});

it("returns a query string for a list with nested lists", () => {
Expand All @@ -45,7 +47,14 @@ describe("<RecordList />/utils - filtersToQueryString", () => {
})
)
).to.equals(
"user_name[0][0]=user1&user_name[0][1]=user2&user_name[1][0]=user3&user_name[1][1]=user4&status[0]=open"
"user_name%5B0%5D%5B0%5D=user1&user_name%5B0%5D%5B1%5D=user2" +
"&user_name%5B1%5D%5B0%5D=user3&user_name%5B1%5D%5B1%5D=user4&status%5B0%5D=open"
);
});

it("returns a query string for a date range with positive time zone", () => {
expect(
filtersToQueryString(fromJS({ created_at: ["1970-01-01T00:00:00+00:00..2025-02-17T20:04:54+00:00"] }))
).to.equals("created_at%5B0%5D=1970-01-01T00%3A00%3A00%2B00%3A00..2025-02-17T20%3A04%3A54%2B00%3A00");
});
});

0 comments on commit dc10f25

Please sign in to comment.