Skip to content

Commit

Permalink
Fix for Submit button not enabled on ComboBox value change (#2162)
Browse files Browse the repository at this point in the history
Signed-off-by: ct-ajovanovic <aleksandra.jovanovic@comtrade.com>
  • Loading branch information
ct-ajovanovic authored and muros-ct committed Nov 8, 2018
1 parent 1151195 commit bf94c32
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void loadCredential() {
credentialStatus.setToolTip(MSGS.dialogAddStatusApiKeyTooltip());
} else if (selectedCredential.getCredentialTypeEnum() == GwtCredentialType.PASSWORD) {
passwordTooltip.show();
DialogUtils.resizeDialog(CredentialEditDialog.this, 400, 335);
DialogUtils.resizeDialog(CredentialEditDialog.this, 400, 355);
expirationDate.setToolTip(MSGS.dialogAddFieldExpirationDatePasswordTooltip());
credentialStatus.setToolTip(MSGS.dialogAddStatusPasswordTooltip());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public void createBody() {

@Override
public void handleEvent(BaseEvent be) {
formPanel.fireEvent(Events.OnClick);
}
AccessRoleAddDialog.this.formPanel.fireEvent(Events.OnClick);
}
});

GWT_ROLE_SERVICE.findAll(currentSession.getAccountId(), new AsyncCallback<List<GwtRole>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
package org.eclipse.kapua.app.console.module.device.client.connection;

import com.extjs.gxt.ui.client.data.ListLoadResult;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
Expand Down Expand Up @@ -75,6 +78,14 @@ public void createBody() {
FormLayout layoutSecurityOptions = new FormLayout();
layoutSecurityOptions.setLabelWidth(Constants.LABEL_WIDTH_DEVICE_FORM);

Listener<BaseEvent> comboBoxListener = new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent be) {
formPanel.fireEvent(Events.OnClick);
}
};

