Compare commits

...

12 Commits

Author SHA1 Message Date
yuri 083e248f21 fix logo 2 2015-12-08 16:56:14 +02:00
yuri df422f6365 v 2015-12-08 16:51:10 +02:00
yuri 47a2fee51d fix logo 2015-12-08 16:50:35 +02:00
yuri 4b0be0137c fix user detail view 2015-12-08 16:23:12 +02:00
yuri 38514941b8 clearfix 2015-12-04 14:24:03 +02:00
yuri d79993ba11 phone field type fix 2015-12-03 14:25:37 +02:00
yuri da62759130 destroy popover on remove 2015-11-30 16:40:01 +02:00
yuri 2e04fd5a3b style 2015-11-30 14:14:29 +02:00
yuri 6174245b22 cleanup 2015-11-30 12:22:48 +02:00
yuri 9b9d3d9634 ORM: ability to join children 2015-11-30 11:15:21 +02:00
yuri e13a722dca cleanup and style fix 2015-11-27 16:03:27 +02:00
yuri dba325aa61 join conditions and alias 2015-11-27 12:21:40 +02:00
19 changed files with 123 additions and 77 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ class FieldManager
$this->setLabel($name, $fieldDefs['label'], $scope);
}
if (isset($fieldDefs['type']) && $fieldDefs['type'] == 'enum') {
if (isset($fieldDefs['type']) && ($fieldDefs['type'] == 'enum' || $fieldDefs['type'] == 'phone')) {
if (isset($fieldDefs['translatedOptions'])) {
$this->setTranslatedOptions($name, $fieldDefs['translatedOptions'], $scope);
}
+27 -10
View File
@@ -693,17 +693,20 @@ abstract class Base
{
$joinsArr = array();
foreach ($joins as $relationName) {
$joinAlias = null;
if (is_array($relationName)) {
$arr = $relationName;
$relationName = $arr[0];
if (count($arr) > 1) {
$joinAlias = $arr[1];
} else {
$joinAlias = $relationName;
}
} else {
$joinAlias = $relationName;
}
$conditions = array();
if (!empty($joinConditions[$relationName])) {
$conditions = $joinConditions[$relationName];
if (!empty($joinConditions[$joinAlias])) {
$conditions = $joinConditions[$joinAlias];
}
if ($joinRelated = $this->getJoinRelated($entity, $relationName, $left, $conditions, $joinAlias)) {
$joinsArr[] = $joinRelated;
@@ -721,6 +724,8 @@ abstract class Base
$joinAlias = $relationName;
}
$joinAlias = $this->sanitize($joinAlias);
$pre = ($left) ? 'LEFT ' : '';
if ($relOpt['type'] == IEntity::MANY_MANY) {
@@ -735,7 +740,7 @@ abstract class Base
$distantTable = $this->toDb($relOpt['entity']);
$alias = $this->sanitize($joinAlias);
$alias = $joinAlias;
$midAlias = $alias . 'Middle';
@@ -756,14 +761,12 @@ abstract class Base
. "{$alias}.deleted = " . $this->pdo->quote(0) . "";
return $join;
}
if ($relOpt['type'] == IEntity::HAS_MANY) {
} else if ($relOpt['type'] == IEntity::HAS_MANY) {
$foreignKey = $keySet['foreignKey'];
$distantTable = $this->toDb($relOpt['entity']);
$alias = $this->sanitize($relationName);
$alias = $joinAlias;
// TODO conditions
@@ -773,9 +776,23 @@ abstract class Base
. "{$alias}.deleted = " . $this->pdo->quote(0) . "";
return $join;
}
} else if ($relOpt['type'] == IEntity::HAS_CHILDREN) {
$foreignKey = $keySet['foreignKey'];
$foreignType = $keySet['foreignType'];
$distantTable = $this->toDb($relOpt['entity']);
if ($relOpt['type'] == IEntity::BELONGS_TO) {
$alias = $joinAlias;
$join =
"{$pre}JOIN `{$distantTable}` AS `{$alias}` ON " . $this->toDb($entity->getEntityType()) . "." . $this->toDb('id') . " = {$alias}." . $this->toDb($foreignKey)
. " AND "
. "{$alias}." . $this->toDb($foreignType) . " = " . $this->pdo->quote($entity->getEntityType())
. " AND "
. "{$alias}.deleted = " . $this->pdo->quote(0) . "";
return $join;
} else if ($relOpt['type'] == IEntity::BELONGS_TO) {
return $pre . $this->getBelongsToJoin($entity, $relationName);
}
@@ -122,7 +122,8 @@
"audited": "Audited",
"trim": "Trim",
"height": "Height (px)",
"provider": "Provider"
"provider": "Provider",
"typeList": "Type List"
},
"messages": {
"upgradeVersion": "Your EspoCRM will be upgraded to version <strong>{version}</strong>. This can take some time.",
@@ -8,7 +8,7 @@
{
"name":"options",
"type":"array",
"view": "Admin.FieldManager.Fields.Options"
"view": "views/admin/field-manager/fields/options"
},
{
"name":"default",
@@ -7,8 +7,9 @@
},
{
"name":"typeList",
"type":"array",
"options": ["Mobile", "Office", "Home", "Fax", "Other"]
"type":"array",
"default": ["Mobile", "Office", "Home", "Fax", "Other"],
"view": "views/admin/field-manager/fields/options"
},
{
"name":"defaultType",
@@ -24,19 +24,19 @@
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
************************************************************************/
Espo.define('crm:controllers/lead', 'controllers/record', function (Dep) {
Espo.define('Crm:Controllers.Lead', 'Controllers.Record', function (Dep) {
return Dep.extend({
convert: function (id) {
this.main('Crm:Lead.Convert', {
this.main('crm:views/lead/convert', {
id: id
});
},
});
});
});
@@ -1,6 +1,6 @@
<div class="detail" id="{{id}}">
{{#if buttonsTop}}
<div class="detail-button-container button-container record-buttons">
<div class="detail-button-container button-container record-buttons clearfix">
<div class="btn-group" role="group">
{{#each buttonList}}{{button name scope=../../scope label=label style=style hidden=hidden}}{{/each}}
{{#if dropdownItemList}}
@@ -27,7 +27,7 @@
</div>
{{/if}}
</div>
<div class="detail-button-container button-container edit-buttons hidden">
<div class="detail-button-container button-container edit-buttons hidden clearfix">
<div class="btn-group" role="group">
{{#each buttonEditList}}{{button name scope=../../scope label=label style=style hidden=hidden}}{{/each}}
{{#if dropdownEditItemList}}
@@ -1,6 +1,6 @@
<div class="edit" id="{{id}}">
{{#if buttonsTop}}
<div class="detail-button-container button-container record-buttons">
<div class="detail-button-container button-container record-buttons clearfix">
<div class="btn-group" role="group">
{{#each buttonList}}{{button name scope=../../scope label=label style=style}}{{/each}}
{{#if dropdownItemList}}
@@ -186,19 +186,17 @@ Espo.define('views/admin/field-manager/edit', ['view', 'model'], function (Dep,
this.trigger('after:save');
}.bind(this), true);
var data = this.getLanguage().data;
if (this.scope in data) {
if (!('fields' in data[this.scope])) {
data[this.scope]['fields'] = {};
var langData = this.getLanguage().data;
if (this.scope in langData) {
if (!('fields' in langData[this.scope])) {
langData[this.scope]['fields'] = {};
}
data[this.scope]['fields'][this.model.get('name')] = this.model.get('label');
langData[this.scope]['fields'][this.model.get('name')] = this.model.get('label');
if (this.model.get('type') == 'enum' && this.model.get('translatedOptions')) {
if (!('options' in data[this.scope])) {
data[this.scope]['options'] = {};
}
data[this.scope]['options'][this.model.get('name')] = this.model.get('translatedOptions') || {};
if (~['enum', 'phone'].indexOf(this.model.get('type')) && this.model.get('translatedOptions')) {
langData[this.scope].options = langData[this.scope].options || {};
langData[this.scope]['options'][this.model.get('name')] = this.model.get('translatedOptions') || {};
}
}
}.bind(this));
@@ -33,7 +33,11 @@ Espo.define('views/admin/field-manager/fields/options', 'views/fields/array', fu
setup: function () {
Dep.prototype.setup.call(this);
this.translatedOptions = this.getLanguage().get(this.options.scope, 'options', this.options.field) || {};
this.translatedOptions = {};
var list = this.model.get(this.name) || [];
list.forEach(function (value) {
this.translatedOptions[value] = this.getLanguage().translateOption(value, this.options.field, this.options.scope);
}, this);
},
getItemHtml: function (value) {
+5 -5
View File
@@ -26,19 +26,19 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Fields.Array', ['Views.Fields.Base', 'lib!Selectize'], function (Dep) {
Espo.define('views/fields/array', ['views/fields/base', 'lib!Selectize'], function (Dep) {
return Dep.extend({
type: 'array',
listTemplate: 'fields.array.detail',
listTemplate: 'fields/array/detail',
detailTemplate: 'fields.array.detail',
detailTemplate: 'fields/array/detail',
editTemplate: 'fields.array.edit',
editTemplate: 'fields/array/edit',
searchTemplate: 'fields.array.search',
searchTemplate: 'fields/array/search',
data: function () {
var itemHtmlList = [];
+7 -1
View File
@@ -214,8 +214,9 @@ Espo.define('views/fields/base', 'view', function (Dep) {
}
if ((this.mode == 'detail' || this.mode == 'edit') && this.model.getFieldParam(this.name, 'tooltip')) {
var $a;
this.once('after:render', function () {
var $a = $('<a href="javascript:" class="text-muted"><span class="glyphicon glyphicon-info-sign"></span></a>');
$a = $('<a href="javascript:" class="text-muted"><span class="glyphicon glyphicon-info-sign"></span></a>');
var $label = this.getLabelElement();
$label.append(' ');
this.getLabelElement().append($a);
@@ -231,6 +232,11 @@ Espo.define('views/fields/base', 'view', function (Dep) {
});
});
}, this);
this.on('remove', function () {
if ($a) {
$a.popover('destroy')
}
}, this);
}
if (this.mode == 'detail') {
+1 -1
View File
@@ -60,7 +60,7 @@ Espo.define('views/login', 'view', function (Dep) {
if (!companyLogoId) {
return this.getThemeManager().getParam('logo') || 'client/img/logo.png';
}
return '?entryPoint=LogoImage';
return '?entryPoint=LogoImage&t=' + companyLogoId;
},
login: function () {
+1 -1
View File
@@ -86,7 +86,7 @@ Espo.define('views/site/navbar', 'view', function (Dep) {
if (!companyLogoId) {
return this.getThemeManager().getParam('logo') || 'client/img/logo.png';
}
return '?entryPoint=LogoImage';
return '?entryPoint=LogoImage&t=' + companyLogoId;
},
setup: function () {
@@ -34,7 +34,7 @@ Espo.define('views/user/record/detail', 'views/record/detail', function (Dep) {
bottomView: 'views/user/record/detail-bottom',
editModeEnabled: false,
editModeDisabled: true,
setup: function () {
Dep.prototype.setup.call(this);
+8 -4
View File
@@ -155,8 +155,12 @@ table.table > thead th {
}
.navbar img.logo {
width: 100%;
height: auto;
max-height: 100%;
max-width: 100%;
}
#login.panel .panel-heading {
border-bottom-width: 0;
}
#login .logo-container {
@@ -165,8 +169,8 @@ table.table > thead th {
}
#login .logo-container img.logo {
width: 100%;
height: auto;
max-height: 100%;
max-width: 100%;
}
#global-search-input {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "3.9.1",
"version": "3.9.2",
"description": "",
"main": "index.php",
"repository": {
+18 -3
View File
@@ -99,7 +99,7 @@ class QueryTest extends PHPUnit_Framework_TestCase
'limit' => 20
));
$expectedSql =
$expectedSql =
"SELECT account.id AS `id`, account.name AS `name`, account.deleted AS `deleted` FROM `account` " .
"WHERE account.deleted = '0' ORDER BY account.name ASC LIMIT 10, 20";
@@ -112,7 +112,7 @@ class QueryTest extends PHPUnit_Framework_TestCase
));
$expectedSql =
$expectedSql =
"SELECT comment.id AS `id`, comment.post_id AS `postId`, post.name AS `postName`, comment.name AS `name`, comment.deleted AS `deleted` FROM `comment` " .
"LEFT JOIN `post` AS `post` ON comment.post_id = post.id " .
"WHERE comment.deleted = '0'";
@@ -125,7 +125,7 @@ class QueryTest extends PHPUnit_Framework_TestCase
$sql = $this->query->createSelectQuery('Comment', array(
'select' => array('id', 'name')
));
$expectedSql =
$expectedSql =
"SELECT comment.id AS `id`, comment.name AS `name` FROM `comment` " .
"WHERE comment.deleted = '0'";
@@ -192,6 +192,21 @@ class QueryTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expectedSql, $sql);
}
public function testSelectWithJoinChildren()
{
$sql = $this->query->createSelectQuery('Post', array(
'select' => ['id', 'name'],
'leftJoins' => [['notes', 'notesLeft']]
));
$expectedSql =
"SELECT post.id AS `id`, post.name AS `name` FROM `post` " .
"LEFT JOIN `note` AS `notesLeft` ON post.id = notesLeft.parent_id AND notesLeft.parent_type = 'Post' AND notesLeft.deleted = '0' " .
"WHERE post.deleted = '0'";
$this->assertEquals($expectedSql, $sql);
}
public function testOrderBy()
{
$sql = $this->query->createSelectQuery('Comment', array(
+24 -24
View File
@@ -14,11 +14,11 @@ class Account extends TEntity
{
public $fields = array(
'id' => array(
'type' => Entity::ID,
'type' => Entity::ID,
),
'name' => array(
'type' => Entity::VARCHAR,
'len' => 255,
'len' => 255,
),
'deleted' => array(
'type' => Entity::BOOL,
@@ -34,20 +34,20 @@ class Account extends TEntity
'entityId',
'teamId',
),
'conditions' => array('entityType' => 'Account')
'conditions' => array('entityType' => 'Account')
),
);
}
class Team extends TEntity
{
{
public $fields = array(
'id' => array(
'type' => Entity::ID,
'type' => Entity::ID,
),
'name' => array(
'type' => Entity::VARCHAR,
'len' => 255,
'len' => 255,
),
'deleted' => array(
'type' => Entity::BOOL,
@@ -58,10 +58,10 @@ class Team extends TEntity
}
class Contact extends TEntity
{
{
public $fields = array(
'id' => array(
'type' => Entity::ID,
'type' => Entity::ID,
),
'name' => array(
'type' => Entity::VARCHAR,
@@ -73,10 +73,10 @@ class Contact extends TEntity
'orderBy' => "contact.first_name {direction}, contact.last_name {direction}",
),
'firstName' => array(
'type' => Entity::VARCHAR,
'type' => Entity::VARCHAR,
),
'lastName' => array(
'type' => Entity::VARCHAR,
'type' => Entity::VARCHAR,
),
'deleted' => array(
'type' => Entity::BOOL,
@@ -87,14 +87,14 @@ class Contact extends TEntity
}
class Post extends TEntity
{
{
public $fields = array(
'id' => array(
'type' => Entity::ID,
'type' => Entity::ID,
),
'name' => array(
'type' => Entity::VARCHAR,
'len' => 255,
'len' => 255,
),
'privateField' => array(
'notStorable' => true,
@@ -111,7 +111,7 @@ class Post extends TEntity
'type' => Entity::BOOL,
'default' => 0,
),
);
);
public $relations = array(
'tags' => array(
'type' => Entity::MANY_MANY,
@@ -144,10 +144,10 @@ class Post extends TEntity
}
class Comment extends TEntity
{
{
public $fields = array(
'id' => array(
'type' => Entity::ID,
'type' => Entity::ID,
),
'postId' => array(
'type' => Entity::FOREIGN_ID,
@@ -159,14 +159,14 @@ class Comment extends TEntity
),
'name' => array(
'type' => Entity::VARCHAR,
'len' => 255,
'len' => 255,
),
'deleted' => array(
'type' => Entity::BOOL,
'default' => 0,
),
);
public $relations = array(
'post' => array(
'type' => Entity::BELONGS_TO,
@@ -178,14 +178,14 @@ class Comment extends TEntity
}
class Tag extends TEntity
{
{
public $fields = array(
'id' => array(
'type' => Entity::ID,
'type' => Entity::ID,
),
'name' => array(
'type' => Entity::VARCHAR,
'len' => 50,
'len' => 50,
),
'deleted' => array(
'type' => Entity::BOOL,
@@ -196,14 +196,14 @@ class Tag extends TEntity
class Note extends TEntity
{
{
public $fields = array(
'id' => array(
'type' => Entity::ID,
'type' => Entity::ID,
),
'name' => array(
'type' => Entity::VARCHAR,
'len' => 50,
'len' => 50,
),
'parentId' => array(
'type' => Entity::FOREIGN_ID,