@dhis2-ui/transfer 10.13.0 → 10.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/__e2e__/reorder-with-buttons.e2e.stories.js +15 -4
- package/build/cjs/__tests__/helper/default-filter-callback.test.js +6 -0
- package/build/cjs/__tests__/helper/is-reorder-down-disabled.test.js +50 -11
- package/build/cjs/__tests__/helper/is-reorder-up-disabled.test.js +50 -11
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-down.test.js +65 -11
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-to-bottom.test.js +85 -0
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-to-top.test.js +85 -0
- package/build/cjs/__tests__/helper/move-highlighted-picked-option-up.test.js +65 -11
- package/build/cjs/__tests__/reordering-actions.test.js +104 -0
- package/build/cjs/features/reorder-with-buttons/index.js +70 -2
- package/build/cjs/features/reorder-with-buttons.feature +97 -5
- package/build/cjs/icons.js +53 -13
- package/build/cjs/locales/en/translations.json +7 -0
- package/build/cjs/locales/index.js +21 -0
- package/build/cjs/reordering-actions.js +93 -27
- package/build/cjs/transfer/default-filter-callback.js +17 -6
- package/build/cjs/transfer/get-highlighted-picked-indices.js +34 -0
- package/build/cjs/transfer/index.js +33 -0
- package/build/cjs/transfer/is-reorder-down-disabled.js +19 -8
- package/build/cjs/transfer/is-reorder-up-disabled.js +18 -8
- package/build/cjs/transfer/move-highlighted-picked-option-down.js +23 -6
- package/build/cjs/transfer/move-highlighted-picked-option-to-bottom.js +45 -0
- package/build/cjs/transfer/move-highlighted-picked-option-to-top.js +44 -0
- package/build/cjs/transfer/move-highlighted-picked-option-up.js +21 -6
- package/build/cjs/transfer.js +58 -6
- package/build/cjs/transfer.prod.stories.js +89 -19
- package/build/es/__e2e__/reorder-with-buttons.e2e.stories.js +14 -2
- package/build/es/__tests__/helper/default-filter-callback.test.js +6 -0
- package/build/es/__tests__/helper/is-reorder-down-disabled.test.js +50 -11
- package/build/es/__tests__/helper/is-reorder-up-disabled.test.js +50 -11
- package/build/es/__tests__/helper/move-highlighted-picked-option-down.test.js +65 -11
- package/build/es/__tests__/helper/move-highlighted-picked-option-to-bottom.test.js +83 -0
- package/build/es/__tests__/helper/move-highlighted-picked-option-to-top.test.js +83 -0
- package/build/es/__tests__/helper/move-highlighted-picked-option-up.test.js +65 -11
- package/build/es/__tests__/reordering-actions.test.js +101 -0
- package/build/es/features/reorder-with-buttons/index.js +70 -2
- package/build/es/features/reorder-with-buttons.feature +97 -5
- package/build/es/icons.js +51 -13
- package/build/es/locales/en/translations.json +7 -0
- package/build/es/locales/index.js +13 -0
- package/build/es/reordering-actions.js +94 -28
- package/build/es/transfer/default-filter-callback.js +17 -6
- package/build/es/transfer/get-highlighted-picked-indices.js +27 -0
- package/build/es/transfer/index.js +3 -0
- package/build/es/transfer/is-reorder-down-disabled.js +20 -8
- package/build/es/transfer/is-reorder-up-disabled.js +19 -8
- package/build/es/transfer/move-highlighted-picked-option-down.js +24 -6
- package/build/es/transfer/move-highlighted-picked-option-to-bottom.js +39 -0
- package/build/es/transfer/move-highlighted-picked-option-to-top.js +38 -0
- package/build/es/transfer/move-highlighted-picked-option-up.js +22 -6
- package/build/es/transfer.js +60 -8
- package/build/es/transfer.prod.stories.js +88 -18
- package/package.json +9 -7
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _enzyme = require("enzyme");
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _reorderingActions = require("../reordering-actions.js");
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
8
|
+
const findButton = (wrapper, dataTest) => wrapper.find(`button[data-test="${dataTest}"]`);
|
|
9
|
+
const allButtonHooks = dataTest => [`${dataTest}-buttonmovetotop`, `${dataTest}-buttonmoveup`, `${dataTest}-buttonmovedown`, `${dataTest}-buttonmovetobottom`];
|
|
10
|
+
describe('Transfer - ReorderingActions', () => {
|
|
11
|
+
const dataTest = 'test-reorderingactions';
|
|
12
|
+
const baseProps = {
|
|
13
|
+
dataTest,
|
|
14
|
+
onChangeUp: jest.fn(),
|
|
15
|
+
onChangeDown: jest.fn(),
|
|
16
|
+
onChangeToTop: jest.fn(),
|
|
17
|
+
onChangeToBottom: jest.fn()
|
|
18
|
+
};
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
Object.values(baseProps).forEach(value => {
|
|
21
|
+
if (jest.isMockFunction(value)) {
|
|
22
|
+
value.mockClear();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it('renders all four reorder buttons', () => {
|
|
27
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, baseProps));
|
|
28
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovetotop`)).toHaveLength(1);
|
|
29
|
+
expect(findButton(wrapper, `${dataTest}-buttonmoveup`)).toHaveLength(1);
|
|
30
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovedown`)).toHaveLength(1);
|
|
31
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovetobottom`)).toHaveLength(1);
|
|
32
|
+
});
|
|
33
|
+
it('invokes the corresponding handler for each button', () => {
|
|
34
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, baseProps));
|
|
35
|
+
findButton(wrapper, `${dataTest}-buttonmovetotop`).simulate('click');
|
|
36
|
+
expect(baseProps.onChangeToTop).toHaveBeenCalledTimes(1);
|
|
37
|
+
findButton(wrapper, `${dataTest}-buttonmoveup`).simulate('click');
|
|
38
|
+
expect(baseProps.onChangeUp).toHaveBeenCalledTimes(1);
|
|
39
|
+
findButton(wrapper, `${dataTest}-buttonmovedown`).simulate('click');
|
|
40
|
+
expect(baseProps.onChangeDown).toHaveBeenCalledTimes(1);
|
|
41
|
+
findButton(wrapper, `${dataTest}-buttonmovetobottom`).simulate('click');
|
|
42
|
+
expect(baseProps.onChangeToBottom).toHaveBeenCalledTimes(1);
|
|
43
|
+
});
|
|
44
|
+
it('does not cross-fire handlers when a single button is clicked', () => {
|
|
45
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, baseProps));
|
|
46
|
+
findButton(wrapper, `${dataTest}-buttonmoveup`).simulate('click');
|
|
47
|
+
expect(baseProps.onChangeUp).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(baseProps.onChangeDown).not.toHaveBeenCalled();
|
|
49
|
+
expect(baseProps.onChangeToTop).not.toHaveBeenCalled();
|
|
50
|
+
expect(baseProps.onChangeToBottom).not.toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
it('disables both up-side buttons when disabledUp is true', () => {
|
|
53
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, _extends({}, baseProps, {
|
|
54
|
+
disabledUp: true
|
|
55
|
+
})));
|
|
56
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovetotop`).prop('disabled')).toBe(true);
|
|
57
|
+
expect(findButton(wrapper, `${dataTest}-buttonmoveup`).prop('disabled')).toBe(true);
|
|
58
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovedown`).prop('disabled')).toBeFalsy();
|
|
59
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovetobottom`).prop('disabled')).toBeFalsy();
|
|
60
|
+
});
|
|
61
|
+
it('disables both down-side buttons when disabledDown is true', () => {
|
|
62
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, _extends({}, baseProps, {
|
|
63
|
+
disabledDown: true
|
|
64
|
+
})));
|
|
65
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovedown`).prop('disabled')).toBe(true);
|
|
66
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovetobottom`).prop('disabled')).toBe(true);
|
|
67
|
+
expect(findButton(wrapper, `${dataTest}-buttonmoveup`).prop('disabled')).toBeFalsy();
|
|
68
|
+
expect(findButton(wrapper, `${dataTest}-buttonmovetotop`).prop('disabled')).toBeFalsy();
|
|
69
|
+
});
|
|
70
|
+
it('does not invoke handlers for disabled buttons', () => {
|
|
71
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, _extends({}, baseProps, {
|
|
72
|
+
disabledUp: true,
|
|
73
|
+
disabledDown: true
|
|
74
|
+
})));
|
|
75
|
+
findButton(wrapper, `${dataTest}-buttonmovetotop`).simulate('click');
|
|
76
|
+
findButton(wrapper, `${dataTest}-buttonmoveup`).simulate('click');
|
|
77
|
+
findButton(wrapper, `${dataTest}-buttonmovedown`).simulate('click');
|
|
78
|
+
findButton(wrapper, `${dataTest}-buttonmovetobottom`).simulate('click');
|
|
79
|
+
expect(baseProps.onChangeToTop).not.toHaveBeenCalled();
|
|
80
|
+
expect(baseProps.onChangeUp).not.toHaveBeenCalled();
|
|
81
|
+
expect(baseProps.onChangeDown).not.toHaveBeenCalled();
|
|
82
|
+
expect(baseProps.onChangeToBottom).not.toHaveBeenCalled();
|
|
83
|
+
});
|
|
84
|
+
it('sets aria-label on every button', () => {
|
|
85
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, baseProps));
|
|
86
|
+
const assertLabel = (hook, label) => {
|
|
87
|
+
expect(findButton(wrapper, hook).prop('aria-label')).toBe(label);
|
|
88
|
+
};
|
|
89
|
+
assertLabel(`${dataTest}-buttonmovetotop`, 'Move selected items to top');
|
|
90
|
+
assertLabel(`${dataTest}-buttonmoveup`, 'Move selected items up');
|
|
91
|
+
assertLabel(`${dataTest}-buttonmovedown`, 'Move selected items down');
|
|
92
|
+
assertLabel(`${dataTest}-buttonmovetobottom`, 'Move selected items to bottom');
|
|
93
|
+
});
|
|
94
|
+
it('still renders and wires up all four buttons when filterActive is true', () => {
|
|
95
|
+
const wrapper = (0, _enzyme.mount)(/*#__PURE__*/_react.default.createElement(_reorderingActions.ReorderingActions, _extends({}, baseProps, {
|
|
96
|
+
filterActive: true
|
|
97
|
+
})));
|
|
98
|
+
allButtonHooks(dataTest).forEach(hook => {
|
|
99
|
+
expect(findButton(wrapper, hook)).toHaveLength(1);
|
|
100
|
+
});
|
|
101
|
+
findButton(wrapper, `${dataTest}-buttonmoveup`).simulate('click');
|
|
102
|
+
expect(baseProps.onChangeUp).toHaveBeenCalledTimes(1);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -5,7 +5,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
|
|
|
5
5
|
// no op
|
|
6
6
|
});
|
|
7
7
|
(0, _cypressCucumberPreprocessor.Given)('the selected list has three items', () => {
|
|
8
|
-
cy.visitStory('Transfer Reorder Buttons', 'Has
|
|
8
|
+
cy.visitStory('Transfer Reorder Buttons', 'Has Three Selected');
|
|
9
9
|
});
|
|
10
10
|
(0, _cypressCucumberPreprocessor.Given)('the selected list has some items', () => {
|
|
11
11
|
cy.visitStory('Transfer Reorder Buttons', 'Has Some Selected');
|
|
@@ -36,11 +36,79 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
|
|
|
36
36
|
force: true
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
(0, _cypressCucumberPreprocessor.When)("the user clicks the 'move to top' button", () => {
|
|
40
|
+
// force, so we click disabled buttons
|
|
41
|
+
cy.get('{transfer-reorderingactions-buttonmovetotop}').click({
|
|
42
|
+
force: true
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
(0, _cypressCucumberPreprocessor.When)("the user clicks the 'move to bottom' button", () => {
|
|
46
|
+
// force, so we click disabled buttons
|
|
47
|
+
cy.get('{transfer-reorderingactions-buttonmovetobottom}').click({
|
|
48
|
+
force: true
|
|
49
|
+
});
|
|
50
|
+
});
|
|
39
51
|
(0, _cypressCucumberPreprocessor.Then)('the highlighted item should be moved to the {int}. place', next => {
|
|
40
52
|
const index = next - 1;
|
|
41
53
|
cy.get('@previousValue').then(previousValue => cy.get(`[data-value="${previousValue}"]`)).invoke('index').should('equal', index);
|
|
42
54
|
});
|
|
43
|
-
(0, _cypressCucumberPreprocessor.Then)(
|
|
55
|
+
(0, _cypressCucumberPreprocessor.Then)('all four reorder buttons should be disabled', () => {
|
|
56
|
+
cy.get('{transfer-reorderingactions-buttonmovetotop}').should('have.attr', 'disabled');
|
|
44
57
|
cy.get('{transfer-reorderingactions-buttonmoveup}').should('have.attr', 'disabled');
|
|
45
58
|
cy.get('{transfer-reorderingactions-buttonmovedown}').should('have.attr', 'disabled');
|
|
59
|
+
cy.get('{transfer-reorderingactions-buttonmovetobottom}').should('have.attr', 'disabled');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// --- Multi-select ---
|
|
63
|
+
|
|
64
|
+
(0, _cypressCucumberPreprocessor.Given)('the selected list has eight items', () => {
|
|
65
|
+
cy.visitStory('Transfer Reorder Buttons', 'Has Some Selected');
|
|
66
|
+
cy.get('{transfer-pickedoptions} {transferoption}').should('have.length', 8);
|
|
67
|
+
});
|
|
68
|
+
const highlightPositionWithCtrl = position => cy.get('{transfer-pickedoptions} {transferoption}').eq(position - 1).then($option => cy.get('@highlightedValues').then(values => {
|
|
69
|
+
values.push($option.attr('data-value'));
|
|
70
|
+
return $option;
|
|
71
|
+
})).clickWith('ctrl');
|
|
72
|
+
(0, _cypressCucumberPreprocessor.When)('the user highlights the items at positions {int} and {int}', (first, second) => {
|
|
73
|
+
cy.wrap([]).as('highlightedValues');
|
|
74
|
+
highlightPositionWithCtrl(first);
|
|
75
|
+
highlightPositionWithCtrl(second);
|
|
76
|
+
});
|
|
77
|
+
(0, _cypressCucumberPreprocessor.When)('the user highlights every item in the selected list', () => {
|
|
78
|
+
cy.wrap([]).as('highlightedValues');
|
|
79
|
+
cy.get('{transfer-pickedoptions} {transferoption}').each($option => {
|
|
80
|
+
cy.get('@highlightedValues').then(values => {
|
|
81
|
+
values.push($option.attr('data-value'));
|
|
82
|
+
});
|
|
83
|
+
cy.wrap($option).clickWith('ctrl');
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
(0, _cypressCucumberPreprocessor.Then)('those items should be at positions {int} and {int}', (first, second) => {
|
|
87
|
+
cy.get('@highlightedValues').then(values => {
|
|
88
|
+
const targetIndices = [first - 1, second - 1];
|
|
89
|
+
values.forEach((value, i) => {
|
|
90
|
+
cy.get(`[data-value="${value}"]`).invoke('index').should('equal', targetIndices[i]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
(0, _cypressCucumberPreprocessor.Then)('those items should still be highlighted', () => {
|
|
95
|
+
cy.get('@highlightedValues').then(values => {
|
|
96
|
+
values.forEach(value => {
|
|
97
|
+
cy.get(`{transfer-pickedoptions} [data-value="${value}"]`).should('have.class', 'highlighted');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
const reorderButtonSelectors = {
|
|
102
|
+
'move up': '{transfer-reorderingactions-buttonmoveup}',
|
|
103
|
+
'move down': '{transfer-reorderingactions-buttonmovedown}',
|
|
104
|
+
'move to top': '{transfer-reorderingactions-buttonmovetotop}',
|
|
105
|
+
'move to bottom': '{transfer-reorderingactions-buttonmovetobottom}'
|
|
106
|
+
};
|
|
107
|
+
(0, _cypressCucumberPreprocessor.Then)('the {string} and {string} buttons should be disabled', (first, second) => {
|
|
108
|
+
cy.get(reorderButtonSelectors[first]).should('have.attr', 'disabled');
|
|
109
|
+
cy.get(reorderButtonSelectors[second]).should('have.attr', 'disabled');
|
|
110
|
+
});
|
|
111
|
+
(0, _cypressCucumberPreprocessor.Then)('the {string} and {string} buttons should not be disabled', (first, second) => {
|
|
112
|
+
cy.get(reorderButtonSelectors[first]).should('not.have.attr', 'disabled');
|
|
113
|
+
cy.get(reorderButtonSelectors[second]).should('not.have.attr', 'disabled');
|
|
46
114
|
});
|
|
@@ -35,12 +35,104 @@ Feature: Reorder items in the selected list using buttons
|
|
|
35
35
|
| 2 | 3 |
|
|
36
36
|
| 3 | 3 |
|
|
37
37
|
|
|
38
|
+
Scenario Outline: The user clicks the 'move to top' button with a highlighted item in the selected list
|
|
39
|
+
Given the selected list has three items
|
|
40
|
+
And the <previous>. item is highlighted
|
|
41
|
+
When the user clicks the 'move to top' button
|
|
42
|
+
Then the highlighted item should be moved to the <next>. place
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
| previous | next |
|
|
46
|
+
| 1 | 1 |
|
|
47
|
+
| 2 | 1 |
|
|
48
|
+
| 3 | 1 |
|
|
49
|
+
|
|
50
|
+
Scenario Outline: The user clicks the 'move to bottom' button with a highlighted item in the selected list
|
|
51
|
+
Given the selected list has three items
|
|
52
|
+
And the <previous>. item is highlighted
|
|
53
|
+
When the user clicks the 'move to bottom' button
|
|
54
|
+
Then the highlighted item should be moved to the <next>. place
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
| previous | next |
|
|
58
|
+
| 1 | 3 |
|
|
59
|
+
| 2 | 3 |
|
|
60
|
+
| 3 | 3 |
|
|
61
|
+
|
|
38
62
|
Scenario: Disable reorder buttons when no items are highlighted
|
|
39
63
|
Given the selected list has some items
|
|
40
64
|
And no items are highlighted in the list
|
|
41
|
-
Then
|
|
65
|
+
Then all four reorder buttons should be disabled
|
|
42
66
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
67
|
+
# --- Multi-select ---
|
|
68
|
+
#
|
|
69
|
+
# All four buttons act on the highlighted picked items as a group,
|
|
70
|
+
# preserving the group's relative order. Non-contiguous selections
|
|
71
|
+
# collapse into a contiguous block before landing at the target edge.
|
|
72
|
+
|
|
73
|
+
Scenario: 'move up' shifts a contiguous block of highlighted items up by one slot
|
|
74
|
+
Given the selected list has eight items
|
|
75
|
+
When the user highlights the items at positions 3 and 4
|
|
76
|
+
And the user clicks the 'move up' button
|
|
77
|
+
Then those items should be at positions 2 and 3
|
|
78
|
+
And those items should still be highlighted
|
|
79
|
+
|
|
80
|
+
Scenario: 'move up' collapses and shifts a non-contiguous selection in one press
|
|
81
|
+
Given the selected list has eight items
|
|
82
|
+
When the user highlights the items at positions 2 and 4
|
|
83
|
+
And the user clicks the 'move up' button
|
|
84
|
+
Then those items should be at positions 1 and 2
|
|
85
|
+
|
|
86
|
+
Scenario: 'move down' shifts a contiguous block of highlighted items down by one slot
|
|
87
|
+
Given the selected list has eight items
|
|
88
|
+
When the user highlights the items at positions 2 and 3
|
|
89
|
+
And the user clicks the 'move down' button
|
|
90
|
+
Then those items should be at positions 3 and 4
|
|
91
|
+
|
|
92
|
+
Scenario: 'move down' collapses and shifts a non-contiguous selection in one press
|
|
93
|
+
Given the selected list has eight items
|
|
94
|
+
When the user highlights the items at positions 2 and 4
|
|
95
|
+
And the user clicks the 'move down' button
|
|
96
|
+
Then those items should be at positions 4 and 5
|
|
97
|
+
|
|
98
|
+
Scenario: 'move to top' collapses a non-contiguous selection flush to the top
|
|
99
|
+
Given the selected list has eight items
|
|
100
|
+
When the user highlights the items at positions 3 and 5
|
|
101
|
+
And the user clicks the 'move to top' button
|
|
102
|
+
Then those items should be at positions 1 and 2
|
|
103
|
+
|
|
104
|
+
Scenario: 'move to bottom' collapses a non-contiguous selection flush to the bottom
|
|
105
|
+
Given the selected list has eight items
|
|
106
|
+
When the user highlights the items at positions 2 and 4
|
|
107
|
+
And the user clicks the 'move to bottom' button
|
|
108
|
+
Then those items should be at positions 7 and 8
|
|
109
|
+
|
|
110
|
+
Scenario: The highlighted group stays highlighted after moving, allowing chained presses
|
|
111
|
+
Given the selected list has eight items
|
|
112
|
+
When the user highlights the items at positions 3 and 4
|
|
113
|
+
And the user clicks the 'move up' button
|
|
114
|
+
And the user clicks the 'move up' button
|
|
115
|
+
Then those items should be at positions 1 and 2
|
|
116
|
+
And those items should still be highlighted
|
|
117
|
+
|
|
118
|
+
Scenario: Both up-side buttons are disabled when the highlighted block is flush to the top
|
|
119
|
+
Given the selected list has eight items
|
|
120
|
+
When the user highlights the items at positions 1 and 2
|
|
121
|
+
Then the 'move up' and 'move to top' buttons should be disabled
|
|
122
|
+
And the 'move down' and 'move to bottom' buttons should not be disabled
|
|
123
|
+
|
|
124
|
+
Scenario: Both down-side buttons are disabled when the highlighted block is flush to the bottom
|
|
125
|
+
Given the selected list has eight items
|
|
126
|
+
When the user highlights the items at positions 7 and 8
|
|
127
|
+
Then the 'move down' and 'move to bottom' buttons should be disabled
|
|
128
|
+
And the 'move up' and 'move to top' buttons should not be disabled
|
|
129
|
+
|
|
130
|
+
Scenario: Up-side buttons remain enabled when a non-contiguous selection contains the top item
|
|
131
|
+
Given the selected list has eight items
|
|
132
|
+
When the user highlights the items at positions 1 and 3
|
|
133
|
+
Then the 'move up' and 'move to top' buttons should not be disabled
|
|
134
|
+
|
|
135
|
+
Scenario: All four reorder buttons are disabled when every picked item is highlighted
|
|
136
|
+
Given the selected list has eight items
|
|
137
|
+
When the user highlights every item in the selected list
|
|
138
|
+
Then all four reorder buttons should be disabled
|
package/build/cjs/icons.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.IconRemoveIndividual = exports.IconRemoveAll = exports.IconMoveUp = exports.IconMoveDown = exports.IconAddIndividual = exports.IconAddAll = void 0;
|
|
6
|
+
exports.IconRemoveIndividual = exports.IconRemoveAll = exports.IconMoveUp = exports.IconMoveToTop = exports.IconMoveToBottom = exports.IconMoveDown = exports.IconAddIndividual = exports.IconAddAll = void 0;
|
|
7
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -24,7 +24,7 @@ const IconAddAll = _ref => {
|
|
|
24
24
|
height: "16",
|
|
25
25
|
viewBox: "0 0 16 16",
|
|
26
26
|
"data-test": dataTest,
|
|
27
|
-
fill: disabled ? _uiConstants.theme.disabled :
|
|
27
|
+
fill: disabled ? _uiConstants.theme.disabled : _uiConstants.colors.grey800,
|
|
28
28
|
className: `jsx-${centerButtonStyles.__hash}`
|
|
29
29
|
}, /*#__PURE__*/_react.default.createElement("g", {
|
|
30
30
|
fillRule: "evenodd",
|
|
@@ -54,7 +54,7 @@ const IconAddIndividual = _ref2 => {
|
|
|
54
54
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
55
55
|
className: `jsx-${centerButtonStyles.__hash}` + " " + "centerButton"
|
|
56
56
|
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
57
|
-
fill: disabled ? _uiConstants.theme.disabled :
|
|
57
|
+
fill: disabled ? _uiConstants.theme.disabled : _uiConstants.colors.grey800,
|
|
58
58
|
xmlns: "http://www.w3.org/2000/svg",
|
|
59
59
|
width: "16",
|
|
60
60
|
height: "16",
|
|
@@ -81,7 +81,7 @@ const IconRemoveAll = _ref3 => {
|
|
|
81
81
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
82
82
|
className: `jsx-${centerButtonStyles.__hash}` + " " + "centerButton"
|
|
83
83
|
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
84
|
-
fill: disabled ? _uiConstants.theme.disabled :
|
|
84
|
+
fill: disabled ? _uiConstants.theme.disabled : _uiConstants.colors.grey800,
|
|
85
85
|
width: "16px",
|
|
86
86
|
height: "16px",
|
|
87
87
|
viewBox: "0 0 16 16",
|
|
@@ -118,7 +118,7 @@ const IconRemoveIndividual = _ref4 => {
|
|
|
118
118
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
119
119
|
className: `jsx-${centerButtonStyles.__hash}` + " " + "centerButton"
|
|
120
120
|
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
121
|
-
fill: disabled ? _uiConstants.theme.disabled :
|
|
121
|
+
fill: disabled ? _uiConstants.theme.disabled : _uiConstants.colors.grey800,
|
|
122
122
|
xmlns: "http://www.w3.org/2000/svg",
|
|
123
123
|
width: "16",
|
|
124
124
|
height: "16",
|
|
@@ -144,15 +144,14 @@ const IconMoveDown = _ref5 => {
|
|
|
144
144
|
disabled
|
|
145
145
|
} = _ref5;
|
|
146
146
|
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
147
|
-
fill: disabled ? _uiConstants.
|
|
147
|
+
fill: disabled ? _uiConstants.colors.grey500 : _uiConstants.colors.grey800,
|
|
148
148
|
xmlns: "http://www.w3.org/2000/svg",
|
|
149
149
|
width: "16",
|
|
150
150
|
height: "16",
|
|
151
151
|
viewBox: "0 0 16 16",
|
|
152
152
|
"data-test": dataTest
|
|
153
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
154
|
-
|
|
155
|
-
transform: "matrix(0 1 1 0 0 0)"
|
|
153
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
154
|
+
d: "M13.5303 8.53027L12.4697 7.46973L8.75 11.1895V2H7.25V11.1895L3.53027 7.46973L2.46973 8.53027L8 14.0605L13.5303 8.53027Z"
|
|
156
155
|
}));
|
|
157
156
|
};
|
|
158
157
|
exports.IconMoveDown = IconMoveDown;
|
|
@@ -166,19 +165,60 @@ const IconMoveUp = _ref6 => {
|
|
|
166
165
|
disabled
|
|
167
166
|
} = _ref6;
|
|
168
167
|
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
169
|
-
fill: disabled ? _uiConstants.
|
|
168
|
+
fill: disabled ? _uiConstants.colors.grey500 : _uiConstants.colors.grey800,
|
|
170
169
|
xmlns: "http://www.w3.org/2000/svg",
|
|
171
170
|
width: "16",
|
|
172
171
|
height: "16",
|
|
173
172
|
viewBox: "0 0 16 16",
|
|
174
173
|
"data-test": dataTest
|
|
175
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
176
|
-
|
|
177
|
-
transform: "rotate(-90 8 8)"
|
|
174
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
175
|
+
d: "M13.5303 7.46973L12.4697 8.53027L8.75 4.81055V14H7.25V4.81055L3.53027 8.53027L2.46973 7.46973L8 1.93945L13.5303 7.46973Z"
|
|
178
176
|
}));
|
|
179
177
|
};
|
|
180
178
|
exports.IconMoveUp = IconMoveUp;
|
|
181
179
|
IconMoveUp.propTypes = {
|
|
182
180
|
dataTest: _propTypes.default.string.isRequired,
|
|
183
181
|
disabled: _propTypes.default.bool
|
|
182
|
+
};
|
|
183
|
+
const IconMoveToTop = _ref7 => {
|
|
184
|
+
let {
|
|
185
|
+
dataTest,
|
|
186
|
+
disabled
|
|
187
|
+
} = _ref7;
|
|
188
|
+
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
189
|
+
fill: disabled ? _uiConstants.colors.grey500 : _uiConstants.colors.grey800,
|
|
190
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
191
|
+
width: "16",
|
|
192
|
+
height: "16",
|
|
193
|
+
viewBox: "0 0 16 16",
|
|
194
|
+
"data-test": dataTest
|
|
195
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
196
|
+
d: "M13.5303 10.4697L12.4697 11.5303L8.75 7.81055V14H7.25V7.81055L3.53027 11.5303L2.46973 10.4697L8 4.93945L13.5303 10.4697ZM13.5303 6.46973L12.4697 7.53027L8 3.06055L3.53027 7.53027L2.46973 6.46973L8 0.939453L13.5303 6.46973Z"
|
|
197
|
+
}));
|
|
198
|
+
};
|
|
199
|
+
exports.IconMoveToTop = IconMoveToTop;
|
|
200
|
+
IconMoveToTop.propTypes = {
|
|
201
|
+
dataTest: _propTypes.default.string.isRequired,
|
|
202
|
+
disabled: _propTypes.default.bool
|
|
203
|
+
};
|
|
204
|
+
const IconMoveToBottom = _ref8 => {
|
|
205
|
+
let {
|
|
206
|
+
dataTest,
|
|
207
|
+
disabled
|
|
208
|
+
} = _ref8;
|
|
209
|
+
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
210
|
+
fill: disabled ? _uiConstants.colors.grey500 : _uiConstants.colors.grey800,
|
|
211
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
212
|
+
width: "16",
|
|
213
|
+
height: "16",
|
|
214
|
+
viewBox: "0 0 16 16",
|
|
215
|
+
"data-test": dataTest
|
|
216
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
217
|
+
d: "M13.5303 5.53027L12.4697 4.46973L8.75 8.18945V2H7.25V8.18945L3.53027 4.46973L2.46973 5.53027L8 11.0605L13.5303 5.53027ZM13.5303 9.53027L12.4697 8.46973L8 12.9395L3.53027 8.46973L2.46973 9.53027L8 15.0605L13.5303 9.53027Z"
|
|
218
|
+
}));
|
|
219
|
+
};
|
|
220
|
+
exports.IconMoveToBottom = IconMoveToBottom;
|
|
221
|
+
IconMoveToBottom.propTypes = {
|
|
222
|
+
dataTest: _propTypes.default.string.isRequired,
|
|
223
|
+
disabled: _propTypes.default.bool
|
|
184
224
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Reordering not allowed when filtering list": "Reordering not allowed when filtering list",
|
|
3
|
+
"Move selected items to top": "Move selected items to top",
|
|
4
|
+
"Move selected items up": "Move selected items up",
|
|
5
|
+
"Move selected items down": "Move selected items down",
|
|
6
|
+
"Move selected items to bottom": "Move selected items to bottom"
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
|
|
8
|
+
var _translations = _interopRequireDefault(require("./en/translations.json"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
//------------------------------------------------------------------------------
|
|
11
|
+
// <auto-generated>
|
|
12
|
+
// This code was generated by d2-i18n-generate.
|
|
13
|
+
//
|
|
14
|
+
// Changes to this file may cause incorrect behavior and will be lost if
|
|
15
|
+
// the code is regenerated.
|
|
16
|
+
// </auto-generated>
|
|
17
|
+
//------------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const namespace = 'default';
|
|
20
|
+
_d2I18n.default.addResources('en', namespace, _translations.default);
|
|
21
|
+
var _default = exports.default = _d2I18n.default;
|
|
@@ -7,49 +7,115 @@ exports.ReorderingActions = void 0;
|
|
|
7
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
var _button = require("@dhis2-ui/button");
|
|
10
|
+
var _tooltip = require("@dhis2-ui/tooltip");
|
|
10
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
12
|
var _react = _interopRequireDefault(require("react"));
|
|
12
13
|
var _icons = require("./icons.js");
|
|
14
|
+
var _index = _interopRequireDefault(require("./locales/index.js"));
|
|
13
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
|
+
const filterActiveTooltip = _index.default.t('Reordering not allowed when filtering list');
|
|
14
18
|
const ReorderingActions = _ref => {
|
|
15
19
|
let {
|
|
16
20
|
dataTest,
|
|
17
21
|
disabledDown,
|
|
18
22
|
disabledUp,
|
|
23
|
+
filterActive,
|
|
19
24
|
onChangeUp,
|
|
20
|
-
onChangeDown
|
|
25
|
+
onChangeDown,
|
|
26
|
+
onChangeToTop,
|
|
27
|
+
onChangeToBottom
|
|
21
28
|
} = _ref;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
const moveToTopLabel = _index.default.t('Move selected items to top');
|
|
30
|
+
const moveUpLabel = _index.default.t('Move selected items up');
|
|
31
|
+
const moveDownLabel = _index.default.t('Move selected items down');
|
|
32
|
+
const moveToBottomLabel = _index.default.t('Move selected items to bottom');
|
|
33
|
+
const renderButtons = function () {
|
|
34
|
+
let tooltipHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
36
|
+
"data-test": dataTest
|
|
37
|
+
}, tooltipHandlers, {
|
|
38
|
+
className: _style.default.dynamic([["3663884558", [_uiConstants.spacers.dp4, _uiConstants.spacers.dp8, _uiConstants.spacers.dp8]]]) + " " + (tooltipHandlers && tooltipHandlers.className != null && tooltipHandlers.className || "")
|
|
39
|
+
}), /*#__PURE__*/_react.default.createElement(_button.Button, {
|
|
40
|
+
small: true,
|
|
41
|
+
secondary: true,
|
|
42
|
+
disabled: disabledUp,
|
|
43
|
+
onClick: () => !disabledUp && onChangeToTop(),
|
|
44
|
+
dataTest: `${dataTest}-buttonmovetotop`,
|
|
45
|
+
"aria-label": moveToTopLabel,
|
|
46
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.IconMoveToTop, {
|
|
47
|
+
dataTest: `${dataTest}-iconmovetotop`,
|
|
48
|
+
disabled: disabledUp
|
|
49
|
+
})
|
|
50
|
+
}), /*#__PURE__*/_react.default.createElement(_button.Button, {
|
|
51
|
+
small: true,
|
|
52
|
+
secondary: true,
|
|
53
|
+
disabled: disabledUp,
|
|
54
|
+
onClick: () => !disabledUp && onChangeUp(),
|
|
55
|
+
dataTest: `${dataTest}-buttonmoveup`,
|
|
56
|
+
"aria-label": moveUpLabel,
|
|
57
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.IconMoveUp, {
|
|
58
|
+
dataTest: `${dataTest}-iconmoveup`,
|
|
59
|
+
disabled: disabledUp
|
|
60
|
+
})
|
|
61
|
+
}), /*#__PURE__*/_react.default.createElement(_button.Button, {
|
|
62
|
+
small: true,
|
|
63
|
+
secondary: true,
|
|
64
|
+
disabled: disabledDown,
|
|
65
|
+
onClick: () => !disabledDown && onChangeDown(),
|
|
66
|
+
dataTest: `${dataTest}-buttonmovedown`,
|
|
67
|
+
"aria-label": moveDownLabel,
|
|
68
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.IconMoveDown, {
|
|
69
|
+
dataTest: `${dataTest}-iconmovedown`,
|
|
70
|
+
disabled: disabledDown
|
|
71
|
+
})
|
|
72
|
+
}), /*#__PURE__*/_react.default.createElement(_button.Button, {
|
|
73
|
+
small: true,
|
|
74
|
+
secondary: true,
|
|
75
|
+
disabled: disabledDown,
|
|
76
|
+
onClick: () => !disabledDown && onChangeToBottom(),
|
|
77
|
+
dataTest: `${dataTest}-buttonmovetobottom`,
|
|
78
|
+
"aria-label": moveToBottomLabel,
|
|
79
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.IconMoveToBottom, {
|
|
80
|
+
dataTest: `${dataTest}-iconmovetobottom`,
|
|
81
|
+
disabled: disabledDown
|
|
82
|
+
})
|
|
83
|
+
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
84
|
+
id: "3663884558",
|
|
85
|
+
dynamic: [_uiConstants.spacers.dp4, _uiConstants.spacers.dp8, _uiConstants.spacers.dp8]
|
|
86
|
+
}, [`div.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;margin-inline-start:auto;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;gap:${_uiConstants.spacers.dp4};padding-top:${_uiConstants.spacers.dp8};}`, `div.__jsx-style-dynamic-selector:last-child{padding-bottom:${_uiConstants.spacers.dp8};}`]));
|
|
87
|
+
};
|
|
88
|
+
if (filterActive) {
|
|
89
|
+
return /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
90
|
+
openDelay: 500,
|
|
91
|
+
content: filterActiveTooltip
|
|
92
|
+
}, _ref2 => {
|
|
93
|
+
let {
|
|
94
|
+
onMouseOver,
|
|
95
|
+
onMouseOut,
|
|
96
|
+
onFocus,
|
|
97
|
+
onBlur,
|
|
98
|
+
ref
|
|
99
|
+
} = _ref2;
|
|
100
|
+
return renderButtons({
|
|
101
|
+
ref,
|
|
102
|
+
onMouseOver,
|
|
103
|
+
onMouseOut,
|
|
104
|
+
onFocus,
|
|
105
|
+
onBlur
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return renderButtons();
|
|
47
110
|
};
|
|
48
111
|
exports.ReorderingActions = ReorderingActions;
|
|
49
112
|
ReorderingActions.propTypes = {
|
|
50
113
|
dataTest: _propTypes.default.string.isRequired,
|
|
51
114
|
onChangeDown: _propTypes.default.func.isRequired,
|
|
115
|
+
onChangeToBottom: _propTypes.default.func.isRequired,
|
|
116
|
+
onChangeToTop: _propTypes.default.func.isRequired,
|
|
52
117
|
onChangeUp: _propTypes.default.func.isRequired,
|
|
53
118
|
disabledDown: _propTypes.default.bool,
|
|
54
|
-
disabledUp: _propTypes.default.bool
|
|
119
|
+
disabledUp: _propTypes.default.bool,
|
|
120
|
+
filterActive: _propTypes.default.bool
|
|
55
121
|
};
|
|
@@ -9,10 +9,21 @@ exports.defaultFilterCallback = void 0;
|
|
|
9
9
|
* @param {string} filter
|
|
10
10
|
* @returns {Object[]}
|
|
11
11
|
*/
|
|
12
|
-
const defaultFilterCallback = (options, filter) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const defaultFilterCallback = (options, filter) => {
|
|
13
|
+
if (filter === '') {
|
|
14
|
+
return options;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const regex = new RegExp(filter, 'i');
|
|
18
|
+
return options.filter(_ref => {
|
|
19
|
+
let {
|
|
20
|
+
label
|
|
21
|
+
} = _ref;
|
|
22
|
+
return label.match(regex);
|
|
23
|
+
});
|
|
24
|
+
} catch {
|
|
25
|
+
console.warn('Invalid regex filter:', filter);
|
|
26
|
+
return options;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
18
29
|
exports.defaultFilterCallback = defaultFilterCallback;
|