Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
Merge c9e8726 into abb2092
Browse files Browse the repository at this point in the history
  • Loading branch information
adelevie committed Mar 15, 2017
2 parents abb2092 + c9e8726 commit 5e170c8
Show file tree
Hide file tree
Showing 60 changed files with 1,011 additions and 590 deletions.
9 changes: 9 additions & 0 deletions bin/deploy-local-branch.sh
@@ -0,0 +1,9 @@
#! /bin/bash

cp .env.test .env

docker-compose build

./bin/predeploy.sh

./bin/deploy.sh staging
5 changes: 5 additions & 0 deletions bin/deploy.sh
Expand Up @@ -21,6 +21,11 @@ elif [ $SPACE = 'staging' ]; then
API_MANIFEST="manifest-api-staging.yml"
FRONTEND_NAME="eqip-prototype-staging"
FRONTEND_MANIFEST="manifest-frontend-staging.yml"
elif [ $SPACE = 'dev' ]; then
API_NAME="eqip-prototype-api-dev"
API_MANIFEST="manifest-api-dev.yml"
FRONTEND_NAME="eqip-prototype-dev"
FRONTEND_MANIFEST="manifest-frontend-dev.yml"
else
echo "Unknown space: $SPACE"
exit
Expand Down
15 changes: 15 additions & 0 deletions manifest-api-dev.yml
@@ -0,0 +1,15 @@
---
applications:
- name: eqip-prototype-api-dev
memory: 64M
instances: 2
domain: fr.cloud.gov
host: eqip-prototype-api-dev
buildpack: https://github.com/cloudfoundry/go-buildpack
path: api
command: ./api
services:
- eqip-postgres
env:
GOVERSION: go1.7.5
ALLOW_2FA_RESET: 1
2 changes: 1 addition & 1 deletion manifest-api-staging.yml
@@ -1,7 +1,7 @@
---
applications:
- name: eqip-prototype-api-staging
memory: 1G
memory: 64M
instances: 2
domain: fr.cloud.gov
host: eqip-prototype-api-staging
Expand Down
2 changes: 1 addition & 1 deletion manifest-api.yml
@@ -1,7 +1,7 @@
---
applications:
- name: eqip-prototype-api
memory: 1G
memory: 64M
instances: 2
domain: fr.cloud.gov
host: eqip-prototype-api
Expand Down
10 changes: 10 additions & 0 deletions manifest-frontend-dev.yml
@@ -0,0 +1,10 @@
---
applications:
- name: eqip-prototype-dev
path: dist
memory: 64M
domain: fr.cloud.gov
host: eqip-prototype-dev
buildpack: https://github.com/cloudfoundry/staticfile-buildpack.git
env:
FORCE_HTTPS: true
4 changes: 4 additions & 0 deletions src/components/Form/Branch/Branch.scss
Expand Up @@ -5,5 +5,9 @@
p {
padding: 0 !important;
}