lastUserField = new LabelField();
lastUserField.setName("connectionUserLastUserField");
lastUserField.setLabelSeparator(":");
Expand Down Expand Up @@ -113,6 +124,7 @@ public void createBody() {
reservedUserCombo.setDisplayField("username");
reservedUserCombo.setTemplate("<tpl for=\".\"><div role=\"listitem\" class=\"x-combo-list-item\" title={username}>{username}</div></tpl>");
reservedUserCombo.setValueField("id");
reservedUserCombo.addListener(Events.Select, comboBoxListener);

if (currentSession.hasPermission(UserSessionPermission.read())) {
// Device User
Expand Down Expand Up @@ -238,6 +250,7 @@ private void setReservedUser() {
}
} else if (gwtUser.getId().equals(selectedDeviceConnection.getReservedUserId())) {
reservedUserCombo.setValue(gwtUser);
break;
} else {
reservedUserCombo.setValue(NO_USER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
package org.eclipse.kapua.app.console.module.device.client.device;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
Expand Down Expand Up @@ -126,6 +129,14 @@ protected void generateBody() {
// formPanel.setStyleAttribute("padding-bottom", "0px");
// formPanel.setLayout(new FlowLayout());

Listener<BaseEvent> comboBoxListener = new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent be) {
DeviceAddDialog.this.formPanel.fireEvent(Events.OnClick);
}
};

// Device general info fieldset
FieldSet fieldSet = new FieldSet();
FormLayout layout = new FormLayout();
Expand Down Expand Up @@ -190,6 +201,7 @@ protected void generateBody() {
groupCombo.setTemplate("<tpl for=\".\"><div role=\"listitem\" class=\"x-combo-list-item\" title={groupName}>{groupName}</div></tpl>");
groupCombo.setValueField("id");
groupCombo.setEmptyText(DEVICE_MSGS.deviceFilteringPanelGroupEmptyText());
groupCombo.addListener(Events.Select, comboBoxListener);

gwtGroupService.findAll(currentSession.getSelectedAccountId(), new AsyncCallback<List<GwtGroup>>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void onFailure(Throwable caught) {

@Override
public void onSuccess(GwtGroup result) {
groupCombo.setValue(result);
setAccessGroup();
}
});
} else {
Expand All @@ -152,4 +152,18 @@ public void onSuccess(GwtGroup result) {
}
formPanel.clearDirtyFields();
}

private void setAccessGroup() {
for (GwtGroup gwtGroup : groupCombo.getStore().getModels()) {
if (gwtGroup.getId() == null) {
if (selectedDevice.getGroupId() == null) {
groupCombo.setValue(gwtGroup);
}
} else if (gwtGroup.getId().equals(selectedDevice.getGroupId())) {
groupCombo.setValue(gwtGroup);
break;
}
}
formPanel.clearDirtyFields();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*******************************************************************************/
package org.eclipse.kapua.app.console.module.device.client.device.tag;

import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
Expand Down Expand Up @@ -101,6 +104,13 @@ public void createBody() {
submitButton.disable();

FormPanel formPanel = new FormPanel(FORM_LABEL_WIDTH);
Listener<BaseEvent> comboBoxListener = new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent be) {
DeviceTagAddDialog.this.formPanel.fireEvent(Events.OnClick);
}
};

//
// Tags
Expand All @@ -116,6 +126,7 @@ public void createBody() {
tagsCombo.setTriggerAction(TriggerAction.ALL);
tagsCombo.setDisplayField("tagName");
tagsCombo.setTemplate("<tpl for=\".\"><div role=\"listitem\" class=\"x-combo-list-item\" title={tagName}>{tagName}</div></tpl>");
tagsCombo.addListener(Events.Select, comboBoxListener);

GWT_TAG_SERVICE.findAll(selectedDevice.getScopeId(), new AsyncCallback<List<GwtTag>>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ public void createBody() {
HorizontalPanel endsOnPanel = new HorizontalPanel();
endsOnPanel.setStyleAttribute("padding", "4px 0px 4px 0px");

Listener<BaseEvent> listener = new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent be) {
formPanel.fireEvent(Events.OnClick);
}
};

triggerName.setAllowBlank(false);
triggerName.setMaxLength(255);
triggerName.setFieldLabel("* " + JOB_MSGS.dialogAddScheduleScheduleNameLabel());
Expand All @@ -103,13 +111,7 @@ public void createBody() {
startsOn.setEmptyText(JOB_MSGS.dialogAddScheduleDatePlaceholder());
startsOn.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
startsOn.setToolTip(JOB_MSGS.dialogAddScheduleStartsOnTooltip());
startsOn.getDatePicker().addListener(Events.Select, new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent be) {
formPanel.fireEvent(Events.OnClick);
}
});
startsOn.getDatePicker().addListener(Events.Select, listener);
startsOnLabel.setText("* " + JOB_MSGS.dialogAddScheduleStartsOnLabel());
startsOnLabel.setWidth(FORM_LABEL_WIDTH);
startsOnLabel.setStyleAttribute("padding", "0px 91px 0px 0px");
Expand All @@ -125,6 +127,7 @@ public void handleEvent(BaseEvent be) {
startsOnTime.setEmptyText(JOB_MSGS.dialogAddScheduleTimePlaceholder());
startsOnTime.setToolTip(JOB_MSGS.dialogAddScheduleStartsOnTimeTooltip());
startsOnTime.setTriggerAction(TriggerAction.ALL);
startsOnTime.addListener(Events.Select, listener);
startsOnPanel.add(startsOnTime);
mainPanel.add(startsOnPanel);

Expand All @@ -136,13 +139,7 @@ public void handleEvent(BaseEvent be) {
endsOnLabel.setText("* " + JOB_MSGS.dialogAddScheduleEndsOnLabel());
endsOnLabel.setWidth(FORM_LABEL_WIDTH);
endsOnLabel.setStyleAttribute("padding", "0px 96px 0px 0px");
endsOn.getDatePicker().addListener(Events.Select, new Listener<BaseEvent>() {

@Override
public void handleEvent(BaseEvent be) {
formPanel.fireEvent(Events.OnClick);
}
});
endsOn.getDatePicker().addListener(Events.Select, listener);
endsOnPanel.add(endsOnLabel);
endsOnPanel.add(endsOn);

Expand All @@ -154,6 +151,7 @@ public void handleEvent(BaseEvent be) {
endsOnTime.setEmptyText(JOB_MSGS.dialogAddScheduleTimePlaceholder());
endsOnTime.setToolTip(JOB_MSGS.dialogAddScheduleEndsOnTimeTooltip());
endsOnTime.setTriggerAction(TriggerAction.ALL);
endsOnTime.addListener(Events.Select, listener);
endsOnPanel.add(endsOnTime);
mainPanel.add(endsOnPanel);

Expand Down

0 comments on commit bf94c32

Please sign in to comment.