Skip to content

Commit

Permalink
apply wcag rules for reference property
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Dec 21, 2023
1 parent 7ae1bad commit da5a277
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<span wicket:id="required" style="color: #f00; font-weight: bold;" wicket:message="title:prismPropertyPanel.required">*</span>
<wicket:enclosure child="help">
<span class="btn btn-tool">
<i wicket:id="help" tabindex="0" wicket:message="aria-label:ItemHeaderPanel.helpTooltip"/>
<i wicket:id="help" tabindex="0"/>
</span>
</wicket:enclosure>
<wicket:enclosure child="deprecated">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ private void createHelpText() {
help.add(AttributeModifier.replace("title", createStringResource(helpModel.getObject() != null ? helpModel.getObject() : "")));
help.add(new InfoTooltipBehavior());
help.add(new VisibleBehaviour(this::isHelpTextVisible));
help.add(AttributeAppender.append(
"aria-label",
getPageBase().createStringResource("ItemHeaderPanel.helpTooltip", createLabelModel().getObject())));
add(help);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,8 @@ public ItemPanelSettings getSettings() {
public Collection<Component> getComponentsToUpdate() {
return Collections.singleton(this);
}

protected final ListView<VW> getValuesContainer() {
return (ListView<VW>) get(createComponentPath(ID_VALUES_CONTAINER, ID_VALUES));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
*/
package com.evolveum.midpoint.gui.impl.prism.panel;

import com.evolveum.midpoint.web.component.form.ValueChoosePanel;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper;
Expand All @@ -18,6 +23,8 @@
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.util.exception.SchemaException;

import org.apache.wicket.util.visit.IVisitor;

/**
* @author katka
*/
Expand All @@ -33,6 +40,41 @@ public PrismReferencePanel(String id, IModel<PrismReferenceWrapper<R>> model, It
super(id, model, settings);
}

@Override
protected void onBeforeRender() {
super.onBeforeRender();

ItemHeaderPanel header = getHeader();
if (header == null || header.getLabelComponent() == null) {
return;
}

ListView<PrismReferenceValueWrapperImpl<R>> listOfValues = getValuesContainer();
listOfValues.visitChildren(ListItem.class, (IVisitor<ListItem, Void>) (item, visit) -> {
PrismReferenceValuePanel valuePanel = (PrismReferenceValuePanel) item.get(ID_VALUE);
Component inputPanel = valuePanel == null ? null : valuePanel.getValuePanel();
if (inputPanel instanceof ValueChoosePanel) {
((ValueChoosePanel)inputPanel).getBaseFormComponent()
.add(AttributeAppender.append(
"aria-label",
getPageBase().createStringResource(
"PrismReferencePanel.readOnlyText", getHeader().createLabelModel().getObject())));
((ValueChoosePanel)inputPanel).getEditButton()
.add(AttributeAppender.append(
"aria-label",
getPageBase().createStringResource(
"PrismReferencePanel.editButtonTitle", getHeader().createLabelModel().getObject())));
} else if (valuePanel != null) {
valuePanel.visitChildren(
FormComponent.class,
(IVisitor<FormComponent, Void>) (component, visitInput) -> component.add(
AttributeAppender.append(
"aria-labelledby",
getHeader().getLabelComponent().getMarkupId())));
}
});
}

@Override
protected ItemHeaderPanel createHeaderPanel() {
return new PrismReferenceHeaderPanel<R>(ID_HEADER, getModel()) {
Expand Down Expand Up @@ -78,4 +120,12 @@ private boolean isLink(PrismReferenceWrapper<R> iw) {
protected <PV extends PrismValue> PV createNewValue(PrismReferenceWrapper<R> itemWrapper) {
return (PV) getPrismContext().itemFactory().createReferenceValue();
}

private PrismReferenceHeaderPanel getHeader() {
return (PrismReferenceHeaderPanel) get(ID_HEADER);
}

private PrismReferenceValuePanel getValue() {
return (PrismReferenceValuePanel) getValuesContainer().get(ID_VALUE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<wicket:message key="PageBase.button.edit" />
</button>
</span>
<input type="text" class="form-control form-control-sm" wicket:id="text" disabled style="cursor: not-allowed; background: #eeeeee;"/>
<input type="text" class="form-control form-control-sm" wicket:id="text" readonly style="cursor: not-allowed; background: #eeeeee;"/>

</div>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,8 @@ protected <O extends ObjectType> void choosePerformedHook(AjaxRequestTarget targ
public FormComponent<String> getBaseFormComponent() {
return (FormComponent<String>) getTextWrapperComponent().get(ID_TEXT);
}

public AjaxLink getEditButton() {
return (AjaxLink)getTextWrapperComponent().get(ID_EDIT);
}
}

0 comments on commit da5a277

Please sign in to comment.