@plusscommunities/pluss-core-web 1.6.9-auth.0 → 1.6.10-beta.1
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/dist/index.cjs.js +130 -216
- package/dist/index.esm.js +130 -216
- package/dist/index.umd.js +133 -219
- package/package.json +47 -50
- package/src/apis/fileActions.js +7 -28
- package/src/components/AudienceSelector.js +149 -101
- package/src/components/FileInput.js +94 -44
- package/src/components/ImageInput.js +2 -3
- package/src/config.js +0 -5
- package/src/session.js +8 -5
package/dist/index.cjs.js
CHANGED
|
@@ -6,12 +6,12 @@ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
|
6
6
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
7
7
|
var _ = require('lodash');
|
|
8
8
|
var axios = require('axios');
|
|
9
|
+
var awsAmplify = require('aws-amplify');
|
|
9
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
11
|
var moment = require('moment');
|
|
11
12
|
var React = require('react');
|
|
12
13
|
var $ = require('jquery');
|
|
13
14
|
var Cookies = require('js-cookie');
|
|
14
|
-
var awsAmplify = require('aws-amplify');
|
|
15
15
|
var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
16
16
|
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
17
17
|
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
@@ -79,75 +79,7 @@ var CoreConfig = {
|
|
|
79
79
|
defaultAllowComments: true,
|
|
80
80
|
makeApiKey: '',
|
|
81
81
|
logo: '',
|
|
82
|
-
clientName: ''
|
|
83
|
-
AuthStrategy: {
|
|
84
|
-
getAccessToken: function () {
|
|
85
|
-
var _getAccessToken = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
86
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
87
|
-
while (1) {
|
|
88
|
-
switch (_context.prev = _context.next) {
|
|
89
|
-
case 0:
|
|
90
|
-
return _context.abrupt("return", null);
|
|
91
|
-
|
|
92
|
-
case 1:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context.stop();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, _callee);
|
|
98
|
-
}));
|
|
99
|
-
|
|
100
|
-
function getAccessToken() {
|
|
101
|
-
return _getAccessToken.apply(this, arguments);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return getAccessToken;
|
|
105
|
-
}(),
|
|
106
|
-
getCurrentUserId: function () {
|
|
107
|
-
var _getCurrentUserId = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
108
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
109
|
-
while (1) {
|
|
110
|
-
switch (_context2.prev = _context2.next) {
|
|
111
|
-
case 0:
|
|
112
|
-
return _context2.abrupt("return", null);
|
|
113
|
-
|
|
114
|
-
case 1:
|
|
115
|
-
case "end":
|
|
116
|
-
return _context2.stop();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}, _callee2);
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
function getCurrentUserId() {
|
|
123
|
-
return _getCurrentUserId.apply(this, arguments);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return getCurrentUserId;
|
|
127
|
-
}(),
|
|
128
|
-
hasActiveSession: function () {
|
|
129
|
-
var _hasActiveSession = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
130
|
-
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
131
|
-
while (1) {
|
|
132
|
-
switch (_context3.prev = _context3.next) {
|
|
133
|
-
case 0:
|
|
134
|
-
return _context3.abrupt("return", false);
|
|
135
|
-
|
|
136
|
-
case 1:
|
|
137
|
-
case "end":
|
|
138
|
-
return _context3.stop();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}, _callee3);
|
|
142
|
-
}));
|
|
143
|
-
|
|
144
|
-
function hasActiveSession() {
|
|
145
|
-
return _hasActiveSession.apply(this, arguments);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return hasActiveSession;
|
|
149
|
-
}()
|
|
150
|
-
}
|
|
82
|
+
clientName: ''
|
|
151
83
|
},
|
|
152
84
|
init: function init(environment) {
|
|
153
85
|
CoreConfig.env = environment;
|
|
@@ -156,28 +88,29 @@ var CoreConfig = {
|
|
|
156
88
|
|
|
157
89
|
var getSessionTokenAWS = /*#__PURE__*/function () {
|
|
158
90
|
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(prefix) {
|
|
159
|
-
var token;
|
|
91
|
+
var data, token;
|
|
160
92
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
161
93
|
while (1) {
|
|
162
94
|
switch (_context.prev = _context.next) {
|
|
163
95
|
case 0:
|
|
164
96
|
_context.next = 2;
|
|
165
|
-
return
|
|
97
|
+
return awsAmplify.Auth.currentSession();
|
|
166
98
|
|
|
167
99
|
case 2:
|
|
168
|
-
|
|
100
|
+
data = _context.sent;
|
|
101
|
+
token = data.getAccessToken().getJwtToken();
|
|
169
102
|
|
|
170
103
|
if (!___default['default'].isUndefined(prefix)) {
|
|
171
|
-
_context.next =
|
|
104
|
+
_context.next = 6;
|
|
172
105
|
break;
|
|
173
106
|
}
|
|
174
107
|
|
|
175
108
|
return _context.abrupt("return", token);
|
|
176
109
|
|
|
177
|
-
case
|
|
110
|
+
case 6:
|
|
178
111
|
return _context.abrupt("return", "".concat(prefix, " ").concat(token));
|
|
179
112
|
|
|
180
|
-
case
|
|
113
|
+
case 7:
|
|
181
114
|
case "end":
|
|
182
115
|
return _context.stop();
|
|
183
116
|
}
|
|
@@ -237,28 +170,30 @@ var unauthedFunction = function unauthedFunction(request) {
|
|
|
237
170
|
};
|
|
238
171
|
var getCurrentUserSub = /*#__PURE__*/function () {
|
|
239
172
|
var _ref3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
173
|
+
var user;
|
|
240
174
|
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
241
175
|
while (1) {
|
|
242
176
|
switch (_context3.prev = _context3.next) {
|
|
243
177
|
case 0:
|
|
244
178
|
_context3.prev = 0;
|
|
245
179
|
_context3.next = 3;
|
|
246
|
-
return
|
|
180
|
+
return awsAmplify.Auth.currentUserInfo();
|
|
247
181
|
|
|
248
182
|
case 3:
|
|
249
|
-
|
|
183
|
+
user = _context3.sent;
|
|
184
|
+
return _context3.abrupt("return", user.id);
|
|
250
185
|
|
|
251
|
-
case
|
|
252
|
-
_context3.prev =
|
|
186
|
+
case 7:
|
|
187
|
+
_context3.prev = 7;
|
|
253
188
|
_context3.t0 = _context3["catch"](0);
|
|
254
189
|
return _context3.abrupt("return", null);
|
|
255
190
|
|
|
256
|
-
case
|
|
191
|
+
case 10:
|
|
257
192
|
case "end":
|
|
258
193
|
return _context3.stop();
|
|
259
194
|
}
|
|
260
195
|
}
|
|
261
|
-
}, _callee3, null, [[0,
|
|
196
|
+
}, _callee3, null, [[0, 7]]);
|
|
262
197
|
}));
|
|
263
198
|
|
|
264
199
|
return function getCurrentUserSub() {
|
|
@@ -267,19 +202,19 @@ var getCurrentUserSub = /*#__PURE__*/function () {
|
|
|
267
202
|
}();
|
|
268
203
|
var checkLoggedIn = /*#__PURE__*/function () {
|
|
269
204
|
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(self) {
|
|
270
|
-
var
|
|
205
|
+
var user;
|
|
271
206
|
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
272
207
|
while (1) {
|
|
273
208
|
switch (_context4.prev = _context4.next) {
|
|
274
209
|
case 0:
|
|
275
210
|
_context4.prev = 0;
|
|
276
211
|
_context4.next = 3;
|
|
277
|
-
return
|
|
212
|
+
return awsAmplify.Auth.currentAuthenticatedUser();
|
|
278
213
|
|
|
279
214
|
case 3:
|
|
280
|
-
|
|
215
|
+
user = _context4.sent;
|
|
281
216
|
|
|
282
|
-
if (
|
|
217
|
+
if (___default['default'].isUndefined(user) || user == null || user.username == null) {
|
|
283
218
|
console.log('redirecting to login');
|
|
284
219
|
self.props.history.push('/login');
|
|
285
220
|
}
|
|
@@ -1720,35 +1655,31 @@ function CanvasImageUploader(options) {
|
|
|
1720
1655
|
var fileActions = {
|
|
1721
1656
|
uploadMediaAsync: function () {
|
|
1722
1657
|
var _uploadMediaAsync = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(file, filename) {
|
|
1723
|
-
var newFilename,
|
|
1658
|
+
var newFilename, userId, url, _Config$env, baseUploadsUrl, uploadBucket;
|
|
1659
|
+
|
|
1724
1660
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
1725
1661
|
while (1) {
|
|
1726
1662
|
switch (_context.prev = _context.next) {
|
|
1727
1663
|
case 0:
|
|
1728
1664
|
newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1729
1665
|
_context.next = 3;
|
|
1730
|
-
return
|
|
1731
|
-
method: 'GET',
|
|
1732
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1733
|
-
filename: newFilename,
|
|
1734
|
-
contentType: file.type
|
|
1735
|
-
})
|
|
1736
|
-
});
|
|
1666
|
+
return getCurrentUserSub();
|
|
1737
1667
|
|
|
1738
1668
|
case 3:
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1669
|
+
userId = _context.sent;
|
|
1670
|
+
url = "uploads/users/".concat(userId, "/public/").concat(randomString(), "/").concat(newFilename);
|
|
1671
|
+
_Config$env = CoreConfig.env, baseUploadsUrl = _Config$env.baseUploadsUrl, uploadBucket = _Config$env.uploadBucket;
|
|
1672
|
+
_context.next = 8;
|
|
1673
|
+
return awsAmplify.Storage.put(url, file, {
|
|
1674
|
+
level: 'public',
|
|
1675
|
+
bucket: uploadBucket
|
|
1745
1676
|
});
|
|
1746
1677
|
|
|
1747
|
-
case 6:
|
|
1748
|
-
baseUploadsUrl = CoreConfig.env.baseUploadsUrl;
|
|
1749
|
-
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(signedUrlRes.data.key));
|
|
1750
|
-
|
|
1751
1678
|
case 8:
|
|
1679
|
+
console.log('uploaded file', "".concat(baseUploadsUrl).concat(url));
|
|
1680
|
+
return _context.abrupt("return", "".concat(baseUploadsUrl).concat(url));
|
|
1681
|
+
|
|
1682
|
+
case 10:
|
|
1752
1683
|
case "end":
|
|
1753
1684
|
return _context.stop();
|
|
1754
1685
|
}
|
|
@@ -1762,15 +1693,6 @@ var fileActions = {
|
|
|
1762
1693
|
|
|
1763
1694
|
return uploadMediaAsync;
|
|
1764
1695
|
}(),
|
|
1765
|
-
// uploadMediaAsync: async (file, filename) => {
|
|
1766
|
-
// const newFilename = filename.replace(/[^a-z0-9+.]+/gi, '').toLowerCase();
|
|
1767
|
-
// const userId = await getCurrentUserSub();
|
|
1768
|
-
// const url = `uploads/users/${userId}/public/${randomString()}/${newFilename}`;
|
|
1769
|
-
// const { baseUploadsUrl, uploadBucket } = Config.env;
|
|
1770
|
-
// await Storage.put(url, file, { level: 'public', bucket: uploadBucket });
|
|
1771
|
-
// console.log('uploaded file', `${baseUploadsUrl}${url}`);
|
|
1772
|
-
// return `${baseUploadsUrl}${url}`;
|
|
1773
|
-
// },
|
|
1774
1696
|
// readBase64: async (file) => {
|
|
1775
1697
|
// return new Promise((resolve, reject) => {
|
|
1776
1698
|
// var reader = new FileReader();
|
|
@@ -1784,14 +1706,6 @@ var fileActions = {
|
|
|
1784
1706
|
// };
|
|
1785
1707
|
// });
|
|
1786
1708
|
// },
|
|
1787
|
-
getPresignedUrl: function getPresignedUrl(filename) {
|
|
1788
|
-
return authedFunction({
|
|
1789
|
-
method: 'GET',
|
|
1790
|
-
url: getUrl('media', 'get/presignedurl', {
|
|
1791
|
-
filename: filename
|
|
1792
|
-
})
|
|
1793
|
-
});
|
|
1794
|
-
},
|
|
1795
1709
|
compressImage: function compressImage(file, maxSize, quality, noCompress) {
|
|
1796
1710
|
return new Promise(function (resolve, reject) {
|
|
1797
1711
|
if (noCompress) {
|
|
@@ -4926,7 +4840,7 @@ function _createSuper$u(Derived) { var hasNativeReflectConstruct = _isNativeRefl
|
|
|
4926
4840
|
function _isNativeReflectConstruct$u() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
4927
4841
|
var DEFAULT_INPUT$1 = {
|
|
4928
4842
|
uploadingFile: false,
|
|
4929
|
-
value:
|
|
4843
|
+
value: ""
|
|
4930
4844
|
};
|
|
4931
4845
|
|
|
4932
4846
|
var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
@@ -4948,17 +4862,17 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
4948
4862
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "state", {
|
|
4949
4863
|
inputs: [{
|
|
4950
4864
|
uploadingFile: false,
|
|
4951
|
-
value:
|
|
4865
|
+
value: ""
|
|
4952
4866
|
}]
|
|
4953
4867
|
});
|
|
4954
4868
|
|
|
4955
4869
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "getAccept", function () {
|
|
4956
|
-
if (_typeof__default['default'](_this.props.accept) ===
|
|
4870
|
+
if (_typeof__default['default'](_this.props.accept) === "object") {
|
|
4957
4871
|
return _this.props.accept;
|
|
4958
4872
|
}
|
|
4959
4873
|
|
|
4960
|
-
if (typeof _this.props.accept ===
|
|
4961
|
-
var accept = _defineProperty__default['default']({}, _this.props.accept, [".".concat(___default['default'].last(_this.props.accept.split(
|
|
4874
|
+
if (typeof _this.props.accept === "string") {
|
|
4875
|
+
var accept = _defineProperty__default['default']({}, _this.props.accept, [".".concat(___default['default'].last(_this.props.accept.split("/")))]);
|
|
4962
4876
|
|
|
4963
4877
|
return accept;
|
|
4964
4878
|
}
|
|
@@ -5052,7 +4966,7 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5052
4966
|
return _this.props.handleFile(file, newInputs);
|
|
5053
4967
|
|
|
5054
4968
|
case 9:
|
|
5055
|
-
_this.checkSetDisplayValue(input,
|
|
4969
|
+
_this.checkSetDisplayValue(input, "");
|
|
5056
4970
|
|
|
5057
4971
|
_context.next = 24;
|
|
5058
4972
|
break;
|
|
@@ -5074,7 +4988,7 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5074
4988
|
case 20:
|
|
5075
4989
|
_context.prev = 20;
|
|
5076
4990
|
_context.t0 = _context["catch"](12);
|
|
5077
|
-
console.log(
|
|
4991
|
+
console.log("handleFile error", _context.t0);
|
|
5078
4992
|
|
|
5079
4993
|
_this.setState({
|
|
5080
4994
|
uploadingFile: false
|
|
@@ -5119,7 +5033,7 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5119
5033
|
}, {
|
|
5120
5034
|
key: "setValue",
|
|
5121
5035
|
value: function setValue(val) {
|
|
5122
|
-
if (typeof val ===
|
|
5036
|
+
if (typeof val === "string") {
|
|
5123
5037
|
this.setState({
|
|
5124
5038
|
inputs: [{
|
|
5125
5039
|
uploadingImage: false,
|
|
@@ -5145,20 +5059,20 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5145
5059
|
}, {
|
|
5146
5060
|
key: "getClassNames",
|
|
5147
5061
|
value: function getClassNames(input, inputsLength) {
|
|
5148
|
-
var classes =
|
|
5062
|
+
var classes = "clearfix imageInput";
|
|
5149
5063
|
|
|
5150
5064
|
if (input.uploadingFile) {
|
|
5151
|
-
classes +=
|
|
5065
|
+
classes += " imageInput-uploading";
|
|
5152
5066
|
} else if (!___default['default'].isEmpty(input.value) && !this.props.onlyAllowUpload) {
|
|
5153
|
-
classes +=
|
|
5067
|
+
classes += " imageInput-hasImage";
|
|
5154
5068
|
}
|
|
5155
5069
|
|
|
5156
5070
|
if (inputsLength === 1) {
|
|
5157
|
-
classes +=
|
|
5071
|
+
classes += " imageInput-only";
|
|
5158
5072
|
}
|
|
5159
5073
|
|
|
5160
5074
|
if (this.props.style && this.props.style.height && this.props.style.height < 150) {
|
|
5161
|
-
classes +=
|
|
5075
|
+
classes += " imageInput-condensed";
|
|
5162
5076
|
}
|
|
5163
5077
|
|
|
5164
5078
|
return classes;
|
|
@@ -5167,10 +5081,10 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5167
5081
|
key: "getErrorState",
|
|
5168
5082
|
value: function getErrorState() {
|
|
5169
5083
|
if (!___default['default'].isUndefined(this.props.showError) && this.props.showError()) {
|
|
5170
|
-
return
|
|
5084
|
+
return " imageInput_upload--error";
|
|
5171
5085
|
}
|
|
5172
5086
|
|
|
5173
|
-
return
|
|
5087
|
+
return "";
|
|
5174
5088
|
}
|
|
5175
5089
|
}, {
|
|
5176
5090
|
key: "checkSetDisplayValue",
|
|
@@ -5189,7 +5103,7 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5189
5103
|
key: "removeFile",
|
|
5190
5104
|
value: function removeFile(input) {
|
|
5191
5105
|
var newState = {};
|
|
5192
|
-
input.value =
|
|
5106
|
+
input.value = "";
|
|
5193
5107
|
|
|
5194
5108
|
var newInputs = ___default['default'].clone(this.state.inputs);
|
|
5195
5109
|
|
|
@@ -5298,7 +5212,7 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5298
5212
|
className: "imageInput_upload ".concat(_this3.getErrorState()),
|
|
5299
5213
|
style: _objectSpread$f({}, _this3.props.style)
|
|
5300
5214
|
}, getRootProps()), /*#__PURE__*/React__default['default'].createElement("input", getInputProps()), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
5301
|
-
className: "".concat(isDragActive ?
|
|
5215
|
+
className: "".concat(isDragActive ? "imageInput_dropZoneActive" : "")
|
|
5302
5216
|
}, !_this3.props.simpleStyle && /*#__PURE__*/React__default['default'].createElement("img", {
|
|
5303
5217
|
src: "https://s3-ap-southeast-2.amazonaws.com/pluss60-dev-media/pluss/document.svg",
|
|
5304
5218
|
className: "imageInput_icon",
|
|
@@ -5324,7 +5238,7 @@ var FileInputComponent = /*#__PURE__*/function (_Component) {
|
|
|
5324
5238
|
var _this4 = this;
|
|
5325
5239
|
|
|
5326
5240
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
5327
|
-
className: "imageInputContainer clearfix ".concat(inputs.length === 1 ?
|
|
5241
|
+
className: "imageInputContainer clearfix ".concat(inputs.length === 1 ? "imageInputContainer-noPadding" : "", " ").concat(this.props.simpleStyle ? "imageInputContainer-simple" : ""),
|
|
5328
5242
|
style: _objectSpread$f({}, this.props.style)
|
|
5329
5243
|
}, inputs.map(function (input, index) {
|
|
5330
5244
|
return _this4.renderInput(input, index, inputs.length);
|
|
@@ -9346,7 +9260,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9346
9260
|
AudienceTagList = _this$state.AudienceTagList;
|
|
9347
9261
|
var categoryTags = categories.map(function (c) {
|
|
9348
9262
|
return {
|
|
9349
|
-
AudienceType:
|
|
9263
|
+
AudienceType: "Category",
|
|
9350
9264
|
AudienceTypeSelection: c.Key,
|
|
9351
9265
|
Id: "category_".concat(c.Key),
|
|
9352
9266
|
Title: c.Title
|
|
@@ -9354,7 +9268,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9354
9268
|
});
|
|
9355
9269
|
var userTypeTags = types.map(function (t) {
|
|
9356
9270
|
return {
|
|
9357
|
-
AudienceType:
|
|
9271
|
+
AudienceType: "UserType",
|
|
9358
9272
|
AudienceTypeSelection: t.typeName,
|
|
9359
9273
|
Id: "userType_".concat(t.typeName),
|
|
9360
9274
|
Title: "User Type: ".concat(t.displayName)
|
|
@@ -9362,7 +9276,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9362
9276
|
});
|
|
9363
9277
|
var userTagTags = tagList.map(function (t) {
|
|
9364
9278
|
return {
|
|
9365
|
-
AudienceType:
|
|
9279
|
+
AudienceType: "UserTags",
|
|
9366
9280
|
AudienceTypeSelection: t.Id,
|
|
9367
9281
|
Id: "userTag_".concat(t.Id),
|
|
9368
9282
|
Title: "User Tag: ".concat(t.Title)
|
|
@@ -9396,26 +9310,26 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9396
9310
|
|
|
9397
9311
|
_this.state = {
|
|
9398
9312
|
categories: [{
|
|
9399
|
-
Title:
|
|
9400
|
-
Key:
|
|
9401
|
-
ShortName:
|
|
9313
|
+
Title: "All Primary Users",
|
|
9314
|
+
Key: "resident",
|
|
9315
|
+
ShortName: "Primary"
|
|
9402
9316
|
}, {
|
|
9403
|
-
Title:
|
|
9404
|
-
Key:
|
|
9405
|
-
ShortName:
|
|
9317
|
+
Title: "All Staff Users",
|
|
9318
|
+
Key: "staff",
|
|
9319
|
+
ShortName: "Staff"
|
|
9406
9320
|
}, {
|
|
9407
|
-
Title:
|
|
9408
|
-
Key:
|
|
9409
|
-
ShortName:
|
|
9321
|
+
Title: "All Linked Users",
|
|
9322
|
+
Key: "family",
|
|
9323
|
+
ShortName: "Linked"
|
|
9410
9324
|
}],
|
|
9411
9325
|
types: [],
|
|
9412
|
-
AudienceType: props.audienceType ||
|
|
9326
|
+
AudienceType: props.audienceType || "All",
|
|
9413
9327
|
showInclude: false,
|
|
9414
9328
|
includeList: [],
|
|
9415
9329
|
showExclude: false,
|
|
9416
9330
|
excludeList: [],
|
|
9417
|
-
Type:
|
|
9418
|
-
Category:
|
|
9331
|
+
Type: "",
|
|
9332
|
+
Category: "",
|
|
9419
9333
|
userList: [],
|
|
9420
9334
|
tagList: [],
|
|
9421
9335
|
AudienceTagList: props.audienceTypeSelection || []
|
|
@@ -9445,7 +9359,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9445
9359
|
}, {
|
|
9446
9360
|
key: "onSubmit",
|
|
9447
9361
|
value: function onSubmit() {
|
|
9448
|
-
if (this.state.AudienceType ===
|
|
9362
|
+
if (this.state.AudienceType === "User" && ___default['default'].isEmpty(this.state.includeList)) {
|
|
9449
9363
|
this.setState({
|
|
9450
9364
|
showInclude: true
|
|
9451
9365
|
});
|
|
@@ -9465,9 +9379,9 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9465
9379
|
Category = _this$state2.Category,
|
|
9466
9380
|
Tag = _this$state2.Tag,
|
|
9467
9381
|
Type = _this$state2.Type;
|
|
9468
|
-
if (AudienceType ===
|
|
9469
|
-
if (AudienceType ===
|
|
9470
|
-
if (AudienceType ===
|
|
9382
|
+
if (AudienceType === "Custom") return AudienceTagList || [];
|
|
9383
|
+
if (AudienceType === "Category") return Category;
|
|
9384
|
+
if (AudienceType === "UserTags") return Tag;
|
|
9471
9385
|
return Type;
|
|
9472
9386
|
}
|
|
9473
9387
|
}, {
|
|
@@ -9512,9 +9426,9 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9512
9426
|
var newState = {
|
|
9513
9427
|
AudienceType: type
|
|
9514
9428
|
};
|
|
9515
|
-
if (type ===
|
|
9516
|
-
if (type ===
|
|
9517
|
-
if (type ===
|
|
9429
|
+
if (type === "Custom") newState.AudienceTagList = selection;
|
|
9430
|
+
if (type === "UserType") newState.Type = selection;
|
|
9431
|
+
if (type === "Category") newState.Category = selection;
|
|
9518
9432
|
this.setState(newState);
|
|
9519
9433
|
}
|
|
9520
9434
|
}, {
|
|
@@ -9522,8 +9436,8 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9522
9436
|
value: function onChangeOption(type) {
|
|
9523
9437
|
this.setState({
|
|
9524
9438
|
AudienceType: type,
|
|
9525
|
-
Type:
|
|
9526
|
-
Category:
|
|
9439
|
+
Type: "",
|
|
9440
|
+
Category: "",
|
|
9527
9441
|
includeList: [],
|
|
9528
9442
|
excludeList: [],
|
|
9529
9443
|
AudienceTagList: []
|
|
@@ -9536,57 +9450,57 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9536
9450
|
var _this4 = this;
|
|
9537
9451
|
|
|
9538
9452
|
var options = [{
|
|
9539
|
-
Label:
|
|
9540
|
-
Value:
|
|
9453
|
+
Label: "All users",
|
|
9454
|
+
Value: "All",
|
|
9541
9455
|
onChange: function onChange() {
|
|
9542
|
-
return _this4.onChangeOption(
|
|
9456
|
+
return _this4.onChangeOption("All");
|
|
9543
9457
|
}
|
|
9544
9458
|
}];
|
|
9545
9459
|
|
|
9546
9460
|
if (this.props.custom) {
|
|
9547
9461
|
options.push({
|
|
9548
|
-
Label:
|
|
9549
|
-
Value:
|
|
9462
|
+
Label: "Custom",
|
|
9463
|
+
Value: "Custom",
|
|
9550
9464
|
onChange: function onChange() {
|
|
9551
|
-
return _this4.onChangeOption(
|
|
9465
|
+
return _this4.onChangeOption("Custom");
|
|
9552
9466
|
}
|
|
9553
9467
|
});
|
|
9554
9468
|
} else {
|
|
9555
9469
|
options.push({
|
|
9556
|
-
Label:
|
|
9557
|
-
Value:
|
|
9470
|
+
Label: "By user category",
|
|
9471
|
+
Value: "Category",
|
|
9558
9472
|
onChange: function onChange() {
|
|
9559
|
-
return _this4.onChangeOption(
|
|
9473
|
+
return _this4.onChangeOption("Category");
|
|
9560
9474
|
}
|
|
9561
9475
|
});
|
|
9562
9476
|
}
|
|
9563
9477
|
|
|
9564
9478
|
if (!this.props.disallowUserType) {
|
|
9565
9479
|
options.push({
|
|
9566
|
-
Label:
|
|
9567
|
-
Value:
|
|
9480
|
+
Label: "By user type",
|
|
9481
|
+
Value: "UserType",
|
|
9568
9482
|
onChange: function onChange() {
|
|
9569
|
-
return _this4.onChangeOption(
|
|
9483
|
+
return _this4.onChangeOption("UserType");
|
|
9570
9484
|
}
|
|
9571
9485
|
});
|
|
9572
9486
|
}
|
|
9573
9487
|
|
|
9574
9488
|
if (this.props.allowTags) {
|
|
9575
9489
|
options.push({
|
|
9576
|
-
Label:
|
|
9577
|
-
Value:
|
|
9490
|
+
Label: "By user tag",
|
|
9491
|
+
Value: "UserTags",
|
|
9578
9492
|
onChange: function onChange() {
|
|
9579
|
-
return _this4.onChangeOption(
|
|
9493
|
+
return _this4.onChangeOption("UserTags");
|
|
9580
9494
|
}
|
|
9581
9495
|
});
|
|
9582
9496
|
}
|
|
9583
9497
|
|
|
9584
9498
|
if (!this.props.disallowSingleUsers) {
|
|
9585
9499
|
options.push({
|
|
9586
|
-
Label:
|
|
9587
|
-
Value:
|
|
9500
|
+
Label: "To single users",
|
|
9501
|
+
Value: "User",
|
|
9588
9502
|
onChange: function onChange() {
|
|
9589
|
-
return _this4.onChangeOption(
|
|
9503
|
+
return _this4.onChangeOption("User");
|
|
9590
9504
|
}
|
|
9591
9505
|
});
|
|
9592
9506
|
}
|
|
@@ -9599,11 +9513,11 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9599
9513
|
var _this$state3 = this.state,
|
|
9600
9514
|
AudienceType = _this$state3.AudienceType,
|
|
9601
9515
|
includeList = _this$state3.includeList;
|
|
9602
|
-
if (AudienceType ===
|
|
9603
|
-
if (AudienceType ===
|
|
9604
|
-
if (AudienceType ===
|
|
9605
|
-
if (AudienceType ===
|
|
9606
|
-
if (AudienceType ===
|
|
9516
|
+
if (AudienceType === "Custom" && !this.validateCustom()) return false;
|
|
9517
|
+
if (AudienceType === "Category" && !this.validateCategory()) return false;
|
|
9518
|
+
if (AudienceType === "UserType" && !this.validateType()) return false;
|
|
9519
|
+
if (AudienceType === "User" && ___default['default'].isEmpty(includeList)) return false;
|
|
9520
|
+
if (AudienceType === "UserTags" && !this.validateTag()) return false;
|
|
9607
9521
|
return true;
|
|
9608
9522
|
}
|
|
9609
9523
|
}, {
|
|
@@ -9629,7 +9543,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9629
9543
|
return typeObject.displayName;
|
|
9630
9544
|
}
|
|
9631
9545
|
|
|
9632
|
-
return
|
|
9546
|
+
return "";
|
|
9633
9547
|
}
|
|
9634
9548
|
}, {
|
|
9635
9549
|
key: "getTagTitle",
|
|
@@ -9644,7 +9558,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9644
9558
|
return tag.Title;
|
|
9645
9559
|
}
|
|
9646
9560
|
|
|
9647
|
-
return
|
|
9561
|
+
return "";
|
|
9648
9562
|
}
|
|
9649
9563
|
}, {
|
|
9650
9564
|
key: "getUserTypes",
|
|
@@ -9665,7 +9579,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9665
9579
|
return c.Key === e.category;
|
|
9666
9580
|
});
|
|
9667
9581
|
|
|
9668
|
-
var shortName = category ? "(".concat(category.ShortName, ") ") :
|
|
9582
|
+
var shortName = category ? "(".concat(category.ShortName, ") ") : "";
|
|
9669
9583
|
e.Title = "".concat(shortName, " ").concat(e.Title);
|
|
9670
9584
|
}
|
|
9671
9585
|
});
|
|
@@ -9674,10 +9588,10 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9674
9588
|
};
|
|
9675
9589
|
|
|
9676
9590
|
if (!___default['default'].some(res.data, function (t) {
|
|
9677
|
-
return t.category ===
|
|
9591
|
+
return t.category === "family";
|
|
9678
9592
|
})) {
|
|
9679
9593
|
newState.categories = ___default['default'].filter(_this7.state.categories, function (c) {
|
|
9680
|
-
return c.Key !==
|
|
9594
|
+
return c.Key !== "family";
|
|
9681
9595
|
});
|
|
9682
9596
|
}
|
|
9683
9597
|
|
|
@@ -9689,15 +9603,15 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9689
9603
|
value: function getUserList() {
|
|
9690
9604
|
var _this8 = this;
|
|
9691
9605
|
|
|
9692
|
-
if (this.state.AudienceType ===
|
|
9606
|
+
if (this.state.AudienceType === "UserType" && !___default['default'].isEmpty(this.state.Type)) {
|
|
9693
9607
|
var users = [];
|
|
9694
9608
|
this.state.userList.forEach(function (element) {
|
|
9695
9609
|
if (element.type !== _this8.state.Type) users.push(element);
|
|
9696
9610
|
});
|
|
9697
|
-
return ___default['default'].sortBy(users,
|
|
9611
|
+
return ___default['default'].sortBy(users, "displayName");
|
|
9698
9612
|
}
|
|
9699
9613
|
|
|
9700
|
-
if (this.state.AudienceType ===
|
|
9614
|
+
if (this.state.AudienceType === "Category" && !___default['default'].isEmpty(this.state.Category)) {
|
|
9701
9615
|
var _users = [];
|
|
9702
9616
|
|
|
9703
9617
|
var types = ___default['default'].filter(this.state.types, function (type) {
|
|
@@ -9711,10 +9625,10 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9711
9625
|
_users.push(element);
|
|
9712
9626
|
}
|
|
9713
9627
|
});
|
|
9714
|
-
return ___default['default'].sortBy(_users,
|
|
9628
|
+
return ___default['default'].sortBy(_users, "displayName");
|
|
9715
9629
|
}
|
|
9716
9630
|
|
|
9717
|
-
return ___default['default'].sortBy(this.state.userList,
|
|
9631
|
+
return ___default['default'].sortBy(this.state.userList, "displayName");
|
|
9718
9632
|
}
|
|
9719
9633
|
}, {
|
|
9720
9634
|
key: "selectCat",
|
|
@@ -9739,7 +9653,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9739
9653
|
return typeObject.Title;
|
|
9740
9654
|
}
|
|
9741
9655
|
|
|
9742
|
-
return
|
|
9656
|
+
return "";
|
|
9743
9657
|
}
|
|
9744
9658
|
}, {
|
|
9745
9659
|
key: "validateCategory",
|
|
@@ -9759,7 +9673,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9759
9673
|
}, {
|
|
9760
9674
|
key: "showUserPickers",
|
|
9761
9675
|
value: function showUserPickers(isInclude) {
|
|
9762
|
-
if (isInclude && this.state.AudienceType ===
|
|
9676
|
+
if (isInclude && this.state.AudienceType === "User") {
|
|
9763
9677
|
return true;
|
|
9764
9678
|
}
|
|
9765
9679
|
|
|
@@ -9771,15 +9685,15 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9771
9685
|
return false;
|
|
9772
9686
|
}
|
|
9773
9687
|
|
|
9774
|
-
if (isInclude && this.state.AudienceType ===
|
|
9688
|
+
if (isInclude && this.state.AudienceType === "All") {
|
|
9775
9689
|
return false;
|
|
9776
9690
|
}
|
|
9777
9691
|
|
|
9778
|
-
if (!isInclude && this.state.AudienceType ===
|
|
9692
|
+
if (!isInclude && this.state.AudienceType === "User") {
|
|
9779
9693
|
return false;
|
|
9780
9694
|
}
|
|
9781
9695
|
|
|
9782
|
-
if (this.state.AudienceType ===
|
|
9696
|
+
if (this.state.AudienceType === "Category" && ___default['default'].isEmpty(this.state.Category) || this.state.AudienceType === "UserType" && ___default['default'].isEmpty(this.state.Type)) {
|
|
9783
9697
|
return false;
|
|
9784
9698
|
}
|
|
9785
9699
|
|
|
@@ -9790,15 +9704,15 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9790
9704
|
value: function getUserExcludeList() {
|
|
9791
9705
|
var _this10 = this;
|
|
9792
9706
|
|
|
9793
|
-
if (this.state.AudienceType ===
|
|
9707
|
+
if (this.state.AudienceType === "UserType" && !___default['default'].isEmpty(this.state.Type)) {
|
|
9794
9708
|
var users = [];
|
|
9795
9709
|
this.state.userList.forEach(function (element) {
|
|
9796
9710
|
if (element.type === _this10.state.Type) users.push(element);
|
|
9797
9711
|
});
|
|
9798
|
-
return ___default['default'].sortBy(users,
|
|
9712
|
+
return ___default['default'].sortBy(users, "displayName");
|
|
9799
9713
|
}
|
|
9800
9714
|
|
|
9801
|
-
if (this.state.AudienceType ===
|
|
9715
|
+
if (this.state.AudienceType === "Category" && !___default['default'].isEmpty(this.state.Category)) {
|
|
9802
9716
|
var _users2 = [];
|
|
9803
9717
|
|
|
9804
9718
|
var types = ___default['default'].filter(this.state.types, function (type) {
|
|
@@ -9812,10 +9726,10 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9812
9726
|
_users2.push(element);
|
|
9813
9727
|
}
|
|
9814
9728
|
});
|
|
9815
|
-
return ___default['default'].sortBy(_users2,
|
|
9729
|
+
return ___default['default'].sortBy(_users2, "displayName");
|
|
9816
9730
|
}
|
|
9817
9731
|
|
|
9818
|
-
return ___default['default'].sortBy(this.state.userList,
|
|
9732
|
+
return ___default['default'].sortBy(this.state.userList, "displayName");
|
|
9819
9733
|
}
|
|
9820
9734
|
}, {
|
|
9821
9735
|
key: "addToInc",
|
|
@@ -9889,12 +9803,12 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9889
9803
|
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
9890
9804
|
type: "formTitleSmall",
|
|
9891
9805
|
className: "marginBottom-16"
|
|
9892
|
-
}, "Exclude Users From Selection ", "(".concat(this.state.excludeList.length, ")"))), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
9806
|
+
}, "Exclude Users From Selection", " ", "(".concat(this.state.excludeList.length, ")"))), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
9893
9807
|
style: {
|
|
9894
9808
|
color: COLOUR_DUSK,
|
|
9895
9809
|
fontSize: 12
|
|
9896
9810
|
},
|
|
9897
|
-
name: this.state.showExclude ?
|
|
9811
|
+
name: this.state.showExclude ? "chevron-up" : "chevron-down"
|
|
9898
9812
|
})), this.state.showExclude && /*#__PURE__*/React__default['default'].createElement(exportObj$1, {
|
|
9899
9813
|
add: this.addToEx.bind(this),
|
|
9900
9814
|
remove: this.removeUserEx.bind(this),
|
|
@@ -9926,12 +9840,12 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9926
9840
|
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
9927
9841
|
type: "formTitleSmall",
|
|
9928
9842
|
className: "marginBottom-16"
|
|
9929
|
-
}, this.state.AudienceType !==
|
|
9843
|
+
}, this.state.AudienceType !== "User" ? "Add Other" : "Select", " ", "Users ", "(".concat(this.state.includeList.length, ")"))), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
9930
9844
|
style: {
|
|
9931
9845
|
color: COLOUR_DUSK,
|
|
9932
9846
|
fontSize: 12
|
|
9933
9847
|
},
|
|
9934
|
-
name: this.state.showInclude ?
|
|
9848
|
+
name: this.state.showInclude ? "chevron-up" : "chevron-down"
|
|
9935
9849
|
})), this.state.showInclude && /*#__PURE__*/React__default['default'].createElement(exportObj$1, {
|
|
9936
9850
|
add: this.addToInc.bind(this),
|
|
9937
9851
|
remove: this.removeUserInc.bind(this),
|
|
@@ -9992,7 +9906,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
9992
9906
|
}, {
|
|
9993
9907
|
key: "renderCustom",
|
|
9994
9908
|
value: function renderCustom() {
|
|
9995
|
-
if (this.state.AudienceType !==
|
|
9909
|
+
if (this.state.AudienceType !== "Custom") return null;
|
|
9996
9910
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
9997
9911
|
className: "optionsContent_bottom"
|
|
9998
9912
|
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
@@ -10010,17 +9924,17 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
10010
9924
|
return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
10011
9925
|
type: "formTitleSmall",
|
|
10012
9926
|
className: "marginBottom-16"
|
|
10013
|
-
}, this.props.title ||
|
|
9927
|
+
}, this.props.title || "Target Audience"), /*#__PURE__*/React__default['default'].createElement(RadioButton, {
|
|
10014
9928
|
isActive: this.state.AudienceType,
|
|
10015
9929
|
rowStyle: {
|
|
10016
|
-
flexDirection:
|
|
9930
|
+
flexDirection: "column"
|
|
10017
9931
|
},
|
|
10018
9932
|
buttonStyle: {
|
|
10019
9933
|
marginBottom: 8
|
|
10020
9934
|
},
|
|
10021
9935
|
options: this.getOptions(),
|
|
10022
9936
|
disabled: this.props.disabled
|
|
10023
|
-
}), this.state.AudienceType ===
|
|
9937
|
+
}), this.state.AudienceType === "Category" && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
|
|
10024
9938
|
id: "typeSelect" // label='User Category'
|
|
10025
9939
|
,
|
|
10026
9940
|
alwaysShowLabel: true,
|
|
@@ -10040,7 +9954,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
10040
9954
|
},
|
|
10041
9955
|
isRequired: true,
|
|
10042
9956
|
disabled: this.props.disabled
|
|
10043
|
-
}), this.state.AudienceType ===
|
|
9957
|
+
}), this.state.AudienceType === "UserType" && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
|
|
10044
9958
|
id: "typeSelect" // label='User Type'
|
|
10045
9959
|
,
|
|
10046
9960
|
alwaysShowLabel: true,
|
|
@@ -10060,7 +9974,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
|
|
|
10060
9974
|
},
|
|
10061
9975
|
isRequired: true,
|
|
10062
9976
|
disabled: this.props.disabled
|
|
10063
|
-
}), this.state.AudienceType ===
|
|
9977
|
+
}), this.state.AudienceType === "UserTags" && /*#__PURE__*/React__default['default'].createElement(DropdownInput, {
|
|
10064
9978
|
id: "tagSelect",
|
|
10065
9979
|
alwaysShowLabel: true,
|
|
10066
9980
|
placeholder: "User Tag",
|