Skip to content

Commit

Permalink
Merge branch 'hotfix/18.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescdavis committed Dec 18, 2018
2 parents 86e7343 + a4f692c commit dedd31a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [18.2.1] - 2018-12-06
### Added
- Mirage:
- `queryParamIsTruthy` util

### Changed
- Routes:
- `guid-node.registrations` - add `?filter[active]=true` when fetching registration schemas
- Mirage:
- use `queryParamIsTruthy` helper for boolean comparison

## [18.2.0] - 2018-11-29
### Changed
- Components:
Expand Down
9 changes: 8 additions & 1 deletion app/guid-node/registrations/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ export default class GuidNodeRegistrations extends Controller {
};

getRegistrationSchemas = task(function *(this: GuidNodeRegistrations) {
let schemas = yield this.store.findAll('registration-schema');
let schemas = yield this.store.findAll('registration-schema',
{
adapterOptions: {
query: {
'filter[active]': true,
},
},
});
schemas = schemas.toArray();
schemas.sort((a: RegistrationSchema, b: RegistrationSchema) => {
return a.name.length - b.name.length;
Expand Down
4 changes: 3 additions & 1 deletion mirage/views/private/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { camelize } from '@ember/string';
import { HandlerContext, Request, Schema } from 'ember-cli-mirage';
import { Resource, ResourceCollectionDocument } from 'osf-api';

import { queryParamIsTruthy } from '../utils';

export enum ComparisonOperators {
Eq = 'eq',
Ne = 'ne',
Expand Down Expand Up @@ -227,7 +229,7 @@ export function compare(actualValue: any, comparisonValue: any, operator: Compar
if (typeof actualValue === 'string') {
return compareStrings(actualValue, comparisonValue, operator);
} else if (typeof actualValue === 'boolean') {
return compareBooleans(actualValue, comparisonValue, operator);
return compareBooleans(actualValue, queryParamIsTruthy(comparisonValue), operator);
} else {
throw new Error(`We haven't implemented comparisons with "${operator}" yet.`);
}
Expand Down
6 changes: 6 additions & 0 deletions mirage/views/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ export function filter(model: any, request: any) {
}
});
}

export function queryParamIsTruthy(value?: string) {
return Boolean(
value && ['true', '1'].includes(value.toString().toLowerCase()),
);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-osf-web",
"version": "18.2.0",
"version": "18.2.1",
"description": "Ember front-end for the Open Science Framework",
"license": "Apache-2.0",
"author": "Center for Open Science <support@cos.io>",
Expand Down

0 comments on commit dedd31a

Please sign in to comment.