Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,9 @@ body .ui-tabs .ui-tabs-panels .ui-tabs-panel {

.shortcut-label {
font-weight: 500;
}

body .ui-menuitem-link {
display: flex;
gap: 0.3em;
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,6 @@
}
}

// Chip
.ui-chip {
background-color: transparent;
color: var(--main-color);
border: 1px solid var(--main-color);
font-size: 16px;
}

// Input fields
.ui-inputfield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,7 @@ public void closeOverview() {

}



public abstract boolean hasPreviousNext() ;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import fr.siamois.domain.services.history.HistoryAuditService;
import fr.siamois.domain.services.vocabulary.ConceptService;
import fr.siamois.domain.services.vocabulary.FieldService;
import fr.siamois.dto.entity.AbstractEntityDTO;
import fr.siamois.dto.entity.PersonDTO;
import fr.siamois.dto.entity.*;
import fr.siamois.ui.bean.dialog.document.DocumentCreationBean;
import fr.siamois.ui.bean.panel.FlowBean;
import fr.siamois.ui.bean.panel.models.panel.AbstractPanel;
Expand Down Expand Up @@ -152,38 +151,70 @@ public void goToPrevious() throws IOException {
/*
Get label of unit to display in breadcrumn
*/
abstract String findLabel(T unit);
public static String findLabel(AbstractEntityDTO unit) {
if(unit instanceof ActionUnitDTO actionUnitDTO) {
return actionUnitDTO.getName();
}
else if(unit instanceof RecordingUnitDTO dto) {
return dto.getFullIdentifier();
}
else if(unit instanceof SpecimenDTO dto) {
return dto.getFullIdentifier();
}
else if(unit instanceof SpatialUnitDTO dto) {
return dto.getName();
}
else {
return "No name";
}
}

protected abstract DefaultMenuItem createRootTypeItem();

/*
Return the command that opens panel for the unit
*/
abstract String getOpenPanelCommand(T unit);
public static String getOpenPanelCommand(AbstractEntityDTO unit, boolean isPanelRoot) {
if (unit == null) {
return null;
}

String path = null;
String method = null;

if (unit instanceof SpatialUnitDTO) {
path = "spatial-unit";
method = "addSpatialUnitToOverview";
} else if (unit instanceof ActionUnitDTO) {
path = "action-unit";
method = "addActionUnitToOverview";
} else if (unit instanceof SpecimenDTO) {
path = "specimen";
method = "addSpecimenToOverview";
} else if (unit instanceof RecordingUnitDTO) {
path = "recording-unit";
method = "addRecordingUnitToOverview";
} else {
return null;
}

if (isPanelRoot) {
return "#{navBean.redirectToBookmarked('/" + path + "/" + unit.getId() + "')}";
}

return "#{flowBean." + method + "(" + unit.getId() + ", focusViewBean.mainPanel, null)}";
}

public List<MenuModel> getAllParentBreadcrumbModels() {

MenuModel breadcrumbModel = new DefaultMenuModel();
breadcrumbModel.getElements().add(createHomeItem());
breadcrumbModel.getElements().add(createRootTypeItem());
T currentUnit = findUnitById(unitId);

if (currentUnit != null) {
breadcrumbModel.getElements().add(createUnitItem(currentUnit));
}

return List.of(breadcrumbModel);
}

protected DefaultMenuItem createHomeItem() {

String instName = flowBean.getSelectedInstitution().getName();
String truncatedName = (instName != null && instName.length() > 23)
? instName.substring(0, 20) + "..."
: instName;

return DefaultMenuItem.builder()
.value(" " + truncatedName)
.id("home")
.icon("bi bi-house")
.command("#{flowBean.redirectToDashboard()}")
Expand All @@ -194,11 +225,30 @@ protected DefaultMenuItem createHomeItem() {
.build();
}

protected DefaultMenuItem createUnitItem(T unit) {
protected String getIcon(AbstractEntityDTO unit) {
if(unit instanceof RecordingUnitDTO) {
return "bi bi-pencil-square";
}
else if(unit instanceof SpatialUnitDTO) {
return "bi bi-geo-alt";
}
else if(unit instanceof ActionUnitDTO) {
return "bi bi-arrow-down-square";
}
else if(unit instanceof SpecimenDTO) {
return "bi bi-bucket";
}
else {
return "";
}
}

public DefaultMenuItem createUnitItem(AbstractEntityDTO unit) {
return DefaultMenuItem.builder()
.value(findLabel(unit))
.id(String.valueOf(unit.getId()))
.command(getOpenPanelCommand(unit))
.command(getOpenPanelCommand(unit, isRoot))
.icon(getIcon(unit))
.update("@this")
.onstart(PF_BUI_CONTENT_SHOW)
.oncomplete(PF_BUI_CONTENT_HIDE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,16 @@ private void findPathsRecursively(Long unitId, List<T> currentPath, List<List<T>
public List<MenuModel> getAllParentBreadcrumbModels() {
List<List<T>> allPaths = findAllParentPathsToRoot();
List<MenuModel> breadcrumbModels = new ArrayList<>();
T currentUnit = findUnitById(unitId);

if (allPaths.isEmpty()) {
MenuModel breadcrumbModel = new DefaultMenuModel();
breadcrumbModel.getElements().add(createHomeItem());
breadcrumbModel.getElements().add(createRootTypeItem());

if (currentUnit != null) {
breadcrumbModel.getElements().add(createUnitItem(currentUnit));
}

breadcrumbModels.add(breadcrumbModel);
} else {
}
else {
for (List<T> path : allPaths) {
MenuModel breadcrumbModel = new DefaultMenuModel();
breadcrumbModel.getElements().add(createHomeItem());
Expand All @@ -84,9 +81,6 @@ public List<MenuModel> getAllParentBreadcrumbModels() {
breadcrumbModel.getElements().add(createUnitItem(unit));
}

if (currentUnit != null) {
breadcrumbModel.getElements().add(createUnitItem(currentUnit));
}

breadcrumbModels.add(breadcrumbModel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,23 +274,9 @@ ActionUnitDTO findUnitById(Long id) {
return actionUnitService.findById(id);
}

@Override
String findLabel(ActionUnitDTO unit) {
return unit.getName();
}


@Override
String getOpenPanelCommand(ActionUnitDTO unit) {

if(isRoot) {
return "#{navBean.redirectToBookmarked('/action-unit/".concat(unit.getId().toString()).concat("')}");
}
else {

return "#{flowBean.addActionUnitToOverview(" + unit.getId() + ", focusViewBean.mainPanel, null)}";
}
}

@Override
public void initForms(boolean forceInit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import fr.siamois.domain.models.form.customfield.CustomFieldInteger;
import fr.siamois.domain.models.form.customform.CustomForm;
import fr.siamois.domain.models.history.RevisionWithInfo;
import fr.siamois.domain.services.form.FormService;
import fr.siamois.domain.services.person.PersonService;
import fr.siamois.domain.services.recordingunit.RecordingUnitService;
import fr.siamois.domain.services.specimen.SpecimenService;
Expand Down Expand Up @@ -215,24 +214,9 @@ RecordingUnitDTO findUnitById(Long id) {
return recordingUnitService.findById(id);
}

@Override
String findLabel(RecordingUnitDTO unit) {
return unit.getFullIdentifier();
}

@Override
String getOpenPanelCommand(RecordingUnitDTO unit) {

if(isRoot) {
return "#{navBean.redirectToBookmarked('/recording-unit/".concat(unit.getId().toString()).concat("')}");
}
else {

return "#{flowBean.addRecordingUnitToOverview(" + unit.getId() + ", focusViewBean.mainPanel, null)}";
}


}

@Override
protected DefaultMenuItem createRootTypeItem()
Expand All @@ -249,8 +233,9 @@ protected DefaultMenuItem createRootTypeItem()

return DefaultMenuItem.builder()
.value(unit.getActionUnit().getName())
.id("allRecordingUnits")
.id("actionUnit")
.command(command)
.icon("bi bi-arrow-down-square")
.update("@this")
.onstart(PF_BUI_CONTENT_SHOW)
.oncomplete(PF_BUI_CONTENT_HIDE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,7 @@ SpatialUnitDTO findUnitById(Long id) {
return spatialUnitService.findById(id);
}

@Override
String findLabel(SpatialUnitDTO unit) {
return unit.getName();
}

@Override
String getOpenPanelCommand(SpatialUnitDTO unit) {

if(isRoot) {
return "#{navBean.redirectToBookmarked('/spatial-unit/".concat(unit.getId().toString()).concat("')}");
}
else {

return "#{flowBean.addSpatialUnitToOverview(" + unit.getId() + ", focusViewBean.mainPanel, null)}";
}
}


@Autowired
Expand Down Expand Up @@ -484,6 +469,8 @@ protected DefaultMenuItem createRootTypeItem()
.build();
}



@Override
public String getPanelTypeClass() {
return "spatial-unit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import fr.siamois.domain.services.specimen.SpecimenService;
import fr.siamois.dto.entity.ConceptDTO;
import fr.siamois.dto.entity.PersonDTO;
import fr.siamois.dto.entity.RecordingUnitDTO;
import fr.siamois.dto.entity.SpecimenDTO;
import fr.siamois.ui.bean.RedirectBean;
import fr.siamois.ui.bean.panel.models.PanelBreadcrumb;
Expand All @@ -20,6 +21,8 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultMenuModel;
import org.primefaces.model.menu.MenuModel;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.ApplicationContext;
Expand Down Expand Up @@ -177,46 +180,54 @@ SpecimenDTO findUnitById(Long id) {
return specimenService.findById(id);
}


@Override
String findLabel(SpecimenDTO unit) {
return unit.getFullIdentifier();
public List<MenuModel> getAllParentBreadcrumbModels() {

MenuModel breadcrumbModel = new DefaultMenuModel();
breadcrumbModel.getElements().add(createHomeItem());

// then add the action
breadcrumbModel.getElements().add(createRootTypeItem());

// then we find the recording unit parent
RecordingUnitDTO ru = recordingUnitService.findById(unit.getRecordingUnit().getId());
breadcrumbModel.getElements().add(createUnitItem(ru));



return List.of(breadcrumbModel);
}

@Override
protected DefaultMenuItem createRootTypeItem() {

String command ;
Long id = unit.getRecordingUnit().getId();

RecordingUnitDTO recordingUnit = recordingUnitService.findById(id);
Long projectId = recordingUnit.getActionUnit().getId();

if(isRoot) {
command = "#{navBean.redirectToBookmarked('/recording-unit/"+id+"')}";
command = "#{navBean.redirectToBookmarked('/action-unit/"+projectId+"')}";
}
else {

command = "#{flowBean.addRecordingUnitToOverview(" + id + ", focusViewBean.mainPanel, 2)}";
command = "#{flowBean.addActionUnitToOverview(" + projectId + ", focusViewBean.mainPanel, 0)}";
}

return DefaultMenuItem.builder()
.value(unit.getRecordingUnit().getFullIdentifier())
.value(recordingUnit.getActionUnit().getFullIdentifier())
.command(command)
.update("@this")
.id("allSpecimen")
.id("rootProject")
.icon("bi bi-arrow-down-square")
.onstart(PF_BUI_CONTENT_SHOW)
.oncomplete(PF_BUI_CONTENT_HIDE)
.process(THIS)
.build();
}

@Override
String getOpenPanelCommand(SpecimenDTO unit) {

if(isRoot) {
return "#{navBean.redirectToBookmarked('/specimen/".concat(unit.getId().toString()).concat("')}");
}
else {

return "#{flowBean.addSpecimenToOverview(" + unit.getId() + ", focusViewBean.mainPanel, null)}";
}
}


@Override
Expand Down
Loading
Loading