From e3fc2de3bd7ffd6880e23614181c2d9cc24797e6 Mon Sep 17 00:00:00 2001 From: "Brian J. Geiger" Date: Wed, 5 Dec 2018 16:50:51 -0500 Subject: [PATCH 1/4] Make registration-schemas filter on active=true to be ready for schema endpoint returning inactive schemas --- app/guid-node/registrations/controller.ts | 9 ++++++++- mirage/helpers.ts | 4 ++++ mirage/views/private/utils.ts | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) 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/helpers.ts b/mirage/helpers.ts index 5260968d51..590bc84409 100644 --- a/mirage/helpers.ts +++ b/mirage/helpers.ts @@ -73,3 +73,7 @@ export function draftRegisterNodeMultiple( } return draftRegistrations; } + +export function isTruthy(val: any) { + return ['true', '1'].includes(val.toString().toLowerCase()); +} diff --git a/mirage/views/private/utils.ts b/mirage/views/private/utils.ts index e9e6668fc4..3589bbd188 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 { isTruthy } from 'ember-osf-web/mirage/helpers'; + 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, isTruthy(comparisonValue), operator); } else { throw new Error(`We haven't implemented comparisons with "${operator}" yet.`); } From caab017bbbe0ec59a915fde17e7f2b860310f245 Mon Sep 17 00:00:00 2001 From: "Brian J. Geiger" Date: Thu, 6 Dec 2018 15:19:38 -0500 Subject: [PATCH 2/4] Make my isTruthy more like @aaxelb's --- mirage/helpers.ts | 4 ---- mirage/views/private/utils.ts | 4 ++-- mirage/views/utils.ts | 6 ++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mirage/helpers.ts b/mirage/helpers.ts index 590bc84409..5260968d51 100644 --- a/mirage/helpers.ts +++ b/mirage/helpers.ts @@ -73,7 +73,3 @@ export function draftRegisterNodeMultiple( } return draftRegistrations; } - -export function isTruthy(val: any) { - return ['true', '1'].includes(val.toString().toLowerCase()); -} diff --git a/mirage/views/private/utils.ts b/mirage/views/private/utils.ts index 3589bbd188..bc41c79faa 100644 --- a/mirage/views/private/utils.ts +++ b/mirage/views/private/utils.ts @@ -2,7 +2,7 @@ import { camelize } from '@ember/string'; import { HandlerContext, Request, Schema } from 'ember-cli-mirage'; import { Resource, ResourceCollectionDocument } from 'osf-api'; -import { isTruthy } from 'ember-osf-web/mirage/helpers'; +import { queryParamIsTruthy } from '../utils'; export enum ComparisonOperators { Eq = 'eq', @@ -229,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, isTruthy(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()), + ); +} From abd7a465169a04c7fa731af947ee57bd26c42c8f Mon Sep 17 00:00:00 2001 From: "James C. Davis" Date: Thu, 6 Dec 2018 12:08:43 -0500 Subject: [PATCH 3/4] chore: bump version for 18.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ", From a4f692c8cb0b0930668a01ec082ed2fb820dff8c Mon Sep 17 00:00:00 2001 From: "James C. Davis" Date: Thu, 6 Dec 2018 12:13:12 -0500 Subject: [PATCH 4/4] chore: update changelog for 18.2.1 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) 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: