Search in sources :

Example 1 with HTMLLabelElement

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;
}
Also used : HTMLLabelElement(elemental2.dom.HTMLLabelElement)

Example 2 with HTMLLabelElement

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();
}
Also used : HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLLabelElement(elemental2.dom.HTMLLabelElement) Test(org.junit.Test)

Example 3 with HTMLLabelElement

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);
    }
}
Also used : HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLLabelElement(elemental2.dom.HTMLLabelElement)

Example 4 with HTMLLabelElement

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", "");
}
Also used : HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Mockito.anyString(org.mockito.Mockito.anyString) HTMLLabelElement(elemental2.dom.HTMLLabelElement) Test(org.junit.Test)

Aggregations

HTMLLabelElement (elemental2.dom.HTMLLabelElement)4 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)3 Test (org.junit.Test)2 HTMLDivElement (elemental2.dom.HTMLDivElement)1 Mockito.anyString (org.mockito.Mockito.anyString)1