Table Action

Size
7,906 Kb
Views
18,216

How do I make an table action?

What is a table action? How do you make a table action? This script and codes were developed by Alexander Hadik on 16 September 2022, Friday.

Table Action Previews

Table Action - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Table Action</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="tableContainer"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Table Action - Script Codes CSS Codes

@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,200i,300,300i,400,400i,600,600i,700,700i,900,900i");
body { color: #0E202E; font-family: 'Source Sans Pro', sans-serif;
}
.modal--hide { display: none;
}
.modal--display { display: auto;
}
#tableContainer { width: 95%; max-width: 1000px; margin-left: auto; margin-right: auto; background-color: #708696; color: white; padding: 20px 0 20px 0;
}
.table { width: calc(100% - 100px); margin-left: auto; margin-right: auto;
}
.table__header { font-weight: 300;
}
.table__header--emphasis { font-weight: 700;
}
.table__row { height: 30px; margin: 10px 0 10px 0; position: relative; pointer-events: all;
}
.table__row--focus { outline: none;
}
.table__row--focus .table__row-data { pointer-events: none; margin-left: -40px;
}
.table__row-data { width: 100%; height: 100%; display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-wrap: nowrap; flex-wrap: nowrap; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-transition: margin .5s; transition: margin .5s; background-color: #525B68;
}
.table__row-data--header { background-color: transparent;
}
.table__row-data--disable { opacity: 0.5;
}
.table__row-data--header { font-weight: 700; background-color: transparent;
}
.table__cell { position: relative; box-sizing: border-box; margin: 0 10px 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; /*Cell Sizing*/ /*Cell State Styling*/
}
.table__cell--icon { width: 1.5em; text-align: center;
}
.table__cell--short { width: calc(10% - (1.5em/7));
}
.table__cell--medium { width: calc(15% - (1em/7));
}
.table__cell--long { width: calc(20% - (1em/7));
}
.table__cell--confirmed { color: #6FCE95;
}
.table__cell--pending { opacity: 0.5;
}
.table__cell:first-of-type { margin-left: 20px; /*Left anchor icons special case*/
}
.table__cell:first-of-type.fa { margin-left: 10px;
}
.table__cell:last-of-type { margin-right: 20px;
}
.table__button-group { position: absolute; pointer-events: all; display: -webkit-box; display: -ms-flexbox; display: flex; z-index: 1; height: 100%; top: 0; right: -40px; width: 70px; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; -webkit-animation-duration: 0.5s; animation-duration: 0.5s; -webkit-animation-delay: 0.25s; animation-delay: 0.25s; opacity: 0; -webkit-animation-fill-mode: forwards; animation-fill-mode: forwards; -webkit-animation-name: button__fadein; animation-name: button__fadein;
}
@-webkit-keyframes button__fadein { from { opacity: 0; } to { opacity: 1; }
}
@keyframes button__fadein { from { opacity: 0; } to { opacity: 1; }
}
.table__action-button { height: 20px; width: 30px; border: none; border-radius: 5px; color: #98A8B4; background-color: white;
}
.table__action-button:hover { background-color: #d9d9d9;
}
.table__action-button:focus { color: white; background-color: #4DA4E3;
}
.table__action-button:focus:hover { background-color: #1f7fc5;
}

Table Action - Script Codes JS Codes

