Skip to content

Commit

Permalink
Merge branch 'OP-1199-Main-Store-Inventory' into OP-1189
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudFonzam authored Sep 12, 2024
2 parents db9e64d + 5e759bd commit 3061e2b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
5 changes: 5 additions & 0 deletions bundle/language_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,11 @@ angal.inventory.clean.btn.key
angal.inventory.choosedischargetypebeforevalidate.msg = Please choose the discharge type and save the inventory before validation.
angal.inventory.choosechargetypebeforevalidate.msg = Please choose the charge type and save the inventory before validation.
angal.inventory.choosesupplierbeforevalidate.msg = Please choose the supplier and save the inventory before validation.
angal.inventory.deletion.confirm.msg = Do you really want to delete this inventory?
angal.inventory.deletion.confirm.title = Confirm Deletion
angal.inventory.deletion.success.msg = The inventory has been successfully marked as deleted.
angal.inventory.deletion.error.msg = Deletion is only allowed for inventories with 'draft' or 'validated' status.
angal.inventory.notfound.msg = Inventory not found.
angal.inventory.destination.label = Destination
angal.inventory.dischargetype.label = Discharge Type
angal.inventory.draft = Draft
Expand Down
33 changes: 32 additions & 1 deletion src/main/java/org/isf/medicalinventory/gui/InventoryBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
Expand Down Expand Up @@ -412,14 +413,44 @@ private JButton getPrintButton() {
jButtonPrint.setEnabled(false);
return jButtonPrint;
}

private JButton getDeleteButton() {
jButtonDelete = new JButton(MessageBundle.getMessage("angal.common.delete.btn"));
jButtonDelete.setMnemonic(MessageBundle.getMnemonic("angal.common.delete.btn.key"));
jButtonDelete.setEnabled(false);

jButtonDelete.addActionListener(actionEvent -> {
if (jTableInventory.getSelectedRowCount() > 1) {
MessageDialog.error(this, "angal.inventory.pleaseselectonlyoneinventory.msg");
return;
}
int selectedRow = jTableInventory.getSelectedRow();
if (selectedRow == -1) {
MessageDialog.error(this, "angal.inventory.pleaseselectinventory.msg");
return;
}
MedicalInventory inventory = inventoryList.get(selectedRow);
String currentStatus = inventory.getStatus();
if (currentStatus.equalsIgnoreCase(InventoryStatus.validated.toString()) || currentStatus.equalsIgnoreCase(InventoryStatus.draft.toString())) {
int response = MessageDialog.yesNo(this, "angal.inventory.deletion.confirm.msg");
if (response == JOptionPane.YES_OPTION) {
try {
medicalInventoryManager.deleteInventory(inventory);
MessageDialog.info(this, "angal.inventory.deletion.success.msg");
jTableInventory.setModel(new InventoryBrowsingModel());
} catch (OHServiceException e) {
MessageDialog.error(this, "angal.inventory.deletion.error.msg");
}
}
} else {
MessageDialog.error(this, "angal.inventory.deletion.error.msg");
}
});
return jButtonDelete;
}



private JButton getCloseButton() {
jButtonClose = new JButton(MessageBundle.getMessage("angal.common.close.btn"));
jButtonClose.setMnemonic(MessageBundle.getMnemonic("angal.common.close.btn.key"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1907,4 +1907,4 @@ private void resetVariable() {
inventoryRowListAdded.clear();
lotsSaved.clear();
}
}
}

0 comments on commit 3061e2b

Please sign in to comment.