forked from bcgov/range-web
-
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.
- Loading branch information
Kyubinhan
committed
Nov 22, 2018
1 parent
e8911b5
commit 0ce7879
Showing
5 changed files
with
280 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classnames from 'classnames'; | ||
import { Icon } from 'semantic-ui-react'; | ||
import { TextField } from '../../common'; | ||
import { | ||
ALLOWABLE_AUMS, PRIVATE_LAND_DEDUCTION, GRACE_DAYS, | ||
PASTURE_NOTES, | ||
} from '../../../constants/strings'; | ||
|
||
class PastureBox extends Component { | ||
static propTypes = { | ||
pasture: PropTypes.shape({}).isRequired, | ||
pastureIndex: PropTypes.number.isRequired, | ||
activePastureIndex: PropTypes.number.isRequired, | ||
onPastureClicked: PropTypes.func.isRequired, | ||
} | ||
|
||
render() { | ||
const { | ||
pasture, | ||
pastureIndex, | ||
activePastureIndex, | ||
onPastureClicked, | ||
} = this.props; | ||
|
||
const { | ||
id, | ||
name, | ||
allowableAum, | ||
pldPercent, | ||
graceDays, | ||
notes, | ||
} = pasture; | ||
|
||
const pld = pldPercent && Math.floor(pldPercent * 100); | ||
const isActive = activePastureIndex === pastureIndex; | ||
|
||
return ( | ||
<li key={id} className="rup__pasture"> | ||
<div className="rup__pasture__header"> | ||
<button | ||
className="rup__pasture__header__title" | ||
onClick={onPastureClicked(pastureIndex)} | ||
> | ||
<div> | ||
{`Pasture: ${name}`} | ||
</div> | ||
<div className="rup__pasture__header__right"> | ||
{ isActive | ||
? <Icon style={{ marginLeft: '10px' }} name="chevron up" /> | ||
: <Icon style={{ marginLeft: '10px' }} name="chevron down" /> | ||
} | ||
</div> | ||
</button> | ||
</div> | ||
|
||
<div className={classnames('rup__pasture__content', { 'rup__pasture__content__hidden': !isActive })}> | ||
<div className="rup__row"> | ||
<div className="rup__cell-4"> | ||
<TextField | ||
label={ALLOWABLE_AUMS} | ||
text={allowableAum} | ||
/> | ||
</div> | ||
<div className="rup__cell-4"> | ||
<TextField | ||
label={PRIVATE_LAND_DEDUCTION} | ||
text={pld} | ||
/> | ||
</div> | ||
<div className="rup__cell-4"> | ||
<TextField | ||
label={GRACE_DAYS} | ||
text={graceDays} | ||
/> | ||
</div> | ||
</div> | ||
<TextField | ||
label={PASTURE_NOTES} | ||
text={notes} | ||
/> | ||
</div> | ||
</li> | ||
); | ||
} | ||
} | ||
|
||
export default PastureBox; |
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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
// import { Icon, Dropdown } from 'semantic-ui-react'; | ||
import { TextField } from '../../common'; | ||
import { | ||
ALLOWABLE_AUMS, PRIVATE_LAND_DEDUCTION, GRACE_DAYS, | ||
PASTURE_NOTES, NOT_PROVIDED, | ||
} from '../../../constants/strings'; | ||
|
||
class Pastures extends Component { | ||
static propTypes = { | ||
elementId: PropTypes.string.isRequired, | ||
plan: PropTypes.shape({}).isRequired, | ||
pasturesMap: PropTypes.shape({}).isRequired, | ||
className: PropTypes.string.isRequired, | ||
}; | ||
|
||
renderPasture = (pasture) => { | ||
// const options = [ | ||
// { | ||
// key: 'edit', | ||
// text: 'Edit', | ||
// icon: 'edit', | ||
// onClick: () => console.log('edit'), | ||
// }, | ||
// { | ||
// key: 'delete', | ||
// text: 'Delete', | ||
// icon: 'delete', | ||
// onClick: () => console.log('delete'), | ||
// }, | ||
// ]; | ||
const { | ||
id, | ||
name, | ||
allowableAum, | ||
pldPercent, | ||
graceDays, | ||
notes, | ||
} = pasture || {}; | ||
const pld = pldPercent && Math.floor(pldPercent * 100); | ||
|
||
return ( | ||
<div className="rup__pasture" key={id}> | ||
<div className="rup__pasture__header"> | ||
<div> | ||
{`Pasture: ${name}`} | ||
</div> | ||
{/* <Dropdown | ||
trigger={<Icon name="ellipsis vertical" />} | ||
options={options} | ||
icon={null} | ||
pointing="top right" | ||
/> */} | ||
</div> | ||
<div className="rup__row"> | ||
<div className="rup__cell-4"> | ||
<TextField | ||
label={ALLOWABLE_AUMS} | ||
text={allowableAum} | ||
/> | ||
</div> | ||
<div className="rup__cell-4"> | ||
<TextField | ||
label={PRIVATE_LAND_DEDUCTION} | ||
text={pld} | ||
/> | ||
</div> | ||
<div className="rup__cell-4"> | ||
<TextField | ||
label={GRACE_DAYS} | ||
text={graceDays} | ||
/> | ||
</div> | ||
</div> | ||
<TextField | ||
label={PASTURE_NOTES} | ||
text={notes} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
renderPastures = (pastures = []) => ( | ||
<div className="rup__pastures"> | ||
{ | ||
pastures.length === 0 ? ( | ||
<div className="rup__section-not-found">{NOT_PROVIDED}</div> | ||
) : ( | ||
pastures.map(this.renderPasture) | ||
) | ||
} | ||
</div> | ||
) | ||
|
||
render() { | ||
const { elementId, plan, pasturesMap, className } = this.props; | ||
const pastureIds = plan && plan.pastures; | ||
const pastures = pastureIds && pastureIds.map(id => pasturesMap[id]); | ||
|
||
return ( | ||
<div id={elementId} className={className}> | ||
<div className="rup__content-title">Pastures</div> | ||
<div className="rup__divider" /> | ||
{this.renderPastures(pastures)} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Pastures; |
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.