Commit a8a4c00f authored by Julien's avatar Julien

Merge pull request #1682 from bonitasoft/feat/home-page-search

Add search box in home page to search in artifact names
parents a21a83f3 b40b5403
(function() {
'use strict';
angular
.module('bonitasoft.designer.home')
.directive('homeFilters', homeFilters);
function homeFilters() {
return {
scope: {
filters: '='
},
templateUrl: 'js/home/home-filters.html'
};
}
})();
<form class="col-xs-4 col-xs-offset-8" role="search">
<div class="form-group">
<input type="text" ng-model="filters.name" class="Home-SearchBox form-control" placeholder="Search">
</div>
</form>
......@@ -40,7 +40,7 @@
</p>
<ul class="ArtifactList">
<li class="ArtifactList-item ArtifactList-item--primary" ng-repeat="page in pages | orderBy:'-lastUpdate'">
<li class="ArtifactList-item ArtifactList-item--primary" ng-repeat="page in pages | filter:filters | orderBy:'-lastUpdate'">
<div class="Artifact-info">
<a ng-if="!page.isEditingName" ui-sref="designer.page({id: page.id})" class="Artifact-link Artifact-link--primary">
<span title="{{ page.name }}">
......
......@@ -34,7 +34,7 @@
</p>
<ul class="ArtifactList">
<li class="ArtifactList-item" ng-repeat="widget in widgets | orderBy:'name'">
<li class="ArtifactList-item" ng-repeat="widget in widgets | filter:filters | orderBy:'name'">
<div class="Artifact-info">
<a ui-sref="designer.widget({ widgetId: widget.id })" class="Artifact-link ">
<span title="{{ widget.name }}">
......
......@@ -18,6 +18,7 @@
angular.module('bonitasoft.designer.home').controller('HomeCtrl', function($scope, $state, $modal, $q, $timeout, $injector, pageRepo, widgetRepo, customWidgetFactory) {
$scope.pages = [];
$scope.widgets = [];
$scope.filters = {};
pageRepo.all().then(function(pages) {
$scope.pages = pages;
......
<home-header></home-header>
<div class="container container--Home">
<div class="row">
<home-filters filters="filters"></home-filters>
</div>
<div class="row row--Home">
<section class="col-sm-7 col--Home" id="pages">
<home-pages></home-pages>
......
export default class Home {
static get() {
browser.get('#/');
return new Home();
}
getListedPageNames() {
return $$('home-pages .Artifact-info').map((element) => element.getText());
}
getListedWidgetNames() {
return $$('home-widgets .Artifact-info').map((element) => element.getText());
}
search(term) {
$('input.Home-SearchBox').clear().sendKeys(term);
}
}
var HomePage = require('../pages/home.page.js');
describe('home page', function() {
var home;
beforeEach(function() {
browser.get('#/');
home = HomePage.get();
});
it('should list pages and widgets', function() {
expect(home.getListedPageNames()).toEqual(['Person', 'empty']);
expect(home.getListedWidgetNames()).toEqual(['awesomeWidget']);
});
it('should navigate to a page', function() {
......@@ -161,4 +170,18 @@ describe('home page', function() {
expect($('.modal-header .modal-title').getText()).toBe('Help');
});
it('should filter widgets and pages by name', function() {
home.search('nowidgetAndnopagesHasANameLikeThat');
expect(home.getListedPageNames()).toEqual([]);
expect(home.getListedWidgetNames()).toEqual([]);
home.search('so'); // 'so' is contained by 'PerSOn' and 'aweSOmeWidget'
expect(home.getListedPageNames()).toEqual(['Person']);
expect(home.getListedWidgetNames()).toEqual(['awesomeWidget']);
home.search('');
expect(home.getListedPageNames()).toEqual(['Person', 'empty']);
expect(home.getListedWidgetNames()).toEqual(['awesomeWidget']);
});
});
......@@ -4,12 +4,20 @@ describe('UI designer: home', function() {
var pagePath = path.resolve(__dirname, '../../fixtures/page-testImport.zip');
var widgetPath = path.resolve(__dirname, '../../fixtures/widget-testImport.zip');
function getListedPages() {
return element.all(by.css('home-pages .Artifact-info'));
}
function getListedWidgets() {
return element.all(by.css('home-widgets .Artifact-info'));
}
beforeEach(function() {
browser.get('/designer/#/en/home');
});
it('should list pages', function() {
var elements = element.all(by.repeater("page in pages | orderBy:'-lastUpdate'"));
var elements = getListedPages();
expect(elements.count()).toBeGreaterThan(0);
});
......@@ -18,7 +26,7 @@ describe('UI designer: home', function() {
var input = $('.file-upload-input');
var upload = element(by.partialButtonText('Import'));
var modal = $('.modal');
var pages = element.all(by.repeater("page in pages | orderBy:'-lastUpdate'"));
var pages = getListedPages();
var nbPages;
......@@ -58,7 +66,7 @@ describe('UI designer: home', function() {
browser.waitForAngular();
expect(modal.isPresent()).toBe(false);
pages = element.all(by.repeater("page in pages | orderBy:'-lastUpdate'"));
pages = getListedPages();
pages.count().then(function(nb) {
expect(nb).toEqual(nbPages);
});
......@@ -70,7 +78,7 @@ describe('UI designer: home', function() {
});
it('should list widgets', function() {
var elements = element.all(by.repeater("widget in widgets | orderBy:'name'"));
var elements = getListedWidgets();
expect(elements.count()).toBeGreaterThan(0);
});
......@@ -80,7 +88,7 @@ describe('UI designer: home', function() {
var input = $('.file-upload-input');
var upload = element(by.partialButtonText('Import'));
var modal = $('.modal');
var widgets = element.all(by.repeater("widget in widgets | orderBy:'name'"));
var widgets = getListedWidgets();
var nbWidgets;
......
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