Skip to content

Commit

Permalink
adding the owner automatically as a resource having edit options when…
Browse files Browse the repository at this point in the history
… creating a new estimate. Disabling sharing for owner
  • Loading branch information
ArunaTebel committed Nov 3, 2019
1 parent 0da82ae commit c9033f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/components/ArchestEstimateShareModalComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ class ArchestEstimateShareModalComponent extends Component {
if (this.state.resourceSharingOptions[phaseResource.id]) {
sharedOption = this.state.resourceSharingOptions[phaseResource.id];
}

let disableOptions = false;
if (parseInt(this.props.estimateData.estimateOwner.id, 10) === parseInt(phaseResource.id, 10)) {
disableOptions = true;
sharedOption = 2;
}
return (
<Row key={phaseResource.id} className="archest-estimate-share-modal-resource-row">
<Col sm={10}>{phaseResource.full_name}</Col>
Expand All @@ -109,6 +113,7 @@ class ArchestEstimateShareModalComponent extends Component {
<Form.Group className="archest-estimate-share-modal-resource-row-share-options-group"
controlId="estimateShareForm.shareOptions">
<Form.Control as="select" size="sm" value={sharedOption}
disabled={disableOptions}
onChange={(element) => this.onChangeShareOption(element, phaseResource.id)}>
<option value={0}/>
<option value={1}>View</option>
Expand Down
11 changes: 7 additions & 4 deletions src/components/ArchestPhaseEstimatesComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,18 @@ class ArchestPhaseEstimatesComponent extends Component {
})
}

showShareEstimateModal(estimatedId) {
showShareEstimateModal(estimatedId, estimateOwner) {
this.setState({
shareEstimateModalProps: {
show: true,
estimateId: estimatedId,
estimateOwner: estimateOwner,
onCancel: () => {
this.setState({
shareEstimateModalProps: {
show: false,
estimateId: estimatedId
estimateId: estimatedId,
estimateOwner: estimateOwner,
}
});
}
Expand Down Expand Up @@ -169,7 +171,8 @@ class ArchestPhaseEstimatesComponent extends Component {
show={this.state.shareEstimateModalProps.show}
estimateData={{
phaseId: this.state.phase.id,
estimateId: this.state.shareEstimateModalProps.estimateId
estimateId: this.state.shareEstimateModalProps.estimateId,
estimateOwner: this.state.shareEstimateModalProps.estimateOwner
}}
onCancel={this.state.shareEstimateModalProps.onCancel}
/>
Expand Down Expand Up @@ -239,7 +242,7 @@ class ArchestPhaseEstimatesComponent extends Component {
</Col>
<Col sm={2}>
<OverlayTrigger key="share" placement="top" overlay={<Tooltip>Share</Tooltip>}>
<i onClick={() => this.showShareEstimateModal(estimate.id)}
<i onClick={() => this.showShareEstimateModal(estimate.id, estimate.owner)}
className="material-icons md-18 archest-phase-estimates-icon">folder_shared</i>
</OverlayTrigger>
</Col>
Expand Down

0 comments on commit c9033f0

Please sign in to comment.