#24 story/medikamente-als-veraltet-markieren #46
4 changed files with 46 additions and 1 deletions
Binary file not shown.
|
@ -7,6 +7,8 @@ import java.util.stream.Collectors;
|
|||
|
||||
import de.hitec.nhplus.Main;
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.login.Permissions;
|
||||
import de.hitec.nhplus.main.MainWindowController;
|
||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||
import de.hitec.nhplus.nurse.Nurse;
|
||||
import de.hitec.nhplus.patient.Patient;
|
||||
|
@ -15,6 +17,7 @@ import de.hitec.nhplus.treatment.TreatmentModalController;
|
|||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
|
@ -51,15 +54,23 @@ public class AllMedicationController {
|
|||
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||
@FXML
|
||||
public Button buttonChangeAvailable;
|
||||
@FXML
|
||||
public Button buttonAdd;
|
||||
@FXML
|
||||
public Button buttonDelete;
|
||||
|
||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||
private MedicationDao dao;
|
||||
private boolean hasEditPermissions;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
int editPermissions = Permissions.MANAGEMENT | Permissions.OWNER;
|
||||
int userPermissions = MainWindowController.getInstance().getUser().getPermissions();
|
||||
hasEditPermissions = (userPermissions & editPermissions) != 0;
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
|
@ -86,6 +97,12 @@ public class AllMedicationController {
|
|||
|
||||
this.tableView.setItems(this.medications);
|
||||
|
||||
if (!hasEditPermissions) {
|
||||
this.buttonAdd.setDisable(true);
|
||||
this.buttonDelete.setDisable(true);
|
||||
this.buttonChangeAvailable.setDisable(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,6 +157,22 @@ public class AllMedicationController {
|
|||
this.readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
public void handleDelete() {
|
||||
Medication selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.dao.delete(selectedItem.getId());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
this.readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
||||
*
|
||||
|
@ -184,4 +217,5 @@ public class AllMedicationController {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,12 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The controller for viewing all deprecated {@link Medication}s.
|
||||
*
|
||||
* @author Armin Ribic
|
||||
* @author Dorian Nemec
|
||||
*/
|
||||
public class DeprecatedMedicationController {
|
||||
@FXML
|
||||
private TableView<Medication> tableView;
|
||||
|
@ -38,6 +44,9 @@ public class DeprecatedMedicationController {
|
|||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||
private MedicationDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
|
@ -79,8 +88,9 @@ public class DeprecatedMedicationController {
|
|||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleChangeAvailable(){
|
||||
public void handleChangeAvailable() {
|
||||
Medication selectedItem = tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
fx:id="buttonDelete"
|
||||
mnemonicParsing="false"
|
||||
prefWidth="90.0"
|
||||
onAction="#handleDelete"
|
||||
text="Löschen"
|
||||
/>
|
||||
<Button
|
||||
|
|
Loading…
Reference in a new issue