Skip to content

Commit

Permalink
fix for MID-6187 - ignore blank string if it already exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Apr 6, 2020
1 parent 0a325f9 commit 43a7fc9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
Expand Up @@ -108,6 +108,7 @@ protected void populateItem(ListItem<VW> item) {
GuiComponentFactory componentFactory = getPageBase().getRegistry()
.findValuePanelFactory(ItemPanel.this.getModelObject());


Component panel = createValuePanel(item, componentFactory, getVisibilityHandler(), getEditabilityHandler());
// panel.add(getEnableBehaviourOfValuePanel(ItemPanel.this.getModelObject()));
createButtons(item);
Expand Down Expand Up @@ -230,8 +231,10 @@ protected void removeValue(VW valueToRemove, AjaxRequestTarget target) throws Sc
break;
case DELETED:
valueToRemove.setStatus(ValueStatus.NOT_CHANGED);
getModelObject().getItem().add(valueToRemove.getNewValue());
break;
case NOT_CHANGED:
getModelObject().getItem().remove(valueToRemove.getNewValue());
valueToRemove.setStatus(ValueStatus.DELETED);
break;
}
Expand All @@ -248,9 +251,9 @@ protected void removeValue(VW valueToRemove, AjaxRequestTarget target) throws Sc
private int countUsableValues(List<VW> values) {
int count = 0;
for (VW value : values) {
// if (ValueStatus.DELETED.equals(value.getStatus())) {
// continue;
// }
if (ValueStatus.DELETED.equals(value.getStatus())) {
continue;
}
if (ValueStatus.ADDED.equals(value.getStatus())) {
continue;
}
Expand Down
Expand Up @@ -93,6 +93,10 @@ public boolean isVisible() {
return false;
}

if (ValueStatus.DELETED == modelObject.getStatus()) {
return false;
}

ItemWrapper parent = modelObject.getParent();
if (!PrismContainerWrapper.class.isAssignableFrom(parent.getClass())) {
return false;
Expand All @@ -103,10 +107,10 @@ public boolean isVisible() {
}


if (!isShowOnTopLevel() && !((PrismContainerWrapper) parent).isExpanded() && parent.isMultiValue()) {
if (!isShowOnTopLevel() && !((PrismContainerWrapper) parent).isExpanded()) { // && parent.isMultiValue()) {
return false;
}
return true;
return ((PrismContainerWrapper) parent).isExpanded();
}

@Override
Expand Down
Expand Up @@ -40,6 +40,11 @@ public void setRealValue(T newRealValue) {
newRealValue = trimValueIfNeeded(newRealValue);

if (newRealValue == null) {
if (getRealValue() == null) {
//nothing to do, value vas not changed
return;
}

getNewValue().setValue(null);
setStatus(ValueStatus.DELETED);
return;
Expand Down
Expand Up @@ -155,7 +155,7 @@ public void setObject(String object) {
PolyString oldModelObject = getModelObject();
if (oldModelObject != null && (oldModelObject.getTranslation() != null || MapUtils.isNotEmpty(oldModelObject.getLang()))) {
getModel().setObject(new PolyString(object, oldModelObject.getNorm(), oldModelObject.getTranslation(), oldModelObject.getLang()));
} else if (StringUtils.isNotBlank(object)) {
} else if (StringUtils.isNotEmpty(object)) {
getModel().setObject(new PolyString(object));
} else {
getModel().setObject(null);
Expand Down
Expand Up @@ -26,7 +26,9 @@ public TextAreaPanel(String id, IModel<T> model, Integer rowsOverride) {
protected boolean shouldTrimInput() {
return false;
}

};
text.setConvertEmptyInputStringToNull(false);
text.add(AttributeModifier.append("style", "max-width: 100%"));

if (rowsOverride != null) {
Expand Down
Expand Up @@ -51,6 +51,7 @@ public void convertInput() {


};
text.setConvertEmptyInputStringToNull(false);
text.setType(clazz);
add(text);
}
Expand Down

0 comments on commit 43a7fc9

Please sign in to comment.