Skip to content

Commit

Permalink
fix(editor) allow empty displayName (#2663)
Browse files Browse the repository at this point in the history
* Use technical name as fallback if displayName is null or empty

Closes UID-30
  • Loading branch information
rbioteau authored and benjaminParisel committed Apr 5, 2019
1 parent 864e1fb commit 6173f6e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -42,7 +43,7 @@ public byte[] build(Page page) throws GenerationException, IOException {
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();
Expand Down
Expand Up @@ -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() {
Expand Down Expand Up @@ -57,7 +57,7 @@ public void setDescription(String description) {

@JsonView({JsonViewPersistence.class})
public String getDisplayName() {
return "".equals(displayName) ? this.getName() : displayName;
return displayName;
}

public void setDisplayName(String displayName) {
Expand Down
11 changes: 4 additions & 7 deletions frontend/app/js/editor/header/metadata-popup.html
Expand Up @@ -4,19 +4,16 @@ <h3 class="modal-title" translate>{{ctrl.page.name}} information</h3>
<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>
Expand Down
4 changes: 2 additions & 2 deletions frontend/test/e2e/spec/editor-menu.spec.js
Expand Up @@ -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();
Expand Down

0 comments on commit 6173f6e

Please sign in to comment.