Skip to content

Commit

Permalink
Merge pull request #4310 from effective-webwork/gallery-context-menu
Browse files Browse the repository at this point in the history
Make the contextMenu in StructurePanel und in GalleryPanel identical
  • Loading branch information
Kathrin-Huber authored Apr 20, 2021
2 parents 76dc5a1 + fba9d5c commit 61f0b53
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class AddDocStrucTypeDialog {
private boolean linkSubDialogVisible = false;
private static final String PREVIEW_MODE = "preview";
private static final String LIST_MODE = "list";
private TreeNode previouslySelectedLogicalNode;

/**
* Backing bean for the add doc struc type dialog of the metadata editor.
Expand Down Expand Up @@ -408,6 +409,7 @@ private void sortMetadataList(List<SelectItem> itemList) {
*/
public void prepare() {
elementsToAddSpinnerValue = 1;
checkSelectedLogicalNode();
Optional<IncludedStructuralElement> selectedStructure = dataEditor.getSelectedStructure();
if (selectedStructure.isPresent()) {
this.parents = MetadataEditor.getAncestorsOfStructure(selectedStructure.get(),
Expand All @@ -422,6 +424,20 @@ public void prepare() {
prepareSelectPageOnAddNodeItems();
}

private void checkSelectedLogicalNode() {
//If a view is selected in logical tree then the 'selectedLogicalNode' will be set to the parent of this view
TreeNode selectedLogicalNode = dataEditor.getStructurePanel().getSelectedLogicalNode();
if (Objects.nonNull(selectedLogicalNode) && selectedLogicalNode.getData() instanceof StructureTreeNode) {
StructureTreeNode structureTreeNode = (StructureTreeNode) selectedLogicalNode.getData();
if (structureTreeNode.getDataObject() instanceof View) {
if (Objects.nonNull(selectedLogicalNode.getParent())) {
previouslySelectedLogicalNode = selectedLogicalNode;
dataEditor.getStructurePanel().setSelectedLogicalNode(selectedLogicalNode.getParent());
}
}
}
}

/**
* Update lists of available doc struct types that can be added to the currently selected structure element in the
* currently selected position.
Expand Down Expand Up @@ -647,6 +663,10 @@ public void resetValues() {
selectFirstPageOnAddNodeSelectedItem = null;
selectLastPageOnAddNodeSelectedItem = null;
docStructPositionSelectionSelectedItem = LAST_CHILD_OF_CURRENT_ELEMENT;
if (Objects.nonNull(previouslySelectedLogicalNode)) {
dataEditor.getStructurePanel().setSelectedLogicalNode(previouslySelectedLogicalNode);
previouslySelectedLogicalNode = null;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void setProcess(Process process) {
*
* @return value of selectedMedia
*/
List<Pair<MediaUnit, IncludedStructuralElement>> getSelectedMedia() {
public List<Pair<MediaUnit, IncludedStructuralElement>> getSelectedMedia() {
return selectedMedia;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ public void assign() {
dataEditor.assignView(includedStructuralElement, viewToAssign, 0);
severalAssignments.add(viewToAssign.getMediaUnit());
show();
dataEditor.getSelectedMedia().clear();
dataEditor.getGalleryPanel().updateStripes();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
oncomplete="updateMetadataEditorView(true);"/>
<p:commandButton value="#{msgs.cancel}"
icon="fa fa-times fa-lg"
action="#{DataEditorForm.addDocStrucTypeDialog.resetValues}"
iconPos="secondary"
styleClass="secondary right"
onclick="PF('dialogAddDocStrucType').hide();"/>
oncomplete="PF('dialogAddDocStrucType').hide();"/>
</h:panelGroup>

<!-- submit buttons for linking processes -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
imagePreviewForm:mediaViewData
logicalTree
physicalTree
metadataAccordion:logicalMetadataWrapperPanel
paginationForm:paginationWrapperPanel"/>
paginationForm:paginationWrapperPanel
imagePreviewForm:stripeContextMenu
imagePreviewForm:mediaContextMenu
metadataAccordion:logicalMetadataWrapperPanel"/>
<p:remoteCommand name="setGalleryViewMode"
action="#{DataEditorForm.galleryPanel.setGalleryViewMode}"
update="imagePreviewForm galleryHeadingWrapper"
Expand Down Expand Up @@ -357,8 +359,34 @@
oncomplete="PF('dialogAddDocStrucType').show()"
update="dialogAddDocStrucTypeDialog">
<f:actionListener binding="#{DataEditorForm.addDocStrucTypeDialog.preparePreselectedViews()}"/>
<f:actionListener binding="#{DataEditorForm.structurePanel.setSelectedLogicalNode(DataEditorForm.structurePanel.logicalTree.children.get(DataEditorForm.structurePanel.logicalTree.childCount - 1))}"/>
</p:menuitem>
<p:menuitem value="#{msgs.assignToNextElement}"
icon="fa fa-link fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignableSeveralTimes and
DataEditorForm.selectedMedia.size() eq 1}"
action="#{DataEditorForm.structurePanel.assign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() == 1}"
action="#{DataEditorForm.structurePanel.unassign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
</p:contextMenu>
<p:contextMenu id="stripeContextMenu"
widgetVar="stripeContextMenu"
Expand All @@ -371,6 +399,14 @@
actionListener="#{DataEditorForm.addDocStrucTypeDialog.resetValues}"
oncomplete="PF('dialogAddDocStrucType').show()"
update="dialogAddDocStrucTypeDialog"/>
<p:menuitem value="#{msgs.changeDocstructType}"
icon="fa fa-pencil fa-sm"
styleClass="plain"
disabled="#{readOnly}"
actionListener="#{DataEditorForm.changeDocStrucTypeDialog.prepare}"
process="@this"
oncomplete="PF('dialogEditDocStrucType').show()"
update="dialogEditDocStrucTypeDialog"/>
<p:menuitem value="#{msgs.removeElement}"
icon="fa fa-trash fa-sm"
styleClass="plain"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
Expand All @@ -37,6 +38,8 @@
contextMenuLogicalTree
physicalTree
paginationForm:paginationWrapperPanel
imagePreviewForm:stripeContextMenu
imagePreviewForm:mediaContextMenu
metadataAccordion:logicalMetadataWrapperPanel"/>
<p:ajax event="contextMenu"
listener="#{DataEditorForm.structurePanel.treeLogicalSelect}"
Expand All @@ -54,7 +57,8 @@
update="logicalTree
contextMenuLogicalTree
metadataAccordion:logicalMetadataWrapperPanel
@(.pageList)"/>
@(.pageList)
imagePreviewForm:mediaContextMenu"/>
<p:ajax event="collapse"
listener="#{DataEditorForm.structurePanel.onNodeCollapse}"/>
<p:ajax event="expand"
Expand All @@ -73,15 +77,17 @@
</p:treeNode>
</p:tree>
<p:contextMenu for="logicalTree" id="contextMenuLogicalTree" widgetVar="contextMenuLogicalTree">
<p:menuitem value="#{msgs.addElement}"
<p:menuitem value="#{msgs.addElement} #{DataEditorForm.selectedMedia.size() ge 1 ? msgs.assignMedia : ''}"
icon="fa fa-plus fa-sm"
styleClass="plain"
disabled="#{readOnly}"
action="#{DataEditorForm.addDocStrucTypeDialog.prepare}"
actionListener="#{DataEditorForm.addDocStrucTypeDialog.resetValues}"
process="@this"
oncomplete="PF('dialogAddDocStrucType').show()"
update="dialogAddDocStrucTypeDialog"/>
update="dialogAddDocStrucTypeDialog">
<f:actionListener binding="#{DataEditorForm.addDocStrucTypeDialog.preparePreselectedViews()}"/>
</p:menuitem>
<p:menuitem value="#{msgs.changeDocstructType}"
rendered="#{DataEditorForm.structurePanel.selectedLogicalNode.data.dataObject['class'].simpleName ne 'View'}"
icon="fa fa-pencil fa-sm"
Expand All @@ -102,7 +108,8 @@
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)"/>
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
Expand All @@ -114,7 +121,8 @@
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)"/>
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.removeElement}"
rendered="#{DataEditorForm.structurePanel.selectedLogicalNode.data.dataObject['class'].simpleName ne 'View'}"
icon="fa fa-trash fa-sm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@
actionListener="#{DataEditorForm.addMediaUnitDialog.prepare}"
oncomplete="PF('dialogAddMediaUnit').show()"
update="dialogAddMediaUnitForm"/>
<p:menuitem value="#{msgs.assignToNextElement}"
icon="fa fa-link fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignableSeveralTimes and not
DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() eq 1}"
action="#{DataEditorForm.structurePanel.assign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() == 1}"
action="#{DataEditorForm.structurePanel.unassign}"
process="@this"
oncomplete="$('#loadingScreen').hide()"
update="logicalTree
paginationForm:paginationWrapperPanel
metadataAccordion:logicalMetadataWrapperPanel
@(.structureElementDataList)
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.removeElement}"
rendered="#{DataEditorForm.structurePanel.selectedPhysicalNode.data.dataObject.type ne 'page'}"
icon="fa fa-trash fa-sm"
Expand Down

0 comments on commit 61f0b53

Please sign in to comment.