mirror of
https://github.com/espocrm/espocrm.git
synced 2026-07-01 08:26:04 +00:00
Stream: Update notes when edited (with web socket) (#2483)
* note edit websocket * fix note update input
This commit is contained in:
@@ -56,10 +56,6 @@ class WebSocketSubmit
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$entity->isNew()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parentId = $entity->get('parentId');
|
||||
$parentType = $entity->get('parentType');
|
||||
|
||||
@@ -75,6 +71,10 @@ class WebSocketSubmit
|
||||
'createdById' => $entity->get('createdById'),
|
||||
];
|
||||
|
||||
if (!$entity->isNew()) {
|
||||
$data->noteId = $entity->getId();
|
||||
}
|
||||
|
||||
$topic = "streamUpdate.{$parentType}.{$parentId}";
|
||||
|
||||
$this->webSocketSubmission->submit($topic, null, $data);
|
||||
|
||||
@@ -170,6 +170,19 @@ class Note extends Record
|
||||
}
|
||||
}
|
||||
|
||||
public function filterUpdateInput(stdClass $data): void
|
||||
{
|
||||
parent::filterUpdateInput($data);
|
||||
|
||||
unset($data->parentId);
|
||||
unset($data->parentType);
|
||||
unset($data->targetType);
|
||||
unset($data->usersIds);
|
||||
unset($data->teamsIds);
|
||||
unset($data->portalsIds);
|
||||
unset($data->isGlobal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NoteEntity $entity
|
||||
* @param stdClass $data
|
||||
@@ -186,14 +199,6 @@ class Note extends Record
|
||||
if (!$entity->isPost() && !$this->user->isAdmin()) {
|
||||
throw new ForbiddenSilent("Only 'Post' type allowed.");
|
||||
}
|
||||
|
||||
$entity->clear('parentId');
|
||||
$entity->clear('parentType');
|
||||
$entity->clear('targetType');
|
||||
$entity->clear('usersIds');
|
||||
$entity->clear('teamsIds');
|
||||
$entity->clear('portalsIds');
|
||||
$entity->clear('isGlobal');
|
||||
}
|
||||
|
||||
protected function handlePostText(NoteEntity $entity): void
|
||||
|
||||
@@ -298,6 +298,16 @@ define('views/stream/panel', ['views/record/panels/relationship', 'lib!Textcompl
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.noteId) {
|
||||
let model = this.collection.get(data.noteId);
|
||||
|
||||
if (model) {
|
||||
model.fetch();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.collection.fetchNew();
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user