intenal post dev
This commit is contained in:
@@ -60,13 +60,26 @@ class Notifications extends \Espo\Core\Hooks\Base
|
||||
return $mentionedUserList;
|
||||
}
|
||||
|
||||
protected function getSubscriberIdList($parentType, $parentId)
|
||||
protected function getSubscriberIdList($parentType, $parentId, $isInternal = false)
|
||||
{
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sql = "
|
||||
SELECT user_id AS userId
|
||||
FROM subscription
|
||||
WHERE entity_id = " . $pdo->quote($parentId) . " AND entity_type = " . $pdo->quote($parentType);
|
||||
|
||||
if (!$isInternal) {
|
||||
$sql = "
|
||||
SELECT user_id AS userId
|
||||
FROM subscription
|
||||
WHERE entity_id = " . $pdo->quote($parentId) . " AND entity_type = " . $pdo->quote($parentType) . "
|
||||
";
|
||||
} else {
|
||||
$sql = "
|
||||
SELECT subscription.user_id AS userId
|
||||
FROM subscription
|
||||
JOIN user ON user.id = subscription.user_id
|
||||
WHERE
|
||||
entity_id = " . $pdo->quote($parentId) . " AND entity_type = " . $pdo->quote($parentType) . " AND
|
||||
user.is_portal_user = 0
|
||||
";
|
||||
}
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
$userIdList = [];
|
||||
@@ -89,9 +102,9 @@ class Notifications extends \Espo\Core\Hooks\Base
|
||||
$userIdList = [];
|
||||
|
||||
if ($parentType && $parentId) {
|
||||
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($parentType, $parentId));
|
||||
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($parentType, $parentId, $entity->get('isInternal')));
|
||||
if ($superParentType && $superParentId) {
|
||||
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($superParentType, $superParentId));
|
||||
$userIdList = array_merge($userIdList, $this->getSubscriberIdList($superParentType, $superParentId, $entity->get('isInternal')));
|
||||
}
|
||||
} else {
|
||||
$targetType = $entity->get('targetType');
|
||||
|
||||
@@ -48,5 +48,6 @@
|
||||
"boolFilterList": ["onlyMy"],
|
||||
"selectDefaultFilters": {
|
||||
"filter": "open"
|
||||
}
|
||||
},
|
||||
"allowInternalNotes": true
|
||||
}
|
||||
|
||||
@@ -224,7 +224,8 @@
|
||||
"writeMessageToSelf": "Write a message to self",
|
||||
"typeAndPressEnter": "Type & press enter",
|
||||
"checkForNewNotifications": "Check for new notifications",
|
||||
"checkForNewNotes": "Check for new Stream entries"
|
||||
"checkForNewNotes": "Check for new Stream entries",
|
||||
"internalPost": "Post will be seen only by internal users"
|
||||
},
|
||||
"boolFilters": {
|
||||
"onlyMy": "Only My",
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
},
|
||||
"Attachment": {
|
||||
"parent": false
|
||||
},
|
||||
"Note": {
|
||||
"isInternal": false,
|
||||
"isGlobal": false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -50,6 +50,9 @@
|
||||
"type": "jsonArray",
|
||||
"notStorable": true
|
||||
},
|
||||
"isInternal": {
|
||||
"type": "bool"
|
||||
},
|
||||
"isToSelf": {
|
||||
"type": "bool"
|
||||
},
|
||||
|
||||
@@ -300,7 +300,7 @@ class Stream extends \Espo\Core\Services\Base
|
||||
|
||||
$selectParamsList = [];
|
||||
|
||||
$selectParamsList[] = array(
|
||||
$selectParamsSubscription = array(
|
||||
'select' => $select,
|
||||
'leftJoins' => ['createdBy'],
|
||||
'customJoin' => "
|
||||
@@ -318,7 +318,15 @@ class Stream extends \Espo\Core\Services\Base
|
||||
'order' => 'DESC'
|
||||
);
|
||||
|
||||
$selectParamsList[] = array(
|
||||
if ($user->get('isPortalUser')) {
|
||||
$selectParamsSubscription['whereClause'][] = array(
|
||||
'isInternal' => false
|
||||
);
|
||||
}
|
||||
|
||||
$selectParamsList[] = $selectParamsSubscription;
|
||||
|
||||
$selectParamsSubscriptionSuper = array(
|
||||
'select' => $select,
|
||||
'leftJoins' => ['createdBy'],
|
||||
'customJoin' => "
|
||||
@@ -342,6 +350,14 @@ class Stream extends \Espo\Core\Services\Base
|
||||
'order' => 'DESC'
|
||||
);
|
||||
|
||||
if ($user->get('isPortalUser')) {
|
||||
$selectParamsSubscriptionSuper['whereClause'][] = array(
|
||||
'isInternal' => false
|
||||
);
|
||||
}
|
||||
|
||||
$selectParamsList[] = $selectParamsSubscriptionSuper;
|
||||
|
||||
$selectParamsList[] = array(
|
||||
'select' => $select,
|
||||
'leftJoins' => ['createdBy'],
|
||||
@@ -594,6 +610,12 @@ class Stream extends \Espo\Core\Services\Base
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->getUser()->get('isPortalUser')) {
|
||||
$where[] = array(
|
||||
'isInternal' => false
|
||||
);
|
||||
}
|
||||
|
||||
$collection = $this->getEntityManager()->getRepository('Note')->find(array(
|
||||
'whereClause' => $where,
|
||||
'offset' => $params['offset'],
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
<div class="buttons-panel margin hide floated-row clearfix">
|
||||
<div>
|
||||
<button class="btn btn-primary post">{{translate 'Post'}}</button>
|
||||
|
||||
{{#if allowInternalNotes}}
|
||||
<span style="cursor: pointer;" class="internal-mode-switcher{{#if isInternalNoteMode}} enabled{{/if}} action" data-action="switchInternalMode" title="{{translate 'internalPost' category='messages'}}">
|
||||
<span class="glyphicon glyphicon-lock"></span>
|
||||
</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="attachments-container">
|
||||
{{{attachments}}}
|
||||
|
||||
@@ -43,6 +43,18 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text
|
||||
'click button.post': function () {
|
||||
this.post();
|
||||
},
|
||||
'click .action[data-action="switchInternalMode"]': function (e) {
|
||||
this.isInternalNoteMode = !this.isInternalNoteMode;
|
||||
|
||||
var $a = $(e.currentTarget);
|
||||
|
||||
if (this.isInternalNoteMode) {
|
||||
$a.addClass('enabled');
|
||||
} else {
|
||||
$a.removeClass('enabled');
|
||||
}
|
||||
|
||||
},
|
||||
'keypress textarea.note': function (e) {
|
||||
if ((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey) {
|
||||
this.post();
|
||||
@@ -62,6 +74,7 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text
|
||||
var data = Dep.prototype.data.call(this);
|
||||
data.postDisabled = this.postDisabled;
|
||||
data.placeholderText = this.placeholderText;
|
||||
data.allowInternalNotes = this.allowInternalNotes;
|
||||
return data;
|
||||
},
|
||||
|
||||
@@ -119,6 +132,13 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text
|
||||
|
||||
this.placeholderText = this.translate('writeYourCommentHere', 'messages');
|
||||
|
||||
this.allowInternalNotes = false;
|
||||
if (!this.getUser().get('isPortalUser')) {
|
||||
this.allowInternalNotes = this.getMetadata().get(['clientDefs', this.scope, 'allowInternalNotes']);
|
||||
}
|
||||
|
||||
this.isInternalNoteMode = false;
|
||||
|
||||
this.wait(true);
|
||||
this.getModelFactory().create('Note', function (model) {
|
||||
this.seed = model;
|
||||
@@ -249,7 +269,7 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text
|
||||
return;
|
||||
}
|
||||
|
||||
model.once('sync', function () {
|
||||
this.listenToOnce(model, 'sync', function () {
|
||||
this.notify('Posted', 'success');
|
||||
this.collection.fetchNew();
|
||||
|
||||
@@ -259,12 +279,12 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text
|
||||
}, this);
|
||||
|
||||
model.set('post', message);
|
||||
model.set('attachmentsIds', _.clone(this.seed.get('attachmentsIds')));
|
||||
model.set('attachmentsIds', Espo.Utils.clone(this.seed.get('attachmentsIds')));
|
||||
model.set('type', 'Post');
|
||||
model.set('isInternal', this.isInternalNoteMode);
|
||||
|
||||
this.prepareNoteForPost(model);
|
||||
|
||||
|
||||
this.notify('Posting...');
|
||||
model.save(null, {
|
||||
error: function () {
|
||||
|
||||
@@ -1019,6 +1019,18 @@ h5 {
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.post-container .internal-mode-switcher {
|
||||
color: @gray-light;
|
||||
margin-left: 10px;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.post-container .internal-mode-switcher.enabled {
|
||||
color: @link-color;
|
||||
}
|
||||
|
||||
@media screen and (min-width: @screen-sm-min) {
|
||||
#global-search-panel {
|
||||
margin-top: 5px;
|
||||
|
||||
Reference in New Issue
Block a user