This web application provides a user interface for managing chemical supply data. It allows users to view, edit, add, delete, and reorder chemical entries in a table format. The application is built using HTML, CSS (Bootstrap), and JavaScript.
- Display chemical data in a sortable table
- Add new chemical entries
- Edit existing chemical entries inline
- Move entries up and down in the table
- Delete chemical entries
- Refresh data from the server
- Save updated data to a JSON file
The main components of the HTML structure are:
- Header: Displays the application title.
- Toolbar: Contains action buttons for managing chemical entries.
- Table: A responsive table to display chemical data.
The application uses Bootstrap 5.1.3 for its primary styling and includes some custom styles to ensure responsiveness and manage table interactions.
chemicalData
: An array that stores the chemical supply data.fetchData()
: Fetches data from 'invoice.json' and populates the table.renderTable()
: Renders the chemical data in the table.updateData()
: Updates thechemicalData
array when inline editing occurs.
- Sorting: Clicking on column headers sorts the table.
- Row selection: Clicking on a row highlights it.
- Inline editing: Table cells are
contenteditable
to allow inline editing.
- Add Row: Adds a new empty row to the table.
- Move Up: Moves the selected row up in the table.
- Move Down: Moves the selected row down in the table.
- Delete Row: Removes the selected row from the table.
- Refresh: Fetches data from the server and updates the table.
- Save: Downloads the updated data as a JSON file.
Each chemical entry in the chemicalData
array has the following properties:
id
: Unique identifier.chemical_name
: Name of the chemical.vendor
: Supplier of the chemical.density
: Density in g/m³.viscosity
: Viscosity in m²/s.packaging
: Type of packaging.pack_size
: Size of the package.unit
: Unit of measurement.quantity
: Amount of the chemical.
The application initializes by calling fetchData()
to load the initial data from 'invoice.json'.
- Implement server-side saving instead of client-side file download.
- Add form validation for inline editing.
- Implement pagination for large datasets.
- Add search functionality.
- Implement undo/redo functionality.
- Add user authentication and authorization.
This documentation provides an overview of the Chemical Supplies Web Application's structure and functionality. It can serve as a reference for understanding the code and for future maintenance or enhancements.