add super parent for note

This commit is contained in:
yuri
2015-03-24 17:24:38 +02:00
parent 8f1a4d2a02
commit 371966e2cf
10 changed files with 94 additions and 43 deletions
@@ -55,6 +55,9 @@
"parent": {
"type": "belongsToParent",
"foreign": "notes"
},
"superParent": {
"type": "belongsToParent"
}
},
"collection": {
+34 -4
View File
@@ -264,8 +264,16 @@ class Stream extends \Espo\Core\Services\Base
'order' => 'DESC',
'customJoin' => "
JOIN subscription ON
note.parent_type = subscription.entity_type AND
note.parent_id = subscription.entity_id AND
(
(
note.parent_type = subscription.entity_type AND
note.parent_id = subscription.entity_id
) OR
(
note.super_parent_type = subscription.entity_type AND
note.super_parent_id = subscription.entity_id
)
) AND
subscription.user_id = '" . $this->getUser()->id . "'
"
);
@@ -322,8 +330,16 @@ class Stream extends \Espo\Core\Services\Base
}
$where = array(
'parentType' => $scope,
'parentId' => $id
'OR' => array(
array(
'parentType' => $scope,
'parentId' => $id
),
array(
'superParentType' => $scope,
'superParentId' => $id
)
)
);
if (!empty($params['after'])) {
@@ -342,6 +358,20 @@ class Stream extends \Espo\Core\Services\Base
if ($e->get('type') == 'Post' || $e->get('type') == 'EmailReceived') {
$e->loadAttachments();
}
if ($e->get('parentId') && $e->get('parentType')) {
if (
($e->get('parentId') != $id) ||
($e->get('parentType') != $scope)
) {
$parent = $this->getEntityManager()->getEntity($e->get('parentType'), $e->get('parentId'));
if ($parent) {
$e->set('parentName', $parent->get('name'));
}
}
}
}
unset($where['createdAt>']);
+1
View File
@@ -36,6 +36,7 @@ Espo.define('Views.Stream.List', 'Views.Record.ListExpanded', function (Dep) {
this.createView(key, viewName, {
model: model,
parentModel: this.model,
acl: {
edit: this.getAcl().checkModel(model)
},
+19 -4
View File
@@ -46,17 +46,32 @@ Espo.define('Views.Stream.Note', 'View', function (Dep) {
init: function () {
this.createField('createdAt', null, null, 'Fields.DatetimeShort');
this.isUserStream = this.options.isUserStream;
this.isThis = !this.isUserStream;
this.parentModel = this.options.parentModel;
if (this.isUserStream) {
this.createField('parent');
}
if (this.messageName) {
if (!this.isUserStream) {
this.messageName += 'This';
if (this.parentModel) {
if (
this.parentModel.name != this.model.get('parentType') ||
this.parentModel.id != this.model.get('parentId')
) {
this.isThis = false;
}
}
if (this.isThis) {
this.messageName += 'This';
}
}
}
if (!this.isThis) {
this.createField('parent');
}
this.messageData = {
'user': 'field:createdBy',
'entity': 'field:parent',
@@ -17,57 +17,57 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
Espo.define('Views.Stream.Notes.Create', 'Views.Stream.Note', function (Dep) {
return Dep.extend({
template: 'stream.notes.create',
assigned: false,
messageName: 'create',
data: function () {
return _.extend({
statusText: this.statusText,
statusStyle: this.statusStyle
}, Dep.prototype.data.call(this));
},
setup: function () {
if (this.model.get('data')) {
setup: function () {
if (this.model.get('data')) {
var data = this.model.get('data');
this.assignedUserId = data.assignedUserId || null;
this.assignedUserName = data.assignedUserName || null;
this.messageData['assignee'] = '<a href="#User/view/' + this.assignedUserId + '">' + this.assignedUserName + '</a>';
if (this.assignedUserId) {
this.messageName = 'createAssigned';
if (!this.isUserStream) {
this.messageName += 'This';
if (this.isThis) {
this.messageName += 'This';
}
}
if (this.isUserStream) {
if (this.assignedUserId == this.getUser().id) {
this.messageData['assignee'] = this.translate('you');
}
}
}
if (data.statusField) {
var statusField = this.statusField = data.statusField;
var statusValue = data.statusValue;
this.statusStyle = data.statusStyle || 'default';
var statusValue = data.statusValue;
this.statusStyle = data.statusStyle || 'default';
this.statusText = this.getLanguage().translateOption(statusValue, statusField, this.model.get('parentType'));
}
}
}
this.createMessage();
},
this.createMessage();
},
});
});
@@ -60,7 +60,7 @@ Espo.define('Views.Stream.Notes.EmailReceived', 'Views.Stream.Note', function (D
this.messageData['from'] = '<a href="#'+data.personEntityType+'/view/' + data.personEntityId + '">' + data.personEntityName + '</a>';
}
if (!this.isUserStream) {
if (this.isThis) {
this.messageName += 'This';
}
@@ -54,7 +54,7 @@ Espo.define('Views.Stream.Notes.EmailSent', 'Views.Stream.Note', function (Dep)
this.messageData['by'] = '<a href="#'+data.personEntityType+'/view/' + data.personEntityId + '">' + data.personEntityName + '</a>';
if (!this.isUserStream) {
if (this.isThis) {
this.messageName += 'This';
}
@@ -17,36 +17,37 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
************************************************************************/
************************************************************************/
Espo.define('Views.Stream.Notes.MentionInPost', 'Views.Stream.Note', function (Dep) {
return Dep.extend({
template: 'stream.notes.post',
messageName: 'mentionInPost',
setup: function () {
setup: function () {
if (this.model.get('post')) {
this.createField('post', null, null, 'Stream.Fields.Post');
}
}
if ((this.model.get('attachmentsIds') || []).length) {
this.createField('attachments', 'attachmentMultiple', {}, 'Stream.Fields.AttachmentMultiple');
}
var data = this.model.get('data');
this.messageData['mentioned'] = this.options.userId;
if (this.isUserStream) {
if (this.options.userId == this.getUser().id) {
this.messageData['mentioned'] = this.translate('you');
}
}
this.createMessage();
},
}
});
});
@@ -40,7 +40,7 @@ Espo.define('Views.Stream.Notes.Post', 'Views.Stream.Note', function (Dep) {
if (!this.model.get('post')) {
this.messageName = 'attach';
if (!this.isUserStream) {
if (this.isThis) {
this.messageName += 'This';
}
}
@@ -122,6 +122,7 @@ Espo.define('Views.Stream.Panel', ['Views.Record.Panels.Relationship', 'lib!Text
this.createView('list', 'Stream.List', {
el: this.options.el + ' > .list-container',
collection: collection,
model: this.model
}, function (view) {
view.render();
});