Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed the below features #3

Merged
merged 12 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/components/ArchestActivityStatusChangeWidgetComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, {Component} from "react";
import {BACKEND_ESTIMATOR_API_URL, SUB_ACTIVITY} from "../constants";
import ArchestHttp from "../modules/archest_http";
import {Form} from "react-bootstrap";
import './styles/ArchestActivityStatusChangeWidgetComponent.scss';

const _ = require('lodash');

class ArchestActivityStatusChangeWidgetComponent extends Component {

constructor(props) {
super(props);
this.state = {
activity: this.props.activity
};
this.onChangeStatus = this.onChangeStatus.bind(this);
}

onChangeStatus(element) {

let urlActivityType = 'activities';
if (this.props.type === SUB_ACTIVITY) {
urlActivityType = 'sub_activities';
}

ArchestHttp.PATCH(`${BACKEND_ESTIMATOR_API_URL}/${urlActivityType}/${this.props.activity.id}/`, {
status: element.target.value,
}).then((response) => {
this.setState({
activity: response.data
});
}).catch((error) => {
console.log(error);
});
}

render() {
return (
<Form className="archest-activity-completion-widget-form">
<Form.Group className="archest-activity-completion-widget-form-group"
controlId="activityCompletionWidgetForm.completeOptions">
<Form.Control as="select" size="sm" value={this.state.activity.status}
onChange={this.onChangeStatus}>
<option value={''}/>
<option value={1}>Backlog</option>
<option value={2}>In Progress</option>
<option value={3}>Completed</option>
<option value={4}>On Hold</option>
</Form.Control>
</Form.Group>
</Form>
);
}

}

export default ArchestActivityStatusChangeWidgetComponent;
2 changes: 1 addition & 1 deletion src/components/ArchestCalendarComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ReactDOM from 'react-dom';
import React, {Component} from "react";
import ArchestAuthEnabledComponent from "./ArchestAuthEnabledComponent";
import ArchestMainContainerComponent from "./ArchestMainContainerComponent";
import './styles/ArchestTimeline.scss';
import './styles/ArchestTimelineComponent.scss';
import FullCalendar from '@fullcalendar/react';
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from "@fullcalendar/interaction";
Expand Down
53 changes: 49 additions & 4 deletions src/components/ArchestEstimateActivityComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -107,14 +109,31 @@ 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(
(feature) => <option value={feature.id} key={feature.id}>{feature.name}</option>
);
}

if (this.props.estimateResources) {
resourcesOptions = this.props.estimateResources.map(
(estimateResource) => <option value={estimateResource.resource.id}
key={estimateResource.resource.id}>{estimateResource.resource.full_name}</option>
);
}

if (this.state.ownerId !== '') {
let estimateResources = this.props.estimateResources.map((estimateResource) => parseInt(estimateResource.resource.id, 10));
if (estimateResources.indexOf(parseInt(this.state.ownerId, 10)) === -1) {
resourcesOptions.unshift(<option value={this.state.ownerId} key={this.state.ownerId}>{this.props.activity.owner.full_name}</option>);
}
}

resourcesOptions.unshift(<option value={''} key={''}>{''}</option>);

