forked from HospitalRun/hospitalrun-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat-HospitalRun#1969' of https://github.com/akshay-ap/…
…hospitalrun-frontend into feat-HospitalRun#1969
- Loading branch information
Showing
9 changed files
with
202 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
import { incidents } from '../../config/pouchdb' | ||
import IncidentFilter from '../../incidents/IncidentFilter' | ||
import Incident from '../../model/Incident' | ||
import Repository from './Repository' | ||
|
||
interface SearchOptions { | ||
status: IncidentFilter | ||
} | ||
class IncidentRepository extends Repository<Incident> { | ||
constructor() { | ||
super(incidents) | ||
} | ||
|
||
async search(options: SearchOptions): Promise<Incident[]> { | ||
return super.search(IncidentRepository.getSearchCriteria(options)) | ||
} | ||
|
||
private static getSearchCriteria(options: SearchOptions): any { | ||
const statusFilter = options.status !== IncidentFilter.all ? [{ status: options.status }] : [] | ||
const selector = { | ||
$and: statusFilter, | ||
} | ||
return { | ||
selector, | ||
} | ||
} | ||
} | ||
|
||
export default new IncidentRepository() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enum IncidentFilter { | ||
reported = 'reported', | ||
all = 'all', | ||
} | ||
|
||
export default IncidentFilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.