Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class App extends Component {
if (this.props.isAuthenticated) {
routes = (
<Switch>
<Route path="/projects/:id/:year" component={Project} />
<Route path="/projects/:id" component={Project} />
<Route path="/projects" component={Projects} />
<Route path="/" exact component={ConstructionBoard} />
<Redirect to="/" />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation/Toolbar/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SearchBox from '../../SearchBox/SearchBox';
const toolbar = (props) => {

let createAction = null;
if (props.hasEditAccess) {
if (props.hasEditAccess && window.location.pathname === '/') {
createAction = (
<Button variant="primary" onClick={props.showCreateWOModal} className={styles.Button}>
<FontAwesomeIcon icon="plus" /> Add New Task
Expand Down
29 changes: 19 additions & 10 deletions src/components/ProjectDetails/ProjectDetails.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Row, Col } from 'react-bootstrap';
import { Row, Col, Button } from 'react-bootstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import moment from 'moment';
import ProjectStatus from './ProjectStatus/ProjectStatus';
Expand All @@ -15,7 +15,7 @@ const ProjectDetails = (props) => {
};
let projectStatus = null, totalBookedHours = 0, totalFinishedHours = 0;
if (props.workingOrders && props.statusList) {
props.workingOrders.forEach(workingOrder => {
Object.values(props.workingOrders).forEach(workingOrder => {
if (workingOrder.status.toString() !== "5") {
workingOrderByStatus[workingOrder.status] = workingOrderByStatus[workingOrder.status] + 1;
}
Expand All @@ -38,7 +38,7 @@ const ProjectDetails = (props) => {
}
});

if (props.workingOrders.length > 0) {
if (Object.values(props.workingOrders).length > 0) {
projectStatus = <ProjectStatus
statusList={props.statusList}
workingOrderByStatus={workingOrderByStatus}
Expand All @@ -51,19 +51,28 @@ const ProjectDetails = (props) => {

}

const woDetail = {
projectNo: props.project.projectNo
};

return (
<Row>
<Col xs="8" className="py-2">
<h3 className="text-info">{props.project.project_name}</h3>
<Col xs="6" className="py-2">
<h3 className="text-info">{props.project.projectName}</h3>
</Col>
<Col xs="4" className="py-2">
<FontAwesomeIcon icon="calendar-alt" /> Start Date: {moment(props.project.start_date).format('DD.MM.YYYY')}
<Col xs="3" className="py-2 text-right">
<FontAwesomeIcon icon="calendar-alt" /> Start Date: {moment(props.project.startDate).format('DD.MM.YYYY')}
</Col>
<Col xs="3" className="py-2 text-right">
<Button variant="primary" onClick={() => props.showCreateWOModal(woDetail, true)}>
<FontAwesomeIcon icon="plus" /> Add task for this project
</Button>
</Col>
<Col xs="4" className="py-2">
<Card icon="user-tie" title="Customer Details">
{props.project.customer_kname}<br/>
{props.project.customer_address}<br/>
{props.project.customer_postcode + ', ' + props.project.customer_city}
{props.project.customerName}<br/>
{props.project.customerAddress}<br/>
{props.project.customerPostcode + ', ' + props.project.customerCity}
</Card>
</Col>
<Col xs="8" className="py-2">
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectDetails/ProjectWO/ProjectWO.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const projectWO = (props) => {

let taskBoardContent = null;
if (props.statusDetail && props.workingOrders) {
const filteredWorkingOrders = props.workingOrders.reduce((workingOrders, woDetail) => {
const filteredWorkingOrders = Object.values(props.workingOrders).reduce((workingOrders, woDetail) => {
if (woDetail.status.toString() === props.statusDetail.status.toString()) {
workingOrders.push({
...woDetail,
Expand Down
1 change: 0 additions & 1 deletion src/components/Tasks/Task/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Draggable } from 'react-beautiful-dnd';

const task = (props) => {

return (
<Draggable
draggableId={props.uniqueKey}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Tasks/Tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TasksList = (props) => {
}

const taskHeader = <Wrapper>
<strong className="mr-auto">{woDetail.customerName}</strong>
<strong className="mr-auto">{woDetail.customer.customerName}</strong>
<small>{moment(woDetail.plannedDate).fromNow()}</small>
<div className={taskActionsClasses.join(' ')}>
<span className="TaskAction">
Expand All @@ -26,7 +26,7 @@ const TasksList = (props) => {
</Wrapper>;

return <Task
key={woDetail.uniqueKey}
key={index+1}
index={index}
uniqueKey={woDetail.uniqueKey}
header={taskHeader}
Expand All @@ -36,7 +36,7 @@ const TasksList = (props) => {
hideActions={() => props.hideActions(index, false, props.statusDetail.status)}
>
<span>
<b>Project:</b> {woDetail.projectName}
<b>Project:</b> {woDetail.project.projectName}
</span>
<span>
<b>Task:</b> {woDetail.detailDescription ? woDetail.detailDescription: woDetail.description}
Expand Down
5 changes: 3 additions & 2 deletions src/components/UI/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const input = (props) => {
};
inputElement = <DatePicker
value={dateValue}
required
formatInputText={formatInputValue}
shouldHighlightWeekends
inputClassName={styles.DatePickerWrapper}
Expand Down Expand Up @@ -72,9 +73,9 @@ const input = (props) => {
disabled={disabled}
onChange={props.changed}>
<option value="-1">{props.config.defaultOption}</option>
{props.config.defaultOptions ? props.config.defaultOptions.map(option => {
{props.config.defaultOptions ? props.config.defaultOptions.map((option, index) => {
if (!option.hideOption) {
return <option key={option.value} value={option.value}>{option.displayText}</option>
return <option key={index+1} value={option.value}>{option.displayText}</option>
}
return false;
}) : null}
Expand Down
27 changes: 0 additions & 27 deletions src/components/WorkingOrder/Comment/Comment.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/components/WorkingOrder/Form/Form.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { Alert, Col } from 'react-bootstrap';
import Input from '../../../components/UI/Input/Input';
import Modal from '../../../components/UI/Modal/Modal';

Expand Down Expand Up @@ -28,6 +29,15 @@ const form = (props) => {
modalTitle = 'Create Working Order';
}

let invalidAlert = null;
if (props.invalidFields.length > 0) {
invalidAlert = <Col xs="12">
<Alert variant="danger" dismissible>
The fields <b>[{props.invalidFields.join(", ")}]</b> must be filled to save a working order.
</Alert>
</Col>
}

return (
<Modal
modalShow={props.showWOModal}
Expand All @@ -39,6 +49,7 @@ const form = (props) => {
>
<div className="row">
{workingOrderFields}
{invalidAlert}
</div>
</Modal>
)
Expand Down
6 changes: 3 additions & 3 deletions src/config/models/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const filters = {
},
defaultOptions: null,
defaultOption: 'Select a customer',
value: -1
value: "-1"
},
projectNo: {
elementType: 'select',
Expand All @@ -19,7 +19,7 @@ export const filters = {
},
defaultOptions: null,
defaultOption: 'Select a project',
value: -1
value: "-1"
},
taskSelection: {
elementType: 'select',
Expand All @@ -29,7 +29,7 @@ export const filters = {
},
defaultOptions: null,
defaultOption: 'Select task',
value: ''
value: "-1"
},
executionStartDate: {
elementType: 'input',
Expand Down
65 changes: 24 additions & 41 deletions src/config/models/workingOrder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import moment from 'moment';

export const workingOrderModel = {
uniqueKey: {
elementType: 'input',
elementConfig: {
type: 'hidden'
},
elementUIConfig: null,
value: '',
addToEditRequest: true
},
customerNo: {
elementType: 'select',
elementConfig: null,
Expand All @@ -11,6 +20,7 @@ export const workingOrderModel = {
defaultOption: 'Select a customer',
value: -1,
displayText: 'Customer',
addToEditRequest: true,
addToCreateRequest: true,
disabledOnEdit: true
},
Expand All @@ -26,24 +36,7 @@ export const workingOrderModel = {
displayText: 'Project',
addToEditRequest: true,
addToCreateRequest: true,
disabledOnEdit: true,
},
projectYear: {
elementType: 'input',
elementConfig: {
type: 'hidden'
},
elementUIConfig: null,
value: 0
},
workingOrderNo: {
elementType: 'input',
elementConfig: {
type: 'hidden'
},
elementUIConfig: null,
value: 0,
addToEditRequest: true
disabledOnEdit: true
},
description: {
elementType: 'input',
Expand Down Expand Up @@ -92,7 +85,7 @@ export const workingOrderModel = {
},
defaultOptions: null,
defaultOption: 'Select task',
value: '',
value: '-1',
displayText: 'Task',
addToEditRequest: true,
addToCreateRequest: true
Expand All @@ -106,7 +99,7 @@ export const workingOrderModel = {
elementUIConfig: {
grid: 'col-12 col-md-6'
},
value: '',
value: 0.0,
displayText: 'Total Planned Hours',
hideOnCreate: true
},
Expand Down Expand Up @@ -148,16 +141,9 @@ export const workingOrderModel = {
},
value: moment().format('YYYY-MM-DDThh:mm:ss'),
displayText: 'Plan Date',
isDate: true
},
planData: {
elementType: 'headline',
elementConfig: null,
elementUIConfig: {
grid: 'col-12 my-2'
},
value: '',
displayText: 'Disposition'
isDate: true,
addToEditRequest: true,
addToCreateRequest: true
},
startTime: {
elementType: 'input',
Expand All @@ -171,8 +157,7 @@ export const workingOrderModel = {
displayText: 'Plan Start Time',
isTime: true,
addToEditRequest: true,
addToCreateRequest: true,
parent: 'planData'
addToCreateRequest: true
},
endTime: {
elementType: 'input',
Expand All @@ -186,8 +171,7 @@ export const workingOrderModel = {
displayText: 'Plan End Time',
isTime: true,
addToEditRequest: true,
addToCreateRequest: true,
parent: 'planData'
addToCreateRequest: true
},
workingHours: {
elementType: 'input',
Expand All @@ -200,8 +184,7 @@ export const workingOrderModel = {
value: 0.0,
displayText: 'Working Hours',
addToEditRequest: true,
addToCreateRequest: true,
parent: 'planData'
addToCreateRequest: true
},
duration: {
elementType: 'input',
Expand All @@ -214,8 +197,7 @@ export const workingOrderModel = {
value: 0.0,
displayText: 'Duration',
addToEditRequest: true,
addToCreateRequest: true,
parent: 'planData'
addToCreateRequest: true
},
travelTime: {
elementType: 'input',
Expand All @@ -228,7 +210,8 @@ export const workingOrderModel = {
value: 0.0,
displayText: 'Travel Time',
addToEditRequest: true,
addToCreateRequest: true,
parent: 'planData'
}
addToCreateRequest: true
},
customer: null,
project: null
}
Loading