Skip to content

Commit

Permalink
Add to Storeroom UI Upgrade
Browse files Browse the repository at this point in the history
Dialog/Modal now stays open when adding existing item to storeroom and shows more status messages.
Still have to implement database update when uploading item to storeroom (or just update the database whenever we make a change to Maximo)
  • Loading branch information
desumai committed Apr 30, 2024
1 parent a475c2e commit c0310f5
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
4 changes: 2 additions & 2 deletions assets/maximo.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ class Maximo {
throw new Error(parseInt(statuscode));
}
}

//TODO: also return maximo link to item in inventory
/**
* Upload item to inventory
* @param {object} item information regarding item to be added to storeroom
* @return {number} status message
* @return {0|1} status message. 0 if failure and 1 if success (Note: why didn't we just use the HTTP codes?)
*/
async uploadToInventory(item) {
try {
Expand Down
51 changes: 50 additions & 1 deletion renderer/item_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,21 @@ <h4 class="modal-title">Add Item to Storeroom</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-md">
<div class="form-floating input-group">
<input type="text" class="form-control" id="storeroom-log" placeholder="Maximo Description"
disabled readonly>
<label for="log">Log</label>
</div>
</div>
</div>
</div>
</div>
<!--footer buttons and confirmation-->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-warning" id="storeroom-btn" data-bs-dismiss="modal">
<button type="button" class="btn btn-warning" id="storeroom-btn">
Add
</a>
</div>
Expand Down Expand Up @@ -967,6 +976,46 @@ <h2 class="accordion-header">
</div>
</div>
</div>
<div class="accordion-item" id="template-upld-btn" style="display: none;">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#accordion-templateUpload">
Template Upload
</button>
</h2>
<div id="accordion-templateUpload" class = "accordian-collapse collapse">
<div class="accordion-body d-flex flex-column gap-3">
<div class="d-flex flex-grow-1">Paste table into the textbox below:</div>
<div class="input-group d-flex">
<button class="btn btn-danger" type="button" id="template-paste-btn">Paste</button>
<textarea class="flex-fill" id="template-items-textinput" rows="1"></textarea>
<button class="btn btn-danger" type="button" id="template-copy-headers-btn">Copy Template</button>
</div>
<div class="card">
<div class="overflow-auto flex-fill" style="min-height: min-content; max-height: 500px;">
<div id="template-items-table-div">
</div>
</div>
</div>
<div class="d-flex gap-1">
<ul class="list-group flex-fill">
<li class="list-group-item" id="template-upload-status-text">Waiting for paste...</li>
</ul>
<button id="template-copy-nums" class="btn btn-danger" style="text-align: center;" disabled>
Copy Item Numbers
</button>
</div>
<div class="d-flex gap-1">
<button class="btn btn-secondary flex-fill" style="text-align: center;"
id="clear-template-items-btn"><strong>Clear Table</strong></button>
<button class="btn btn-danger flex-fill" style="text-align: center;"
id="template-upload-btn"><strong>Upload Item(s)</strong></button>
</div>
<div>
</div>
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
Expand Down
21 changes: 19 additions & 2 deletions renderer/item_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ document.getElementById('related-table').addEventListener('click', (event) => {
event.target.parentElement.cells[2].textContent;
document.getElementById('storeroom-item-uom').value =
event.target.parentElement.cells[3].textContent;
document.getElementById('storeroom-log').value =
"Select Storeroom...";
document.getElementById('storeroom-btn').disabled = false;

const siteID = localStorage.getItem('userSite');
const storeroomSelect = document.getElementById('storeroom-storeroom');
Expand All @@ -535,12 +538,22 @@ document.getElementById('related-table').addEventListener('click', (event) => {
console.log('Col index is: ' + col + ' - Row index is: ' + row);
});

document.getElementById('storeroom-storeroom').addEventListener('change', () => {
if(document.getElementById('storeroom-storeroom').reportValidity()){
document.getElementById('storeroom-log').value = "Click Add...";
} else {
document.getElementById('storeroom-log').value = "Select Storeroom...";
}
})
document.getElementById('storeroom-btn').addEventListener('click', () => {
if (!(
document.getElementById('storeroom-storeroom').reportValidity())) {
console.log('Required fields still empty');
document.getElementById('storeroom-log').value = "Required Fields Are Still Empty";
return;
}
document.getElementById('storeroom-btn').disabled = true;
document.getElementById("storeroom-log").value = "Adding item..."
const worker = new WorkerHandler();
const upload = {
cataloguenum: '',
Expand All @@ -551,9 +564,13 @@ document.getElementById('storeroom-btn').addEventListener('click', () => {
vendorname: '',
};
worker.work(['uploadInventory', upload, true], (result) => {
//log in firestore if upload is successful
if (result[0] == 1) {
ipcRenderer.send("firestore-log", { event: CONSTANTS.FIRESTORE_EVENT_ADDTOINVENTORY })
//TODO: update database to show changes
ipcRenderer.send("firestore-log", { event: CONSTANTS.FIRESTORE_EVENT_ADDTOINVENTORY }); //log in firestore if upload is successful
document.getElementById("storeroom-log").value = "Added Item to Storeroom"; //Add maximo link
} else {
document.getElementById("storeroom-log").value = "Error: Couldn't Add Item to Storeroom" //TODO: error codes
document.getElementById('storeroom-btn').disabled = false;
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion renderer/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async function uploadInventory(item, rtrn) {
const maximo = new Maximo();
const statusCode = await maximo.uploadToInventory(item);
try{
if(rtrn == true) {
if(rtrn) {
return statusCode;
}
} catch (err){
Expand Down

0 comments on commit c0310f5

Please sign in to comment.