Skip to content

Commit 4e43bf1

Browse files
authored
Merge pull request #742 from ovh/develop
Release v5.3.0
2 parents 89b107a + ca41a52 commit 4e43bf1

File tree

5 files changed

+72
-3
lines changed

5 files changed

+72
-3
lines changed

packages/apps/workshop/stories/design-system/components/datagrid/datagrid-webcomponent.stories.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,34 @@ export const RowActions = forModule(moduleName).createElement(
269269

270270
RowActions.storyName = 'Row actions';
271271

272+
export const Helper = forModule(moduleName).createElement(
273+
() => compileTemplate(
274+
`
275+
<oui-datagrid
276+
page-size="5"
277+
rows="$ctrl.data">
278+
<oui-datagrid-column title="'First name'" property="firstName" helper="'This is an helper text'"></oui-datagrid-column>
279+
<oui-datagrid-column title="'Last name'" property="lastName"></oui-datagrid-column>
280+
<oui-datagrid-column title="'Email'" property="email"></oui-datagrid-column>
281+
<oui-datagrid-column title="'Phone'" property="phone"></oui-datagrid-column>
282+
<oui-action-menu text="Actions" compact>
283+
<oui-action-menu-item
284+
on-click="$ctrl.onActionClick($row)">
285+
Action
286+
</oui-action-menu-item>
287+
</oui-action-menu>
288+
</oui-datagrid>`,
289+
{
290+
$ctrl: {
291+
data,
292+
onActionClick: action('onActionClick'),
293+
},
294+
},
295+
),
296+
);
297+
298+
Helper.storyName = 'With helper';
299+
272300
export const CustomizableColumnsDisplay = forModule(moduleName).createElement(
273301
() => compileTemplate(
274302
`

packages/components/datagrid/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ angular.module('myModule', ['oui.datagrid'])
2929
| ---- | ---- | ---- | ---- | ---- | ---- | ----
3030
| `id` | string | @? | no | n/a | n/a | id of the datagrid
3131
| `page-size` | number | @? | no | n/a | `25` | maximum number of rows to show on each pages
32-
| `page` | number | @? | no | n/a | `1` | page to display
32+
| `page` | number | @? | no | n/a | `1` | page to display
3333
| `rows` | array | <? | yes | n/a | n/a | local rows to load in the datagrid
3434
| `criteria` | array | <? | yes | n/a | n/a | default filter criteria to apply
3535
| `empty-placeholder` | string | @? | yes | n/a | n/a | custom placeholder text when there is no data
@@ -128,7 +128,7 @@ The template inside the element will be placed at the bottom of each row, making
128128
</oui-datagrid>
129129
```
130130

131-
As many row details can be added as needed
131+
As many row details can be added as needed
132132

133133
```html
134134
<oui-datagrid rows="$ctrl.data">
@@ -350,6 +350,7 @@ These parameters override properties defined in `oui-datagrid-column` or `column
350350
| `type` | string | n/a | no | See below | `string` | define a column type
351351
| `property` | string | n/a | yes | n/a | `null` | property path used to get value from value
352352
| `sortable` | string | n/a | yes | `asc`, `desc` | `asc` | makes a column sortable and gives the order
353+
| `helper` | string | n/a | yes | n/a | null | adds a helper text next to column title
353354
| `filterable` | n/a | n/a | no | n/a | n/a | define a filterable column
354355
| `searchable` | n/a | n/a | no | n/a | n/a | define a searchable column
355356
| `type-options` | object | n/a | no | See below | `{}` | define options related to column type (see below)

packages/components/datagrid/src/js/datagrid-column-builder.service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default class DatagridColumnBuilder {
3939

4040
const column = {
4141
footer: description.footer || getAttribute(element, 'footer'),
42+
helper: getAttribute(element, 'helper'),
4243
hidden: description.hidden || hasAttribute(element, 'hidden'),
4344
name: description.name || getAttribute(element, 'name'),
4445
preventCustomization: description.preventCustomization || hasAttribute(element, 'prevent-customization'),

packages/components/datagrid/src/js/datagrid.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
ng-if="column.sortable"
3636
aria-hidden="true">
3737
</span>
38+
<button
39+
ng-if="!!column.helper"
40+
type="button"
41+
class="oui-popover-button"
42+
oui-popover="{{:: column.helper }}"
43+
oui-popover-placement="right"
44+
></button>
3845
</th>
3946
<th ng-if="$ctrl.hasActionMenu || $ctrl.customizable"
4047
class="oui-datagrid__header oui-datagrid__header_s">

packages/components/datagrid/src/js/datagrid.spec.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('ouiDatagrid', () => {
128128
expect(getCell($firstRow, 2).children().html()).toBe(additionnalDataValue);
129129
}));
130130

131-
it('shoshould display a skeleton when a cell is not loaded', inject(($q) => {
131+
it('should display a skeleton when a cell is not loaded', inject(($q) => {
132132
const deferred = $q.defer();
133133
const loadRowSpy = jasmine.createSpy('loadRow');
134134

@@ -860,6 +860,38 @@ describe('ouiDatagrid', () => {
860860
});
861861
});
862862

863+
describe('Helper popover', () => {
864+
it('should be present if helper text is provided', () => {
865+
const element = TestUtils.compileTemplate(`
866+
<oui-datagrid rows="$ctrl.rows"
867+
columns="$ctrl.columns">
868+
<oui-datagrid-column property="firstName" type="text" helper="Helper text"></oui-datagrid-column>
869+
</oui-datagrid>
870+
`, {
871+
columns: columnsData.columns1,
872+
rows: fakeData.slice(0, 5),
873+
});
874+
875+
const helperPopover = element[0].querySelector('.oui-popover-button');
876+
expect(helperPopover).not.toEqual(null);
877+
});
878+
879+
it('should not be present if helper text is not provided', () => {
880+
const element = TestUtils.compileTemplate(`
881+
<oui-datagrid rows="$ctrl.rows"
882+
columns="$ctrl.columns">
883+
<oui-datagrid-column property="firstName" type="text"></oui-datagrid-column>
884+
</oui-datagrid>
885+
`, {
886+
columns: columnsData.columns1,
887+
rows: fakeData.slice(0, 5),
888+
});
889+
890+
const helperPopover = element[0].querySelector('.oui-popover-button');
891+
expect(helperPopover).toEqual(null);
892+
});
893+
});
894+
863895
describe('Dynamic columns', () => {
864896
it('should update columns list', () => {
865897
const element = TestUtils.compileTemplate(`

0 commit comments

Comments
 (0)