Erweiterungen
This commit is contained in:
@@ -10,6 +10,8 @@ import com.vaadin.flow.component.dialog.Dialog;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.button.ButtonVariant;
|
||||
import com.vaadin.flow.component.html.H4;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.notification.NotificationVariant;
|
||||
import com.vaadin.flow.component.icon.Icon;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.router.BeforeEvent;
|
||||
@@ -41,6 +43,7 @@ import de.assecutor.votianlt.model.Barcode;
|
||||
import de.assecutor.votianlt.model.Photo;
|
||||
import de.assecutor.votianlt.model.Comment;
|
||||
import de.assecutor.votianlt.pages.service.AppUserService;
|
||||
import de.assecutor.votianlt.service.MessageService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
@@ -63,13 +66,15 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
|
||||
private final PhotoRepository photoRepository;
|
||||
private final CommentRepository commentRepository;
|
||||
private final AppUserService appUserService;
|
||||
private final MessageService messageService;
|
||||
|
||||
private final VerticalLayout content;
|
||||
private final List<Div> taskCards = new ArrayList<>();
|
||||
|
||||
public JobSummaryView(JobRepository jobRepository, CargoItemRepository cargoItemRepository,
|
||||
TaskRepository taskRepository, SignatureRepository signatureRepository, BarcodeRepository barcodeRepository,
|
||||
PhotoRepository photoRepository, CommentRepository commentRepository, AppUserService appUserService) {
|
||||
PhotoRepository photoRepository, CommentRepository commentRepository, AppUserService appUserService,
|
||||
MessageService messageService) {
|
||||
this.jobRepository = jobRepository;
|
||||
this.cargoItemRepository = cargoItemRepository;
|
||||
this.taskRepository = taskRepository;
|
||||
@@ -78,6 +83,7 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
|
||||
this.photoRepository = photoRepository;
|
||||
this.commentRepository = commentRepository;
|
||||
this.appUserService = appUserService;
|
||||
this.messageService = messageService;
|
||||
|
||||
setSizeFull();
|
||||
addClassNames(LumoUtility.BoxSizing.BORDER, LumoUtility.Display.FLEX, LumoUtility.FlexDirection.COLUMN,
|
||||
@@ -119,6 +125,32 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create Send Message Button for toolbar
|
||||
Button sendMessageButton = new Button("Nachricht senden");
|
||||
sendMessageButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
sendMessageButton.addClickListener(e -> {
|
||||
// Check if job has an app user assigned
|
||||
if (job.getAppUser() == null || job.getAppUser().isBlank()) {
|
||||
Notification.show(
|
||||
"Diesem Auftrag ist kein App-Nutzer zugeordnet",
|
||||
3000,
|
||||
Notification.Position.MIDDLE
|
||||
).addThemeVariants(NotificationVariant.LUMO_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
String appUserId = job.getAppUser();
|
||||
String jobNumber = job.getJobNumber() != null ? job.getJobNumber() : job.getId().toHexString();
|
||||
|
||||
// Check if messages exist for this job
|
||||
List<de.assecutor.votianlt.model.Message> existingMessages = messageService.getMessagesForJob(job.getId());
|
||||
|
||||
// Navigate to message details view with job conversation
|
||||
// Format: message-details/{clientId}/job-{jobNumber}
|
||||
String conversationId = "job-" + jobNumber;
|
||||
getUI().ifPresent(ui -> ui.navigate("message-details/" + appUserId + "/" + conversationId));
|
||||
});
|
||||
|
||||
// Create Job History Button for toolbar
|
||||
Button jobHistoryButton = new Button("Job Historie");
|
||||
jobHistoryButton.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
|
||||
@@ -126,8 +158,8 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
|
||||
getUI().ifPresent(ui -> ui.navigate("job_history/" + job.getId().toHexString()));
|
||||
});
|
||||
|
||||
// Add toolbar with Job History button in top right
|
||||
add(new ViewToolbar("Zusammenfassung", jobHistoryButton));
|
||||
// Add toolbar with both buttons in top right (Send Message button on the left)
|
||||
add(new ViewToolbar("Zusammenfassung", sendMessageButton, jobHistoryButton));
|
||||
|
||||
List<CargoItem> cargo = cargoItemRepository.findByJobId(jobId);
|
||||
List<BaseTask> tasks = taskRepository.findByJobIdOrderByTaskOrderAsc(jobId);
|
||||
|
||||
@@ -114,9 +114,6 @@ public class ShowJobsView extends VerticalLayout {
|
||||
java.time.LocalDateTime endDt = end != null ? end.atTime(23, 59, 59)
|
||||
: java.time.LocalDate.now().atTime(23, 59, 59);
|
||||
|
||||
// Aktuellen Benutzer (ObjectId Hex) ermitteln
|
||||
String currentUserIdHex = securityService.getCurrentUserId().toHexString();
|
||||
|
||||
// Status-Filter bestimmen
|
||||
String selectedStatus = statusFilter.getValue();
|
||||
java.util.List<JobStatus> statusList;
|
||||
@@ -139,8 +136,7 @@ public class ShowJobsView extends VerticalLayout {
|
||||
// leer
|
||||
|
||||
// Verwende die erweiterte Suchmethode
|
||||
var filteredJobs = jobRepository.findWithFilters(startDt, endDt, currentUserIdHex, jobNumberPattern,
|
||||
statusList);
|
||||
var filteredJobs = jobRepository.findWithFilters(startDt, endDt, jobNumberPattern, statusList);
|
||||
grid.setItems(filteredJobs);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ public interface JobRepository extends MongoRepository<Job, ObjectId> {
|
||||
/**
|
||||
* Erweiterte Suche: Zeitraum, Auftragsnummer und Status kombiniert
|
||||
*/
|
||||
@Query("{'createdAt': {'$gte': ?0, '$lte': ?1}, 'createdBy': ?2, "
|
||||
+ "'jobNumber': {'$regex': ?3, '$options': 'i'}, " + "'status': {'$in': ?4}}")
|
||||
List<Job> findWithFilters(LocalDateTime startDate, LocalDateTime endDate, String createdBy, String jobNumberPattern,
|
||||
@Query("{'createdAt': {'$gte': ?0, '$lte': ?1}, "
|
||||
+ "'jobNumber': {'$regex': ?2, '$options': 'i'}, " + "'status': {'$in': ?3}}")
|
||||
List<Job> findWithFilters(LocalDateTime startDate, LocalDateTime endDate, String jobNumberPattern,
|
||||
List<JobStatus> statusList);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user