diff --git a/CHANGELOG.md b/CHANGELOG.md index 50e52b2072..f32252f295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/app/guid-node/registrations/controller.ts b/app/guid-node/registrations/controller.ts index fd2b7cdc76..b3bc3a9c5b 100644 --- a/app/guid-node/registrations/controller.ts +++ b/app/guid-node/registrations/controller.ts @@ -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; diff --git a/mirage/views/private/utils.ts b/mirage/views/private/utils.ts index e9e6668fc4..bc41c79faa 100644 --- a/mirage/views/private/utils.ts +++ b/mirage/views/private/utils.ts @@ -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', @@ -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.`); } diff --git a/mirage/views/utils.ts b/mirage/views/utils.ts index 7c2f58a2b1..c3fda543f6 100644 --- a/mirage/views/utils.ts +++ b/mirage/views/utils.ts @@ -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()), + ); +} diff --git a/package.json b/package.json index e7e5d1e304..2c212b9328 100644 --- a/package.json +++ b/package.json @@ -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 ",