Commit 48488d11 authored by DMyTryC's avatar DMyTryC Committed by benjaminParisel

Adding an implementation for showing that a modal error exists on top of page...

Adding an implementation for showing that a modal error exists on top of page during runtime (#2563)

* Adding the show error on the top of the editor
parent 31a6b43b
......@@ -202,7 +202,11 @@ public abstract class AbstractPage extends DesignerArtifact implements Previewab
}
@JsonView({JsonViewLight.class, JsonViewPersistence.class})
public boolean hasValidationError() { return hasValidationError; }
public boolean getHasValidationError() {
return hasValidationError;
}
public void setHasValidationError(boolean hasValidationError) { this.hasValidationError = hasValidationError; }
public void setHasValidationError(boolean hasValidationError) {
this.hasValidationError = hasValidationError;
}
}
......@@ -18,13 +18,13 @@ import static java.lang.String.format;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonView;
import org.bonitasoft.web.designer.model.JsonViewLight;
import org.bonitasoft.web.designer.model.JsonViewPersistence;
import org.bonitasoft.web.designer.visitor.ElementVisitor;
......@@ -38,6 +38,8 @@ public abstract class Element {
private Map<String, PropertyValue> propertyValues = new HashMap<>();
private String reference;
private boolean hasValidationError = false;
public Element() {
this.dimension.put("xs", 12);
}
......@@ -90,4 +92,13 @@ public abstract class Element {
private String stringifyColumn(String prefix, Integer size) {
return size == null ? "" : format("col-%s-%d ", prefix, size);
}
@JsonView({JsonViewLight.class, JsonViewPersistence.class})
public boolean getHasValidationError() {
return hasValidationError;
}
public void setHasValidationError(boolean hasValidationError) {
this.hasValidationError = hasValidationError;
}
}
......@@ -20,7 +20,7 @@
.module('bonitasoft.designer.common.repositories')
.factory('Repository', repositoryService);
function repositoryService($http) {
function repositoryService($http, componentUtils) {
class Repository {
constructor(type, baseUrl) {
......@@ -50,6 +50,9 @@
* @return {Boolean}
*/
needSave(artifact) {
if (artifact && artifact.hasValidationError) {
artifact.hasValidationError = componentUtils.hasModalContainingModal(artifact);
}
return angular.toJson(artifact) !== this.lastSavedState;
}
......
......@@ -41,6 +41,10 @@
</form>
<open-preview on-open-preview="vm.save(vm.page)" mode="{{vm.mode}}" artifact-id="vm.page.id"
is-disabled="!formName.$valid || vm.isPageDirty(vm.page)"></open-preview>
<div ng-if="vm.page.hasValidationError" uib-tooltip="{{ 'Validation error on the page. Fix is recommended before export' | translate }}" tooltip-placement="bottom" tooltip-popup-delay="300" style="margin-left:10px">
<i class="fa fa-times-circle" style="color:red;"></i>
<translate>Validation Errors</translate>
</div>
<save-indicator class="EditorHeader-saveIndicator"></save-indicator>
</div>
<div class="EditorHeader-resolutions">
......
......@@ -154,7 +154,6 @@
if (modalInParents && container.type === 'modalContainer') {
return true;
}
// We normalize container and tabs container into an array of rows
// For tabs, we merge rows of each tabs container
var rows = container.rows ||
......
......@@ -107,6 +107,6 @@ angular.module('bonitasoft.designer.editor.whiteboard').controller('ContainerDir
};
$scope.hasModalContainingModal = function(container) {
return componentUtils.hasModalContainingModal(container) && container.type === 'modalContainer';
return container && container.type === 'modalContainer' && componentUtils.hasModalContainingModal(container);
};
});
......@@ -119,13 +119,6 @@
margin-bottom: 10px;
}
.error {
.modal-element,
.fragment-element{
border-color: @btn-bonita-primary-bg;
}
}
.component-element--hover {
border-color: @widget-hover-color;
transition: opacity .3s ease;
......@@ -243,6 +236,13 @@
color: @widget-active-color;
}
.error-icon {
.error {
.modal-element,
.fragment-element{
border-color: @btn-bonita-primary-bg;
}
}
.error-icon, .modal-element .error-icon {
color: @btn-bonita-primary-bg;
}
describe('widgetRepo', function() {
var widgetRepo, $httpBackend;
beforeEach(angular.mock.module('bonitasoft.designer.common.repositories'));
beforeEach(angular.mock.module('bonitasoft.designer.common.repositories', 'bonitasoft.designer.editor.whiteboard'));
beforeEach(inject(function(_$httpBackend_, _widgetRepo_) {
widgetRepo = _widgetRepo_;
$httpBackend = _$httpBackend_;
......
......@@ -8,7 +8,7 @@ describe('CustomWidgetEditorCtrl', function() {
id: 'awesomeCustomWidget'
};
beforeEach(angular.mock.module('bonitasoft.designer.custom-widget', 'mock.modal'));
beforeEach(angular.mock.module('bonitasoft.designer.custom-widget', 'mock.modal', 'bonitasoft.designer.editor.whiteboard'));
beforeEach(inject(function($rootScope, $controller, $timeout, _$q_, _widgetRepo_, _alerts_, _$uibModal_, $uibModalInstance, _$state_, _browserHistoryService_) {
$scope = $rootScope.$new();
......
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