Skip to content

Commit

Permalink
CAUSEWAY-3833: polishing prev. commits (renaming)
Browse files Browse the repository at this point in the history
  • Loading branch information
andi-huber committed Nov 26, 2024
1 parent 7c15208 commit e749242
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,12 @@ public record SelectOperationChoice(
SelectOperationChoiceKey key,
String translatedTitle,
String cssClass)
implements Serializable{
implements Serializable {

public SelectOperationChoice(
final SelectOperationChoiceKey key,
final String translatedTitle) {
this(key, translatedTitle, "");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.causeway.viewer.wicket.model.tableoption;

import java.util.function.Predicate;

import lombok.RequiredArgsConstructor;

/**
Expand All @@ -38,4 +40,11 @@ public boolean isPageSpecific() {
return this==PAGE_SEL
|| this == PAGE_UNSEL;
}

public static Predicate<SelectOperationChoiceKey> isAvailableWhen(final boolean isTablePaged) {
return (final SelectOperationChoiceKey key)->isTablePaged
? true
: !key.isPageSpecific();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.causeway.viewer.wicket.model.models.interaction.coll.DataRowToggleWkt;
import org.apache.causeway.viewer.wicket.model.models.interaction.coll.DataRowWkt;
import org.apache.causeway.viewer.wicket.ui.components.table.DataTableWithPagesAndFilter;
import org.apache.causeway.viewer.wicket.ui.components.table.nav.pageact.PageActionChooser;
import org.apache.causeway.viewer.wicket.ui.components.table.nav.selop.SelectOperationChooser;
import org.apache.causeway.viewer.wicket.ui.components.widgets.checkbox.ContainedToggleboxPanel;
import org.apache.causeway.viewer.wicket.ui.util.Wkt;

Expand Down Expand Up @@ -60,7 +60,7 @@ protected Component createCellComponent(final String componentId, final DataRowW

@Override
public Component getHeader(final String componentId) {
var pageActionChooser = new PageActionChooser(componentId, table);
var pageActionChooser = new SelectOperationChooser(componentId, table);
Wkt.cssAppend(pageActionChooser, "togglebox-column");
return pageActionChooser;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public List<PagesizeChoice> getPagesizeChoices() {
public List<SelectOperationChoice> getSelectOperationChoices() {
return isRowSelectionEnabled()
? Stream.of(SelectOperationChoiceKey.values())
.filter(key->isPaged() ? true : !key.isPageSpecific())
.map(key->new SelectOperationChoice(key, translate(key.englishTitle), ""))
.filter(SelectOperationChoiceKey.isAvailableWhen(isPaged()))
.map(key->new SelectOperationChoice(key, translate(key.englishTitle)))
.toList()
: Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
<body>
<wicket:panel>
<div class="dropdown">
<button wicket:id="pageActionButton"
<button wicket:id="selectOperationButton"
class="btn btn-sm btn-light dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false">
<i class="fa-regular fa-square"></i>
</button>
<ul class="dropdown-menu" role="menu">
<li wicket:id="pageActionChoices">
<li wicket:id="selectOperationChoices">
<!-- link entry -->
<a href="#" wicket:id="pageActionChoice" class="dropdown-item">
<a href="#" wicket:id="selectOperationChoice" class="dropdown-item">
<span wicket:id="viewItemIcon" class="ViewLinkItem"></span>
<span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[link title]</span>
<span wicket:id="viewItemTitle" class="ViewLinkItemTitle">[select operation title]</span>
</a>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.causeway.viewer.wicket.ui.components.table.nav.pageact;
package org.apache.causeway.viewer.wicket.ui.components.table.nav.selop;

import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.list.ListItem;
Expand All @@ -35,19 +35,19 @@
import lombok.Getter;
import lombok.NonNull;

public class PageActionChooser extends Panel {
public class SelectOperationChooser extends Panel {
private static final long serialVersionUID = 1L;

private static final String ID_PAGE_ACTION_BUTTON = "pageActionButton";
private static final String ID_PAGE_ACTION_CHOICE = "pageActionChoice";
private static final String ID_PAGE_ACTION_CHOICES = "pageActionChoices";
private static final String ID_SELECT_OPERATION_BUTTON = "selectOperationButton";
private static final String ID_SELECT_OPERATION_CHOICE = "selectOperationChoice";
private static final String ID_SELECT_OPERATION_CHOICES = "selectOperationChoices";

private static final String ID_VIEW_ITEM_TITLE = "viewItemTitle";
private static final String ID_VIEW_ITEM_ICON = "viewItemIcon";

@Getter final DataTableWithPagesAndFilter<?, ?> table;

public PageActionChooser(final String id, final DataTableWithPagesAndFilter<?, ?> table) {
public SelectOperationChooser(final String id, final DataTableWithPagesAndFilter<?, ?> table) {
super(id);
this.table = table;
}
Expand All @@ -64,10 +64,10 @@ private void buildGui() {

var selectOperationChoices = table.getSelectOperationChoices();

var button = Wkt.add(this, new Button(ID_PAGE_ACTION_BUTTON));
var button = Wkt.add(this, new Button(ID_SELECT_OPERATION_BUTTON));

Wkt.listViewAdd(this, ID_PAGE_ACTION_CHOICES, selectOperationChoices, item->{
var link = Wkt.linkAdd(item, ID_PAGE_ACTION_CHOICE, target->{
Wkt.listViewAdd(this, ID_SELECT_OPERATION_CHOICES, selectOperationChoices, item->{
var link = Wkt.linkAdd(item, ID_SELECT_OPERATION_CHOICE, target->{
var selectActionChoice = item.getModelObject();
table.executeSelectOperation(selectActionChoice);
target.add(table);
Expand All @@ -82,7 +82,7 @@ private void buildGui() {
if(selectOperationChoices.isEmpty()) {
this.setVisible(false);
} else {
WktTooltips.addTooltip(button, translate("Select actions"));
WktTooltips.addTooltip(button, translate("Select operations"));
}

}
Expand Down

0 comments on commit e749242

Please sign in to comment.