assignmentPermission 2
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
"users": "Users",
|
||||
"teams": "Teams"
|
||||
},
|
||||
"tooltips": {
|
||||
"assignmentPermission": "Allows to restrict an ability for users to assign records to other users.\n\nall - no restriction\n\nteam - can assign users from own teams\n\nno - can assign only to self"
|
||||
},
|
||||
"labels": {
|
||||
"Access": "Access",
|
||||
"Create Role": "Create Role"
|
||||
|
||||
@@ -55,5 +55,8 @@
|
||||
"forbidden": "Forbidden, please try later",
|
||||
"uniqueLinkHasBeenSent": "The unique link has been sent to the specified email address.",
|
||||
"passwordChangedByRequest": "Password has been changed."
|
||||
},
|
||||
"boolFilters": {
|
||||
"onlyMyTeam": "Only My Team"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
"detail":"Team.Record.Detail",
|
||||
"edit":"Team.Record.Edit",
|
||||
"list":"Team.Record.List"
|
||||
}
|
||||
},
|
||||
"boolFilters": ["onlyMy"]
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
"edit":"User.Record.Edit",
|
||||
"editQuick":"User.Record.Edit",
|
||||
"list":"User.Record.List"
|
||||
}
|
||||
},
|
||||
"boolFilters": ["onlyMyTeam"]
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"assignmentPermission": {
|
||||
"type": "enum",
|
||||
"options": ["not-set", "all", "team", "no"],
|
||||
"default": "not-set"
|
||||
"default": "not-set",
|
||||
"tooltip": true
|
||||
},
|
||||
"data": {
|
||||
"type": "jsonObject"
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\SelectManagers;
|
||||
|
||||
class Team extends \Espo\Core\SelectManagers\Base
|
||||
{
|
||||
|
||||
protected function boolFilterOnlyMy(&$result)
|
||||
{
|
||||
if (!in_array('users', $result['joins'])) {
|
||||
$result['joins'][] = 'users';
|
||||
}
|
||||
$result['whereClause'][] = array(
|
||||
'teamUser.userId' => $this->getUser()->id
|
||||
);
|
||||
$result['distinct'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,5 +33,20 @@ class User extends \Espo\Core\SelectManagers\Base
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function boolFilterOnlyMyTeam(&$result)
|
||||
{
|
||||
if (!in_array('teams', $result['joins'])) {
|
||||
$result['joins'][] = 'teams';
|
||||
}
|
||||
$teamIds = $this->getUser()->get('teamsIds');
|
||||
if (empty($teamIds)) {
|
||||
$teamIds = [];
|
||||
}
|
||||
$result['whereClause'][] = array(
|
||||
'teamUser.teamId' => $teamIds
|
||||
);
|
||||
$result['distinct'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
@@ -48,6 +48,13 @@ _.extend(Espo.Acl.prototype, {
|
||||
this.data.table = this.data.table || {};
|
||||
},
|
||||
|
||||
get: function (name) {
|
||||
if (this.user.isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
return this.data[name] || null;
|
||||
},
|
||||
|
||||
check: function (controller, action, isOwner, inTeam) {
|
||||
if (this.user.isAdmin()) {
|
||||
return true;
|
||||
|
||||
@@ -153,6 +153,11 @@
|
||||
this.data.advanced = advanced;
|
||||
},
|
||||
|
||||
setBool: function (bool) {
|
||||
this.data = Espo.Utils.clone(this.data);
|
||||
this.data.bool = bool;
|
||||
},
|
||||
|
||||
set: function (data) {
|
||||
this.data = data;
|
||||
if (this.storage) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Fields.AssignedUser', 'Views.Fields.UserWithAvatar', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
init: function () {
|
||||
|
||||
if (this.getAcl().get('assignmentPermission') == 'no') {
|
||||
this.readOnly = true;
|
||||
|
||||
/*if (this.mode == 'edit') {
|
||||
this.mode = 'detail';
|
||||
}*/
|
||||
}
|
||||
Dep.prototype.init.call(this);
|
||||
},
|
||||
|
||||
getSelectBoolFilters: function () {
|
||||
var assignmentPermission = this.getAcl().get('assignmentPermission');
|
||||
if (assignmentPermission == 'team') {
|
||||
return {'onlyMyTeam': true};
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -212,7 +212,8 @@ Espo.define('Views.Fields.Base', 'View', function (Dep) {
|
||||
$a.popover({
|
||||
placement: 'bottom',
|
||||
container: 'body',
|
||||
content: this.translate(this.name, 'tooltips', this.model.name),
|
||||
html: true,
|
||||
content: this.translate(this.name, 'tooltips', this.model.name).replace(/\n/g, "<br />"),
|
||||
trigger: 'click',
|
||||
}).on('shown.bs.popover', function () {
|
||||
$('body').one('click', function () {
|
||||
|
||||
@@ -54,6 +54,8 @@ Espo.define('Views.Fields.LinkMultiple', 'Views.Fields.Base', function (Dep) {
|
||||
|
||||
getSelectFilters: function () {},
|
||||
|
||||
getSelectBoolFilters: function () {},
|
||||
|
||||
setup: function () {
|
||||
this.nameHashName = this.name + 'Names';
|
||||
this.idsName = this.name + 'Ids';
|
||||
@@ -82,6 +84,7 @@ Espo.define('Views.Fields.LinkMultiple', 'Views.Fields.Base', function (Dep) {
|
||||
scope: this.foreignScope,
|
||||
createButton: this.mode != 'search',
|
||||
filters: this.getSelectFilters(),
|
||||
boolFilters: this.getSelectBoolFilters(),
|
||||
multiple: true
|
||||
}, function (dialog) {
|
||||
dialog.render();
|
||||
|
||||
@@ -52,6 +52,10 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) {
|
||||
}, Dep.prototype.data.call(this));
|
||||
},
|
||||
|
||||
getSelectFilters: function () {},
|
||||
|
||||
getSelectBoolFilters: function () {},
|
||||
|
||||
setup: function () {
|
||||
this.nameName = this.name + 'Name';
|
||||
this.typeName = this.name + 'Type';
|
||||
@@ -76,9 +80,11 @@ Espo.define('Views.Fields.LinkParent', 'Views.Fields.Base', function (Dep) {
|
||||
this.addActionHandler('selectLink', function () {
|
||||
this.notify('Loading...');
|
||||
this.createView('dialog', 'Modals.SelectRecords', {
|
||||
scope: this.foreignScope,
|
||||
createButton: this.mode != 'search'
|
||||
}, function (dialog) {
|
||||
scope: this.foreignScope,
|
||||
createButton: this.mode != 'search',
|
||||
filters: this.getSelectFilters(),
|
||||
boolFilters: this.getSelectBoolFilters(),
|
||||
}, function (dialog) {
|
||||
dialog.render();
|
||||
Espo.Ui.notify(false);
|
||||
dialog.once('select', function (model) {
|
||||
|
||||
@@ -51,6 +51,8 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) {
|
||||
|
||||
getSelectFilters: function () {},
|
||||
|
||||
getSelectBoolFilters: function () {},
|
||||
|
||||
setup: function () {
|
||||
this.nameName = this.name + 'Name';
|
||||
this.idName = this.name + 'Id';
|
||||
@@ -67,7 +69,8 @@ Espo.define('Views.Fields.Link', 'Views.Fields.Base', function (Dep) {
|
||||
this.createView('dialog', 'Modals.SelectRecords', {
|
||||
scope: this.foreignScope,
|
||||
createButton: this.mode != 'search',
|
||||
filters: this.getSelectFilters()
|
||||
filters: this.getSelectFilters(),
|
||||
boolFilters: this.getSelectBoolFilters(),
|
||||
}, function (dialog) {
|
||||
dialog.render();
|
||||
self.notify(false);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: http://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.Fields.Teams', 'Views.Fields.LinkMultiple', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
getSelectBoolFilters: function () {
|
||||
var assignmentPermission = this.getAcl().get('assignmentPermission');
|
||||
if (assignmentPermission == 'team' || assignmentPermission == 'no') {
|
||||
return {'onlyMy': true};
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) {
|
||||
|
||||
setup: function () {
|
||||
this.filters = this.options.filters || {};
|
||||
this.boolFilters = this.options.boolFilters || {};
|
||||
|
||||
if ('multiple' in this.options) {
|
||||
this.multiple = this.options.multiple;
|
||||
@@ -116,7 +117,12 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) {
|
||||
|
||||
var searchManager = new SearchManager(collection, 'listSelect', null, this.getDateTime());
|
||||
searchManager.emptyOnReset = true;
|
||||
searchManager.setAdvanced(this.filters);
|
||||
if (this.filters) {
|
||||
searchManager.setAdvanced(this.filters);
|
||||
}
|
||||
if (this.boolFilters) {
|
||||
searchManager.setBool(this.boolFilters);
|
||||
}
|
||||
collection.where = searchManager.getWhere();
|
||||
|
||||
this.createView('search', 'Record.Search', {
|
||||
|
||||
@@ -37,9 +37,12 @@
|
||||
fieldList: [
|
||||
{
|
||||
name: 'assignedUser',
|
||||
view: 'Fields.UserWithAvatar'
|
||||
view: 'Fields.AssignedUser'
|
||||
},
|
||||
'teams'
|
||||
{
|
||||
name: 'teams',
|
||||
view: 'Fields.Teams'
|
||||
}
|
||||
],
|
||||
mode: 'detail',
|
||||
}
|
||||
|
||||
@@ -31,11 +31,20 @@ Espo.define('Views.Record.EditSide', 'Views.Record.DetailSide', function (Dep) {
|
||||
label: false,
|
||||
view: 'Record.Panels.Side',
|
||||
options: {
|
||||
fieldList: ['assignedUser', 'teams'],
|
||||
fieldList: [
|
||||
{
|
||||
name: 'assignedUser',
|
||||
view: 'Fields.AssignedUser'
|
||||
},
|
||||
{
|
||||
name: 'teams',
|
||||
view: 'Fields.Teams'
|
||||
}
|
||||
],
|
||||
mode: 'edit',
|
||||
}
|
||||
}
|
||||
],
|
||||
]
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user