@selfcommunity/react-ui 0.7.9-alpha.3 → 0.7.9-alpha.30
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/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
- package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.js +9 -2
- package/lib/cjs/components/Composer/Composer.d.ts +2 -1
- package/lib/cjs/components/Composer/Composer.js +39 -12
- package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +46 -12
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- package/lib/cjs/components/EditGroupButton/EditGroupButton.js +61 -0
- package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/EditGroupButton/index.js +5 -0
- package/lib/cjs/components/FeedObject/Actions/Follow/Follow.js +18 -0
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -0
- package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/cjs/components/FeedObject/FeedObject.js +43 -9
- package/lib/cjs/components/Group/Group.d.ts +4 -3
- package/lib/cjs/components/Group/Group.js +5 -4
- package/lib/cjs/components/Group/Skeleton.js +1 -1
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
- package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
- package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
- package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
- package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
- package/lib/cjs/components/GroupForm/index.d.ts +3 -0
- package/lib/cjs/components/GroupForm/index.js +5 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/cjs/components/GroupHeader/GroupHeader.js +21 -11
- package/lib/cjs/components/GroupHeader/Skeleton.d.ts +2 -4
- package/lib/cjs/components/GroupHeader/Skeleton.js +10 -10
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +7 -6
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +3 -2
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +36 -16
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +132 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +24 -9
- package/lib/cjs/components/Groups/Groups.d.ts +16 -16
- package/lib/cjs/components/Groups/Groups.js +47 -96
- package/lib/cjs/components/Groups/Skeleton.d.ts +14 -2
- package/lib/cjs/components/Groups/Skeleton.js +12 -5
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
- package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
- package/lib/cjs/components/Notification/Group/Group.js +79 -0
- package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
- package/lib/cjs/components/Notification/Group/index.js +5 -0
- package/lib/cjs/components/Notification/Notification.js +32 -1
- package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +10 -7
- package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
- package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/cjs/components/VoteButton/VoteButton.js +19 -0
- package/lib/cjs/index.d.ts +7 -4
- package/lib/cjs/index.js +13 -6
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
- package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/esm/components/Composer/Attributes/Attributes.js +9 -2
- package/lib/esm/components/Composer/Composer.d.ts +2 -1
- package/lib/esm/components/Composer/Composer.js +39 -12
- package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +45 -12
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- package/lib/esm/components/EditGroupButton/EditGroupButton.js +58 -0
- package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
- package/lib/esm/components/EditGroupButton/index.js +2 -0
- package/lib/esm/components/FeedObject/Actions/Follow/Follow.js +20 -2
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +20 -2
- package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/esm/components/FeedObject/FeedObject.js +45 -11
- package/lib/esm/components/Group/Group.d.ts +4 -3
- package/lib/esm/components/Group/Group.js +5 -4
- package/lib/esm/components/Group/Skeleton.js +1 -1
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
- package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/esm/components/GroupAutocomplete/index.js +2 -0
- package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/esm/components/GroupForm/GroupForm.js +236 -0
- package/lib/esm/components/GroupForm/constants.d.ts +1 -0
- package/lib/esm/components/GroupForm/constants.js +1 -0
- package/lib/esm/components/GroupForm/index.d.ts +3 -0
- package/lib/esm/components/GroupForm/index.js +2 -0
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/esm/components/GroupHeader/GroupHeader.js +21 -11
- package/lib/esm/components/GroupHeader/Skeleton.d.ts +2 -4
- package/lib/esm/components/GroupHeader/Skeleton.js +10 -10
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +7 -6
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +4 -3
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +38 -18
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +129 -0
- package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +25 -10
- package/lib/esm/components/Groups/Groups.d.ts +16 -16
- package/lib/esm/components/Groups/Groups.js +52 -101
- package/lib/esm/components/Groups/Skeleton.d.ts +14 -2
- package/lib/esm/components/Groups/Skeleton.js +13 -5
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
- package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
- package/lib/esm/components/Notification/Group/Group.js +76 -0
- package/lib/esm/components/Notification/Group/index.d.ts +3 -0
- package/lib/esm/components/Notification/Group/index.js +2 -0
- package/lib/esm/components/Notification/Notification.js +32 -1
- package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +11 -8
- package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
- package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/esm/components/VoteButton/VoteButton.js +20 -1
- package/lib/esm/index.d.ts +7 -4
- package/lib/esm/index.js +8 -5
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
- package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
- package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
- package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
- package/lib/cjs/components/CreateGroup/index.js +0 -5
- package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
- package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
- package/lib/esm/components/CreateGroup/constants.js +0 -1
- package/lib/esm/components/CreateGroup/index.d.ts +0 -3
- package/lib/esm/components/CreateGroup/index.js +0 -2
|
@@ -23,6 +23,10 @@ const messages = defineMessages({
|
|
|
23
23
|
errorLoadImage: {
|
|
24
24
|
id: 'ui.changeGroupCover.button.change.alertErrorImage',
|
|
25
25
|
defaultMessage: 'ui.changeGroupCover.button.change.alertErrorImage'
|
|
26
|
+
},
|
|
27
|
+
errorImageSize: {
|
|
28
|
+
id: 'ui.changeGroupCover.alert',
|
|
29
|
+
defaultMessage: 'ui.changeGroupCover.alert'
|
|
26
30
|
}
|
|
27
31
|
});
|
|
28
32
|
/**
|
|
@@ -73,7 +77,26 @@ export default function ChangeGroupCover(inProps) {
|
|
|
73
77
|
*/
|
|
74
78
|
const handleUpload = (event) => {
|
|
75
79
|
fileInput = event.target.files[0];
|
|
76
|
-
|
|
80
|
+
if (fileInput) {
|
|
81
|
+
const reader = new FileReader();
|
|
82
|
+
reader.onload = (e) => {
|
|
83
|
+
const img = new Image();
|
|
84
|
+
img.onload = () => {
|
|
85
|
+
if (img.width < 1920) {
|
|
86
|
+
setAlert(intl.formatMessage(messages.errorImageSize));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
img.src = e.target.result;
|
|
95
|
+
};
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
reader.readAsDataURL(fileInput);
|
|
99
|
+
}
|
|
77
100
|
};
|
|
78
101
|
/**
|
|
79
102
|
* Handles cover saving after upload action
|
|
@@ -14,8 +14,8 @@ import { defineMessages, useIntl } from 'react-intl';
|
|
|
14
14
|
import { LoadingButton } from '@mui/lab';
|
|
15
15
|
const messages = defineMessages({
|
|
16
16
|
errorLoadImage: {
|
|
17
|
-
id: 'ui.
|
|
18
|
-
defaultMessage: 'ui.
|
|
17
|
+
id: 'ui.changeGroupPicture.alert',
|
|
18
|
+
defaultMessage: 'ui.changeGroupPicture.alert'
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
const classes = {
|
|
@@ -57,12 +57,12 @@ export default function ChangeGroupPicture(inProps) {
|
|
|
57
57
|
name: PREFIX
|
|
58
58
|
});
|
|
59
59
|
const { groupId, onChange, autoHide, className, isCreationMode = false } = props, rest = __rest(props, ["groupId", "onChange", "autoHide", "className", "isCreationMode"]);
|
|
60
|
+
//CONTEXT
|
|
61
|
+
const scUserContext = useContext(SCUserContext);
|
|
60
62
|
//STATE
|
|
63
|
+
let fileInput = useRef(null);
|
|
61
64
|
const [loading, setLoading] = useState(false);
|
|
62
65
|
const [alert, setAlert] = useState(null);
|
|
63
|
-
let fileInput = useRef(null);
|
|
64
|
-
//CONTEXT
|
|
65
|
-
const scUserContext = useContext(SCUserContext);
|
|
66
66
|
// INTL
|
|
67
67
|
const intl = useIntl();
|
|
68
68
|
// Anonymous
|
|
@@ -73,26 +73,47 @@ export default function ChangeGroupPicture(inProps) {
|
|
|
73
73
|
* Handles avatar upload
|
|
74
74
|
* @param event
|
|
75
75
|
*/
|
|
76
|
-
|
|
76
|
+
const handleUpload = (event) => {
|
|
77
77
|
fileInput = event.target.files[0];
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
if (fileInput) {
|
|
79
|
+
const reader = new FileReader();
|
|
80
|
+
reader.onload = (e) => {
|
|
81
|
+
const img = new Image();
|
|
82
|
+
img.onload = () => {
|
|
83
|
+
if (img.width < 600 && img.height < 600) {
|
|
84
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
img.src = e.target.result;
|
|
93
|
+
};
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
reader.readAsDataURL(fileInput);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
80
99
|
/**
|
|
81
100
|
* Performs save avatar after upload
|
|
82
101
|
*/
|
|
83
102
|
function handleSave() {
|
|
84
103
|
setLoading(true);
|
|
85
104
|
const formData = new FormData();
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
106
|
+
// @ts-ignore
|
|
86
107
|
formData.append('image_original', fileInput);
|
|
87
108
|
GroupService.changeGroupAvatarOrCover(groupId, formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
88
109
|
.then((data) => {
|
|
110
|
+
onChange && onChange(data.image_big);
|
|
89
111
|
setLoading(false);
|
|
90
|
-
onChange && onChange(data.image_bigger);
|
|
91
112
|
})
|
|
92
113
|
.catch((error) => {
|
|
93
|
-
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
94
|
-
setLoading(false);
|
|
95
114
|
Logger.error(SCOPE_SC_UI, error);
|
|
115
|
+
setLoading(false);
|
|
116
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
96
117
|
});
|
|
97
118
|
}
|
|
98
119
|
/**
|
|
@@ -16,7 +16,7 @@ export interface AttributesProps extends Omit<BoxProps, 'value' | 'onChange' | '
|
|
|
16
16
|
* @param value
|
|
17
17
|
* @default empty object
|
|
18
18
|
*/
|
|
19
|
-
onClick?: (attribute: 'categories' | 'addressing' | 'location') => void;
|
|
19
|
+
onClick?: (attribute: 'categories' | 'group' | 'addressing' | 'location') => void;
|
|
20
20
|
}
|
|
21
21
|
declare const _default: (props: AttributesProps) => JSX.Element;
|
|
22
22
|
export default _default;
|
|
@@ -13,7 +13,7 @@ const Root = styled(Box, {
|
|
|
13
13
|
slot: 'AttributesRoot'
|
|
14
14
|
})(() => ({}));
|
|
15
15
|
export default (props) => {
|
|
16
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c;
|
|
17
17
|
// PROPS
|
|
18
18
|
const { className = null, value = null, onChange = null, onClick = null } = props;
|
|
19
19
|
// HANDLERS
|
|
@@ -23,6 +23,12 @@ export default (props) => {
|
|
|
23
23
|
const handleClickCategory = useCallback(() => {
|
|
24
24
|
onClick && onClick('categories');
|
|
25
25
|
}, [onClick]);
|
|
26
|
+
const handleDeleteGroup = useCallback(() => {
|
|
27
|
+
onChange && onChange(Object.assign(Object.assign({}, value), { group: null }));
|
|
28
|
+
}, [value, onChange]);
|
|
29
|
+
const handleClickGroup = useCallback(() => {
|
|
30
|
+
onClick && onClick('group');
|
|
31
|
+
}, [onClick]);
|
|
26
32
|
const handleDeleteTag = useCallback((id) => () => {
|
|
27
33
|
onChange && onChange(Object.assign(Object.assign({}, value), { addressing: value.addressing.filter((tag) => tag.id !== id) }));
|
|
28
34
|
}, [value, onChange]);
|
|
@@ -38,7 +44,8 @@ export default (props) => {
|
|
|
38
44
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
39
45
|
((_a = value === null || value === void 0 ? void 0 : value.categories) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
40
46
|
(value === null || value === void 0 ? void 0 : value.categories.map((c) => (React.createElement(Chip, { key: c.id, label: c.name, onDelete: handleDeleteCategory(c.id), icon: React.createElement(Icon, null, "category"), onClick: handleClickCategory })))),
|
|
41
|
-
((_b = value === null || value === void 0 ? void 0 : value.
|
|
47
|
+
(value === null || value === void 0 ? void 0 : value.group) && (React.createElement(Chip, { key: value === null || value === void 0 ? void 0 : value.group.id, label: value === null || value === void 0 ? void 0 : value.group.name, onDelete: handleDeleteGroup, icon: React.createElement(Icon, null, "groups"), onClick: handleClickGroup, disabled: !((_b = value === null || value === void 0 ? void 0 : value.group) === null || _b === void 0 ? void 0 : _b.subscription_status) })),
|
|
48
|
+
((_c = value === null || value === void 0 ? void 0 : value.addressing) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
|
|
42
49
|
(value === null || value === void 0 ? void 0 : value.addressing.map((t) => (React.createElement(TagChip, { key: t.id, tag: t, onDelete: handleDeleteTag(t.id), icon: React.createElement(Icon, null, "label"), onClick: handleClickTag })))),
|
|
43
50
|
(value === null || value === void 0 ? void 0 : value.location) && (React.createElement(Chip, { icon: React.createElement(Icon, null, "add_location_alt"), label: value === null || value === void 0 ? void 0 : value.location.location, onDelete: handleDeleteLocation, onClick: handleClickLocation }))));
|
|
44
51
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SyntheticEvent } from 'react';
|
|
2
|
-
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
2
|
+
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCGroupType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
3
3
|
import { DialogProps } from '@mui/material';
|
|
4
4
|
import { EditorProps } from '../Editor';
|
|
5
5
|
import { SCMediaObjectType } from '../../types/media';
|
|
@@ -27,6 +27,7 @@ export interface ComposerProps extends Omit<DialogProps, 'defaultValue' | 'scrol
|
|
|
27
27
|
title?: string;
|
|
28
28
|
text?: string;
|
|
29
29
|
categories?: SCCategoryType[];
|
|
30
|
+
group?: SCGroupType;
|
|
30
31
|
audience?: string;
|
|
31
32
|
addressing?: SCTagType[];
|
|
32
33
|
medias?: SCMediaType[];
|
|
@@ -57,7 +57,9 @@ const COMPOSER_INITIAL_STATE = {
|
|
|
57
57
|
html: '',
|
|
58
58
|
htmlError: null,
|
|
59
59
|
categories: [],
|
|
60
|
+
group: null,
|
|
60
61
|
categoriesError: null,
|
|
62
|
+
groupsError: null,
|
|
61
63
|
addressing: null,
|
|
62
64
|
addressingError: null,
|
|
63
65
|
medias: [],
|
|
@@ -131,7 +133,7 @@ export default function Composer(inProps) {
|
|
|
131
133
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
132
134
|
const [layer, setLayer] = useState();
|
|
133
135
|
const [state, dispatch] = useReducer(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { key: random() }));
|
|
134
|
-
const { key, id, type, title, titleError, html, categories, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
136
|
+
const { key, id, type, title, titleError, html, categories, group, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
135
137
|
const destructureFeedObject = (_feedObject) => {
|
|
136
138
|
if (_feedObject.type === SCContributionType.POST) {
|
|
137
139
|
_feedObject = _feedObject;
|
|
@@ -151,6 +153,7 @@ export default function Composer(inProps) {
|
|
|
151
153
|
title: _feedObject.title,
|
|
152
154
|
html: _feedObject.html,
|
|
153
155
|
categories: _feedObject.categories,
|
|
156
|
+
group: _feedObject.group,
|
|
154
157
|
addressing: _feedObject.addressing,
|
|
155
158
|
medias: _feedObject.medias,
|
|
156
159
|
poll: _feedObject.poll,
|
|
@@ -302,18 +305,23 @@ export default function Composer(inProps) {
|
|
|
302
305
|
}
|
|
303
306
|
}), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
|
|
304
307
|
const handleChangeAudience = useCallback((value) => {
|
|
305
|
-
|
|
308
|
+
if (group || typeof value === 'object') {
|
|
309
|
+
dispatch({ type: 'group', value });
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
dispatch({ type: 'addressing', value });
|
|
313
|
+
}
|
|
306
314
|
setLayer(null);
|
|
307
|
-
}, []);
|
|
315
|
+
}, [group]);
|
|
308
316
|
const handleAddAudienceLayer = useCallback(() => handleAddLayer({
|
|
309
317
|
name: 'audience',
|
|
310
318
|
Component: AudienceLayer,
|
|
311
319
|
ComponentProps: {
|
|
312
320
|
onClose: handleRemoveLayer,
|
|
313
321
|
onSave: handleChangeAudience,
|
|
314
|
-
defaultValue: addressing
|
|
322
|
+
defaultValue: group || typeof addressing === 'object' ? group : addressing
|
|
315
323
|
}
|
|
316
|
-
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing]);
|
|
324
|
+
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, group]);
|
|
317
325
|
const handleChangeLocation = useCallback((value) => {
|
|
318
326
|
dispatch({ type: 'location', value });
|
|
319
327
|
setLayer(null);
|
|
@@ -404,6 +412,9 @@ export default function Composer(inProps) {
|
|
|
404
412
|
if (features.includes(SCFeatureName.TAGGING) && addressing !== null) {
|
|
405
413
|
data.addressing = addressing.map((t) => t.id);
|
|
406
414
|
}
|
|
415
|
+
if (features.includes(SCFeatureName.GROUPING) && group !== null) {
|
|
416
|
+
data.group = group.id;
|
|
417
|
+
}
|
|
407
418
|
setIsSubmitting(true);
|
|
408
419
|
// Finding right url
|
|
409
420
|
const _type = type === COMPOSER_TYPE_POLL ? SCContributionType.POST : type;
|
|
@@ -431,7 +442,7 @@ export default function Composer(inProps) {
|
|
|
431
442
|
dispatch({ type: 'multiple', value: formatHttpErrorCode(error) });
|
|
432
443
|
})
|
|
433
444
|
.then(() => setIsSubmitting(false));
|
|
434
|
-
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, addressing, audience, medias, poll, location, hasPoll]);
|
|
445
|
+
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, group, addressing, audience, medias, poll, location, hasPoll]);
|
|
435
446
|
//edited here
|
|
436
447
|
const handleClose = useCallback((event, reason) => {
|
|
437
448
|
if (unloadRef.current) {
|
|
@@ -486,13 +497,29 @@ export default function Composer(inProps) {
|
|
|
486
497
|
}
|
|
487
498
|
switch (type) {
|
|
488
499
|
case COMPOSER_TYPE_POLL:
|
|
489
|
-
return (React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html,
|
|
500
|
+
return (React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html, group, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting }));
|
|
490
501
|
case SCContributionType.DISCUSSION:
|
|
491
|
-
return (React.createElement(ContentDiscussion, { key: key, value: { title, html, categories, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
502
|
+
return (React.createElement(ContentDiscussion, { key: key, value: { title, html, categories, group, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
492
503
|
default:
|
|
493
|
-
return (React.createElement(ContentPost, { key: key, value: { html, categories, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
504
|
+
return (React.createElement(ContentPost, { key: key, value: { html, categories, group, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
494
505
|
}
|
|
495
|
-
}, [
|
|
506
|
+
}, [
|
|
507
|
+
key,
|
|
508
|
+
type,
|
|
509
|
+
title,
|
|
510
|
+
html,
|
|
511
|
+
categories,
|
|
512
|
+
group,
|
|
513
|
+
addressing,
|
|
514
|
+
medias,
|
|
515
|
+
poll,
|
|
516
|
+
pollError,
|
|
517
|
+
location,
|
|
518
|
+
error,
|
|
519
|
+
handleChangePoll,
|
|
520
|
+
handleChangePost,
|
|
521
|
+
isSubmitting
|
|
522
|
+
]);
|
|
496
523
|
if (!scUserContext.user && !(scUserContext.loading && open)) {
|
|
497
524
|
return null;
|
|
498
525
|
}
|
|
@@ -504,7 +531,7 @@ export default function Composer(inProps) {
|
|
|
504
531
|
React.createElement(LoadingButton, { size: "small", type: "submit", color: "secondary", variant: "contained", disabled: !canSubmit, loading: isSubmitting },
|
|
505
532
|
React.createElement(FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" }))),
|
|
506
533
|
React.createElement(DialogContent, { className: classes.content },
|
|
507
|
-
React.createElement(Attributes, { value: { categories, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
534
|
+
React.createElement(Attributes, { value: { categories, group, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
508
535
|
content,
|
|
509
536
|
medias && medias.length > 0 && (React.createElement(Box, { className: classes.medias }, mediaObjectTypes.map((mediaObjectType) => {
|
|
510
537
|
if (mediaObjectType.previewComponent) {
|
|
@@ -524,7 +551,7 @@ export default function Composer(inProps) {
|
|
|
524
551
|
}),
|
|
525
552
|
React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddCategoryLayer },
|
|
526
553
|
React.createElement(Icon, null, "category")),
|
|
527
|
-
React.createElement(IconButton, { disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING), onClick: handleAddAudienceLayer }, addressing === null || addressing.length === 0 ? React.createElement(Icon, null, "public") : React.createElement(Icon, null, "label")),
|
|
554
|
+
React.createElement(IconButton, { disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING) || Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group), onClick: handleAddAudienceLayer }, (!group && addressing === null) || (addressing === null || addressing === void 0 ? void 0 : addressing.length) === 0 ? React.createElement(Icon, null, "public") : group ? React.createElement(Icon, null, "groups") : React.createElement(Icon, null, "label")),
|
|
528
555
|
preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && (React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' },
|
|
529
556
|
React.createElement(Icon, null, "add_location_alt"))))),
|
|
530
557
|
layer && (React.createElement(LayerTransitionRoot, { className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" },
|
|
@@ -23,6 +23,7 @@ const Root = styled(Box, {
|
|
|
23
23
|
const DEFAULT_DISCUSSION = {
|
|
24
24
|
title: '',
|
|
25
25
|
categories: [],
|
|
26
|
+
group: null,
|
|
26
27
|
medias: [],
|
|
27
28
|
html: '',
|
|
28
29
|
addressing: []
|
|
@@ -42,9 +43,12 @@ export default (props) => {
|
|
|
42
43
|
}, [value]);
|
|
43
44
|
// RENDER
|
|
44
45
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
45
|
-
generalError && React.createElement(Typography, { className: classes.generalError },
|
|
46
|
-
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
|
|
47
|
-
React.createElement(TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
46
|
+
generalError && (React.createElement(Typography, { className: classes.generalError },
|
|
47
|
+
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
|
|
48
|
+
React.createElement(TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
49
|
+
id: 'ui.composer.content.discussion.title.label',
|
|
50
|
+
defaultMessage: 'ui.composer.content.discussion.title.label'
|
|
51
|
+
}), autoFocus: true, fullWidth: true, variant: "outlined", value: value.title, multiline: true, onChange: handleChangeTitle, InputProps: {
|
|
48
52
|
endAdornment: React.createElement(Typography, { variant: "body2" }, COMPOSER_TITLE_MAX_LENGTH - value.title.length)
|
|
49
53
|
}, error: Boolean(titleError), helperText: titleError, disabled: disabled }),
|
|
50
54
|
React.createElement(Editor, Object.assign({}, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
|
|
@@ -22,7 +22,8 @@ const DEFAULT_POST = {
|
|
|
22
22
|
categories: [],
|
|
23
23
|
medias: [],
|
|
24
24
|
html: '',
|
|
25
|
-
addressing: []
|
|
25
|
+
addressing: [],
|
|
26
|
+
group: null
|
|
26
27
|
};
|
|
27
28
|
export default (props) => {
|
|
28
29
|
// PROPS
|
|
@@ -40,7 +41,7 @@ export default (props) => {
|
|
|
40
41
|
}, [value]);
|
|
41
42
|
// RENDER
|
|
42
43
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
43
|
-
generalError && React.createElement(Typography, { className: classes.generalError },
|
|
44
|
-
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
|
|
44
|
+
generalError && (React.createElement(Typography, { className: classes.generalError },
|
|
45
|
+
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
|
|
45
46
|
React.createElement(Editor, Object.assign({ ref: editorRef }, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
|
|
46
47
|
};
|
|
@@ -3,8 +3,14 @@ import { TextFieldProps } from '@mui/material/TextField';
|
|
|
3
3
|
import { BoxProps } from '@mui/material';
|
|
4
4
|
import { SCTagType } from '@selfcommunity/types/src/index';
|
|
5
5
|
import { ComposerLayerProps } from '../../../../types/composer';
|
|
6
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
7
|
+
export declare enum AudienceTypes {
|
|
8
|
+
AUDIENCE_ALL = "all",
|
|
9
|
+
AUDIENCE_TAG = "tag",
|
|
10
|
+
AUDIENCE_GROUP = "group"
|
|
11
|
+
}
|
|
6
12
|
export interface AudienceLayerProps extends Omit<BoxProps, 'defaultValue'>, ComposerLayerProps {
|
|
7
|
-
defaultValue: SCTagType[];
|
|
13
|
+
defaultValue: SCTagType[] | SCGroupType;
|
|
8
14
|
TextFieldProps?: TextFieldProps;
|
|
9
15
|
}
|
|
10
16
|
declare const AudienceLayer: React.ForwardRefExoticComponent<Pick<AudienceLayerProps, "p" | "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "component" | "sx" | "classes" | "onClose" | "TextFieldProps" | "onSave"> & React.RefAttributes<unknown>>;
|
|
@@ -12,8 +12,13 @@ import Icon from '@mui/material/Icon';
|
|
|
12
12
|
import DialogContent from '@mui/material/DialogContent';
|
|
13
13
|
import { useSCFetchAddressingTagList } from '@selfcommunity/react-core';
|
|
14
14
|
import { PREFIX } from '../../constants';
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import GroupAutocomplete from '../../../GroupAutocomplete';
|
|
16
|
+
export var AudienceTypes;
|
|
17
|
+
(function (AudienceTypes) {
|
|
18
|
+
AudienceTypes["AUDIENCE_ALL"] = "all";
|
|
19
|
+
AudienceTypes["AUDIENCE_TAG"] = "tag";
|
|
20
|
+
AudienceTypes["AUDIENCE_GROUP"] = "group";
|
|
21
|
+
})(AudienceTypes || (AudienceTypes = {}));
|
|
17
22
|
const classes = {
|
|
18
23
|
root: `${PREFIX}-layer-audience-root`,
|
|
19
24
|
title: `${PREFIX}-layer-title`,
|
|
@@ -27,23 +32,36 @@ const Root = styled(Box, {
|
|
|
27
32
|
})(() => ({}));
|
|
28
33
|
const AudienceLayer = React.forwardRef((props, ref) => {
|
|
29
34
|
// Props
|
|
30
|
-
const { className, onClose, onSave, defaultValue = [], TextFieldProps = {
|
|
35
|
+
const { className, onClose, onSave, defaultValue = AudienceTypes.AUDIENCE_TAG ? [] : null, TextFieldProps = {
|
|
31
36
|
variant: 'outlined',
|
|
32
37
|
label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tags.label", defaultMessage: "ui.composer.layer.audience.tags.label" })
|
|
33
38
|
} } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultValue", "TextFieldProps"]);
|
|
34
39
|
// STATE
|
|
35
40
|
const [autocompleteOpen, setAutocompleteOpen] = useState(false);
|
|
36
|
-
const [audience, setAudience] = useState(
|
|
41
|
+
const [audience, setAudience] = useState(
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
defaultValue === null || defaultValue.length === 0
|
|
45
|
+
? AudienceTypes.AUDIENCE_ALL
|
|
46
|
+
: defaultValue && typeof defaultValue === 'object'
|
|
47
|
+
? AudienceTypes.AUDIENCE_GROUP
|
|
48
|
+
: AudienceTypes.AUDIENCE_TAG);
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
+
// @ts-ignore
|
|
37
51
|
const [value, setValue] = useState(defaultValue || undefined);
|
|
38
52
|
// HOOKS
|
|
39
53
|
const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: autocompleteOpen });
|
|
40
54
|
// HANDLERS
|
|
41
|
-
const handleSave = useCallback(
|
|
55
|
+
const handleSave = useCallback(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
() => (audience === AudienceTypes.AUDIENCE_GROUP ? onSave(value) : onSave((value === null || value === void 0 ? void 0 : value.length) && (value === null || value === void 0 ? void 0 : value.length) > 0 ? value : null)), [value, onSave, audience]);
|
|
42
59
|
const handleChange = useCallback((event, tags) => setValue(tags), []);
|
|
60
|
+
const handleGroupChange = useCallback((group) => setValue(group), []);
|
|
43
61
|
const handleChangeAudience = useCallback((event, data) => setAudience(data), []);
|
|
44
62
|
const handleAutocompleteOpen = useCallback(() => setAutocompleteOpen(true), []);
|
|
45
63
|
const handleAutocompleteClose = useCallback(() => setAutocompleteOpen(false), []);
|
|
46
|
-
return React.createElement(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest),
|
|
64
|
+
return (React.createElement(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest),
|
|
47
65
|
React.createElement(DialogTitle, { className: classes.title },
|
|
48
66
|
React.createElement(IconButton, { onClick: onClose },
|
|
49
67
|
React.createElement(Icon, null, "arrow_back")),
|
|
@@ -53,12 +71,26 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
53
71
|
React.createElement(FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }))),
|
|
54
72
|
React.createElement(DialogContent, { className: classes.content },
|
|
55
73
|
React.createElement(Tabs, { value: audience, onChange: handleChangeAudience, "aria-label": "audience type" },
|
|
56
|
-
React.createElement(Tab, { value: AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
57
|
-
React.createElement(Tab
|
|
74
|
+
React.createElement(Tab, { value: AudienceTypes.AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
75
|
+
React.createElement(Tab
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
, {
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
disabled: defaultValue && typeof defaultValue !== 'object', value: AudienceTypes.AUDIENCE_GROUP, icon: React.createElement(Icon, null, "groups"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) }),
|
|
82
|
+
React.createElement(Tab
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
, {
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
disabled: value && typeof defaultValue === 'object', value: AudienceTypes.AUDIENCE_TAG, icon: React.createElement(Icon, null, "label"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
|
|
58
89
|
React.createElement(Typography, { className: classes.message },
|
|
59
|
-
audience === AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
60
|
-
audience ===
|
|
61
|
-
|
|
90
|
+
audience === AudienceTypes.AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
91
|
+
audience === AudienceTypes.AUDIENCE_GROUP && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.audience.layer.group.message" })),
|
|
92
|
+
audience === AudienceTypes.AUDIENCE_TAG && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.audience.layer.tag.message" }))),
|
|
93
|
+
audience === AudienceTypes.AUDIENCE_TAG && (React.createElement(Autocomplete, { className: classes.autocomplete, open: autocompleteOpen, onOpen: handleAutocompleteOpen, onClose: handleAutocompleteClose, multiple: true, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
|
|
62
94
|
return value.map((option, index) => React.createElement(TagChip, Object.assign({ key: option.id, tag: option }, getTagProps({ index }))));
|
|
63
95
|
}, renderOption: (props, option, { selected, inputValue }) => {
|
|
64
96
|
const matches = match(option.name, inputValue);
|
|
@@ -67,6 +99,7 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
67
99
|
React.createElement(TagChip, { key: option.id, tag: option, label: React.createElement(React.Fragment, null, parts.map((part, index) => (React.createElement("span", { key: index, style: { fontWeight: part.highlight ? 700 : 400 } }, part.text)))) })));
|
|
68
100
|
}, renderInput: (params) => {
|
|
69
101
|
return (React.createElement(TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: React.createElement(React.Fragment, null, params.InputProps.endAdornment) }) })));
|
|
70
|
-
} }))
|
|
102
|
+
} })),
|
|
103
|
+
audience === AudienceTypes.AUDIENCE_GROUP && React.createElement(GroupAutocomplete, { onChange: handleGroupChange, defaultValue: defaultValue }))));
|
|
71
104
|
});
|
|
72
105
|
export default AudienceLayer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from '@mui/material/Button/Button';
|
|
2
|
-
import {
|
|
2
|
+
import { GroupFormProps } from '../GroupForm';
|
|
3
3
|
export interface CreateGroupButtonProps extends ButtonProps {
|
|
4
4
|
/**
|
|
5
5
|
* Overrides or extends the styles applied to the component.
|
|
@@ -10,7 +10,7 @@ export interface CreateGroupButtonProps extends ButtonProps {
|
|
|
10
10
|
* Props to spread to CreateGroup component
|
|
11
11
|
* @default empty object
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
GroupFormProps?: GroupFormProps;
|
|
14
14
|
/**
|
|
15
15
|
* Any other properties
|
|
16
16
|
*/
|
|
@@ -6,7 +6,7 @@ import { Button, Icon } from '@mui/material';
|
|
|
6
6
|
import { FormattedMessage } from 'react-intl';
|
|
7
7
|
import { SCUserContext } from '@selfcommunity/react-core';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
-
import
|
|
9
|
+
import GroupForm from '../GroupForm';
|
|
10
10
|
const PREFIX = 'SCCreateGroupButton';
|
|
11
11
|
const classes = {
|
|
12
12
|
root: `${PREFIX}-root`
|
|
@@ -41,7 +41,7 @@ export default function CreateGroupButton(inProps) {
|
|
|
41
41
|
props: inProps,
|
|
42
42
|
name: PREFIX
|
|
43
43
|
});
|
|
44
|
-
const { className,
|
|
44
|
+
const { className, GroupFormProps = {}, children } = props, rest = __rest(props, ["className", "GroupFormProps", "children"]);
|
|
45
45
|
// CONTEXT
|
|
46
46
|
const scUserContext = useContext(SCUserContext);
|
|
47
47
|
// STATE
|
|
@@ -52,7 +52,7 @@ export default function CreateGroupButton(inProps) {
|
|
|
52
52
|
* Handle click on button
|
|
53
53
|
*/
|
|
54
54
|
const handleClick = () => {
|
|
55
|
-
setOpen((
|
|
55
|
+
setOpen((o) => !o);
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
58
58
|
* If there's no authUserId, component is hidden.
|
|
@@ -64,7 +64,6 @@ export default function CreateGroupButton(inProps) {
|
|
|
64
64
|
* Renders root object
|
|
65
65
|
*/
|
|
66
66
|
return (React.createElement(React.Fragment, null,
|
|
67
|
-
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick,
|
|
68
|
-
|
|
69
|
-
open && React.createElement(CreateGroup, Object.assign({}, CreateGroupProps, { open: true, onClose: handleClick }))));
|
|
67
|
+
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick, variant: "contained", startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest), children !== null && children !== void 0 ? children : React.createElement(FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
|
|
68
|
+
open && React.createElement(GroupForm, Object.assign({}, GroupFormProps, { open: true, onClose: handleClick }))));
|
|
70
69
|
}
|
|
@@ -23,6 +23,10 @@ export interface CustomAdvProps extends VirtualScrollerItemProps {
|
|
|
23
23
|
* Category ids if the adv must be related to specific categories
|
|
24
24
|
*/
|
|
25
25
|
categoriesId?: Array<number> | null;
|
|
26
|
+
/**
|
|
27
|
+
* Group ids if the adv must be related to specific groups
|
|
28
|
+
*/
|
|
29
|
+
groupsId?: Array<number> | null;
|
|
26
30
|
/**
|
|
27
31
|
* Prefixed height. Usefull to re-mount item on scroll feed.
|
|
28
32
|
*/
|
package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts}
RENAMED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateGroupButtonProps } from '../CreateGroupButton';
|
|
2
2
|
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
-
export interface
|
|
3
|
+
export interface EditGroupButtonProps extends CreateGroupButtonProps {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Group Object
|
|
6
6
|
* @default null
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Open dialog
|
|
11
|
-
* @default true
|
|
12
|
-
*/
|
|
13
|
-
open?: boolean;
|
|
8
|
+
group?: SCGroupType;
|
|
14
9
|
/**
|
|
15
|
-
*
|
|
10
|
+
* Id of the group
|
|
16
11
|
* @default null
|
|
17
12
|
*/
|
|
18
|
-
|
|
13
|
+
groupId?: number | string;
|
|
19
14
|
/**
|
|
20
|
-
*
|
|
15
|
+
* On edit success callback function
|
|
21
16
|
* @default null
|
|
22
17
|
*/
|
|
23
|
-
|
|
18
|
+
onEditSuccess?: (data: SCGroupType) => void;
|
|
24
19
|
/**
|
|
25
20
|
* Any other properties
|
|
26
21
|
*/
|
|
@@ -35,14 +30,14 @@ export interface CreateGroupProps extends BaseDialogProps {
|
|
|
35
30
|
```
|
|
36
31
|
|
|
37
32
|
#### Component Name
|
|
38
|
-
The name `
|
|
33
|
+
The name `SCEditGroupButton` can be used when providing style overrides in the theme.
|
|
39
34
|
|
|
40
35
|
#### CSS
|
|
41
36
|
|
|
42
37
|
|Rule Name|Global class|Description|
|
|
43
38
|
|---|---|---|
|
|
44
|
-
|root|.
|
|
39
|
+
|root|.SCEditGroupButton-root|Styles applied to the root element.|
|
|
45
40
|
|
|
46
41
|
* @param inProps
|
|
47
42
|
*/
|
|
48
|
-
export default function
|
|
43
|
+
export default function EditGroupButton(inProps: EditGroupButtonProps): JSX.Element;
|