'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var data = [{ checkedin: true, id: 'lk2a4jd1k9d7', intake: 'WTF', barcode: undefined, label: '96 well testing plate', container: '96-flat', storage: 'cold_4', location: { shipment_level: ['4C Fridge WC #2', 'S1R1', 'Yin\'s Test Lab'], container_level: ['Row: 1 Col: 1'] }, pendingConfirm: false
}, { checkedin: false, id: 'lk2a4jd13r4f', intake: 'KDS', barcode: undefined, label: '96 well testing plate', container: '96-flat', storage: 'cold_4', location: { shipment_level: ['4C Fridge WC #2', 'S1R1', 'Yin\'s Test Lab'], container_level: ['Row: 1 Col: 2'] }, pendingConfirm: true
}, { checkedin: false, id: 'lk2d7hg43r4f', intake: 'XKL', barcode: undefined, label: '96 well testing plate', container: '96-flat', storage: 'cold_4', location: { shipment_level: ['4C Fridge WC #2', 'S1R1', 'Yin\'s Test Lab'], container_level: ['Row: 1 Col: 3'] }, pendingConfirm: true
}, { checkedin: false, id: 'lkd6dgd13r4f', intake: 'OSF', barcode: undefined, label: '96 well testing plate', container: '96-flat', storage: 'cold_4', location: { shipment_level: ['4C Fridge WC #2', 'S1R1', 'Yin\'s Test Lab'], container_level: ['Row: 1 Col: 4'] }, pendingConfirm: true
}, { checkedin: false, id: 'kc09wjd13r4f', intake: 'SFF', barcode: undefined, label: '96 well testing plate', container: '96-flat', storage: 'cold_4', location: { shipment_level: ['4C Fridge WC #2', 'S1R1', 'Yin\'s Test Lab'], container_level: ['Row: 1 Col: 5'] }, pendingConfirm: true
}];
var ConfirmationModal = function (_React$Component) { _inherits(ConfirmationModal, _React$Component); function ConfirmationModal() { _classCallCheck(this, ConfirmationModal); return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); } ConfirmationModal.prototype.render = function render() { return React.createElement( 'div', { className: 'modal ' + (this.state.display ? 'modal--display' : 'modal--hide') }, React.createElement( 'div', { className: 'modal__window' }, React.createElement( 'p', { className: 'modal__message' }, this.props.message ), React.createElement( 'button', { className: 'modal__button modal__button--reject' }, 'Cancel' ), React.createElement( 'button', { className: 'modal__button modal__button--confirm' }, 'Continue' ) ) ); }; return ConfirmationModal;
}(React.Component);
var ContainerTable = function (_React$Component2) { _inherits(ContainerTable, _React$Component2); function ContainerTable(props) { _classCallCheck(this, ContainerTable); var _this2 = _possibleConstructorReturn(this, _React$Component2.call(this, props)); var pendingContainers = props.containers.filter(function (container) { return container.pendingConfirm; }); _this2.state = { currentFocus: pendingContainers.shift().id, pendingContainers: pendingContainers }; return _this2; } ContainerTable.prototype.iterate = function iterate() { var pendingContainersPrime = this.state.pendingContainers; var currentContainer = pendingContainersPrime.shift(); var currentID = currentContainer ? currentContainer.id : undefined; this.setState({ currentFocus: currentID, pendingContainers: pendingContainersPrime }); }; ContainerTable.prototype.render = function render() { return React.createElement( 'div', { className: 'table' }, React.createElement( 'p', { className: 'table__header' }, '4C Fridge WC #2 / S1R1 / ', React.createElement( 'span', { className: 'table__header--emphasis' }, 'Yin\'s Test Lab' ) ), React.createElement(ContainerDatum, { checkedin: false, id: 'ID', intake: 'Intake Code', barcode: 'Barcode', label: 'Label', container: 'Container', storage: 'Storage', location: 'Location', pendingConfirm: false, focus: false, iterate: undefined, header: true }), this.props.containers.map(function (container) { container['setCurrentFocus'] = function (id) { this.setState({ currentFocus: id }); }.bind(this); container['focus'] = this.state.currentFocus == container.id; return React.createElement(ContainerDatum, Object.assign({}, container, { iterate: this.iterate.bind(this) })); }.bind(this)) ); }; return ContainerTable;
}(React.Component);
ContainerTable.PropTypes = { containers: React.PropTypes.array
};
var ContainerDatum = function (_React$Component3) { _inherits(ContainerDatum, _React$Component3); function ContainerDatum(props) { _classCallCheck(this, ContainerDatum); var _this3 = _possibleConstructorReturn(this, _React$Component3.call(this, props)); _this3.state = { toBeConfirmed: props.pendingConfirm, checkedin: props.checkedin }; return _this3; } ContainerDatum.prototype.onAccept = function onAccept(e) { e.preventDefault(); this.setState({ toBeConfirmed: false, checkedin: true }); this.props.iterate(); }; ContainerDatum.prototype.onReject = function onReject(e) { e.preventDefault(); this.setState({ checkedin: false }); }; ContainerDatum.prototype.render = function render() { return React.createElement( 'div', { className: 'table__row ' + (this.props.focus ? 'table__row--focus' : '') }, React.createElement( 'div', { className: 'table__row-data ' + (this.props.header ? 'table__row-data--header' : '') + ' ' + (!this.props.focus && this.state.toBeConfirmed ? 'table__row-data--disable' : '') }, React.createElement('div', { className: 'table__cell table__cell--icon table__cell--confirmed fa ' + (this.state.checkedin ? 'fa-check' : '') }), React.createElement( 'div', { className: 'table__cell table__cell--long' }, this.props.id ), React.createElement( 'div', { className: 'table__cell table__cell--short' }, this.props.intake ), React.createElement( 'div', { className: 'table__cell table__cell--medium ' + (this.props.barcode ? '' : 'table__cell--pending') }, this.props.barcode ? this.props.barcode : 'Click to Add' ), React.createElement( 'div', { className: 'table__cell table__cell--medium' }, this.props.label ), React.createElement( 'div', { className: 'table__cell table__cell--short' }, this.props.container ), React.createElement( 'div', { className: 'table__cell table__cell--short' }, this.props.storage ), React.createElement( 'div', { className: 'table__cell table__cell--long ' + (this.props.location ? '' : 'table__cell--pending') }, !this.props.location ? 'Click to Add' : this.props.location.container_level ? this.props.location.container_level[0] : this.props.location ) ), this.props.focus && this.state.toBeConfirmed ? React.createElement(LocationConfirm, { location: this.props.location, onAccept: this.onAccept.bind(this), onReject: this.onReject.bind(this) }) : '' ); }; return ContainerDatum;
}(React.Component);
ContainerDatum.PropTypes = { checkedin: React.PropTypes.bool.isRequired, id: React.PropTypes.string.isRequired, intake: React.PropTypes.string.isRequired, barcode: React.PropTypes.string.isRequired, label: React.PropTypes.string.isRequired, container: React.PropTypes.string.isRequired, storage: React.PropTypes.string.isRequired, location: React.PropTypes.object.isRequired, pendingConfirm: React.PropTypes.bool.isRequired, focus: React.PropTypes.bool.isRequired, iterate: React.PropTypes.func.isRequired
};
var LocationConfirm = function (_React$Component4) { _inherits(LocationConfirm, _React$Component4); function LocationConfirm(props) { _classCallCheck(this, LocationConfirm); var _this4 = _possibleConstructorReturn(this, _React$Component4.call(this, props)); _this4.state = { activeOption: 'confirm' }; return _this4; } LocationConfirm.prototype.render = function render() { return React.createElement( 'form', { className: 'table__button-group', onSubmit: function onSubmit(e) { e.preventDefault(); } }, React.createElement('button', { tabIndex: '1', autoFocus: true, type: 'submit', className: 'table__action-button fa fa-check', name: 'accept', onClick: this.props.onAccept }), React.createElement('button', { tabIndex: '1', type: 'submit', className: 'table__action-button fa fa-times', name: 'reject', onClick: this.props.onReject }) ); }; return LocationConfirm;
}(React.Component);
LocationConfirm.PropTypes = { location: React.PropTypes.string.isRequired, onAccept: React.PropTypes.func.isRequired, onReject: React.PropTypes.func.isRequired
};
var table = React.createElement(ContainerTable, { containers: data });
var modal = React.createElement(ConfirmationModal, { message: 'Rejecting an auto-assigned location will reject all auto-assigned containers' });
ReactDOM.render(table, document.querySelector('#tableContainer'));
Table Action - Script Codes
Table Action - Script Codes
Home Page Home
Developer Alexander Hadik
Username ahadik
Uploaded September 16, 2022
Rating 3
Size 7,906 Kb
Views 18,216
Do you need developer help for Table Action?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Alexander Hadik (ahadik) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!