return (
<Row className="archest-card-container-row">
<Modal show={this.state.showDeleteActivityModal} onHide={this.hideDeleteActivityModal}>
Expand Down Expand Up @@ -155,6 +174,7 @@ class ArchestEstimateActivityComponent extends Component {
size="sm"
as="select"
value={this.state.featureId}
disabled={!this.props.activity.is_editable}
name="featureId"
onChange={this.handleActivityFormFieldChange}
onBlur={this.saveActivityData}>
Expand All @@ -167,7 +187,7 @@ class ArchestEstimateActivityComponent extends Component {
<Col lg="1">
<Row>
<Col lg="1">
<Dropdown>
<Dropdown hidden={!this.props.activity.is_editable}>
<Dropdown.Toggle variant="link"
className="archest-activity-settings-dropdown"
size="sm">
Expand All @@ -183,29 +203,51 @@ class ArchestEstimateActivityComponent extends Component {
</Col>
</Row>
<Row>
<Col lg={11}>
<Col lg={9}>
<Form.Label>Activity</Form.Label>
</Col>
<Col lg={2}>
<Form.Label id="archest-activity-owner-label">Owner</Form.Label>
</Col>
<Col lg={1}>
<Form.Label className="archest-activity-estimated-time-label">
Hrs.
</Form.Label>
</Col>
</Row>
<Row>
<Col lg={11}>
<Col lg={9}>
<Form.Group controlId={'activityForm.ActivityName_' + this.state.activityId}
className="archest-activity-name-form-group">
<Form.Control as="textarea"
rows="1"
placeholder="Activity Name"
size="sm"
disabled={!this.props.activity.is_editable}
value={this.state.activityName}
name="activityName"
onChange={this.handleActivityFormFieldChange}
onBlur={this.saveActivityData}/>
</Form.Group>
</Col>
<Col lg={2}>
<Form.Group as={Row}
controlId={'activityForm.ActivityOwnerId_' + this.state.ownerId}
className="archest-activity-owner-name-form-group">
<Col>
<Form.Control
size="sm"
as="select"
value={this.state.ownerId}
disabled={!this.props.activity.is_editable}
name="ownerId"
onChange={this.handleActivityFormFieldChange}
onBlur={this.saveActivityData}>
{resourcesOptions}
</Form.Control>
</Col>
</Form.Group>
</Col>

<Col lg={1}>
<Row>
Expand All @@ -216,6 +258,7 @@ class ArchestEstimateActivityComponent extends Component {
placeholder="Hrs."
size="sm"
value={this.state.activityEstimatedTime}
disabled={!this.props.activity.is_editable}
name="activityEstimatedTime"
onChange={this.handleActivityFormFieldChange}
onBlur={this.saveActivityData}/>
Expand All @@ -224,6 +267,7 @@ class ArchestEstimateActivityComponent extends Component {
overlay={<Tooltip>Auto calculate from Sub Activity
Hours</Tooltip>}>
<i className="material-icons archest-activity-estimated-time-sync-icon"
hidden={!this.props.activity.is_editable}
onClick={this.syncActivityHoursBySubActivityHours}
>
sync
Expand All @@ -237,6 +281,7 @@ class ArchestEstimateActivityComponent extends Component {
subActivities={this.props.activity.sub_activities}
subActivityChangeHandler={this.subActivityChangeHandler}
subActivityTotalHours={this.state.subActivityTotalHours}
estimateResources={this.props.estimateResources}
/>
</Form>
</Card.Body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {BACKEND_ESTIMATOR_API_URL} from "../constants";
import ArchestHttp from "../modules/archest_http";
import ArchestMainContainerComponent from "./ArchestMainContainerComponent";
import ArchestEstimateActivityComponent from "./ArchestEstimateActivityComponent";
import './styles/ArchestEditEstimate.scss';
import './styles/ArchestEstimateEditComponent.scss';
import autosize from 'autosize';

const _ = require('lodash');

class EstimateEditComponent extends Component {
class ArchestEstimateEditComponent extends Component {

constructor(props) {
super(props);
Expand All @@ -20,6 +20,7 @@ class EstimateEditComponent extends Component {
redirectTo: false,
estimate: {},
estimateDetails: {},
estimateResources: [],
estimateTableData: [],
breadcrumbs: []
};
Expand All @@ -34,36 +35,43 @@ class EstimateEditComponent 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},
]
});
});

}

Expand Down Expand Up @@ -109,6 +117,7 @@ class EstimateEditComponent extends Component {
key={activity.id}
activity={activity}
features={this.state.estimate.features}
estimateResources={this.state.estimateResources}
removeActivityItemHandler={this.removeActivityItem}
/>
);
Expand Down Expand Up @@ -169,4 +178,4 @@ class EstimateEditComponent extends Component {

}

export default EstimateEditComponent;
export default ArchestEstimateEditComponent;
Loading