@plusscommunities/pluss-core-web 1.2.4 → 1.2.8
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 +446 -327
- package/dist/index.esm.js +445 -326
- package/dist/index.umd.js +449 -330
- package/package.json +1 -1
- package/src/components/AudienceSelector.js +63 -63
- package/src/components/Comment.js +22 -0
- package/src/components/CommentSection.js +63 -0
- package/src/components/index.js +2 -0
package/package.json
CHANGED
|
@@ -12,38 +12,41 @@ import { DropdownInput } from './DropdownInput';
|
|
|
12
12
|
import { Tag } from './Tag';
|
|
13
13
|
|
|
14
14
|
class AudienceSelector extends Component {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
|
|
18
|
+
this.state = {
|
|
19
|
+
categories: [
|
|
20
|
+
{
|
|
21
|
+
Title: 'All Primary Users',
|
|
22
|
+
Key: 'resident',
|
|
23
|
+
ShortName: 'Primary',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
Title: 'All Staff Users',
|
|
27
|
+
Key: 'staff',
|
|
28
|
+
ShortName: 'Staff',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
Title: 'All Linked Users',
|
|
32
|
+
Key: 'family',
|
|
33
|
+
ShortName: 'Linked',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
types: [],
|
|
37
|
+
AudienceType: props.audienceType || 'All',
|
|
38
|
+
showInclude: false,
|
|
39
|
+
includeList: [],
|
|
40
|
+
showExclude: false,
|
|
41
|
+
excludeList: [],
|
|
42
|
+
Type: '',
|
|
43
|
+
Category: '',
|
|
44
|
+
|
|
45
|
+
userList: [],
|
|
46
|
+
tagList: [],
|
|
47
|
+
AudienceTagList: props.audienceTypeSelection || [],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
47
50
|
|
|
48
51
|
componentDidMount() {
|
|
49
52
|
const { disallowUserType, custom, disallowSingleUsers, allowTags } = this.props;
|
|
@@ -52,6 +55,14 @@ class AudienceSelector extends Component {
|
|
|
52
55
|
if (allowTags || custom) this.getUserTags();
|
|
53
56
|
}
|
|
54
57
|
|
|
58
|
+
componentDidUpdate(prevProps) {
|
|
59
|
+
const newState = {};
|
|
60
|
+
if (prevProps.audienceType !== this.props.audienceType) newState.AudienceType = this.props.audienceType;
|
|
61
|
+
if (!_.isEqual(prevProps.audienceTypeSelection, this.props.audienceTypeSelection))
|
|
62
|
+
newState.AudienceTagList = this.props.audienceTypeSelection;
|
|
63
|
+
if (!_.isEmpty(newState)) this.setState(newState);
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
onSubmit() {
|
|
56
67
|
if (this.state.AudienceType === 'User' && _.isEmpty(this.state.includeList)) {
|
|
57
68
|
this.setState({ showInclude: true });
|
|
@@ -64,13 +75,7 @@ class AudienceSelector extends Component {
|
|
|
64
75
|
|
|
65
76
|
getAudienceTypeSelection() {
|
|
66
77
|
const { AudienceType, AudienceTagList, Category, Tag, Type } = this.state;
|
|
67
|
-
if (AudienceType === 'Custom')
|
|
68
|
-
return AudienceTagList.map((at) => {
|
|
69
|
-
return {
|
|
70
|
-
AudienceType: at.AudienceType,
|
|
71
|
-
AudienceTypeSelection: at.AudienceTypeSelection,
|
|
72
|
-
};
|
|
73
|
-
});
|
|
78
|
+
if (AudienceType === 'Custom') return AudienceTagList || [];
|
|
74
79
|
if (AudienceType === 'Category') return Category;
|
|
75
80
|
if (AudienceType === 'UserTags') return Tag;
|
|
76
81
|
return Type;
|
|
@@ -116,6 +121,13 @@ class AudienceSelector extends Component {
|
|
|
116
121
|
this.setState(newState);
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
onChangeSelection = () => {
|
|
125
|
+
const { updateValidation, onChange } = this.props;
|
|
126
|
+
const isValid = this.validateAudienceSelection();
|
|
127
|
+
if (updateValidation) updateValidation(isValid);
|
|
128
|
+
if (onChange) onChange(this.getAudienceType(), this.getAudienceTypeSelection(), isValid);
|
|
129
|
+
};
|
|
130
|
+
|
|
119
131
|
onChangeOption(type) {
|
|
120
132
|
this.setState({
|
|
121
133
|
AudienceType: type,
|
|
@@ -123,10 +135,9 @@ class AudienceSelector extends Component {
|
|
|
123
135
|
Category: '',
|
|
124
136
|
includeList: [],
|
|
125
137
|
excludeList: [],
|
|
138
|
+
AudienceTagList: [],
|
|
126
139
|
});
|
|
127
|
-
setTimeout(
|
|
128
|
-
this.props.updateValidation(this.validateAudienceSelection());
|
|
129
|
-
}, 50);
|
|
140
|
+
setTimeout(this.onChangeSelection, 50);
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
getOptions() {
|
|
@@ -190,9 +201,7 @@ class AudienceSelector extends Component {
|
|
|
190
201
|
includeList: [],
|
|
191
202
|
excludeList: [],
|
|
192
203
|
});
|
|
193
|
-
setTimeout(
|
|
194
|
-
this.props.updateValidation(this.validateAudienceSelection());
|
|
195
|
-
}, 50);
|
|
204
|
+
setTimeout(this.onChangeSelection, 50);
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
getTypeTitle() {
|
|
@@ -211,9 +220,7 @@ class AudienceSelector extends Component {
|
|
|
211
220
|
includeList: [],
|
|
212
221
|
excludeList: [],
|
|
213
222
|
});
|
|
214
|
-
setTimeout(
|
|
215
|
-
this.props.updateValidation(this.validateAudienceSelection());
|
|
216
|
-
}, 50);
|
|
223
|
+
setTimeout(this.onChangeSelection, 50);
|
|
217
224
|
};
|
|
218
225
|
|
|
219
226
|
getTagTitle() {
|
|
@@ -281,9 +288,7 @@ class AudienceSelector extends Component {
|
|
|
281
288
|
includeList: [],
|
|
282
289
|
excludeList: [],
|
|
283
290
|
});
|
|
284
|
-
setTimeout(
|
|
285
|
-
this.props.updateValidation(this.validateAudienceSelection());
|
|
286
|
-
}, 50);
|
|
291
|
+
setTimeout(this.onChangeSelection, 50);
|
|
287
292
|
}
|
|
288
293
|
|
|
289
294
|
getCatTitle() {
|
|
@@ -370,9 +375,7 @@ class AudienceSelector extends Component {
|
|
|
370
375
|
profilePic: user.profilePic,
|
|
371
376
|
});
|
|
372
377
|
this.setState({ includeList: list });
|
|
373
|
-
setTimeout(
|
|
374
|
-
this.props.updateValidation(this.validateAudienceSelection());
|
|
375
|
-
}, 50);
|
|
378
|
+
setTimeout(this.onChangeSelection, 50);
|
|
376
379
|
}
|
|
377
380
|
|
|
378
381
|
removeUserInc(user) {
|
|
@@ -381,9 +384,7 @@ class AudienceSelector extends Component {
|
|
|
381
384
|
return ev.Id !== user.Id;
|
|
382
385
|
}),
|
|
383
386
|
});
|
|
384
|
-
setTimeout(
|
|
385
|
-
this.props.updateValidation(this.validateAudienceSelection());
|
|
386
|
-
}, 50);
|
|
387
|
+
setTimeout(this.onChangeSelection, 50);
|
|
387
388
|
}
|
|
388
389
|
|
|
389
390
|
addToEx(user) {
|
|
@@ -404,7 +405,7 @@ class AudienceSelector extends Component {
|
|
|
404
405
|
});
|
|
405
406
|
}
|
|
406
407
|
|
|
407
|
-
getAvailableAudienceTags = () => {
|
|
408
|
+
getAvailableAudienceTags = (includeSelected = false) => {
|
|
408
409
|
const { categories, types, tagList, AudienceTagList } = this.state;
|
|
409
410
|
const categoryTags = categories.map((c) => {
|
|
410
411
|
return {
|
|
@@ -430,19 +431,18 @@ class AudienceSelector extends Component {
|
|
|
430
431
|
Title: `User Tag: ${t.Title}`,
|
|
431
432
|
};
|
|
432
433
|
});
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
});
|
|
434
|
+
const result = [...categoryTags, ...userTypeTags, ...userTagTags];
|
|
435
|
+
return includeSelected ? result : result.filter((t) => !_.some(AudienceTagList, (at) => at.Id === t.Id));
|
|
436
436
|
};
|
|
437
437
|
|
|
438
438
|
onAttachAudienceTag = (tag) => {
|
|
439
439
|
const AudienceTagList = [...this.state.AudienceTagList, tag];
|
|
440
|
-
this.setState({ AudienceTagList },
|
|
440
|
+
this.setState({ AudienceTagList }, this.onChangeSelection);
|
|
441
441
|
};
|
|
442
442
|
|
|
443
443
|
onDetachAudienceTag = (tag) => {
|
|
444
444
|
const AudienceTagList = _.filter(this.state.AudienceTagList, (at) => at.Id !== tag.Id);
|
|
445
|
-
this.setState({ AudienceTagList },
|
|
445
|
+
this.setState({ AudienceTagList }, this.onChangeSelection);
|
|
446
446
|
};
|
|
447
447
|
|
|
448
448
|
renderExcludes() {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import { toParagraphed } from '../helper';
|
|
4
|
+
import { ProfilePic } from './ProfilePic';
|
|
5
|
+
|
|
6
|
+
class Comment extends Component {
|
|
7
|
+
render() {
|
|
8
|
+
const { comment } = this.props;
|
|
9
|
+
return (
|
|
10
|
+
<div key={comment.Id} className="comment">
|
|
11
|
+
<p className="comment_text">{toParagraphed(comment.Comment)}</p>
|
|
12
|
+
<div className="comment_bottom">
|
|
13
|
+
<ProfilePic className="comment_profilePic" size={25} image={comment.User.profilePic} />
|
|
14
|
+
<p className="comment_name">{comment.User.displayName}</p>
|
|
15
|
+
<p className="comment_time">{moment.utc(comment.Timestamp).local().format('D MMM YYYY • h:mma')}</p>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { Comment };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import FontAwesome from 'react-fontawesome';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import Textarea from 'react-textarea-autosize';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
import { Comment } from './Comment';
|
|
7
|
+
|
|
8
|
+
class CommentSection extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
|
|
12
|
+
this.state = {
|
|
13
|
+
commentInput: '',
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
onHandleChange = (event) => {
|
|
18
|
+
var stateChange = {};
|
|
19
|
+
stateChange[event.target.getAttribute('id')] = event.target.value;
|
|
20
|
+
this.setState(stateChange);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
onAddComment = async () => {
|
|
24
|
+
const { commentInput } = this.state;
|
|
25
|
+
this.setState({ commentInput: '' });
|
|
26
|
+
this.props.onAddComment(commentInput);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
{this.props.includeTitle && (
|
|
33
|
+
<Text type="formTitleSmall" className="marginBottom-16">
|
|
34
|
+
Comments
|
|
35
|
+
</Text>
|
|
36
|
+
)}
|
|
37
|
+
<div className="commentSection">
|
|
38
|
+
{this.props.comments.map((c) => (
|
|
39
|
+
<Comment key={c.Id} comment={c} />
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
<div className="commentReply">
|
|
43
|
+
<div
|
|
44
|
+
className={`commentReply_button${!_.isEmpty(this.state.commentInput) ? ' commentReply_button-active' : ''}`}
|
|
45
|
+
onClick={this.onAddComment}
|
|
46
|
+
>
|
|
47
|
+
<FontAwesome className="commentReply_icon" name="paper-plane-o" />
|
|
48
|
+
</div>
|
|
49
|
+
<Textarea
|
|
50
|
+
id="commentInput"
|
|
51
|
+
placeholder="Reply here..."
|
|
52
|
+
type="text"
|
|
53
|
+
className="commentReply_input"
|
|
54
|
+
value={this.state.commentInput}
|
|
55
|
+
onChange={(e) => this.onHandleChange(e)}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { CommentSection };
|
package/src/components/index.js
CHANGED
|
@@ -2,6 +2,8 @@ export * from './AddButton';
|
|
|
2
2
|
export * from './Attachment';
|
|
3
3
|
export * from './Button';
|
|
4
4
|
export * from './CheckBox';
|
|
5
|
+
export * from './Comment';
|
|
6
|
+
export * from './CommentSection';
|
|
5
7
|
export * from './DatePicker';
|
|
6
8
|
export * from './FileInput';
|
|
7
9
|
export * from './GenericInput';
|