Fix for the dialog window must not close after save if duplicate exists.
Signed-off-by: Gaurav <gaurav.sahay@in.bosch.com>
This commit is contained in:
@@ -202,9 +202,11 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent implements Se
|
||||
if (HawkbitCommonUtil.isDuplicate(name, version, type)) {
|
||||
uiNotifcation.displayValidationError(
|
||||
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
|
||||
window.setIsDuplicate(Boolean.TRUE);
|
||||
} else {
|
||||
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name,
|
||||
version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
|
||||
window.setIsDuplicate(Boolean.FALSE);
|
||||
if (newBaseSoftwareModule != null) {
|
||||
/* display success message */
|
||||
uiNotifcation.displaySuccess(i18n.get("message.save.success",
|
||||
|
||||
@@ -101,6 +101,8 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
private final List<AbstractField<?>> allComponents;
|
||||
|
||||
private final I18N i18n;
|
||||
|
||||
private boolean isDuplicate;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -137,11 +139,15 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
orginalValues.clear();
|
||||
removeListeners();
|
||||
allComponents.clear();
|
||||
this.saveButton.setEnabled(false);
|
||||
if(!isDuplicate){
|
||||
super.close();
|
||||
orginalValues.clear();
|
||||
removeListeners();
|
||||
allComponents.clear();
|
||||
this.saveButton.setEnabled(false);
|
||||
}else{
|
||||
isDuplicate = Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
private void removeListeners() {
|
||||
@@ -523,4 +529,22 @@ public class CommonDialogWindow extends Window implements Serializable {
|
||||
public void setCancelButtonEnabled(final boolean enabled) {
|
||||
cancelButton.setEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Boolean.TRUE/Boolean.FALSE based on the entity saved in the window already exists.
|
||||
* @return isDuplicate
|
||||
*/
|
||||
public boolean getIsDuplicate() {
|
||||
return isDuplicate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Boolean.TRUE/Boolean.FALSE based on the entity saved in the window already exists.
|
||||
* @param isDuplicate
|
||||
*/
|
||||
public void setIsDuplicate(final boolean isDuplicate) {
|
||||
this.isDuplicate = isDuplicate;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -563,8 +563,10 @@ public abstract class AbstractCreateUpdateTagLayout extends CustomComponent
|
||||
protected Boolean checkIsDuplicate(final Tag existingTag) {
|
||||
if (existingTag != null) {
|
||||
displayValidationError(i18n.get("message.tag.duplicate.check", new Object[] { existingTag.getName() }));
|
||||
window.setIsDuplicate(Boolean.TRUE);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
window.setIsDuplicate(Boolean.FALSE);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,8 +260,10 @@ public abstract class CreateUpdateTypeLayout extends AbstractCreateUpdateTagLayo
|
||||
if (existingType != null) {
|
||||
uiNotification.displayValidationError(
|
||||
i18n.get("message.tag.duplicate.check", new Object[] { existingType.getName() }));
|
||||
window.setIsDuplicate(Boolean.TRUE);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
window.setIsDuplicate(Boolean.FALSE);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@@ -271,13 +273,16 @@ public abstract class CreateUpdateTypeLayout extends AbstractCreateUpdateTagLayo
|
||||
if (existingType instanceof DistributionSetType) {
|
||||
uiNotification.displayValidationError(i18n.get("message.type.key.duplicate.check",
|
||||
new Object[] { ((DistributionSetType) existingType).getKey() }));
|
||||
window.setIsDuplicate(Boolean.TRUE);
|
||||
return Boolean.TRUE;
|
||||
} else if (existingType instanceof SoftwareModuleType) {
|
||||
uiNotification.displayValidationError(i18n.get("message.type.key.swmodule.duplicate.check",
|
||||
new Object[] { ((SoftwareModuleType) existingType).getKey() }));
|
||||
window.setIsDuplicate(Boolean.TRUE);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
window.setIsDuplicate(Boolean.FALSE);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,9 +273,11 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
|
||||
distVersionTextField.addStyleName("v-textfield-error");
|
||||
notificationMessage.displayValidationError(
|
||||
i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() }));
|
||||
window.setIsDuplicate(Boolean.TRUE);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
window.setIsDuplicate(Boolean.FALSE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,8 +201,10 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
|
||||
if (existingTarget != null) {
|
||||
uINotification.displayValidationError(
|
||||
i18n.get("message.target.duplicate.check", new Object[] { newControlllerId }));
|
||||
window.setIsDuplicate(Boolean.TRUE);
|
||||
return false;
|
||||
} else {
|
||||
window.setIsDuplicate(Boolean.FALSE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user