Commit 6173f6e9 authored by Romain Bioteau's avatar Romain Bioteau Committed by benjaminparisel

fix(editor) allow empty displayName (#2663)

* Use technical name as fallback if displayName is null or empty

Closes UID-30
parent 864e1fb9
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
package org.bonitasoft.web.designer.controller.export.properties; package org.bonitasoft.web.designer.controller.export.properties;
import org.apache.commons.lang3.StringUtils;
import org.bonitasoft.web.designer.controller.PageResource; import org.bonitasoft.web.designer.controller.PageResource;
import org.bonitasoft.web.designer.model.page.Page; import org.bonitasoft.web.designer.model.page.Page;
import org.bonitasoft.web.designer.rendering.GenerationException; import org.bonitasoft.web.designer.rendering.GenerationException;
...@@ -42,7 +43,7 @@ public class PagePropertiesBuilder { ...@@ -42,7 +43,7 @@ public class PagePropertiesBuilder {
Properties properties = new Properties(); Properties properties = new Properties();
properties.put("name", "custompage_" + page.getName()); properties.put("name", "custompage_" + page.getName());
properties.put("contentType", String.valueOf(page.getType()).toLowerCase(Locale.ENGLISH)); properties.put("contentType", String.valueOf(page.getType()).toLowerCase(Locale.ENGLISH));
properties.put("displayName", page.getDisplayName()); properties.put("displayName", StringUtils.isBlank(page.getDisplayName())? page.getName() : page.getDisplayName());
properties.put("description", page.getDescription()); properties.put("description", page.getDescription());
properties.put("resources", resources.toString()); properties.put("resources", resources.toString());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
......
...@@ -25,7 +25,7 @@ public class Page extends AbstractPage implements HasUUID { ...@@ -25,7 +25,7 @@ public class Page extends AbstractPage implements HasUUID {
private String uuid; private String uuid;
private String type = "page"; private String type = "page";
private String description = "Page generated with Bonita UI designer"; private String description = "Page generated with Bonita UI designer";
private String displayName = ""; private String displayName;
@JsonView({JsonViewLight.class, JsonViewPersistence.class}) @JsonView({JsonViewLight.class, JsonViewPersistence.class})
public String getType() { public String getType() {
...@@ -57,7 +57,7 @@ public class Page extends AbstractPage implements HasUUID { ...@@ -57,7 +57,7 @@ public class Page extends AbstractPage implements HasUUID {
@JsonView({JsonViewPersistence.class}) @JsonView({JsonViewPersistence.class})
public String getDisplayName() { public String getDisplayName() {
return "".equals(displayName) ? this.getName() : displayName; return displayName;
} }
public void setDisplayName(String displayName) { public void setDisplayName(String displayName) {
......
...@@ -4,19 +4,16 @@ ...@@ -4,19 +4,16 @@
<form class="form EditorHeader-editMetadata" name="editMetadata" novalidate> <form class="form EditorHeader-editMetadata" name="editMetadata" novalidate>
<div class="modal-body" id="modal-edit-metadata"> <div class="modal-body" id="modal-edit-metadata">
<h4 translate>Metadata</h4> <h4 translate>Metadata</h4>
<div class="form-group" ng-class="{'has-error': editMetadata.displayName.$invalid && editMetadata.displayName.$error.required}"> <div class="form-group">
<label class="control-label control-label--required" for="page-displayName" translate>Display name</label> <label class="control-label" for="page-displayName" translate>Display name</label>
<i class="fa fa-info-circle" uib-tooltip="{{'Used in the portal list of Resources. Part of the page.properties descriptor in the exported page archive.' | translate}}" tooltip-placement="right"></i> <i class="fa fa-info-circle" uib-tooltip="{{'Used in the portal list of Resources. Part of the page.properties descriptor in the exported page archive. If empty, page technical name is used as fallback.' | translate}}" tooltip-placement="right"></i>
<input <input
name="displayName" name="displayName"
ng-model="ctrl.displayName" ng-model="ctrl.displayName"
class="form-control" class="form-control"
id="page-displayName" id="page-displayName"
placeholder="{{ 'Page display name' | translate }}" placeholder="{{ 'Page display name' | translate }}"
maxlength="255" maxlength="255"/>
required/>
<span class="help-block" ng-show="editMetadata.displayName.$invalid
&& editMetadata.displayName.$error.required" translate>Display name is required.</span>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="page-description" translate>Description</label> <label for="page-description" translate>Description</label>
......
...@@ -133,9 +133,9 @@ describe('editor menu', function() { ...@@ -133,9 +133,9 @@ describe('editor menu', function() {
var submitButton = $('.modal-footer .btn-primary'); var submitButton = $('.modal-footer .btn-primary');
// button disabled when we enter a wrong display name // button enable when no display name
displayName.clear(); displayName.clear();
expect(submitButton.isEnabled()).toBeFalsy(); expect(submitButton.isEnabled()).toBeTruthy();
// display name and description are changed // display name and description are changed
displayName.clear(); displayName.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment