Commit 2687d201 authored by benjaminParisel's avatar benjaminParisel Committed by abirembaut

Feat/bs 19121 hide modal container fragment editor (#2577)

* feat(fragment) Remove modal widget into fragment editor

closes [BS-19121](https://bonitasoft.atlassian.net/browse/BS-19121)

* fix cursor on modalContainer widget in fragment editor
parent b7a39171
......@@ -55,3 +55,11 @@
text-align: center;
padding: 3em;
}
.display-widget {
cursor: default;
}
.display-widget > div {
display: none;
}
......@@ -39,7 +39,6 @@
function EditorPaletteCtrl($scope, paletteService) {
var palette = this;
/**
* The palette contains all the widgets that can be added to the page.
*/
......@@ -50,7 +49,7 @@
this.isNarrow = isNarrow;
this.isClosed = isClosed;
this.getIconClassName = getIconClassName;
this.isFragment = isFragment;
resize();
function toggleSection(section) {
......@@ -77,6 +76,10 @@
return palette.currentSection === undefined;
}
function isFragment() {
return $scope.$parent.mode === 'fragment';
}
function getIconClassName(section) {
return 'ui-' + section.name.replace(/ /g, ''); // remove white spaces
}
......
......@@ -17,6 +17,6 @@
<div palette-widget
class="PaletteItem text-center"
ng-repeat="widget in palette.currentSection.widgets | orderBy:'component.order'"
widget="widget">
widget="widget" is-fragment="palette.isFragment()">
</div>
</div>
......@@ -27,6 +27,7 @@
return {
restrict: 'EA',
scope: {
isFragment: '=isFragment',
widget: '='
},
templateUrl: 'js/editor/palette/palette-widget.html',
......
<div uib-tooltip="{{ widget.component.description | translate }}"
<div ng-class="{'display-widget': widget.component.id === 'pbModalContainer' && isFragment }">
<div
uib-tooltip="{{ widget.component.description | translate }}"
tooltip-popup-delay="1000" tooltip-append-to-body="true" tooltip-placement="right"
tooltip-is-open="tooltipIsOpen" ng-mousedown="tooltipIsOpen = !tooltipIsOpen">
<div id="{{ widget.component.id }}" bo-draggable-data="widget" bo-draggable>
<img class="PaletteItem-icon" ng-if="widget.component.icon" ng-src="{{iconData}}" height="20" width="50"/>
<identicon ng-if="!widget.component.icon" name="{{widget.component.id}}" size="30" background-color="[0,0,0,0]"></identicon>
<identicon ng-if="!widget.component.icon" name="{{widget.component.id}}" size="30"
background-color="[0,0,0,0]"></identicon>
<h5 class="PaletteItem-label">{{ widget.component.name }}</h5>
</div>
</div>
</div>
describe('paletteWidget', function() {
describe('paletteWidget', function () {
var $compile, $rootScope, element, directiveScope;
describe('in page, form or layout editor', function () {
beforeEach(angular.mock.module('bonitasoft.designer.editor.palette'));
beforeEach(inject(function(_$compile_, _$rootScope_) {
beforeEach(inject(function (_$compile_, _$rootScope_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
// given an element containing the directive
var template = '<palette-widget widget="widget" ></palette-widget>';
var template = '<palette-widget widget="widget" is-fragment="false"></palette-widget>';
// when compiling with an input
$rootScope.widget = {
component: {
......@@ -20,10 +20,43 @@ describe('paletteWidget', function() {
directiveScope = element.isolateScope();
}));
it('should display the widget in palette', function() {
it('should display the widget in palette', function () {
// then we should have
console.log(element.find('div[bo-draggable]'));
expect(element.find('.display-widget').length).toBe(0);
expect(element.find('div[bo-draggable]').attr('id')).toBe('w-input');
expect(element.text()).toContain('input');
});
it('should display the widget in palette', function () {
// then we should have
expect(element.find('div[bo-draggable]').attr('id')).toBe('w-input');
expect(element.text()).toContain('input');
});
});
describe('in fragment editor', function () {
beforeEach(angular.mock.module('bonitasoft.designer.editor.palette'));
beforeEach(inject(function (_$compile_, _$rootScope_) {
$compile = _$compile_;
$rootScope = _$rootScope_;
// given an element containing the directive
var template = '<palette-widget widget="widget" is-fragment="true"></palette-widget>';
// when compiling with an input
$rootScope.widget = {
component: {
id: 'pbModalContainer',
name: 'Modal container'
}
};
element = $compile(template)($rootScope);
$rootScope.$digest();
directiveScope = element.isolateScope();
}));
it('should hide modalContainer widget in palette in fragment editor', function () {
expect(element.find('.display-widget').length).toBe(1);
});
});
});
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