use of elemental2.dom.HTMLLabelElement in project kie-wb-common by kiegroup.
the class VariableListItemWidgetViewImpl method getBadgeElement.
protected HTMLLabelElement getBadgeElement(String tag) {
final HTMLLabelElement tagLabel = (HTMLLabelElement) document.createElement("label");
tagLabel.textContent = tag;
tagLabel.className = "badge tagBadge tagBadges";
tagLabel.htmlFor = "closeButton";
return tagLabel;
}
use of elemental2.dom.HTMLLabelElement in project kie-wb-common by kiegroup.
the class VariableListItemWidgetTest method testHandleBadgeCloseEvent.
@Test
public void testHandleBadgeCloseEvent() {
VariablesEditorWidgetView.Presenter presenter = mock(VariablesEditorWidgetView.Presenter.class);
widget.setParentWidget(presenter);
HTMLLabelElement tagLabel = mock(HTMLLabelElement.class);
HTMLAnchorElement tagCloseButton = mock(HTMLAnchorElement.class);
elemental2.dom.Event ex = mock(elemental2.dom.Event.class);
ex.type = "SomeType";
widget.setTagSet(new HashSet<>());
widget.handleBadgeCloseEvent("internal", tagLabel, tagCloseButton, ex);
verify(tagLabel, times(1)).remove();
verify(tagCloseButton, times(1)).remove();
// Updated Model
verify(widget, times(1)).notifyModelChanged();
ex.type = "DoNotUpdateModel";
widget.setTagSet(new HashSet<>());
widget.handleBadgeCloseEvent("internal", tagLabel, tagCloseButton, ex);
verify(tagLabel, times(2)).remove();
verify(tagCloseButton, times(2)).remove();
// No New Calls to Updated Model
verify(widget, times(1)).notifyModelChanged();
}
use of elemental2.dom.HTMLLabelElement in project kie-wb-common by kiegroup.
the class VariableListItemWidgetViewImpl method renderTagElementsBadges.
protected void renderTagElementsBadges() {
for (final String tag : tagSet) {
final HTMLLabelElement tagLabel = getBadgeElement(tag);
final HTMLAnchorElement badgeCloseButton = getBadgeCloseButton();
badgeCloseButton.onclick = ex -> {
handleBadgeCloseEvent(tag, tagLabel, badgeCloseButton, ex);
return null;
};
tagLabel.appendChild(badgeCloseButton);
tagsContainer.appendChild(tagLabel);
updateTagCount();
removeButtons.put(tag, badgeCloseButton);
}
}
use of elemental2.dom.HTMLLabelElement in project kie-wb-common by kiegroup.
the class VariableListItemWidgetTest method testSetTags.
@Test
public void testSetTags() {
List<String> tags = Arrays.asList("internal", "input", "customTag");
VariablesEditorWidgetView.Presenter presenter = mock(VariablesEditorWidgetView.Presenter.class);
widget.setParentWidget(presenter);
widget.setTagSet(new HashSet<>());
HTMLLabelElement tagLabel = mock(HTMLLabelElement.class);
HTMLAnchorElement tagCloseButton = mock(HTMLAnchorElement.class);
when(widget.getBadgeElement(anyString())).thenReturn(tagLabel);
when(widget.getBadgeCloseButton()).thenReturn(tagCloseButton);
HTMLDivElement tagsContainer = mock(HTMLDivElement.class);
widget.tagsContainer = tagsContainer;
widget.removeButtons = new HashMap<>();
widget.setTagTypes(tags);
verify(tagNamesComboBox, times(1)).addCustomValueToListBoxValues("customTag", "");
}
Aggregations