ul {
margin-left: 4.6rem;
}
}
}
82 changes: 50 additions & 32 deletions src/components/Form/BranchCollection/BranchCollection.jsx
Expand Up @@ -6,8 +6,13 @@ export default class BranchCollection extends React.Component {
constructor (props) {
super(props)

let indices = []
for (let i = 0; i < this.props.items.length; i++) {
indices.push(newGuid())
}

this.state = {
indices: []
indices: indices
}

this.content = this.content.bind(this)
Expand Down Expand Up @@ -105,7 +110,7 @@ export default class BranchCollection extends React.Component {
help={this.props.branchHelp}
onValidate={this.props.onValidate}
{...props}
>
>
{this.props.branch}
</Branch>
)
Expand All @@ -115,9 +120,13 @@ export default class BranchCollection extends React.Component {
// When no items are present, render default branch yes/no
if (this.props.items.length === 0) {
return (
this.branch({
onUpdate: this.onDefaultBranchClick.bind(this)
})
<div key={this.state.indices[0]}>
{
this.branch({
onUpdate: this.onDefaultBranchClick.bind(this)
})
}
</div>
)
}

Expand All @@ -126,43 +135,52 @@ export default class BranchCollection extends React.Component {
if (this.props.items.length === 1 && this.props.items[0][this.props.valueKey] === 'No') {
var item = this.props.items[0]
return (
this.branch({
value: 'No',
onUpdate: this.onBranchClick.bind(this, item, 0)
})
<div key={this.state.indices[0]}>
{
this.branch({
value: 'No',
onUpdate: this.onBranchClick.bind(this, item, 0)
})
}
</div>
)
}

// When more than 1 item is in
let rows = this.props.items.map((item, index) => {
const top = (index, item) => {
return this.branch({
value: item[this.props.valueKey],
onUpdate: this.onBranchClick.bind(this, item, index)
})
}

// Render the branch question at the very end
const bottom = (index, item) => {
return this.props.items.length - 1 === index
? this.branch({
className: 'last-branch',
onUpdate: this.onLastBranchClick.bind(this)
})
: null
}

const kiddos = (index, item) => {
return item[this.props.valueKey] && item[this.props.valueKey] === 'Yes'
? this.recursiveCloneChildren(this.props.children, item, index)
: null
}

const rows = this.props.items.map((item, index) => {
return (
<div key={this.state.indices[index]}>
{
this.branch({
value: item[this.props.valueKey],
onUpdate: this.onBranchClick.bind(this, item, index)
})
}
<div>
{item[this.props.valueKey] && item[this.props.valueKey] === 'Yes' && this.recursiveCloneChildren(this.props.children, item, index)}
</div>
{
// Render the branch question at the very end
this.props.items.length - 1 === index &&
this.branch({
className: 'last-branch',
onUpdate: this.onLastBranchClick.bind(this)
})
}
{ top(index, item) }
<div>{ kiddos(index, item) }</div>
{ bottom(index, item) }
</div>
)
})

return (
<div>
{rows}
</div>
)
return (<div>{rows}</div>)
}

render () {
Expand Down
Expand Up @@ -8,7 +8,6 @@ describe('The BranchCollection component', () => {

it('renders yes/no and branch contents', () => {
const component = mount(<BranchCollection branch={hello} />)

expect(component.find({type: 'radio', value: 'Yes'}).length).toBe(1)
expect(component.find({type: 'radio', value: 'No'}).length).toBe(1)
expect(component.find('div#summary').text()).toBe('Hola')
Expand Down
8 changes: 8 additions & 0 deletions src/components/Form/Checkbox/Checkbox.jsx
Expand Up @@ -154,3 +154,11 @@ export default class Checkbox extends ValidationElement {
)
}
}

Checkbox.defaultProps = {
name: 'checkbox_input',
checked: false,
focus: false,
error: false,
valid: false
}
59 changes: 32 additions & 27 deletions src/components/Form/Collection/Collection.jsx
Expand Up @@ -8,43 +8,41 @@ export default class Collection extends ValidationElement {
constructor (props) {
super(props)

let min = this.props.minimum || 0
let indices = []
for (let i = 0; i < this.props.items.length; i++) {
indices.push(super.guid())
}
const factoryOfThings = this.factory(this.props.minimum, this.props.items, indices)

this.state = {
id: super.guid(),
minimum: min,
length: min,
items: this.props.items || [],
indices: [],
children: []
minimum: this.props.minimum,
length: this.props.minimum,
items: factoryOfThings.items,
indices: factoryOfThings.indices,
children: factoryOfThings.children
}

this.append = this.append.bind(this)
this.toggle = this.toggle.bind(this)
this.onUpdate = this.onUpdate.bind(this)
}

/**
* Upon the first mounting we need to ensure the minimum number of items
* are present in the collection.
*/
componentDidMount () {
const f = this.factory(this.state.minimum, this.state.items)
this.setState({items: f.items, children: f.children})
}

/**
* Factory to generate the initial amount of items in the collection
*/
factory (min, localItems) {
factory (min, localItems, localIndices) {
let items = []
let children = []
let indices = []

localItems.forEach((item, index) => {
items.push({
...item,
open: false
})
children.push(this.createChildren(item, index))
indices.push(localIndices[index])
})

for (let index = children.length; index < min; index++) {
Expand All @@ -53,11 +51,13 @@ export default class Collection extends ValidationElement {
// go ary.
items.push({open: false})
children.push(this.createChildren(null, index))
indices.push(super.guid())
}

return {
items: items,
children: children
children: children,
indices: indices
}
}

Expand Down Expand Up @@ -85,12 +85,12 @@ export default class Collection extends ValidationElement {
// we are modifying this behavior.
items.push({open: false})

let children = [...this.state.children]
children = this.factory(items.length, items).children

let indices = [...this.state.indices]
indices.push(super.guid())

let children = [...this.state.children]
children = this.factory(items.length, items, indices).children

this.setState({ items: items, children: children, indices: indices }, () => {
this.dispatcher(this.state.items)
this.scroll()
Expand All @@ -104,12 +104,12 @@ export default class Collection extends ValidationElement {
let items = [...this.state.items]
items.splice(index, 1)

let children = [...this.state.children]
children = this.factory(items.length, items).children

let indices = [...this.state.indices]
indices.splice(index, 1)

let children = [...this.state.children]
children = this.factory(items.length, items, indices).children

this.setState({ items: items, children: children, indices: indices }, () => {
this.dispatcher(this.state.items)
this.scroll()
Expand Down Expand Up @@ -303,10 +303,10 @@ export default class Collection extends ValidationElement {
<div className="summary">
<Show when={index === 0}>
<div className="caption gutters">
<div className="title">
<h4>{this.props.summaryTitle || i18n.t('collection.summary')}</h4>
<hr />
</div>
<div className="title">
<h4>{this.props.summaryTitle || i18n.t('collection.summary')}</h4>
<hr />
</div>
</div>
</Show>
<div className={`row gutters ${klassOpen} ${klassLast}`.trim()}>
Expand Down Expand Up @@ -368,3 +368,8 @@ export default class Collection extends ValidationElement {
)
}
}

Collection.defaultProps = {
minimum: 0,
items: []
}

0 comments on commit 5e170c8

Please sign in to comment.