Skip to content

Commit

Permalink
Add includeHidden param for GET on columns gristlabs#601
Browse files Browse the repository at this point in the history
  • Loading branch information
fflorent authored and Florent F committed Aug 10, 2023
1 parent 6f56582 commit f647f1e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/server/lib/DocApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,9 @@ export class DocWorkerApi {
this._app.get('/api/docs/:docId/tables/:tableId/columns', canView,
withDoc(async (activeDoc, req, res) => {
const tableId = req.params.tableId;
const includeHidden = isAffirmative(req.query.includeHidden);
const columns = await handleSandboxError('', [],
activeDoc.getTableCols(docSessionFromRequest(req), tableId));
activeDoc.getTableCols(docSessionFromRequest(req), tableId, includeHidden));
res.json({columns});
})
);
Expand Down
15 changes: 15 additions & 0 deletions test/server/lib/DocApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,21 @@ function testDocApi() {
);
});

it("GET /docs/{did}/tables/{tid}/columns retrieves hidden columns when includeHidden is set", async function () {
const params = { includeHidden: true };
const resp = await axios.get(
`${serverUrl}/api/docs/${docIds.Timesheets}/tables/Table1/columns`,
{ ...chimpy, params }
);
assert.equal(resp.status, 200);
const columnsMap = new Map(resp.data.columns.map(({id, fields}: {id: string, fields: object}) => [id, fields]));
assert.include([...columnsMap.keys()], "manualSort");
assert.deepInclude(columnsMap.get("manualSort"), {
colRef: 1,
type: 'ManualSortPos',
});
});

it("GET/POST/PATCH /docs/{did}/tables and /columns", async function () {
// POST /tables: Create new tables
let resp = await axios.post(`${serverUrl}/api/docs/${docIds.Timesheets}/tables`, {
Expand Down

0 comments on commit f647f1e

Please sign in to comment.