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 @@
*/
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.model.page.Page;
import org.bonitasoft.web.designer.rendering.GenerationException;
......@@ -42,7 +43,7 @@ public class PagePropertiesBuilder {
Properties properties = new Properties();
properties.put("name", "custompage_" + page.getName());
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("resources", resources.toString());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
......
......@@ -25,7 +25,7 @@ public class Page extends AbstractPage implements HasUUID {
private String uuid;
private String type = "page";
private String description = "Page generated with Bonita UI designer";
private String displayName = "";
private String displayName;
@JsonView({JsonViewLight.class, JsonViewPersistence.class})
public String getType() {
......@@ -57,7 +57,7 @@ public class Page extends AbstractPage implements HasUUID {
@JsonView({JsonViewPersistence.class})
public String getDisplayName() {
return "".equals(displayName) ? this.getName() : displayName;
return displayName;
}
public void setDisplayName(String displayName) {
......
......@@ -4,19 +4,16 @@
<form class="form EditorHeader-editMetadata" name="editMetadata" novalidate>
<div class="modal-body" id="modal-edit-metadata">
<h4 translate>Metadata</h4>
<div class="form-group" ng-class="{'has-error': editMetadata.displayName.$invalid && editMetadata.displayName.$error.required}">
<label class="control-label control-label--required" 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>
<div class="form-group">
<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. If empty, page technical name is used as fallback.' | translate}}" tooltip-placement="right"></i>
<input
name="displayName"
ng-model="ctrl.displayName"
class="form-control"
id="page-displayName"
placeholder="{{ 'Page display name' | translate }}"
maxlength="255"
required/>
<span class="help-block" ng-show="editMetadata.displayName.$invalid
&& editMetadata.displayName.$error.required" translate>Display name is required.</span>
maxlength="255"/>
</div>
<div class="form-group">
<label for="page-description" translate>Description</label>
......
......@@ -133,9 +133,9 @@ describe('editor menu', function() {
var submitButton = $('.modal-footer .btn-primary');
// button disabled when we enter a wrong display name
// button enable when no display name
displayName.clear();
expect(submitButton.isEnabled()).toBeFalsy();
expect(submitButton.isEnabled()).toBeTruthy();
// display name and description are changed
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