Skip to content

Commit

Permalink
Merge pull request #825 from digirati-co-uk/feature/NS-61
Browse files Browse the repository at this point in the history
NS-61 Switched to optional POST request for auto-complete to avoid bugs
  • Loading branch information
stephenwf authored Jul 2, 2024
2 parents de876f6 + a8d756a commit 79ee59b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- New button to filter manifest tasks from reviews (NS-66)

### Fixed
- Fixed bug with large projects and adding content (NS-61)
- Fixed bug with filtering out Manifests/Collections when adding content to projects (NS-61)

## [v2.2.5](https://github.com/digirati-co-uk/madoc-platform/compare/v2.2.4...v2.2.5) - 22/05/2024

### Fixed
Expand Down
18 changes: 10 additions & 8 deletions services/madoc-ts/src/gateway/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1210,19 +1210,21 @@ export class ApiClient {

async autocompleteManifests(q: string, project_id?: string, blacklist_ids?: number[], page = 1) {
return this.request<Array<{ id: number; label: string }>>(
`/api/madoc/iiif/autocomplete/manifests?${stringify(
{ q, project_id, blacklist_ids, page },
{ arrayFormat: 'comma' }
)}`
`/api/madoc/iiif/autocomplete/manifests?${stringify({ q, project_id, page }, { arrayFormat: 'comma' })}`,
{
method: 'POST',
body: { blacklist_ids },
}
);
}

async autocompleteCollections(q: string, project_id?: string, blacklist_ids?: number[], page = 1) {
return this.request<Array<{ id: number; label: string }>>(
`/api/madoc/iiif/autocomplete/collections?${stringify(
{ q, project_id, blacklist_ids, page },
{ arrayFormat: 'comma' }
)}`
`/api/madoc/iiif/autocomplete/collections?${stringify({ q, project_id, page }, { arrayFormat: 'comma' })}`,
{
method: 'POST',
body: { blacklist_ids },
}
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ export const getManifestAutocomplete: RouteMiddleware<{}, { blacklist_ids?: numb
.map((blacklistId: string) => Number(blacklistId))
.filter((blacklistId: number) => !Number.isNaN(blacklistId));

if (!q) {
context.response.body = [];
return;
}

if (context.requestBody) {
const postBlacklistIds = context.requestBody.blacklist_ids;
if (postBlacklistIds && Array.isArray(postBlacklistIds)) {
blackListIds.push(...postBlacklistIds);
}
}

if (!q) {
context.response.body = [];
return;
}

const pageSize = 10;
const offset = (page - 1) * pageSize;

Expand Down

0 comments on commit 79ee59b

Please sign in to comment.