diff --git a/src/components/ArchestEstimateActivityComponent.js b/src/components/ArchestEstimateActivityComponent.js index cea4521..297a84a 100644 --- a/src/components/ArchestEstimateActivityComponent.js +++ b/src/components/ArchestEstimateActivityComponent.js @@ -16,6 +16,7 @@ class ArchestEstimateActivityComponent extends Component { featureId: this.props.activity.feature.id, activityStatus: this.props.activity.status, activityName: this.props.activity.name, + ownerId: this.props.activity.owner ? this.props.activity.owner.id : '', activityEstimatedTime: this.props.activity.estimated_time, subActivityTotalHours: 0, savingData: false, @@ -37,6 +38,7 @@ class ArchestEstimateActivityComponent extends Component { ArchestHttp.PATCH(BACKEND_ESTIMATOR_API_URL + "/activities/" + this.state.activityId + "/", { name: this.state.activityName, feature_id: this.state.featureId, + owner_id: this.state.ownerId, estimated_time: this.state.activityEstimatedTime, status: this.state.activityStatus, }).then(function (response) { @@ -107,7 +109,8 @@ class ArchestEstimateActivityComponent extends Component { render() { const activityId = this.props.activity.id; - let featureOptions; + let featureOptions = []; + let resourcesOptions = []; if (this.props.features) { featureOptions = this.props.features.map( @@ -115,6 +118,15 @@ class ArchestEstimateActivityComponent extends Component { ); } + if (this.props.estimateResources) { + resourcesOptions = this.props.estimateResources.map( + (estimateResource) => + ); + } + + resourcesOptions.unshift(); + return ( @@ -183,9 +195,12 @@ class ArchestEstimateActivityComponent extends Component { - + Activity + + Owner + Hrs. @@ -193,7 +208,7 @@ class ArchestEstimateActivityComponent extends Component { - + + + + + + {resourcesOptions} + + + + @@ -237,6 +269,7 @@ class ArchestEstimateActivityComponent extends Component { subActivities={this.props.activity.sub_activities} subActivityChangeHandler={this.subActivityChangeHandler} subActivityTotalHours={this.state.subActivityTotalHours} + estimateResources={this.props.estimateResources} /> diff --git a/src/components/ArchestEstimateEditComponent.js b/src/components/ArchestEstimateEditComponent.js index 1cdb4e9..e6eb26b 100644 --- a/src/components/ArchestEstimateEditComponent.js +++ b/src/components/ArchestEstimateEditComponent.js @@ -20,6 +20,7 @@ class ArchestEstimateEditComponent extends Component { redirectTo: false, estimate: {}, estimateDetails: {}, + estimateResources: [], estimateTableData: [], breadcrumbs: [] }; @@ -34,36 +35,43 @@ class ArchestEstimateEditComponent extends Component { let estimateId = this.props.match.params.estimateId; - ArchestHttp.GET(BACKEND_ESTIMATOR_API_URL + '/estimates/' + estimateId + '/detailed_view/', {}) - .then(function (response) { - - component.setState({ - estimateDetails: response.data.results, - dataLoaded: true - }); - }) - .catch(function (error) { - console.log(error); - }); - - ArchestHttp.GET(BACKEND_ESTIMATOR_API_URL + '/estimates/' + estimateId + '/', {}) - .then(function (response) { - let estimate = response.data; - component.setState({ - estimate: estimate, - breadcrumbs: [ - {title: 'Home', url: '/'}, - { - title: estimate.phase.name + ' - Estimates', - url: `/phase/${estimate.phase.id}/estimates/` - }, - {title: estimate.name, url: '#', active: true}, - ] - }); - }) - .catch(function (error) { - console.log(error); + let requestConfigs = [ + { + name: 'estimateDetailedView', + url: `${BACKEND_ESTIMATOR_API_URL}/estimates/${estimateId}/detailed_view/`, + params: {} + }, + { + name: 'estimate', + url: `${BACKEND_ESTIMATOR_API_URL}/estimates/${estimateId}/`, + params: {} + }, + { + name: 'estimateResources', + url: `${BACKEND_ESTIMATOR_API_URL}/estimates/${estimateId}/shared_resources/`, + params: {} + }, + ]; + + ArchestHttp.BATCH_GET(requestConfigs, (responses) => { + + let estimate = responses.estimate.data; + + component.setState({ + estimateDetails: responses.estimateDetailedView.data.results, + dataLoaded: true, + estimateResources: responses.estimateResources.data.results, + estimate: estimate, + breadcrumbs: [ + {title: 'Home', url: '/'}, + { + title: estimate.phase.name + ' - Estimates', + url: `/phase/${estimate.phase.id}/estimates/` + }, + {title: estimate.name, url: '#', active: true}, + ] }); + }); } @@ -109,6 +117,7 @@ class ArchestEstimateEditComponent extends Component { key={activity.id} activity={activity} features={this.state.estimate.features} + estimateResources={this.state.estimateResources} removeActivityItemHandler={this.removeActivityItem} /> ); diff --git a/src/components/ArchestEstimateSubActivitiesComponent.js b/src/components/ArchestEstimateSubActivitiesComponent.js index 1b05008..4004772 100644 --- a/src/components/ArchestEstimateSubActivitiesComponent.js +++ b/src/components/ArchestEstimateSubActivitiesComponent.js @@ -78,6 +78,7 @@ class ArchestEstimateSubActivitiesComponent extends Component { removeSubActivityItemHandler={this.removeSubActivityItem} saveSubActivityItemCallback={this.saveSubActivityItemCallback} subActivityChangeHandler={this.subActivityChangeHandler} + estimateResources={this.props.estimateResources} /> ); diff --git a/src/components/ArchestEstimateSubActivityItemComponent.js b/src/components/ArchestEstimateSubActivityItemComponent.js index 4f564c7..9d4b0ee 100644 --- a/src/components/ArchestEstimateSubActivityItemComponent.js +++ b/src/components/ArchestEstimateSubActivityItemComponent.js @@ -10,6 +10,7 @@ class ArchestEstimateSubActivityItemComponent extends Component { this.state = { parentActivityId: this.props.subActivity.parent_id, subActivityId: this.props.subActivity.id, + ownerId: this.props.subActivity.owner ? this.props.subActivity.owner.id : '', subActivityName: this.props.subActivity.name, subActivityEstimatedTime: this.props.subActivity.estimated_time, }; @@ -25,6 +26,7 @@ class ArchestEstimateSubActivityItemComponent extends Component { this.props.saveSubActivityItemCallback(this.state.subActivityId, { name: this.state.subActivityName, estimated_time: this.state.subActivityEstimatedTime, + owner_id: this.state.ownerId }); } @@ -67,6 +69,17 @@ class ArchestEstimateSubActivityItemComponent extends Component { render() { + let resourcesOptions = []; + + if (this.props.estimateResources) { + resourcesOptions = this.props.estimateResources.map( + (estimateResource) => + ); + } + + resourcesOptions.unshift(); + return ( @@ -83,7 +96,7 @@ class ArchestEstimateSubActivityItemComponent extends Component { - + + + + + + {resourcesOptions} + + + +