FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add Alert support to Form component · patternfly-java/patternfly-java@a2d7821 · GitHub

Commit a2d7821

Browse files
committed
feat: add Alert support to Form component
Add convenience methods to accept Alert directly in addition to FormAlert, wrapping it in a FormAlert automatically.
1 parent 3b24fa1 commit a2d7821

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

  • components/src/main/java/org/patternfly/component/form

‎components/src/main/java/org/patternfly/component/form/Form.java‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
import org.patternfly.component.HasItems;
3131
import org.patternfly.component.RemoveItemHandler;
3232
import org.patternfly.component.UpdateItemHandler;
33+
import org.patternfly.component.alert.Alert;
3334
import org.patternfly.style.Modifiers.Horizontal;
3435

3536
import elemental2.dom.HTMLFormElement;
3637

3738
import static org.jboss.elemento.Elements.failSafeRemoveFromParent;
3839
import static org.jboss.elemento.Elements.insertFirst;
40+
import static org.patternfly.component.form.FormAlert.formAlert;
3941
import static org.patternfly.style.Classes.component;
4042
import static org.patternfly.style.Classes.form;
4143
import static org.patternfly.style.Classes.limitWidth;
@@ -97,10 +99,46 @@ public Form add(FormGroup item) {
9799
return aur.added(item);
98100
}
99101

102+
/**
103+
* Adds an alert to the form. The alert will be displayed in the context of the form, allowing the user to see
104+
* context-specific notifications or warnings.
105+
*
106+
* @param alert the alert to be added to the form
107+
* @return the updated form instance with the added alert
108+
*/
109+
public Form addAlert(Alert alert) {
110+
return add(alert);
111+
}
112+
113+
/**
114+
* Adds an alert to the form. This method integrates the specified alert into the form's structure, allowing it to be
115+
* displayed within the form for user visibility and context-specific notifications or warnings.
116+
*
117+
* @param alert the alert to be added to the form
118+
* @return the updated instance of the form after adding the alert
119+
*/
120+
public Form add(Alert alert) {
121+
return add(formAlert().addAlert(alert));
122+
}
123+
124+
/**
125+
* Adds a {@link FormAlert} to the form. The alert will be displayed within the form, allowing for context-specific
126+
* notifications or warnings to be presented to the user.
127+
*
128+
* @param alert the {@link FormAlert} to be added to the form
129+
* @return the updated {@link Form} instance with the added alert
130+
*/
100131
public Form addAlert(FormAlert alert) {
101132
return add(alert);
102133
}
103134

135+
/**
136+
* Adds a {@link FormAlert} to this form. The alert will be displayed within the form, providing context-specific
137+
* notifications or warnings to the user.
138+
*
139+
* @param alert the {@link FormAlert} to be added to the form
140+
* @return the updated {@link Form} instance with the added alert
141+
*/
104142
public Form add(FormAlert alert) {
105143
alerts.add(alert);
106144
insertFirst(element(), alert.element());

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL