From a3f3f7cdaa8f8eb1505f75982e447825591cb4bb Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 10 Jan 2019 12:36:58 +0200 Subject: [PATCH 01/22] fix email address modal view name --- client/src/views/fields/email.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/views/fields/email.js b/client/src/views/fields/email.js index 645a937cf2..0ab045caa4 100644 --- a/client/src/views/fields/email.js +++ b/client/src/views/fields/email.js @@ -385,8 +385,10 @@ Espo.define('views/fields/email', 'views/fields/varchar', function (Dep) { return; } + var viewName = this.getMetadata().get('clientDefs.' + this.scope + '.modalViews.compose') || 'views/modals/compose-email'; + this.notify('Loading...'); - this.createView('quickCreate', 'views/modals/compose-email', { + this.createView('quickCreate', viewName, { attributes: attributes, }, function (view) { view.render(); From 0fa58aaee6835cb756cea6093a9c831c2890d400 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 10 Jan 2019 12:37:12 +0200 Subject: [PATCH 02/22] text email address compose email links --- client/src/view-helper.js | 2 ++ client/src/views/fields/text.js | 39 ++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/client/src/view-helper.js b/client/src/view-helper.js index ea86203654..9285aff2bd 100644 --- a/client/src/view-helper.js +++ b/client/src/view-helper.js @@ -217,6 +217,8 @@ Espo.define('view-helper', [], function () { text = marked(text); + text = text.replace(/' + self.language.translate('See more')) + ''; return new Handlebars.SafeString(text); }.bind(this)); diff --git a/client/src/views/fields/text.js b/client/src/views/fields/text.js index 1b1d2489e5..96a5f2e11d 100644 --- a/client/src/views/fields/text.js +++ b/client/src/views/fields/text.js @@ -56,7 +56,10 @@ Espo.define('views/fields/text', 'views/fields/base', function (Dep) { 'click a[data-action="seeMoreText"]': function (e) { this.seeMoreText = true; this.reRender(); - } + }, + 'click [data-action="mailTo"]': function (e) { + this.mailTo($(e.currentTarget).data('email-address')); + }, }, setup: function () { @@ -287,8 +290,38 @@ Espo.define('views/fields/text', 'views/fields/base', function (Dep) { getSearchType: function () { return this.getSearchParamsData().type || this.searchParams.typeFront || this.searchParams.type; - } + }, + + mailTo: function (emailAddress) { + var attributes = { + status: 'Draft', + to: emailAddress + }; + + if ( + this.getConfig().get('emailForceUseExternalClient') || + this.getPreferences().get('emailUseExternalClient') || + !this.getAcl().checkScope('Email', 'create') + ) { + require('email-helper', function (EmailHelper) { + var emailHelper = new EmailHelper(); + var link = emailHelper.composeMailToLink(attributes, this.getConfig().get('outboundEmailBccAddress')); + document.location.href = link; + }.bind(this)); + + return; + } + + var viewName = this.getMetadata().get('clientDefs.' + this.scope + '.modalViews.compose') || 'views/modals/compose-email'; + + this.notify('Loading...'); + this.createView('quickCreate', viewName, { + attributes: attributes, + }, function (view) { + view.render(); + view.notify(false); + }); + }, }); }); - From cc75457e5031914cdc099b532fcd692409adbcde Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 10 Jan 2019 14:28:18 +0200 Subject: [PATCH 03/22] select manager transform date time --- application/Espo/Core/SelectManagers/Base.php | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index 668e8fbf90..a3c7c1baa3 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -843,7 +843,7 @@ class Base return $this->userTimeZone; } - public function convertDateTimeWhere($item) + public function tranformDateTimeWhereItem($item) { $format = 'Y-m-d H:i:s'; @@ -997,6 +997,7 @@ class Base $dt->setTimezone(new \DateTimeZone('UTC')); $where['value'] = $dt->format($format); break; + case 'between': $where['type'] = 'between'; if (is_array($value)) { @@ -1012,11 +1013,39 @@ class Base $where['value'] = [$from, $to]; } break; + + case 'currentMonth': + case 'lastMonth': + case 'nextMonth': + $where['type'] = 'between'; + $dtFrom = new \DateTime('now', new \DateTimeZone($timeZone)); + $dtFrom = $dt->modify('first day of this month')->setTime(0, 0, 0); + + if ($type == 'lastMonth') { + $dtFrom->modify('-1 month'); + } else if ($type == 'nextMonth') { + $dtFrom->modify('+1 month'); + } + + $dtTo = clone $dtFrom; + $dtTo->modify('+1 month'); + + $dtFrom->setTimezone(new \DateTimeZone('UTC')); + $dtTo->setTimezone(new \DateTimeZone('UTC')); + + $where['value'] = [$dtFrom->format($format), $dtTo->format($format)]; + default: $where['type'] = $type; } - $result = $this->getWherePart($where); + return $where; + } + + public function convertDateTimeWhere($item) + { + $where = $this->tranformDateTimeWhereItem($item); + $result = $this->getWherePart($where); return $result; } @@ -1056,6 +1085,11 @@ class Base } $value = $item['value']; + $timeZone = null; + if (isset($item['timeZone'])) { + $timeZone = $item['timeZone']; + } + if (!empty($item['type'])) { $type = $item['type']; From 79befe9508e095383d12447e63642cfa7398b48f Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 10 Jan 2019 14:47:07 +0200 Subject: [PATCH 04/22] select manager originalType --- application/Espo/Core/SelectManagers/Base.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index a3c7c1baa3..8d706608c3 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -1039,6 +1039,8 @@ class Base $where['type'] = $type; } + $where['originalType'] = $type; + return $where; } From d1b35594e7921cee611a9efbac4a14e3e2da7b64 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 10 Jan 2019 14:47:44 +0200 Subject: [PATCH 05/22] fix select manager --- application/Espo/Core/SelectManagers/Base.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index 8d706608c3..4483bec05e 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -1034,6 +1034,7 @@ class Base $dtTo->setTimezone(new \DateTimeZone('UTC')); $where['value'] = [$dtFrom->format($format), $dtTo->format($format)]; + break; default: $where['type'] = $type; From ae18ce444cf22f4fd53519cd547b42597541444f Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 10 Jan 2019 14:53:02 +0200 Subject: [PATCH 06/22] fix typo --- application/Espo/Core/SelectManagers/Base.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/Espo/Core/SelectManagers/Base.php b/application/Espo/Core/SelectManagers/Base.php index 4483bec05e..660dc8fad5 100644 --- a/application/Espo/Core/SelectManagers/Base.php +++ b/application/Espo/Core/SelectManagers/Base.php @@ -843,7 +843,7 @@ class Base return $this->userTimeZone; } - public function tranformDateTimeWhereItem($item) + public function transformDateTimeWhereItem($item) { $format = 'Y-m-d H:i:s'; @@ -1047,7 +1047,7 @@ class Base public function convertDateTimeWhere($item) { - $where = $this->tranformDateTimeWhereItem($item); + $where = $this->transformDateTimeWhereItem($item); $result = $this->getWherePart($where); return $result; } From dc4c4c374251c6589bbc2872dac0c36fff907904 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 11:45:20 +0200 Subject: [PATCH 07/22] user controller restore lost code --- application/Espo/Controllers/User.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/application/Espo/Controllers/User.php b/application/Espo/Controllers/User.php index acb1aef297..a862e344ee 100644 --- a/application/Espo/Controllers/User.php +++ b/application/Espo/Controllers/User.php @@ -106,6 +106,13 @@ class User extends \Espo\Core\Controllers\Record return $this->getService('User')->passwordChangeRequest($userName, $emailAddress, $url); } + public function postActionGenerateNewApiKey($params, $data, $request) + { + if (empty($data->id)) throw new BadRequest(); + if (!$this->getUser()->isAdmin()) throw new Forbidden(); + return $this->getRecordService()->generateNewApiKeyForEntity($data->id)->getValueMap(); + } + public function actionCreateLink($params, $data, $request) { if (!$this->getUser()->isAdmin()) throw new Forbidden(); From b5392733519017836073be9eb1b7cdc40ad81830 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 12:02:22 +0200 Subject: [PATCH 08/22] date time system formats static prop --- application/Espo/Core/Utils/DateTime.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application/Espo/Core/Utils/DateTime.php b/application/Espo/Core/Utils/DateTime.php index 065c0bfe58..b79eae670d 100644 --- a/application/Espo/Core/Utils/DateTime.php +++ b/application/Espo/Core/Utils/DateTime.php @@ -37,6 +37,10 @@ class DateTime protected $timezone; + public static $systemDateTimeFormat = 'Y-m-d H:i:s'; + + public static $systemDateFormat = 'Y-m-d'; + protected $internalDateTimeFormat = 'Y-m-d H:i:s'; protected $internalDateFormat = 'Y-m-d'; From 619856ad58ce60e3013a0f842ad8219b6bba3c84 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 12:02:40 +0200 Subject: [PATCH 09/22] fix cron is running check --- application/Espo/Core/Utils/ScheduledJob.php | 43 +++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/application/Espo/Core/Utils/ScheduledJob.php b/application/Espo/Core/Utils/ScheduledJob.php index 9fe7c467f2..b108897b20 100644 --- a/application/Espo/Core/Utils/ScheduledJob.php +++ b/application/Espo/Core/Utils/ScheduledJob.php @@ -208,30 +208,33 @@ class ScheduledJob */ public function isCronConfigured() { - $startDate = new \DateTime('-' . $this->checkingCronPeriod, new \DateTimeZone("UTC")); - $endDate = new \DateTime('+' . $this->checkingCronPeriod, new \DateTimeZone("UTC")); + $r1From = new \DateTime('-' . $this->checkingCronPeriod); + $r1To = new \DateTime('+' . $this->checkingCronPeriod); - $query = " - SELECT job.id FROM scheduled_job - LEFT JOIN job ON job.scheduled_job_id = scheduled_job.id AND job.deleted = 0 - WHERE - scheduled_job.job = 'Dummy' - AND scheduled_job.deleted = 0 - AND job.execute_time BETWEEN '". $startDate->format('Y-m-d H:i:s') ."' AND '". $endDate->format('Y-m-d H:i:s') ."' - AND job.status IN ('Success', 'Failed', 'Pending') - ORDER BY job.execute_time DESC - "; + $r2From = new \DateTime('- 1 hour'); + $r2To = new \DateTime(); - $pdo = $this->getEntityManager()->getPDO(); - $sth = $pdo->prepare($query); - $sth->execute(); + $format = \Espo\Core\Utils\DateTime::$systemDateTimeFormat; - $row = $sth->fetch(\PDO::FETCH_ASSOC); + $selectParams = [ + 'select' => ['id'], + 'leftJoins' => ['scheduledJob'], + 'whereClause' => [ + 'OR' => [ + [ + ['executedAt>=' => $r2From->format($format)] , + ['executedAt<=' => $r2To->format($format)], + ], + [ + ['executeTime>=' => $r1From->format($format)], + ['executeTime<='=> $r1To->format($format)], + 'scheduledJob.job' => 'Dummy' + ] + ] + ] + ]; - if (!empty($row['id'])) { - return true; - } - return false; + return !!$this->getEntityManager()->getRepository('Job')->findOne($selectParams); } } From 86cb2015396e1a2aa624bafe8f1e5b3e05034a00 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 12:14:03 +0200 Subject: [PATCH 10/22] fix css --- client/res/templates/header.tpl | 5 ++--- frontend/less/espo/custom.less | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/res/templates/header.tpl b/client/res/templates/header.tpl index 9998ab1798..1b9c556c2a 100644 --- a/client/res/templates/header.tpl +++ b/client/res/templates/header.tpl @@ -1,8 +1,8 @@
-
+

{{{header}}}

-
+
{{#each items.buttons}} @@ -47,4 +47,3 @@
- diff --git a/frontend/less/espo/custom.less b/frontend/less/espo/custom.less index 68a268f80a..60f50cef7a 100644 --- a/frontend/less/espo/custom.less +++ b/frontend/less/espo/custom.less @@ -207,10 +207,14 @@ label { } .page-header { - margin: 10px 0; - border-bottom: 0; - padding-bottom: 2px; - min-height: 33px; + margin: 10px 0; + border-bottom: 0; + padding-bottom: 2px; + min-height: 33px; + + .page-header-column-1 { + overflow: hidden; + } } .page-header > .row { From 6933c599ad1499acc11768c78f029343e9964066 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 12:34:10 +0200 Subject: [PATCH 11/22] css hr color --- frontend/less/espo/custom.less | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/less/espo/custom.less b/frontend/less/espo/custom.less index 60f50cef7a..1c1f66a4e0 100644 --- a/frontend/less/espo/custom.less +++ b/frontend/less/espo/custom.less @@ -108,6 +108,10 @@ .clearfix(); } +hr { + border-top: 1px solid @panel-default-border; +} + blockquote { font-size: @font-size-base; border-left-width: 3px; From cef5e09a58c124a20c2dd04a0e1d25905da25ea7 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 13:09:06 +0200 Subject: [PATCH 12/22] fix css --- frontend/less/espo/custom.less | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/less/espo/custom.less b/frontend/less/espo/custom.less index 1c1f66a4e0..1efc5837c3 100644 --- a/frontend/less/espo/custom.less +++ b/frontend/less/espo/custom.less @@ -929,6 +929,12 @@ table.table > tbody td > .list-row-buttons button { margin-top: 2px; } +table.table > tbody > tr > td, +table.table > thead > tr > th { + text-overflow: ellipsis; + overflow: hidden; +} + .list-row-buttons span.caret { border-top-color: @gray-light; } From 5ef8588ad1160eb4711cb708ad4e3c858c2edbb5 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 13:12:57 +0200 Subject: [PATCH 13/22] fix css --- frontend/less/espo/custom.less | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/less/espo/custom.less b/frontend/less/espo/custom.less index 1efc5837c3..3b2a386ab3 100644 --- a/frontend/less/espo/custom.less +++ b/frontend/less/espo/custom.less @@ -930,6 +930,7 @@ table.table > tbody td > .list-row-buttons button { } table.table > tbody > tr > td, +table.table > tbody > tr > th, table.table > thead > tr > th { text-overflow: ellipsis; overflow: hidden; From c22f23a1c435319f49dd59ad32df3a977116ed1c Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 15 Jan 2019 13:49:09 +0200 Subject: [PATCH 14/22] phone email max length --- client/res/templates/fields/email/edit.tpl | 2 +- client/res/templates/fields/phone/edit.tpl | 2 +- client/src/views/fields/email.js | 4 ++++ client/src/views/fields/phone.js | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/res/templates/fields/email/edit.tpl b/client/res/templates/fields/email/edit.tpl index 742d888191..e6270e601d 100644 --- a/client/res/templates/fields/email/edit.tpl +++ b/client/res/templates/fields/email/edit.tpl @@ -2,7 +2,7 @@
{{#each emailAddressData}}