@kineticdata/bundle-queue 5.0.15 → 5.0.18

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.
@@ -0,0 +1,251 @@
1
+ import React from 'react';
2
+ import { compose, withHandlers, withProps, withState } from 'recompose';
3
+ import { connect } from '../../redux/store';
4
+ import { actions } from '../../redux/modules/queue';
5
+ import { selectAssignmentTeams, mapTeamsToAssignments } from '../../redux/modules/queueApp';
6
+ import { BulkAssignModal } from './BulkAssignModal';
7
+ import { BulkWorkModal } from './BulkWorkModal';
8
+ import { BulkStatusModal } from './BulkStatusModal';
9
+ import { UncontrolledTooltip } from 'reactstrap';
10
+ import { I18n } from '@kineticdata/react';
11
+ import { addToast } from '@kineticdata/bundle-common';
12
+ import { Map, Set } from 'immutable';
13
+ import classNames from 'classnames';
14
+ export var QueueListSelectionComponent = function QueueListSelectionComponent(_ref) {
15
+ var selectedList = _ref.selectedList,
16
+ toggleSelectionMode = _ref.toggleSelectionMode,
17
+ toggleSelectedItem = _ref.toggleSelectedItem,
18
+ assignUnavailable = _ref.assignUnavailable,
19
+ assignTooltip = _ref.assignTooltip,
20
+ workHidden = _ref.workHidden,
21
+ workUnavailable = _ref.workUnavailable,
22
+ workTooltip = _ref.workTooltip,
23
+ action = _ref.action,
24
+ toggleAssign = _ref.toggleAssign,
25
+ handleAssignSubmit = _ref.handleAssignSubmit,
26
+ toggleWork = _ref.toggleWork,
27
+ handleWorkSubmit = _ref.handleWorkSubmit,
28
+ assignments = _ref.assignments,
29
+ isMobile = _ref.isMobile,
30
+ refresh = _ref.refresh;
31
+ return /*#__PURE__*/React.createElement("div", {
32
+ className: "queue-controls"
33
+ }, /*#__PURE__*/React.createElement("div", {
34
+ className: "queue-controls__selection"
35
+ }, /*#__PURE__*/React.createElement("div", {
36
+ className: "details"
37
+ }, /*#__PURE__*/React.createElement("div", null, selectedList.size, ' ', /*#__PURE__*/React.createElement(I18n, null, "Item".concat(selectedList.size !== 1 ? 's' : '', " Selected")))), /*#__PURE__*/React.createElement("div", {
38
+ className: "buttons d-flex"
39
+ }, /*#__PURE__*/React.createElement("button", {
40
+ id: "bulk-assign-btn",
41
+ type: "button",
42
+ className: classNames('btn btn-icon', {
43
+ 'text-danger unavailable': assignUnavailable
44
+ }),
45
+ onClick: toggleAssign,
46
+ "aria-label": "Assign Selected Items",
47
+ disabled: selectedList.size === 0
48
+ }, /*#__PURE__*/React.createElement("span", {
49
+ className: "icon"
50
+ }, /*#__PURE__*/React.createElement("span", {
51
+ className: "fa fa-fw fa-share-square-o"
52
+ })), !isMobile && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(I18n, null, "Assign"))), assignTooltip && !isMobile && /*#__PURE__*/React.createElement(UncontrolledTooltip, {
53
+ placement: "top",
54
+ target: "bulk-assign-btn",
55
+ delay: 0,
56
+ trigger: "hover focus"
57
+ }, /*#__PURE__*/React.createElement(I18n, null, assignTooltip)), !workHidden && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
58
+ id: "bulk-work-btn",
59
+ type: "button",
60
+ className: classNames('btn btn-icon', {
61
+ 'text-danger unavailable': workUnavailable
62
+ }),
63
+ onClick: toggleWork,
64
+ "aria-label": "Work Selected Items",
65
+ disabled: selectedList.size === 0
66
+ }, /*#__PURE__*/React.createElement("span", {
67
+ className: "icon"
68
+ }, /*#__PURE__*/React.createElement("span", {
69
+ className: "fa fa-fw fa-pencil-square-o"
70
+ })), !isMobile && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(I18n, null, "Work"))), workTooltip && !isMobile && /*#__PURE__*/React.createElement(UncontrolledTooltip, {
71
+ placement: "top",
72
+ target: "bulk-work-btn",
73
+ delay: 0,
74
+ trigger: "hover focus"
75
+ }, /*#__PURE__*/React.createElement(I18n, null, workTooltip))), /*#__PURE__*/React.createElement("div", {
76
+ className: "ml-1 mr-2 border-right",
77
+ "aria-hidden": "true"
78
+ }), /*#__PURE__*/React.createElement("button", {
79
+ type: "button",
80
+ className: "btn btn-icon",
81
+ onClick: toggleSelectionMode,
82
+ "aria-label": "Cancel Selection Mode"
83
+ }, /*#__PURE__*/React.createElement("span", {
84
+ className: "icon"
85
+ }, /*#__PURE__*/React.createElement("span", {
86
+ className: "fa fa-fw fa-times"
87
+ }))))), action === 'assign' && /*#__PURE__*/React.createElement(BulkAssignModal, {
88
+ toggle: toggleAssign,
89
+ handleSubmit: handleAssignSubmit,
90
+ message: assignTooltip,
91
+ assignments: assignments
92
+ }), action === 'work' && /*#__PURE__*/React.createElement(BulkWorkModal, {
93
+ toggle: toggleWork,
94
+ handleSubmit: handleWorkSubmit,
95
+ message: workTooltip
96
+ }), /*#__PURE__*/React.createElement(BulkStatusModal, {
97
+ refresh: refresh
98
+ }));
99
+ };
100
+
101
+ var mapStateToProps = function mapStateToProps(state, props) {
102
+ return {
103
+ profile: state.app.profile,
104
+ selectedList: state.queue.selectedList,
105
+ forms: state.queueApp.forms,
106
+ teams: state.queueApp.allTeams,
107
+ isMobile: state.app.layoutSize === 'small'
108
+ };
109
+ };
110
+
111
+ var mapDispatchToProps = {
112
+ toggleSelectionMode: actions.toggleSelectionMode,
113
+ toggleSelectedItem: actions.toggleSelectedItem,
114
+ bulkAssign: actions.bulkAssignRequest,
115
+ bulkWork: actions.bulkWorkRequest
116
+ };
117
+ export var QueueListSelection = compose(connect(mapStateToProps, mapDispatchToProps), withProps(function (props) {
118
+ // Create default additional props
119
+ var addProps = {
120
+ assignUnavailable: false,
121
+ assignTooltip: null,
122
+ workHidden: true,
123
+ workUnavailable: false,
124
+ workTooltip: null,
125
+ assignments: []
126
+ }; // Calculate whether the assign button is available
127
+
128
+ if (props.selectedList.size > 0) {
129
+ // Create a unique list of form and Assigned Team pairs, and calculate the
130
+ // teams that the items can be assigned to.
131
+ var teamsPerUniqueItem = props.selectedList.reduce(function (map, item) {
132
+ var key = "".concat(item.form.slug, "_").concat(item.values['Assigned Team']);
133
+
134
+ if (!map.has(key)) {
135
+ return map.set(key, item);
136
+ }
137
+
138
+ return map;
139
+ }, Map()).map(function (item) {
140
+ return selectAssignmentTeams(props.teams, item.form, item);
141
+ }).toList(); // If there aren't any teams that all selected items can be assigned to,
142
+ // prevent the assign action.
143
+
144
+ if (!props.teams.some(function (team) {
145
+ return teamsPerUniqueItem.every(function (assignmentTeams) {
146
+ return assignmentTeams.find(function (at) {
147
+ return at.name === team.name;
148
+ });
149
+ });
150
+ })) {
151
+ addProps.assignUnavailable = true;
152
+ addProps.assignTooltip = 'There are no valid teams that all the selected items can be assigned to.';
153
+ } // If the set of available teams for each item isn't the same, show a
154
+ // warning message that the avialable assignment will be limited
155
+ else if (teamsPerUniqueItem.map(function (teams) {
156
+ return teams.map(function (team) {
157
+ return team.name;
158
+ }).sort().join('_');
159
+ }).some(function (teamString, i, iter) {
160
+ return teamString !== iter.get(0);
161
+ })) {
162
+ addProps.assignTooltip = 'The available assignments for the selected items will be limited due to assignment restrictions of some of the selected items.';
163
+ } // Set the available assignments for the itnersection set of available teams
164
+
165
+
166
+ addProps.assignments = mapTeamsToAssignments(props.teams.filter(function (team) {
167
+ return teamsPerUniqueItem.every(function (assignmentTeams) {
168
+ return assignmentTeams.find(function (at) {
169
+ return at.name === team.name;
170
+ });
171
+ });
172
+ })).toJS();
173
+ } // Calculate whether the work button is available
174
+
175
+
176
+ if (props.selectedList.size > 0) {
177
+ // Get a set of unique forms from the selected items
178
+ var uniqueSelectedForms = Set(props.selectedList.map(function (item) {
179
+ return item.form.slug;
180
+ }).toList()); // If all items are for a single form, get the from
181
+
182
+ var selectedForm = uniqueSelectedForms.size === 1 && props.selectedList.first().form; // Show work button if any of the selected items support bulk operations
183
+
184
+ if (!!props.selectedList.find(function (item) {
185
+ return item.form && item.form.fields && item.form.fields.some(function (field) {
186
+ return field.name === 'Bulk Action';
187
+ });
188
+ })) {
189
+ addProps.workHidden = false; // If multiple forms have been selected, prevent the work action.
190
+
191
+ if (!selectedForm) {
192
+ addProps.workUnavailable = true;
193
+ addProps.workTooltip = 'All selected items must be from the same form, and the form must support bulk work actions.';
194
+ } // If the selected items aren't all assigned to me, prevent the work action.
195
+ else if (props.selectedList.some(function (item) {
196
+ return item.values['Assigned Individual'] !== props.profile.username;
197
+ })) {
198
+ addProps.workUnavailable = true;
199
+ addProps.workTooltip = 'The selected items must all be assigned to you.';
200
+ }
201
+ }
202
+ }
203
+
204
+ return addProps;
205
+ }), withState('action', 'setAction', null), withHandlers({
206
+ toggleAssign: function toggleAssign(props) {
207
+ return function () {
208
+ if (props.selectedList.size > 0) {
209
+ if (!props.assignUnavailable) {
210
+ props.setAction(props.action === 'assign' ? null : 'assign');
211
+ } else if (props.assignTooltip && props.isMobile) {
212
+ addToast({
213
+ severity: 'danger',
214
+ message: props.assignTooltip
215
+ });
216
+ }
217
+ }
218
+ };
219
+ },
220
+ toggleWork: function toggleWork(props) {
221
+ return function () {
222
+ if (props.selectedList.size > 0) {
223
+ if (!props.workUnavailable) {
224
+ props.setAction(props.action === 'work' ? null : 'work');
225
+ } else if (props.workTooltip && props.isMobile) {
226
+ addToast({
227
+ severity: 'danger',
228
+ message: props.workTooltip
229
+ });
230
+ }
231
+ }
232
+ };
233
+ }
234
+ }), withHandlers({
235
+ handleAssignSubmit: function handleAssignSubmit(props) {
236
+ return function (assignment) {
237
+ props.toggleAssign();
238
+ props.bulkAssign({
239
+ assignment: assignment
240
+ });
241
+ };
242
+ },
243
+ handleWorkSubmit: function handleWorkSubmit(props) {
244
+ return function (values) {
245
+ props.toggleWork();
246
+ props.bulkWork({
247
+ values: values
248
+ });
249
+ };
250
+ }
251
+ }))(QueueListSelectionComponent);
@@ -0,0 +1,114 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useCallback } from 'react';
3
+ import { Link } from '@reach/router';
4
+ import { Nav, NavItem } from 'reactstrap';
5
+ import { I18n } from '@kineticdata/react';
6
+ import classNames from 'classnames';
7
+ import matchPath from 'rudy-match-path';
8
+ import { connect } from '../../redux/store';
9
+ import { selectMyTeamForms } from '../../redux/modules/queueApp';
10
+ import { actions as queueActions } from '../../redux/modules/queue';
11
+
12
+ var formatCount = function formatCount(count) {
13
+ return count || count === 0 ? count >= 1000 ? '(999+)' : "(".concat(count, ")") : '';
14
+ };
15
+
16
+ var QueueListSidebarComponent = function QueueListSidebarComponent(_ref) {
17
+ var counts = _ref.counts,
18
+ openNewItemMenu = _ref.openNewItemMenu,
19
+ myFilters = _ref.myFilters,
20
+ teamFilters = _ref.teamFilters,
21
+ hasTeams = _ref.hasTeams,
22
+ hasForms = _ref.hasForms,
23
+ pathname = _ref.pathname,
24
+ appLocation = _ref.appLocation,
25
+ onSidebarAction = _ref.onSidebarAction,
26
+ _ref$showCreateNew = _ref.showCreateNew,
27
+ showCreateNew = _ref$showCreateNew === void 0 ? true : _ref$showCreateNew;
28
+ var SidebarLink = useCallback(function (_ref2) {
29
+ var to = _ref2.to,
30
+ _ref2$matchParams = _ref2.matchParams,
31
+ matchParams = _ref2$matchParams === void 0 ? {} : _ref2$matchParams,
32
+ icon = _ref2.icon,
33
+ children = _ref2.children;
34
+ return /*#__PURE__*/React.createElement(Link, {
35
+ to: to,
36
+ className: classNames('nav-link', {
37
+ active: matchPath(pathname, {
38
+ path: decodeURI(to),
39
+ exact: true
40
+ })
41
+ }),
42
+ onClick: onSidebarAction
43
+ }, /*#__PURE__*/React.createElement("span", {
44
+ className: icon
45
+ }), children);
46
+ }, [pathname, onSidebarAction]);
47
+ return /*#__PURE__*/React.createElement("div", {
48
+ className: "queue-sidebar"
49
+ }, showCreateNew && hasForms && /*#__PURE__*/React.createElement("div", {
50
+ className: "px-4 pt-4 pb-2"
51
+ }, /*#__PURE__*/React.createElement("button", {
52
+ type: "button",
53
+ className: "btn btn-secondary btn-block",
54
+ onClick: openNewItemMenu
55
+ }, /*#__PURE__*/React.createElement(I18n, null, "New Task"))), /*#__PURE__*/React.createElement(Nav, {
56
+ className: "nav-tabs nav-tabs--vertical"
57
+ }, /*#__PURE__*/React.createElement("div", {
58
+ className: "nav-item nav-item--header"
59
+ }, "Default Filters"), /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement(SidebarLink, {
60
+ to: "".concat(appLocation, "/list/Mine"),
61
+ icon: "fa fa-user fa-fw"
62
+ }, /*#__PURE__*/React.createElement(I18n, null, "Mine"), " ", formatCount(counts.get('Mine', 0)))), hasTeams && /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement(SidebarLink, {
63
+ to: "".concat(appLocation, "/list/Unassigned"),
64
+ icon: "fa fa-inbox fa-fw"
65
+ }, /*#__PURE__*/React.createElement(I18n, null, "Unassigned"), " ", formatCount(counts.get('Unassigned', 0)))), /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement(SidebarLink, {
66
+ to: "".concat(appLocation, "/list/Created By Me"),
67
+ icon: "fa fa-user-circle-o fa-fw"
68
+ }, /*#__PURE__*/React.createElement(I18n, null, "Created By Me"), ' ', formatCount(counts.get('Created By Me', 0)))), /*#__PURE__*/React.createElement("div", {
69
+ className: "nav-item nav-item--header"
70
+ }, /*#__PURE__*/React.createElement(I18n, null, "Team Filters")), teamFilters.map(function (filter) {
71
+ return /*#__PURE__*/React.createElement(NavItem, {
72
+ key: filter.name
73
+ }, /*#__PURE__*/React.createElement(SidebarLink, {
74
+ to: "".concat(appLocation, "/team/").concat(encodeURIComponent(filter.name)),
75
+ icon: "fa fa-fw fa-".concat(filter.icon)
76
+ }, /*#__PURE__*/React.createElement(I18n, null, "".concat(filter.name))));
77
+ }), /*#__PURE__*/React.createElement("div", {
78
+ className: "nav-item nav-item--header"
79
+ }, /*#__PURE__*/React.createElement(I18n, null, "My Filters")), myFilters.map(function (filter) {
80
+ return /*#__PURE__*/React.createElement(NavItem, {
81
+ key: filter.name
82
+ }, /*#__PURE__*/React.createElement(SidebarLink, {
83
+ to: "".concat(appLocation, "/custom/").concat(encodeURIComponent(filter.name)),
84
+ icon: "fa fa-star-o fa-fw"
85
+ }, filter.name));
86
+ }), myFilters.size === 0 && /*#__PURE__*/React.createElement(NavItem, null, /*#__PURE__*/React.createElement("span", {
87
+ className: "nav-link"
88
+ }, /*#__PURE__*/React.createElement("span", {
89
+ className: "fa fa-filled-star",
90
+ role: "presentation"
91
+ }), /*#__PURE__*/React.createElement("em", null, /*#__PURE__*/React.createElement(I18n, null, "None Configured"))))));
92
+ };
93
+
94
+ export var QueueListSidebar = connect(function (state) {
95
+ return {
96
+ appLocation: state.app.location,
97
+ pathname: state.router.location.pathname,
98
+ teamFilters: state.queueApp.teamFilters,
99
+ myFilters: state.queueApp.myFilters,
100
+ counts: state.queueApp.filters.toMap().mapEntries(function (_ref3) {
101
+ var _ref4 = _slicedToArray(_ref3, 2),
102
+ _ = _ref4[0],
103
+ filter = _ref4[1];
104
+
105
+ return [filter.name, state.queue.counts.get(filter)];
106
+ }),
107
+ hasTeams: state.queueApp.myTeams.size > 0,
108
+ hasForms: selectMyTeamForms(state).filter(function (form) {
109
+ return form.type === 'Task';
110
+ }).length > 0
111
+ };
112
+ }, {
113
+ openNewItemMenu: queueActions.openNewItemMenu
114
+ })(QueueListSidebarComponent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kineticdata/bundle-queue",
3
- "version": "5.0.15",
3
+ "version": "5.0.18",
4
4
  "main": "./lib/index.js",
5
5
  "main:src": "./src/index.js",
6
6
  "files": [
@@ -17,9 +17,9 @@
17
17
  "prepublishOnly": "yarn build"
18
18
  },
19
19
  "dependencies": {
20
- "@kineticdata/bundle-common": "^5.0.15",
21
- "@kineticdata/react": "^5.0.15",
22
- "@reach/router": "git://github.com/kineticdata/router.git",
20
+ "@kineticdata/bundle-common": "5.0.18",
21
+ "@kineticdata/react": "5.0.18",
22
+ "@reach/router": "https://github.com/kineticdata/router.git",
23
23
  "axios": "^0.21.1",
24
24
  "bootstrap": "^4.3.1",
25
25
  "classnames": "^2.2.5",
@@ -66,5 +66,5 @@
66
66
  "eslintConfig": {
67
67
  "extends": "react-app"
68
68
  },
69
- "gitHead": "c2406bd024de982e1fec2e971643f4283dbfa29f"
69
+ "gitHead": "4af3c0d37633d85f65119ab5a2d2410f72128bda"
70
70
  }