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