diff options
Diffstat (limited to 'front/odiparpack/app/components')
14 files changed, 407 insertions, 41 deletions
diff --git a/front/odiparpack/app/components/Forms/ReduxFormMUI.js b/front/odiparpack/app/components/Forms/ReduxFormMUI.js index 383a717..285543f 100644 --- a/front/odiparpack/app/components/Forms/ReduxFormMUI.js +++ b/front/odiparpack/app/components/Forms/ReduxFormMUI.js @@ -4,6 +4,14 @@ import TextField from '@material-ui/core/TextField'; import Select from '@material-ui/core/Select'; import Checkbox from '@material-ui/core/Checkbox'; import Switch from '@material-ui/core/Switch'; +import { DateTimePicker, MuiPickersUtilsProvider } from '@material-ui/pickers'; + +import { etiqueta } from '../Odipar/common'; +import { Chip } from '@material-ui/core'; +import MomentUtils from '@date-io/moment'; +import moment from 'moment' +import 'moment/locale/es' +moment.locale('es'); /* Textfield */ export const TextFieldRedux = ({ meta: { touched, error }, input, ...rest }) => ( @@ -67,3 +75,23 @@ SwitchRedux.propTypes = { input: PropTypes.object.isRequired, }; /* End */ + +export const DatePickerRedux = ({ input, label, readonly}) => ( + + <MuiPickersUtilsProvider locale={'es'} utils={MomentUtils}> + <DateTimePicker + format="DD/MM/YYYY hh:mm A" + autoOk + onChange={date => input.onChange(moment(date).format("DD/MM/YYYY hh:mm A"))} + value={input.value ? moment(input.value,"DD/MM/YYYY hh:mm A"): null} + label={label} + readOnly = {readonly} + disabled = {readonly} + /> + </MuiPickersUtilsProvider> +); + +export const EstadoRedux = ({input, label}) => { + const value = input.value? input.value : 0 + return etiqueta("etiq_pedido", value) +} diff --git a/front/odiparpack/app/components/Header/Header.js b/front/odiparpack/app/components/Header/Header.js index e1d0bf5..2b86b41 100644 --- a/front/odiparpack/app/components/Header/Header.js +++ b/front/odiparpack/app/components/Header/Header.js @@ -36,7 +36,7 @@ function Header(props) { > <MenuIcon /> </IconButton> - <div className={classes.flex}> + {/* <div className={classes.flex}> <div className={classes.wrapper}> <div className={classes.search}> <SearchIcon /> @@ -46,8 +46,8 @@ function Header(props) { </div> <Hidden xsDown> <span className={classes.separatorV} /> - </Hidden> - <UserMenu /> + </Hidden> + <UserMenu />*/} </Toolbar> </AppBar> ); diff --git a/front/odiparpack/app/components/Notification/Notification.js b/front/odiparpack/app/components/Notification/Notification.js index 7e73896..fcc53a4 100644 --- a/front/odiparpack/app/components/Notification/Notification.js +++ b/front/odiparpack/app/components/Notification/Notification.js @@ -2,8 +2,13 @@ import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; import CloseIcon from '@material-ui/icons/Close'; +import classNames from 'classnames'; +import CheckCircleOutlinedIcon from '@material-ui/icons/CheckCircleOutlined'; +import ErrorOutlineOutlinedIcon from '@material-ui/icons/ErrorOutlineOutlined'; +import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined'; +import ReportProblemOutlinedIcon from '@material-ui/icons/ReportProblemOutlined'; -import { Snackbar, IconButton } from '@material-ui/core'; +import { Snackbar, IconButton, SnackbarContent } from '@material-ui/core'; const styles = theme => ({ close: { @@ -11,6 +16,41 @@ const styles = theme => ({ }, }); +const variantIcon = { + success: CheckCircleOutlinedIcon, + warning: ReportProblemOutlinedIcon, + error: ErrorOutlineOutlinedIcon, + info: InfoOutlinedIcon, +}; + +const styles1 = theme => ({ + success: { + backgroundColor: '#b6f8c4', + }, + error: { + backgroundColor: '#faabab', + }, + info: { + backgroundColor: '#b2e7f5', + }, + warning: { + backgroundColor: '#f5ea9f', + }, + icon: { + fontSize: 20, + color: 'black' + }, + iconVariant: { + opacity: 0.9, + marginRight: theme.spacing(1), + }, + message: { + display: 'flex', + alignItems: 'center', + color: 'black' + }, +}); + class Notification extends React.Component { handleClose = (event, reason) => { if (reason === 'clickaway') { @@ -20,20 +60,30 @@ class Notification extends React.Component { }; render() { - const { classes, message } = this.props; + const { classes, message, variant } = this.props; + const Icon = variantIcon[variant]; return ( <Snackbar - anchorOrigin={{ - vertical: 'bottom', - horizontal: 'left', - }} open={message !== ''} autoHideDuration={3000} onClose={() => this.handleClose()} ContentProps={{ 'aria-describedby': 'message-id', }} - message={message} + anchorOrigin={{ + vertical: 'top', + horizontal: 'right', + }} + + > + <SnackbarContent + className={classNames(classes[variant])} + message={( + <span id="client-snackbar" className={classes.message}> + <Icon className={classNames(classes.icon, classes.iconVariant)} /> + {message} + </span> + )} action={[ <IconButton key="close" @@ -42,10 +92,11 @@ class Notification extends React.Component { className={classes.close} onClick={() => this.handleClose()} > - <CloseIcon /> + <CloseIcon className={classes.icon}/> </IconButton>, ]} /> + </Snackbar> ); } } @@ -56,4 +107,4 @@ Notification.propTypes = { message: PropTypes.string.isRequired, }; -export default withStyles(styles)(Notification); +export default withStyles(styles1)(Notification); diff --git a/front/odiparpack/app/components/Odipar/EtiquetaData.js b/front/odiparpack/app/components/Odipar/EtiquetaData.js new file mode 100644 index 0000000..a2f262d --- /dev/null +++ b/front/odiparpack/app/components/Odipar/EtiquetaData.js @@ -0,0 +1,80 @@ +//Pedido +export const pedido = { + pendiente:{ + text: "Pendiente", + color: "#FFB74D", + icon: false + }, + enCamino: { + text: "En Camino", + color: "#64B5F6", + icon: false + }, + entregado: { + text: "Entregado", + color: "#81C784", + icon: false + }, + cancelado: { + text: "Cancelado", + color: "#E57373", + icon: false + }, + pendienteAveria:{ + text: "Pendiente por Averia", + color: "#FFB74D", + icon: false + } + } + + //Camion + export const camion = { + disponible : { + text: "Disponible", + color: "#81C784", + icon: false + }, + enReparto: { + text: "En Reparto", + color: "#64B5F6", + icon: false + }, + mantenimiento:{ + text: "Mantenimiento", + color: "#FFB74D", + icon: false + }, + cancelado: { + text: "Inhabilitado", + color: "#E57373", + icon: false + } + } + + //Bloqueos + export const bloqueo = { + desbloqueado: { + text: "Disponible", + color: "#81C784", + icon: false + }, + bloqueado:{ + text: "Bloqueado", + color: "#E57373", + icon: false + } + } + + //Almacen + export const almacen = { + noPrincipal: { + text: "Pequeño", + color: "#DED8D8", + icon: 10 + }, + principal:{ + text: "Principal", + color: "#DED8D8", + icon: 16 + } + }
\ No newline at end of file diff --git a/front/odiparpack/app/components/Odipar/common.js b/front/odiparpack/app/components/Odipar/common.js new file mode 100644 index 0000000..b6fb49d --- /dev/null +++ b/front/odiparpack/app/components/Odipar/common.js @@ -0,0 +1,43 @@ +import React from "react" +import { Chip } from "@material-ui/core"; +import { pedido, camion, bloqueo, almacen } from './EtiquetaData' +import Brightness1Icon from '@material-ui/icons/Brightness1'; + +export const etiquetaStyle = color => ({ + fontWeight: 'bold', + color: '#FFF', + backgroundColor: color +}); + + +//Etiquetas +export function etiqueta(tipo , estado) { // eslint-disable-line + let {color, text, icon} = "" + switch(tipo){ + case 'etiq_pedido': + text = pedido[Object.keys(pedido)[estado]].text + color = pedido[Object.keys(pedido)[estado]].color + break; + case 'etiq_camion': + text = camion[Object.keys(camion)[estado]].text + color = camion[Object.keys(camion)[estado]].color + break; + case 'etiq_bloqueo': + text = bloqueo[Object.keys(bloqueo)[estado]].text + color = bloqueo[Object.keys(bloqueo)[estado]].color + break; + case 'etiq_alma': + let {estadoNum} = 2 + estado === false? estadoNum = 0 : estadoNum = 1 + text = almacen[Object.keys(almacen)[estadoNum]].text + color = almacen[Object.keys(almacen)[estadoNum]].color + icon = almacen[Object.keys(almacen)[estadoNum]].icon + break; + } + + return ( + tipo == "etiq_alma" ? + <Chip label={text} icon = {<Brightness1Icon style={{ fontSize: icon, color: "#B1ABAB" }}/>} style={{fontWeight: 'bold', backgroundColor: color}}/> : + <Chip label={text} style={etiquetaStyle(color)}/> + ) +}
\ No newline at end of file diff --git a/front/odiparpack/app/components/Panel/FloatingPanel.js b/front/odiparpack/app/components/Panel/FloatingPanel.js index 675166a..f0a0e6b 100644 --- a/front/odiparpack/app/components/Panel/FloatingPanel.js +++ b/front/odiparpack/app/components/Panel/FloatingPanel.js @@ -82,7 +82,7 @@ FloatingPanel.propTypes = { }; FloatingPanel.defaultProps = { - title: 'Add New Item', + title: 'Añadir nuevo', extraSize: false, }; diff --git a/front/odiparpack/app/components/Sidebar/MainMenuSimple.js b/front/odiparpack/app/components/Sidebar/MainMenuSimple.js new file mode 100644 index 0000000..18ac8fd --- /dev/null +++ b/front/odiparpack/app/components/Sidebar/MainMenuSimple.js @@ -0,0 +1,96 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import classNames from 'classnames'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; +import { NavLink } from 'react-router-dom'; +// Menu Object +import MenuContent from 'odi-utils/menu'; +import { List, ListItem, ListItemIcon, ListItemText, Collapse, Icon } from '@material-ui/core'; +import styles from './sidebar-jss'; + +function sortByKey(array, key) { + return array.sort((a, b) => { + const x = a[key]; const y = b[key]; + return ((x < y) ? -1 : ((x > y) ? 1 : 0)); + }); +} + +const LinkBtn = React.forwardRef(function LinkBtn(props, ref) { // eslint-disable-line + return <NavLink to={props.to} {...props} innerRef={ref} />; // eslint-disable-line +}); + +function MainMenuSimple(props) { + const { + classes, + toggleDrawerOpen, + loadTransition, + openSubMenu, + open, + } = props; + + const handleClick = () => { + //toggleDrawerOpen(); + loadTransition(false); + }; + + const getMenus = menuArray => menuArray.map((item, index) => { + return ( + <div key={index.toString()}> + <ListItem + button + exact + className={classNames(classes.head, open.indexOf(item.key) > -1 ? classes.opened : '')} + activeClassName={classes.active} + component={LinkBtn} + to={item.link} + onClick={handleClick} + timeout="auto" + unmountOnExit + > + {item.icon + && ( + <ListItemIcon className={classes.iconWrapper}> + <Icon className={classes.icon}>{item.icon}</Icon> + </ListItemIcon> + ) + } + <ListItemText classes={{ primary: classes.primary }} variant="inset" primary={item.name} /> + </ListItem> + </div> + ); + }); + return ( + <div> + {getMenus(MenuContent)} + </div> + ); +} + +MainMenuSimple.propTypes = { + classes: PropTypes.object.isRequired, + open: PropTypes.object.isRequired, + openSubMenu: PropTypes.func.isRequired, + toggleDrawerOpen: PropTypes.func.isRequired, + loadTransition: PropTypes.func.isRequired, +}; + +const openAction = (key, keyParent) => ({ type: 'OPEN_SUBMENU', key, keyParent }); +const reducer = 'ui'; + +const mapStateToProps = state => ({ + force: state, // force active class for sidebar menu + open: state.getIn([reducer, 'subMenuOpen']) +}); + +const mapDispatchToProps = dispatch => ({ + openSubMenu: bindActionCreators(openAction, dispatch) +}); + +const MainMenuMapped = connect( + mapStateToProps, + mapDispatchToProps +)(MainMenuSimple); + +export default withStyles(styles)(MainMenuMapped); diff --git a/front/odiparpack/app/components/Sidebar/Sidebar.js b/front/odiparpack/app/components/Sidebar/Sidebar.js index 01de4ec..b4f5626 100644 --- a/front/odiparpack/app/components/Sidebar/Sidebar.js +++ b/front/odiparpack/app/components/Sidebar/Sidebar.js @@ -4,10 +4,10 @@ import { withStyles } from '@material-ui/core/styles'; import classNames from 'classnames'; import brand from 'ba-api/brand'; import dummy from 'ba-api/dummyContents'; -import logo from 'ba-images/logo.svg'; -import { Hidden, Drawer, SwipeableDrawer, List, Divider, Avatar } from '@material-ui/core'; -import MainMenu from './MainMenu'; -import OtherMenu from './OtherMenu'; +import logo from 'ba-images/logo.png'; +import { Hidden, Drawer, SwipeableDrawer, Avatar } from '@material-ui/core'; +import MainMenuSimple from './MainMenuSimple'; +//import OtherMenu from './OtherMenu'; import styles from './sidebar-jss'; const MenuContent = props => { @@ -38,11 +38,11 @@ const MenuContent = props => { </div> </div> <div className={classes.menuContainer}> - <MainMenu loadTransition={loadTransition} toggleDrawerOpen={toggleDrawerOpen} /> - <Divider className={classes.divider} /> + <MainMenuSimple loadTransition={loadTransition} toggleDrawerOpen={toggleDrawerOpen} /> + {/* <Divider className={classes.divider} /> <List> <OtherMenu toggleDrawerOpen={toggleDrawerOpen} /> - </List> + </List> */} </div> </div> ); diff --git a/front/odiparpack/app/components/Sidebar/sidebar-jss.js b/front/odiparpack/app/components/Sidebar/sidebar-jss.js index e9bf4f6..95fb2b2 100644 --- a/front/odiparpack/app/components/Sidebar/sidebar-jss.js +++ b/front/odiparpack/app/components/Sidebar/sidebar-jss.js @@ -76,11 +76,14 @@ const styles = theme => ({ } }, avatar: { - margin: 10, + marginBottom: 10, + marginTop: 10, + marginLeft: 6, + marginRight: 10 }, bigAvatar: { - width: 80, - height: 80, + width: 55, + height: 55, }, brandBar: { transition: theme.transitions.create(['width', 'margin', 'background'], { @@ -168,16 +171,19 @@ const styles = theme => ({ fontSize: 14, padding: 10, alignItems: 'center', + justifyContent: 'flex-start', '& h4': { - fontSize: 18, + fontSize: 19, marginBottom: 0, textOverflow: 'ellipsis', + display: 'flex', overflow: 'hidden', whiteSpace: 'nowrap', - width: 110 + wordBreak:'break-all', + width: 180, }, '& span': { - fontSize: 12, + fontSize: 14, textOverflow: 'ellipsis', whiteSpace: 'nowrap', width: 110, diff --git a/front/odiparpack/app/components/Tables/CrudTableForm.js b/front/odiparpack/app/components/Tables/CrudTableForm.js index d2d2ea8..017a3fc 100644 --- a/front/odiparpack/app/components/Tables/CrudTableForm.js +++ b/front/odiparpack/app/components/Tables/CrudTableForm.js @@ -5,14 +5,42 @@ import MainTableForm from './tableParts/MainTableForm'; import FloatingPanel from './../Panel/FloatingPanel'; class CrudTableForm extends React.Component { - componentDidMount() { + /* componentDidMount(){ this.props.fetchData(this.props.dataInit, this.props.branch); + } */ + + componentDidUpdate(previousProps) { + if (previousProps.dataInit !== this.props.dataInit) { + //console.log("en el FORM",this.props.dataInit)} + this.props.fetchData(this.props.dataInit, this.props.branch); + } } sendValues = (values) => { setTimeout(() => { this.props.submit(values, this.props.branch); }, 500); + if (this.props.editingId === this.props.initValues.get('id')) { + this.props.dispatch(this.props.editRowAPI()).then((res) => { + if (res) { + console.log("EDIT RO ", res) + } + }) + } else { + this.props.dispatch(this.props.addNewAPI()).then((res) => { + if (res) { + console.log("ADD NEW FORM ", res) + } + }) + } + + } + + getTitle( ){ + if (this.props.editingId === this.props.initValues.get(this.props.anchor[0].name)) { + return "Editar" + } + return "Añadir nuevo" } render() { @@ -27,11 +55,13 @@ class CrudTableForm extends React.Component { anchor, children, branch, - initValues + initValues, + removeRowAPI } = this.props; return ( <div> - <FloatingPanel openForm={openForm} branch={branch} closeForm={closeForm}> + + <FloatingPanel openForm={openForm} branch={branch} closeForm={closeForm} title = {this.getTitle()}> <Form onSubmit={this.sendValues} initValues={initValues} branch={branch}> {children} </Form> @@ -44,6 +74,7 @@ class CrudTableForm extends React.Component { editRow={editRow} anchor={anchor} branch={branch} + removeRowAPI={removeRowAPI} /> </div> ); diff --git a/front/odiparpack/app/components/Tables/tableParts/Form.js b/front/odiparpack/app/components/Tables/tableParts/Form.js index da66966..66188c7 100644 --- a/front/odiparpack/app/components/Tables/tableParts/Form.js +++ b/front/odiparpack/app/components/Tables/tableParts/Form.js @@ -31,14 +31,14 @@ class Form extends Component { </section> <div className={css.buttonArea}> <Button variant="contained" color="secondary" type="submit" disabled={submitting}> - Submit + Guardar </Button> <Button type="button" disabled={pristine || submitting} onClick={reset} > - Reset + Limpiar </Button> </div> </form> diff --git a/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js b/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js index ccf0e4a..1437fa8 100644 --- a/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js +++ b/front/odiparpack/app/components/Tables/tableParts/MainTableForm.js @@ -29,7 +29,8 @@ class MainTableForm extends React.Component { editRow, addNew, anchor, - branch + branch, + removeRowAPI } = this.props; const getItems = dataArray => dataArray.map(item => ( <RowReadOnly @@ -39,6 +40,7 @@ class MainTableForm extends React.Component { editRow={() => editRow(item, branch)} anchor={anchor} branch={branch} + removeRowAPI = {removeRowAPI} /> )); @@ -61,7 +63,7 @@ class MainTableForm extends React.Component { <Tooltip title="Add Item"> <Button variant="contained" onClick={() => addNew(anchor, branch)} color="secondary" className={classes.button}> <AddIcon className={classNames(classes.leftIcon, classes.iconSmall)} /> - Add New + Añadir </Button> </Tooltip> </div> diff --git a/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js b/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js index 7da655f..d060d02 100644 --- a/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js +++ b/front/odiparpack/app/components/Tables/tableParts/RowReadOnly.js @@ -5,8 +5,10 @@ import classNames from 'classnames'; import css from 'ba-styles/Table.scss'; import DeleteIcon from '@material-ui/icons/Delete'; import EditIcon from '@material-ui/icons/BorderColor'; +import { etiqueta } from 'ba-components/Odipar/common'; -import { TableCell, IconButton } from '@material-ui/core'; +import { TableCell, IconButton, LinearProgress } from '@material-ui/core'; +import { connect } from 'react-redux'; const styles = theme => ({ button: { @@ -22,21 +24,40 @@ class RowReadOnly extends React.Component { item, removeRow, editRow, - branch + branch, + removeRowAPI } = this.props; const eventDel = () => { removeRow(item, branch); + this.props.dispatch(removeRowAPI()).then((res) => { + if (res) { + console.log("REMOVE READ ONLY ", res) + } + }) }; const eventEdit = () => { editRow(item, branch); }; const renderCell = dataArray => dataArray.map((itemCell, index) => { if (itemCell.name !== 'action' && !itemCell.hidden) { - return ( - <TableCell padding="none" key={index.toString()}> - {item.get(itemCell.name) !== undefined ? item.get(itemCell.name).toString() : ''} - </TableCell> - ); + const inputType = anchor[index].type; + switch (inputType) { + case 'etiq_pedido': + case 'etiq_camion': + case 'etiq_bloqueo': + case 'etiq_alma': + return ( + <TableCell padding="none" key={index.toString()}> + {etiqueta(inputType, item.get(itemCell.name))} + </TableCell> + ); + case 'texto': + return ( + <TableCell padding="none" key={index.toString()}> + {item.get(itemCell.name) !== undefined ? item.get(itemCell.name).toString() : ''} + </TableCell> + ); + } } return false; }); @@ -72,5 +93,11 @@ RowReadOnly.propTypes = { editRow: PropTypes.func.isRequired, branch: PropTypes.string.isRequired, }; +const mapDispatchToProps = dispatch => ({ + dispatch +}); -export default withStyles(styles)(RowReadOnly); +const RowReadOnlyMapped = connect( + mapDispatchToProps +)(RowReadOnly); +export default withStyles(styles)(RowReadOnlyMapped); diff --git a/front/odiparpack/app/components/index.js b/front/odiparpack/app/components/index.js index 9d7bdb3..123b48c 100644 --- a/front/odiparpack/app/components/index.js +++ b/front/odiparpack/app/components/index.js @@ -3,6 +3,8 @@ export Sidebar from './Sidebar/Sidebar'; export BreadCrumb from './BreadCrumb/BreadCrumb'; export SourceReader from './SourceReader/SourceReader'; export PapperBlock from './PapperBlock/PapperBlock'; +//Odipar + // Dashboard and Widget export CounterWidget from './Counter/CounterWidget'; export SliderWidget from './Widget/SliderWidget'; |
