Erweiterungen
This commit is contained in:
@@ -1509,22 +1509,41 @@ public class AddJobView extends Main {
|
|||||||
task.setTaskOrder(tasksState.size()); // Set order based on current position
|
task.setTaskOrder(tasksState.size()); // Set order based on current position
|
||||||
tasksState.add(task);
|
tasksState.add(task);
|
||||||
|
|
||||||
|
// Use an array to hold the current task reference (allows modification in lambda)
|
||||||
|
final BaseTask[] currentTask = {task};
|
||||||
|
|
||||||
taskTypeCombo.addValueChangeListener(ev -> {
|
taskTypeCombo.addValueChangeListener(ev -> {
|
||||||
TaskType selectedType = ev.getValue();
|
TaskType selectedType = ev.getValue();
|
||||||
if (selectedType != null) {
|
if (selectedType != null) {
|
||||||
// Create new task instance based on type
|
// Create new task instance based on type
|
||||||
BaseTask newTask = createTaskByType(selectedType);
|
BaseTask newTask = createTaskByType(selectedType);
|
||||||
newTask.setText(task.getText());
|
BaseTask oldTask = currentTask[0];
|
||||||
newTask.setCompleted(task.isCompleted());
|
|
||||||
newTask.setCompletedAt(task.getCompletedAt());
|
newTask.setText(oldTask.getText());
|
||||||
newTask.setCompletedBy(task.getCompletedBy());
|
newTask.setCompleted(oldTask.isCompleted());
|
||||||
newTask.setCompletionNote(task.getCompletionNote());
|
newTask.setCompletedAt(oldTask.getCompletedAt());
|
||||||
|
newTask.setCompletedBy(oldTask.getCompletedBy());
|
||||||
|
newTask.setCompletionNote(oldTask.getCompletionNote());
|
||||||
|
|
||||||
|
// Preserve task-specific properties
|
||||||
|
if (oldTask instanceof ConfirmationTask oldConfirmationTask && newTask instanceof ConfirmationTask newConfirmationTask) {
|
||||||
|
newConfirmationTask.setButtonText(oldConfirmationTask.getButtonText());
|
||||||
|
} else if (oldTask instanceof TodoListTask oldTodoTask && newTask instanceof TodoListTask newTodoTask) {
|
||||||
|
newTodoTask.setTodoItems(oldTodoTask.getTodoItems());
|
||||||
|
} else if (oldTask instanceof PhotoTask oldPhotoTask && newTask instanceof PhotoTask newPhotoTask) {
|
||||||
|
newPhotoTask.setMinPhotoCount(oldPhotoTask.getMinPhotoCount());
|
||||||
|
newPhotoTask.setMaxPhotoCount(oldPhotoTask.getMaxPhotoCount());
|
||||||
|
} else if (oldTask instanceof BarcodeTask oldBarcodeTask && newTask instanceof BarcodeTask newBarcodeTask) {
|
||||||
|
newBarcodeTask.setMinBarcodeCount(oldBarcodeTask.getMinBarcodeCount());
|
||||||
|
newBarcodeTask.setMaxBarcodeCount(oldBarcodeTask.getMaxBarcodeCount());
|
||||||
|
}
|
||||||
|
|
||||||
// Replace in state and preserve order
|
// Replace in state and preserve order
|
||||||
int index = tasksState.indexOf(task);
|
int index = tasksState.indexOf(oldTask);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
newTask.setTaskOrder(index); // Preserve the order
|
newTask.setTaskOrder(index); // Preserve the order
|
||||||
tasksState.set(index, newTask);
|
tasksState.set(index, newTask);
|
||||||
|
currentTask[0] = newTask; // Update the reference
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTaskConfiguration(configContainer, newTask);
|
updateTaskConfiguration(configContainer, newTask);
|
||||||
@@ -1533,7 +1552,7 @@ public class AddJobView extends Main {
|
|||||||
|
|
||||||
// Set initial configuration
|
// Set initial configuration
|
||||||
taskTypeCombo.setValue(TaskType.CONFIRMATION);
|
taskTypeCombo.setValue(TaskType.CONFIRMATION);
|
||||||
updateTaskConfiguration(configContainer, task);
|
updateTaskConfiguration(configContainer, currentTask[0]);
|
||||||
|
|
||||||
tasksList.add(taskContainer);
|
tasksList.add(taskContainer);
|
||||||
}
|
}
|
||||||
@@ -1573,7 +1592,14 @@ public class AddJobView extends Main {
|
|||||||
buttonTextField.setValue(confirmationTask.getButtonText() != null ?
|
buttonTextField.setValue(confirmationTask.getButtonText() != null ?
|
||||||
confirmationTask.getButtonText() : "");
|
confirmationTask.getButtonText() : "");
|
||||||
buttonTextField.addValueChangeListener(ev -> {
|
buttonTextField.addValueChangeListener(ev -> {
|
||||||
confirmationTask.setButtonText(ev.getValue());
|
// Find the current ConfirmationTask in tasksState and update it
|
||||||
|
for (int i = 0; i < tasksState.size(); i++) {
|
||||||
|
BaseTask stateTask = tasksState.get(i);
|
||||||
|
if (stateTask == task && stateTask instanceof ConfirmationTask) {
|
||||||
|
((ConfirmationTask) stateTask).setButtonText(ev.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
configContainer.add(buttonTextField);
|
configContainer.add(buttonTextField);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user