From 60f15224d43384e5805c0cbb5febc1959d8153e1 Mon Sep 17 00:00:00 2001 From: staniel359 Date: Wed, 6 Apr 2022 14:45:51 +0300 Subject: [PATCH] [WIP] Add communities --- src/assets/styles/Main.sass | 14 +- src/components/BaseTimestamp.vue | 2 +- src/components/buttons/BaseSubmitButton.vue | 8 + .../community/BaseCommunityCreateButton.vue | 2 +- .../playlist/BasePlaylistCreateButton.vue | 2 +- .../containers/BaseDropdownContainer.vue | 8 +- .../containers/forms/BaseFormContainer.vue | 2 +- .../BaseCommunityCreateFormContainer.vue | 6 +- .../post/BasePostCreateFormContainer.vue | 33 +++-- .../post/BasePostUpdateFormContainer.vue | 55 ++++--- .../lists/BasePaginatedListContainer.vue | 8 +- .../community/BaseCommunityPageContainer.vue | 4 + .../posts/BaseCommunityPostsPageContainer.vue | 104 +++++++++++++ .../BaseConversationSegmentContainer.vue | 4 +- .../playlist/BasePlaylistSegmentContainer.vue | 4 +- src/components/dropdowns/BaseDropdown.vue | 9 +- .../BaseOptionsDropdown/DeleteOption.vue | 3 +- src/components/fields/BaseContentField.vue | 7 + src/components/fields/BaseImageField.vue | 9 +- .../fields/post/BasePostAsCommunityField.vue | 41 ++++++ .../fields/profile/BaseProfileImageField.vue | 11 +- .../profile/BaseProfileRememberField.vue | 2 +- .../forms/BaseFormAddButtonsSection.vue | 23 +-- .../ImagesButton.vue | 21 +-- src/components/inputs/BaseImageInput.vue | 4 + .../SearchContent/SearchSourceSelect.vue | 1 + .../DataOptions/ClearCacheOption.vue | 2 + .../DataOptions/ClearSearchHistoryOption.vue | 2 + src/components/links/BaseLink.vue | 4 +- .../CommunityItem.vue | 6 +- .../lists/messages/BaseMessagesSimpleList.vue | 15 +- .../BaseMessagesSimpleList/MessageItem.vue | 66 +++++---- .../lists/posts/BasePostsSimpleList.vue | 4 +- .../posts/BasePostsSimpleList/PostItem.vue | 139 +++++++++++------- .../PostItem/CommunityTitle.vue | 50 +++++++ src/components/modals/BaseDeleteModal.vue | 3 +- .../modals/post/BasePostDeleteModal.vue | 31 +++- .../modals/post/BasePostUpdateModal.vue | 28 +++- .../FolderSelectSection.vue | 1 + .../profile/BaseProfileFollowButton.vue | 1 + .../segments/posts/BasePostsFormSegment.vue} | 25 +++- .../actions/api/community/post/create.js | 51 +++++++ .../actions/api/community/post/delete.js | 37 +++++ .../actions/api/community/post/update.js | 55 +++++++ src/helpers/actions/api/profile/get.js | 6 +- .../actions/api/{ => profile}/post/create.js | 6 + .../actions/api/{ => profile}/post/delete.js | 0 .../actions/api/{ => profile}/post/update.js | 5 +- src/helpers/data/plugins/i18n/locales/en.json | 7 +- src/helpers/data/plugins/i18n/locales/ru.json | 7 +- src/helpers/data/plugins/router/routes.js | 20 ++- src/helpers/formatters/links.js | 8 + src/helpers/formatters/links/communities.js | 15 -- src/helpers/formatters/links/community.js | 15 ++ .../navigation/sections/communities.js | 4 +- .../navigation/sections/community.js | 6 +- src/helpers/formatters/tabs/communities.js | 4 +- src/helpers/formatters/tabs/community.js | 6 +- .../formatters/tabs/community/posts.js | 25 ++++ .../MainPage.vue => CommunitiesPage.vue} | 2 +- src/views/community/MainPage/PostsSegment.vue | 82 +++++++++++ .../PostsSegment/PostsListSegment.vue | 93 ++++++++++++ src/views/community/PostsPage.vue | 73 +++++++++ src/views/profile/CommunitiesPage.vue | 4 +- .../FavoritesSegment/FavoritesTabsSegment.vue | 4 +- .../MainPage/InfoSegment/MessageSection.vue | 2 +- .../LibrarySegment/LibraryTabsSegment.vue | 4 +- src/views/profile/MainPage/PostsSegment.vue | 8 +- .../ImportSegment/LibraryImportBlock.vue | 2 +- .../ImportSegment/SearchImportBlock.vue | 2 +- .../ImportSegment/AccountImportBlock.vue | 2 +- .../ImportSegment/FolderImportBlock.vue | 6 +- .../ImportSegment/SearchImportBlock.vue | 6 +- 73 files changed, 1072 insertions(+), 259 deletions(-) create mode 100644 src/components/containers/pages/community/posts/BaseCommunityPostsPageContainer.vue create mode 100644 src/components/fields/post/BasePostAsCommunityField.vue create mode 100644 src/components/lists/posts/BasePostsSimpleList/PostItem/CommunityTitle.vue rename src/{views/profile/MainPage/PostsSegment/FormSegment.vue => components/segments/posts/BasePostsFormSegment.vue} (79%) create mode 100644 src/helpers/actions/api/community/post/create.js create mode 100644 src/helpers/actions/api/community/post/delete.js create mode 100644 src/helpers/actions/api/community/post/update.js rename src/helpers/actions/api/{ => profile}/post/create.js (87%) rename src/helpers/actions/api/{ => profile}/post/delete.js (100%) rename src/helpers/actions/api/{ => profile}/post/update.js (91%) delete mode 100644 src/helpers/formatters/links/communities.js create mode 100644 src/helpers/formatters/links/community.js create mode 100644 src/helpers/formatters/tabs/community/posts.js rename src/views/{communities/MainPage.vue => CommunitiesPage.vue} (98%) create mode 100644 src/views/community/MainPage/PostsSegment.vue create mode 100644 src/views/community/MainPage/PostsSegment/PostsListSegment.vue create mode 100644 src/views/community/PostsPage.vue diff --git a/src/assets/styles/Main.sass b/src/assets/styles/Main.sass index 3568cd175..58deae6c1 100644 --- a/src/assets/styles/Main.sass +++ b/src/assets/styles/Main.sass @@ -259,7 +259,7 @@ a & > .content @extend .flex-full, .no-padding .content-container - margin-top: 1em + margin-top: 0.75em .content-section margin-top: 5px !important .text @@ -267,6 +267,8 @@ a line-height: 1.2em & > .description margin-top: 0.25em !important + &.main-timestamp + @extend .no-margin .main-options-dropdown-container @extend .visibility-hidden margin-left: 0.5em @@ -279,10 +281,8 @@ a @extend .text-color-base .main-options-dropdown-container @extend .visibility-visible - -.main-message-item, .main-profile-item - & > .image - align-self: start + &.main-post-item, &.main-message-item, &.main-profile-item + @extend .align-items-start .main-message @extend .no-shadow, .no-margin @@ -630,8 +630,10 @@ a & > .buttons-container @extend .d-flex, .align-items-center margin-top: 1em - & > .add-buttons + & > .add-buttons-container @extend .flex-full + & > .main-as-community-checkbox + margin: 0 1em .images-tracks-section margin-top: 1em diff --git a/src/components/BaseTimestamp.vue b/src/components/BaseTimestamp.vue index cb09a792f..255bac58c 100644 --- a/src/components/BaseTimestamp.vue +++ b/src/components/BaseTimestamp.vue @@ -1,5 +1,5 @@ @@ -14,6 +15,9 @@ export default { props: { value: String }, + emits: [ + 'submit' + ], computed: { contentText () { return this.$t( @@ -22,6 +26,9 @@ export default { } }, methods: { + handleCtrlEnter () { + this.$emit('submit') + }, focus () { this.$refs.input.focus() }, diff --git a/src/components/fields/BaseImageField.vue b/src/components/fields/BaseImageField.vue index c7a60be6f..2ed3a4e48 100644 --- a/src/components/fields/BaseImageField.vue +++ b/src/components/fields/BaseImageField.vue @@ -9,8 +9,9 @@ @@ -58,9 +59,9 @@ export default { } }, computed: { - addText () { + uploadText () { return this.$t( - 'forms.fields.image' + 'actions.upload' ) }, deleteText () { diff --git a/src/components/fields/post/BasePostAsCommunityField.vue b/src/components/fields/post/BasePostAsCommunityField.vue new file mode 100644 index 000000000..0162948b5 --- /dev/null +++ b/src/components/fields/post/BasePostAsCommunityField.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/components/fields/profile/BaseProfileImageField.vue b/src/components/fields/profile/BaseProfileImageField.vue index 7b549455c..e371e5a97 100644 --- a/src/components/fields/profile/BaseProfileImageField.vue +++ b/src/components/fields/profile/BaseProfileImageField.vue @@ -9,15 +9,16 @@ @@ -54,9 +55,9 @@ export default { } }, computed: { - addText () { + uploadText () { return this.$t( - 'forms.fields.image' + 'actions.upload' ) }, deleteText () { diff --git a/src/components/fields/profile/BaseProfileRememberField.vue b/src/components/fields/profile/BaseProfileRememberField.vue index 8dd04b71c..7fd9b2c52 100644 --- a/src/components/fields/profile/BaseProfileRememberField.vue +++ b/src/components/fields/profile/BaseProfileRememberField.vue @@ -24,7 +24,7 @@ export default { computed: { rememberText () { return this.$t( - 'forms.remember' + 'forms.fields.remember' ) } }, diff --git a/src/components/forms/BaseFormAddButtonsSection.vue b/src/components/forms/BaseFormAddButtonsSection.vue index bc5bc8061..0a07acce8 100644 --- a/src/components/forms/BaseFormAddButtonsSection.vue +++ b/src/components/forms/BaseFormAddButtonsSection.vue @@ -1,24 +1,29 @@ diff --git a/src/components/lists/posts/BasePostsSimpleList/PostItem.vue b/src/components/lists/posts/BasePostsSimpleList/PostItem.vue index 92d16c92f..c86c31fd9 100644 --- a/src/components/lists/posts/BasePostsSimpleList/PostItem.vue +++ b/src/components/lists/posts/BasePostsSimpleList/PostItem.vue @@ -1,6 +1,6 @@ @@ -77,17 +80,18 @@ import { mapState } from 'vuex' import BaseDeletedBlock from '*/components/BaseDeletedBlock.vue' import BaseImage from '*/components/images/BaseImage.vue' +import CommunityTitle from './PostItem/CommunityTitle.vue' import BaseProfileNickname from '*/components/models/profile/BaseProfileNickname.vue' import BaseTimestamp from '*/components/BaseTimestamp.vue' +import BaseImagesSection from '*/components/BaseImagesSection.vue' +import BaseTracksSection from '*/components/BaseTracksSection.vue' import BaseOptionsDropdown from '*/components/dropdowns/BaseOptionsDropdown.vue' import BasePostUpdateModal from '*/components/modals/post/BasePostUpdateModal.vue' import BasePostDeleteModal from '*/components/modals/post/BasePostDeleteModal.vue' -import BaseImagesSection from '*/components/BaseImagesSection.vue' -import BaseTracksSection from '*/components/BaseTracksSection.vue' import { setToast } from '*/helpers/actions/plugins/semantic' export default { @@ -95,13 +99,14 @@ export default { components: { BaseDeletedBlock, BaseImage, + CommunityTitle, BaseProfileNickname, BaseTimestamp, + BaseImagesSection, + BaseTracksSection, BaseOptionsDropdown, BasePostUpdateModal, - BasePostDeleteModal, - BaseImagesSection, - BaseTracksSection + BasePostDeleteModal }, inject: [ 'findPaginationItem', @@ -112,14 +117,22 @@ export default { type: Object, required: true }, - profileId: String + profileId: String, + communityCreatorId: String }, computed: { ...mapState('profile', { profileInfo: 'info' }), imageData () { - return this.profileData.image + if (this.isByCommunity) { + return this.communityData.image + } else { + return this.profileData.image + } + }, + communityData () { + return this.postData.community }, profileData () { return this.postData.profile @@ -129,11 +142,12 @@ export default { }, isWithOptions () { return ( - this.isPostOwner || - this.isPageOwner + this.isPostCreator || + this.isPageOwner || + this.isCommunityCreator ) }, - isPostOwner () { + isPostCreator () { return ( this.currentProfileId === this.postProfileId @@ -151,6 +165,12 @@ export default { this.profileId ) }, + isCommunityCreator () { + return ( + this.currentProfileId === + this.communityCreatorId + ) + }, updatedMessage () { return this.$t( 'notifications.updated.post' @@ -175,6 +195,26 @@ export default { }, uuid () { return this.postData.uuid + }, + isWithEditOption () { + return this.isPostCreator + }, + isByCommunity () { + return this.postData.by_community + }, + imageClass () { + if (this.isByCommunity) { + return 'rounded' + } else { + return 'circular' + } + }, + imageModel () { + if (this.isByCommunity) { + return 'community' + } else { + return 'profile' + } } }, methods: { @@ -207,13 +247,4 @@ export default { } - + diff --git a/src/components/lists/posts/BasePostsSimpleList/PostItem/CommunityTitle.vue b/src/components/lists/posts/BasePostsSimpleList/PostItem/CommunityTitle.vue new file mode 100644 index 000000000..31e092c81 --- /dev/null +++ b/src/components/lists/posts/BasePostsSimpleList/PostItem/CommunityTitle.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/src/components/modals/BaseDeleteModal.vue b/src/components/modals/BaseDeleteModal.vue index 28630bcef..343c578fb 100644 --- a/src/components/modals/BaseDeleteModal.vue +++ b/src/components/modals/BaseDeleteModal.vue @@ -22,12 +22,13 @@
import BaseDeleteModal from '*/components/modals/BaseDeleteModal.vue' -import deletePost from '*/helpers/actions/api/post/delete' +import deleteProfilePost from '*/helpers/actions/api/profile/post/delete' +import deleteCommunityPost from '*/helpers/actions/api/community/post/delete' export default { name: 'BasePostDeleteModal', @@ -36,17 +37,22 @@ export default { postId () { return this.postData.id }, + postType () { + return this.postData.post_type + }, + communityId () { + return this.postData.community?.id + }, deleteArgs () { return { + communityId: this.communityId, postId: this.postId } } }, methods: { handleDeleteButtonClick () { - this.deletePost( - this.deleteArgs - ).then( + this.deletePost().then( this.handleSuccess ) }, @@ -55,7 +61,22 @@ export default { this.$emit('deleted') }, - deletePost, + deleteProfilePost, + deleteCommunityPost, + deletePost () { + switch (this.postType) { + case 'profile': + return this.deleteProfilePost( + this.deleteArgs + ) + case 'community': + return this.deleteCommunityPost( + this.deleteArgs + ) + default: + return null + } + }, show () { this.$refs.modal.show() } diff --git a/src/components/modals/post/BasePostUpdateModal.vue b/src/components/modals/post/BasePostUpdateModal.vue index e00744ed3..b03fb2ff0 100644 --- a/src/components/modals/post/BasePostUpdateModal.vue +++ b/src/components/modals/post/BasePostUpdateModal.vue @@ -3,14 +3,15 @@
+ +
@@ -59,6 +66,8 @@ import BaseFormTracksSection from '*/components/forms/BaseFormTracksSection.vue' import BaseFormAddButtonsSection from '*/components/forms/BaseFormAddButtonsSection.vue' +import BasePostAsCommunityField + from '*/components/fields/post/BasePostAsCommunityField.vue' import BaseSubmitButton from '*/components/buttons/BaseSubmitButton.vue' import { generateKey } from '*/helpers/utils' import { collection as formatCollection } from '*/helpers/formatters' @@ -72,13 +81,15 @@ export default { BaseFormImagesSection, BaseFormTracksSection, BaseFormAddButtonsSection, + BasePostAsCommunityField, BaseSubmitButton }, props: { postData: { type: Object, required: true - } + }, + isWithAsCommunityOption: Boolean }, emits: [ 'updated' @@ -90,9 +101,6 @@ export default { } }, computed: { - postId () { - return this.postData.id.toString() - }, postContent () { return this.postData.content }, @@ -106,6 +114,9 @@ export default { }, postTracks () { return this.postData.tracks || [] + }, + isByCommunity () { + return this.postData.by_community } }, mounted () { @@ -116,13 +127,16 @@ export default { this.tracks = this.tracksCollection }, methods: { + handleSubmit () { + this.$refs.submit.click() + }, handleTracksChange (value) { this.tracks = value }, handleImagesChange (value) { this.images = value }, - handlePostDataChange (value) { + handleSuccess (value) { this.$emit( 'updated', value diff --git a/src/components/modals/profile/library/BaseProfileLibraryFolderImportModal/FolderSelectSection.vue b/src/components/modals/profile/library/BaseProfileLibraryFolderImportModal/FolderSelectSection.vue index 2b82eb23a..81b41d7c6 100644 --- a/src/components/modals/profile/library/BaseProfileLibraryFolderImportModal/FolderSelectSection.vue +++ b/src/components/modals/profile/library/BaseProfileLibraryFolderImportModal/FolderSelectSection.vue @@ -13,6 +13,7 @@