Social: Load promoted messages in wall

pull/4161/head
Angel Fernando Quiroz Campos 3 years ago
parent 3b37acc1a8
commit 4db22d774e
  1. 2
      assets/vue/components/social/CommentForm.vue
  2. 2
      assets/vue/components/social/PostForm.vue
  3. 8
      assets/vue/components/social/WallPost.vue
  4. 19
      src/CoreBundle/Entity/SocialPost.php
  5. 19
      src/CoreBundle/Filter/SocialWallFilter.php
  6. 5
      src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php

@ -1,5 +1,5 @@
<template> <template>
<q-form class="q-gutter-md p-4 pt-0"> <q-form class="q-gutter-md p-4">
<q-input <q-input
v-model="comment" v-model="comment"
:label="$t('Write new comment')" :label="$t('Write new comment')"

@ -81,7 +81,7 @@ export default {
content: postState.content, content: postState.content,
type: SOCIAL_TYPE_WALL_POST, type: SOCIAL_TYPE_WALL_POST,
sender: currentUser['@id'], sender: currentUser['@id'],
userReceiver: user.value['@id'] userReceiver: currentUser['@id'] === user.value['@id'] ? null : user.value['@id'],
}; };
await store.dispatch('socialpost/create', createPostPayload); await store.dispatch('socialpost/create', createPostPayload);

@ -1,8 +1,9 @@
<template> <template>
<q-card <q-card
:class="{ 'border-green-400': post.type === 4 }"
:flat="post.type !== 4"
bordered bordered
class="mb-4" class="mb-4"
flat
> >
<q-item> <q-item>
<q-item-section side> <q-item-section side>
@ -60,11 +61,14 @@
/> />
<q-card-section v-html="post.content" /> <q-card-section v-html="post.content" />
<q-separator /> <q-separator :color="post.type === 4 ? 'green-400' : false" />
<q-list <q-list
v-if="comments.length" v-if="comments.length"
:class="{ 'border-green-400': post.type === 4 }"
bordered bordered
class="border-t-0"
separator
> >
<q-item-label header>{{ $t('Comments') }}</q-item-label> <q-item-label header>{{ $t('Comments') }}</q-item-label>

@ -110,6 +110,11 @@ class SocialPost
#[Groups(['social_post:read', 'social_post:write'])] #[Groups(['social_post:read', 'social_post:write'])]
protected ?User $userReceiver; protected ?User $userReceiver;
/**
* @ORM\Column(name="subject", type="text", nullable=true)
*/
protected ?string $subject;
/** /**
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
@ -127,7 +132,7 @@ class SocialPost
* ) * )
* @ORM\Column(type="smallint") * @ORM\Column(type="smallint")
*/ */
#[Groups(['social_post:write'])] #[Groups(['social_post:write', 'social_post:read'])]
protected int $type; protected int $type;
/** /**
@ -259,6 +264,18 @@ class SocialPost
return $this; return $this;
} }
public function getSubject(): ?string
{
return $this->subject;
}
public function setSubject(?string $subject): self
{
$this->subject = $subject;
return $this;
}
public function getContent(): string public function getContent(): string
{ {
return $this->content; return $this->content;

@ -47,14 +47,19 @@ class SocialWallFilter extends AbstractContextAwareFilter
$rootAlias = $queryBuilder->getRootAliases()[0]; $rootAlias = $queryBuilder->getRootAliases()[0];
$queryBuilder $queryBuilder
->andWhere(sprintf('%1$s.sender = :owner OR %1$s.userReceiver = :owner', $rootAlias)) ->andWhere(
->andWhere(sprintf('%s.type = :type', $rootAlias)) $queryBuilder->expr()->andX(
->setParameters( $queryBuilder->expr()->orX(
[ $queryBuilder->expr()->eq("$rootAlias.sender", ':owner'),
'owner' => $value, $queryBuilder->expr()->eq("$rootAlias.userReceiver", ':owner')
'type' => SocialPost::TYPE_WALL_POST, ),
] $queryBuilder->expr()->eq("$rootAlias.type", SocialPost::TYPE_WALL_POST)
) )
)
->orWhere(
$queryBuilder->expr()->eq("$rootAlias.type", SocialPost::TYPE_PROMOTED_MESSAGE)
)
->setParameter('owner', $value)
; ;
} }
} }

@ -165,14 +165,15 @@ final class Version20200821224242 extends AbstractMigrationChamilo
//$this->addSql('ALTER TABLE message CHANGE msg_status msg_status SMALLINT NOT NULL;'); //$this->addSql('ALTER TABLE message CHANGE msg_status msg_status SMALLINT NOT NULL;');
$this->addSql("CREATE TABLE social_post (id BIGINT AUTO_INCREMENT NOT NULL, sender_id INT NOT NULL, user_receiver_id INT DEFAULT NULL, group_receiver_id INT DEFAULT NULL, parent_id BIGINT DEFAULT NULL, content LONGTEXT NOT NULL, type SMALLINT NOT NULL, status SMALLINT NOT NULL, send_date DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_159BBFE9727ACA70 (parent_id), INDEX idx_social_post_sender (sender_id), INDEX idx_social_post_user (user_receiver_id), INDEX idx_social_post_group (group_receiver_id), INDEX idx_social_post_type (type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC"); $this->addSql("CREATE TABLE social_post (id BIGINT AUTO_INCREMENT NOT NULL, sender_id INT NOT NULL, user_receiver_id INT DEFAULT NULL, group_receiver_id INT DEFAULT NULL, parent_id BIGINT DEFAULT NULL, subject LONGTEXT DEFAULT NULL, content LONGTEXT NOT NULL, type SMALLINT NOT NULL, status SMALLINT NOT NULL, send_date DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_159BBFE9727ACA70 (parent_id), INDEX idx_social_post_sender (sender_id), INDEX idx_social_post_user (user_receiver_id), INDEX idx_social_post_group (group_receiver_id), INDEX idx_social_post_type (type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC");
$sql = 'INSERT INTO social_post (id, sender_id, user_receiver_id, group_receiver_id, parent_id, content, type, status, send_date, updated_at) $sql = 'INSERT INTO social_post (id, sender_id, user_receiver_id, group_receiver_id, parent_id, subject, content, type, status, send_date, updated_at)
SELECT DISTINCT m.id, SELECT DISTINCT m.id,
m.user_sender_id, m.user_sender_id,
m.user_receiver_id, m.user_receiver_id,
m.group_id, m.group_id,
m.parent_id, m.parent_id,
m.title,
m.content, m.content,
CASE m.msg_type CASE m.msg_type
WHEN 1 THEN 3 WHEN 1 THEN 3

Loading…
Cancel
Save