1.0.0 • Published 4 years ago

customer-test v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

Functions:

Clickable id or name of property to open page to edit Borders on table and cells Alternative row colours Visual Row selection Row count: Showing 1 to 10 of 57 entries Action buttons per row Pagination Sorting - single Sorting - multiple by more than 1 column Selection of number of elements to display Selection of column visibility Total row on the bottom Inline edition of the data displayed Export: PDF Excel CSV Copy Print Column Reorder Column Filter Responsive Row Grouping Row Reorder Collapse / Expand sections of the screen / Accordion Application structure:

In src folder you will find:

  • components - these are the components used including TableComponent inside tablecomponent folder

  • resources - the css files and themes

  • services - connections with back-end

If you start new project from these sources you must run first: "npm install" in the folder where package.json is and then "npm start"

If you want to implement TableComponent into an existing project you must run first:

npm install primeicons --save

npm install jspdf jspdf-autotable --save

npm install xlsx file-saver --save

...and you must copy the compenents folder and resources folder in their respective location

Example of usage in your own component:

import React from 'react';

import TableComponent from "./tablecomponent/TableComponent";

import {Button} from 'element-react';

export default class MilesAndMore extends React.Component {

constructor(props) { super(props); this.state = { this.data = {"id": "1", "creationDate": "2012.02.19", "name": "Orange", "fromDate": "2016.02.09", "toDate" : "2012.02.09"}, {"id": "2", "creationDate": "2012.02.13", "name": "Black", "fromDate": "2014.02.09", "toDate" : "2012.02.15"}, {"id": "3", "creationDate": "2012.08.19", "name": "Orange", "fromDate": "2016.08.09", "toDate" : "2012.02.26"}, ; }

showActionButtons(){

return ( <Button type="success" onClick={() => this.editRow()} size="mini">Edit <Button type="danger" onClick={() => this.archiveRow()} size="mini">Archive

}

columns = {key: "reorder", header: "Reorder", rowReorder : true, style : {width: '3em'} }, {key: "id", header: "Id", style: {textAlign: 'center', width: '60px'}, sortable: true, filter: true }, {key: "creationDate", header: "Creation Date", sortable: true, filter: true }, {key: "name", header: "Name", sortable: true, filter: true, edit: true }, {key: "fromDate", header: "From Date", sortable: true, filter: true }, {key: "toDate", header: "To Date", sortable: true, filter: true }, {key: "body", body: this.showActionButtons, header: "Actions", style: { textAlign: 'center', width: '150px' }} ;

render() { return ( <TableComponent title="Miles and More" data={this.data} style={{marginLeft: 'auto', marginRight: 'auto', width: '60%'}} columns={this.columns} lazy={false} //groupByKey="name" onRowClick={this.onRowClick.bind(this)} footer={Add} />

) }

}brand

Properties of

-data - JSON format data array (as above example)

-columns - an array of column objects contained by the table

- the keys for these objects are:

     - key - unique identifier

     - header - Name of the column

      - you can set sortable: true if you want that column to have the capability of sorting

     - you can set sortable: true if you want that column to have the capability of filtering

     - style - CSS style. Example style: {width: "80px"}

     - body - a function that returns (as in example above) content in JSX format. You must add rowReorder: true

      If you want that a specific column to has the capability of sorting you must add: sortable: true. For filter element of a specific column can be activated by adding: filter: true

     if you want a column to be used for changing order of rows you must use 

    - edit If you want to inline edit rows of a column add: edit: true/>

-lazy - if true then only the current page data will be loaded

-title - the ttile of the table that appears in the upper right corner

-groupByKey - the key from columns you what the table to be group by

-footer - contains JSX that will appear in the bottom of the page (likes Buttons)

-onRowClick is a function that has a parameter "event" with these properties:

event.originalEvent: Browser event event.data: Clicked row data event.index: Clicked row data index

This function can handle single clicks (if you doubleclick and if the column has edit: true then the edit for that cell is starting)

Example:

clicks = 0; onRowClick(event){ this.clicks++; let child = event.originalEvent.target.children0 ; let index = event.index; setTimeout(() =>{ if(this.clicks === 1){ this.rowIndex = event.index; if(child != null && (child.innerText ==='Name' || child.innerText ==='Id')) {

this.editRow(index); }

} this.clicks = 0; }, 400, event, child, index);

}

Reset will reset filters, sorting and columns order

For multiple select you must press on CTRL and click on other columns

When you do Row Group you can see the total of that group for the columns that have numbers (exception is the columns with the key 'id')


Base react application, useful for development of new components in EP/CP. Contains :

  • Main App component - with call to get the cloudfront host from va-btfl-rest project, specific for each environment - this can be used to access resources : images/css/js files.
  • Routing using React Router, with 2 default routes for / - Home page and /admin - Admin page, in a way that we can send the cloudfrontHost to the components
  • 2 Example components : Home and Admin with an example state and an example use of cloudfrontHost
  • proxy configured in package.json - for localhost environment - should be configured for each environment properly - in order to redirect requests to proper backend server and solve the CORS issue "proxy": "http://localhost:9080"
  • Application should be started, on local environment, with npm install ; npm start.

-In order to embed the application in EP, we should add in the desired .ftl page the following piece of code (keeping in mind that the application is running locally on http://localhost:3000/) :

Deployment of application:

TBD (EP's liferay or CP's tomcat - both solutions are possible)

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits. You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode. See the section about running tests for more information.

npm run build

Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

See the section about deployment for more information.

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

npm run build fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

Running in Docker

Building the image

  1. docker build --build-arg REACT_APP_API_BASE_URL=http://127.0.0.1:3000/ . -t customer-react

Running a container

  1. docker run -d -it -v ${PWD}:/app -v /app/node_modules --name customer-react -p 3000:80 customer-react