note.related_id
This commit is contained in:
@@ -73,6 +73,12 @@ class Stream extends \Espo\Core\Hooks\Base
|
||||
if ($this->checkHasStream($entity)) {
|
||||
$this->getStreamService()->unfollowAllUsersFromEntity($entity);
|
||||
}
|
||||
$query = $this->getEntityManager()->getQuery();
|
||||
$sql = "
|
||||
DELETE FROM `note`
|
||||
WHERE related_id = ".$query->quote($entity->id)." AND related_type = ".$query->quote($entity->getEntityType()) ."
|
||||
";
|
||||
$this->getEntityManager()->getPDO()->query($sql);
|
||||
}
|
||||
|
||||
protected function handleCreateRelated(Entity $entity)
|
||||
|
||||
@@ -4,13 +4,20 @@
|
||||
"type": "text"
|
||||
},
|
||||
"data": {
|
||||
"type": "jsonObject"
|
||||
"type": "jsonObject",
|
||||
"readOnly": true
|
||||
},
|
||||
"type": {
|
||||
"type": "varchar"
|
||||
"type": "varchar",
|
||||
"readOnly": true
|
||||
},
|
||||
"parent": {
|
||||
"type": "linkParent"
|
||||
"type": "linkParent",
|
||||
"readOnly": true
|
||||
},
|
||||
"related": {
|
||||
"type": "linkParent",
|
||||
"readOnly": true
|
||||
},
|
||||
"attachments": {
|
||||
"type": "linkMultiple",
|
||||
@@ -18,7 +25,8 @@
|
||||
},
|
||||
"number": {
|
||||
"type": "autoincrement",
|
||||
"index": true
|
||||
"index": true,
|
||||
"readOnly": true
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
@@ -58,6 +66,9 @@
|
||||
},
|
||||
"superParent": {
|
||||
"type": "belongsToParent"
|
||||
},
|
||||
"related": {
|
||||
"type": "belongsToParent"
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
|
||||
@@ -279,6 +279,8 @@ class Stream extends \Espo\Core\Services\Base
|
||||
note.data AS 'data',
|
||||
note.parent_type AS 'parentType',
|
||||
note.parent_id AS 'parentId',
|
||||
note.related_type AS 'relatedType',
|
||||
note.related_id AS 'relatedId',
|
||||
note.created_at AS 'createdAt',
|
||||
note.created_by_id AS 'createdById',
|
||||
TRIM(CONCAT(createdBy.first_name, ' ', createdBy.last_name)) AS `createdByName`
|
||||
@@ -305,6 +307,8 @@ class Stream extends \Espo\Core\Services\Base
|
||||
note.data AS 'data',
|
||||
note.parent_type AS 'parentType',
|
||||
note.parent_id AS 'parentId',
|
||||
note.related_type AS 'relatedType',
|
||||
note.related_id AS 'relatedId',
|
||||
note.created_at AS 'createdAt',
|
||||
note.created_by_id AS 'createdById',
|
||||
TRIM(CONCAT(createdBy.first_name, ' ', createdBy.last_name)) AS `createdByName`
|
||||
@@ -357,6 +361,12 @@ class Stream extends \Espo\Core\Services\Base
|
||||
$e->set('parentName', $entity->get('name'));
|
||||
}
|
||||
}
|
||||
if ($e->get('relatedId') && $e->get('relatedType')) {
|
||||
$entity = $this->getEntityManager()->getEntity($e->get('relatedType'), $e->get('relatedId'));
|
||||
if ($entity) {
|
||||
$e->set('relatedName', $entity->get('name'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($collection) > $maxSize) {
|
||||
@@ -427,7 +437,12 @@ class Stream extends \Espo\Core\Services\Base
|
||||
$e->set('parentName', $parent->get('name'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($e->get('relatedId') && $e->get('relatedType')) {
|
||||
$entity = $this->getEntityManager()->getEntity($e->get('relatedType'), $e->get('relatedId'));
|
||||
if ($entity) {
|
||||
$e->set('relatedName', $entity->get('name'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -575,13 +590,13 @@ class Stream extends \Espo\Core\Services\Base
|
||||
$data['assignedUserName'] = $entity->get('assignedUserName');
|
||||
}
|
||||
|
||||
$statusStyles = $this->getStatusStyles();
|
||||
$statusFields = $this->getStatusFields();
|
||||
|
||||
if (!empty($statusFields[$entityType])) {
|
||||
$field = $statusFields[$entityType];
|
||||
$value = $entity->get($field);
|
||||
if (!empty($value)) {
|
||||
$statusStyles = $this->getStatusStyles();
|
||||
$style = 'default';
|
||||
if (!empty($statusStyles[$entityType]) && !empty($statusStyles[$entityType][$value])) {
|
||||
$style = $statusStyles[$entityType][$value];
|
||||
@@ -597,26 +612,25 @@ class Stream extends \Espo\Core\Services\Base
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
|
||||
public function noteCreateRelated(Entity $entity, $entityType, $id, $action = 'created')
|
||||
public function noteCreateRelated(Entity $entity, $parentType, $parentId)
|
||||
{
|
||||
$note = $this->getEntityManager()->getEntity('Note');
|
||||
|
||||
$entityType = $entity->getEntityType();
|
||||
|
||||
$note->set('type', 'CreateRelated');
|
||||
$note->set('parentId', $id);
|
||||
$note->set('parentType', $entityType);
|
||||
$note->set('parentId', $parentId);
|
||||
$note->set('parentType', $parentType);
|
||||
$note->set(array(
|
||||
'relatedType' => $entityType,
|
||||
'relatedId' => $entity->id,
|
||||
));
|
||||
|
||||
if ($entity->has('accountId') && $entity->get('accountId')) {
|
||||
$note->set('superParentId', $entity->get('accountId'));
|
||||
$note->set('superParentType', 'Account');
|
||||
}
|
||||
|
||||
$note->set('data', array(
|
||||
'action' => $action,
|
||||
'entityType' => $entity->getEntityName(),
|
||||
'entityId' => $entity->id,
|
||||
'entityName' => $entity->get('name')
|
||||
));
|
||||
|
||||
$this->getEntityManager()->saveEntity($note);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
{{{avatar}}}
|
||||
</div>
|
||||
<div class="stream-head-text-container">
|
||||
{{#if statusText}}
|
||||
<span class="label label-{{statusStyle}}">{{statusText}}</span>
|
||||
{{/if}}
|
||||
<span class="text-muted message">{{{message}}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -29,10 +29,6 @@ Espo.define('Views.Stream.Notes.CreateRelated', 'Views.Stream.Note', function (D
|
||||
|
||||
data: function () {
|
||||
return _.extend({
|
||||
entityType: this.entityType,
|
||||
entityId: this.entityId,
|
||||
entityName: this.entityName,
|
||||
action: this.action,
|
||||
relatedTypeString: this.translate(this.entityType, 'scopeNames').toLowerCase()
|
||||
}, Dep.prototype.data.call(this));
|
||||
},
|
||||
@@ -45,17 +41,14 @@ Espo.define('Views.Stream.Notes.CreateRelated', 'Views.Stream.Note', function (D
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
if (this.model.get('data')) {
|
||||
var data = this.model.get('data');
|
||||
var data = this.model.get('data') || {};
|
||||
|
||||
this.entityType = data.entityType || null;
|
||||
this.entityId = data.entityId || null;
|
||||
this.entityName = data.entityName || null;
|
||||
this.action = data.action || null;
|
||||
this.entityType = this.model.get('relatedType') || data.entityType || null;
|
||||
this.entityId = this.model.get('relatedId') || data.entityId || null;
|
||||
this.entityName = this.model.get('relatedName') || data.entityName || null;
|
||||
|
||||
this.messageData['relatedEntityType'] = this.translate(this.entityType, 'scopeNames').toLowerCase();
|
||||
this.messageData['relatedEntity'] = '<a href="#' + this.entityType + '/view/' + this.entityId + '">' + this.entityName +'</a>';
|
||||
}
|
||||
this.messageData['relatedEntityType'] = this.translate(this.entityType, 'scopeNames').toLowerCase();
|
||||
this.messageData['relatedEntity'] = '<a href="#' + this.entityType + '/view/' + this.entityId + '">' + this.entityName +'</a>';
|
||||
|
||||
this.createMessage();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user