mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-03 21:07:01 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddc90a05d9 | ||
|
|
bbbadb1c32 | ||
|
|
8995835d8e | ||
|
|
df3c119f5f | ||
|
|
6a2ba73412 | ||
|
|
cbee8cc541 |
@@ -74,6 +74,7 @@ abstract class Mapper implements IMapper
|
||||
if ($ps) {
|
||||
foreach ($ps as $row) {
|
||||
$entity = $this->fromRow($entity, $row);
|
||||
$entity->setAsFetched();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -118,8 +119,9 @@ abstract class Mapper implements IMapper
|
||||
|
||||
if ($this->returnCollection) {
|
||||
$collectionClass = $this->collectionClass;
|
||||
$entityArr = new $collectionClass($dataArr, $entity->getEntityType(), $this->entityFactory);
|
||||
return $entityArr;
|
||||
$collection = new $collectionClass($dataArr, $entity->getEntityType(), $this->entityFactory);
|
||||
$collection->setAsFetched();
|
||||
return $collection;
|
||||
} else {
|
||||
return $dataArr;
|
||||
}
|
||||
@@ -197,6 +199,7 @@ abstract class Mapper implements IMapper
|
||||
foreach ($ps as $row) {
|
||||
if (!$totalCount) {
|
||||
$relEntity = $this->fromRow($relEntity, $row);
|
||||
$relEntity->setAsFetched();
|
||||
return $relEntity;
|
||||
} else {
|
||||
return $row['AggregateValue'];
|
||||
@@ -237,13 +240,17 @@ abstract class Mapper implements IMapper
|
||||
|
||||
if ($relType == IEntity::HAS_ONE) {
|
||||
if (count($resultArr)) {
|
||||
return $this->fromRow($relEntity, $resultArr[0]);
|
||||
$relEntity = $this->fromRow($relEntity, $resultArr[0]);
|
||||
$relEntity->setAsFetched();
|
||||
return $relEntity;
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if ($this->returnCollection) {
|
||||
$collectionClass = $this->collectionClass;
|
||||
return new $collectionClass($resultArr, $relEntity->getEntityType(), $this->entityFactory);
|
||||
$collection = new $collectionClass($resultArr, $relEntity->getEntityType(), $this->entityFactory);
|
||||
$collection->setAsFetched();
|
||||
return $collection;
|
||||
} else {
|
||||
return $resultArr;
|
||||
}
|
||||
@@ -282,7 +289,9 @@ abstract class Mapper implements IMapper
|
||||
}
|
||||
if ($this->returnCollection) {
|
||||
$collectionClass = $this->collectionClass;
|
||||
return new $collectionClass($resultArr, $relEntity->getEntityType(), $this->entityFactory);
|
||||
$collection = new $collectionClass($resultArr, $relEntity->getEntityType(), $this->entityFactory);
|
||||
$collection->setAsFetched();
|
||||
return $collection;
|
||||
} else {
|
||||
return $resultArr;
|
||||
}
|
||||
@@ -899,5 +908,3 @@ abstract class Mapper implements IMapper
|
||||
$this->collectionClass = $collectionClass;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -150,9 +150,6 @@ class EntityCollection implements \Iterator, \Countable, \ArrayAccess, \Seekable
|
||||
$value = $this->container[$offset];
|
||||
|
||||
if ($value instanceof Entity) {
|
||||
if ($this->isFetched) {
|
||||
$value->setAsFetched();
|
||||
}
|
||||
return $value;
|
||||
} else if (is_array($value)) {
|
||||
$this->container[$offset] = $this->buildEntityFromArray($value);
|
||||
|
||||
@@ -117,7 +117,6 @@ class RDB extends \Espo\ORM\Repository
|
||||
$params = array();
|
||||
$this->handleSelectParams($params);
|
||||
if ($this->getMapper()->selectById($entity, $id, $params)) {
|
||||
$entity->setAsFetched();
|
||||
return $entity;
|
||||
}
|
||||
|
||||
@@ -253,11 +252,9 @@ class RDB extends \Espo\ORM\Repository
|
||||
return $collection;
|
||||
} else if ($result instanceof EntityCollection) {
|
||||
$collection = $result;
|
||||
$collection->setAsFetched();
|
||||
return $collection;
|
||||
} else if ($result instanceof Entity) {
|
||||
$entity = $result;
|
||||
$entity->setAsFetched();
|
||||
return $entity;
|
||||
} else {
|
||||
return $result;
|
||||
|
||||
@@ -164,8 +164,8 @@
|
||||
},
|
||||
"body": {
|
||||
"type": "wysiwyg",
|
||||
"seeMoreDisabled": true,
|
||||
"view": "views/email/fields/body"
|
||||
"view": "views/email/fields/body",
|
||||
"attachmentField": "attachments"
|
||||
},
|
||||
"isHtml": {
|
||||
"type": "bool",
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
{
|
||||
"name":"readOnly",
|
||||
"type":"bool"
|
||||
},
|
||||
{
|
||||
"name": "attachmentField",
|
||||
"type": "varchar",
|
||||
"hidden": true
|
||||
}
|
||||
],
|
||||
"filter": true,
|
||||
|
||||
@@ -68,7 +68,7 @@ Espo.define('views/email/record/compose', ['views/record/edit', 'views/email/rec
|
||||
}
|
||||
|
||||
this.listenTo(this.model, 'insert-template', function (data) {
|
||||
var body = this.model.get('body');
|
||||
var body = this.model.get('body') || '';
|
||||
|
||||
var bodyPlain = body.replace(/<br\s*\/?>/mg, '');
|
||||
bodyPlain = bodyPlain.replace(/<\/p\s*\/?>/mg, '');
|
||||
|
||||
@@ -64,6 +64,29 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
['misc',['codeview', 'fullscreen']]
|
||||
];
|
||||
|
||||
this.buttons = {};
|
||||
|
||||
if (!this.params.toolbar) {
|
||||
if (this.params.attachmentField) {
|
||||
this.toolbar.push([
|
||||
'attachment',
|
||||
['attachment']
|
||||
]);
|
||||
var AttachmentButton = function (context) {
|
||||
var ui = $.summernote.ui;
|
||||
var button = ui.button({
|
||||
contents: '<i class="glyphicon glyphicon-paperclip"></i>',
|
||||
tooltip: this.translate('Attach File'),
|
||||
click: function () {
|
||||
this.attachFile();
|
||||
}.bind(this)
|
||||
});
|
||||
return button.render();
|
||||
}.bind(this);
|
||||
this.buttons['attachment'] = AttachmentButton;
|
||||
}
|
||||
}
|
||||
|
||||
this.listenTo(this.model, 'change:isHtml', function (model) {
|
||||
if (this.mode == 'edit') {
|
||||
if (this.isRendered()) {
|
||||
@@ -99,6 +122,9 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
|
||||
this.once('remove', function () {
|
||||
$(window).off('resize.' + this.cid);
|
||||
if (this.$scrollable) {
|
||||
this.$scrollable.off('scroll.' + this.cid + '-edit');
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@@ -305,11 +331,22 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
this.trigger('change')
|
||||
}.bind(this),
|
||||
},
|
||||
toolbar: this.toolbar
|
||||
toolbar: this.toolbar,
|
||||
buttons: this.buttons
|
||||
};
|
||||
|
||||
if (this.height) {
|
||||
options.height = this.height;
|
||||
} else {
|
||||
var $scrollable = this.$el.closest('.modal-body');
|
||||
if (!$scrollable.size()) {
|
||||
$scrollable = $(window);
|
||||
}
|
||||
this.$scrollable = $scrollable;
|
||||
$scrollable.off('scroll.' + this.cid + '-edit');
|
||||
$scrollable.on('scroll.' + this.cid + '-edit', function (e) {
|
||||
this.onScrollEdit(e);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
if (this.minHeight) {
|
||||
@@ -317,6 +354,9 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
}
|
||||
|
||||
this.$summernote.summernote(options);
|
||||
|
||||
this.$toolbar = this.$el.find('.note-toolbar');
|
||||
this.$area = this.$el.find('.note-editing-area');
|
||||
},
|
||||
|
||||
plainToHtml: function (html) {
|
||||
@@ -346,6 +386,10 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
this.$summernote.addClass('hidden');
|
||||
}
|
||||
this.$element.removeClass('hidden');
|
||||
|
||||
if (this.$scrollable) {
|
||||
this.$scrollable.off('scroll.' + this.cid + '-edit');
|
||||
}
|
||||
},
|
||||
|
||||
fetch: function () {
|
||||
@@ -364,7 +408,58 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
onScrollEdit: function (e) {
|
||||
var $target = $(e.target);
|
||||
var toolbarHeight = this.$toolbar.height();
|
||||
var top;
|
||||
if ($target.get(0) === window.document) {
|
||||
var $buttonContainer = $target.find('.detail-button-container:not(.hidden)');
|
||||
var offset = $buttonContainer.offset();
|
||||
if (offset) {
|
||||
var edgeTop = offset.top + $buttonContainer.height();
|
||||
var edgeTopAbsolute = edgeTop - $(window).scrollTop();
|
||||
}
|
||||
} else {
|
||||
var offset = $target.offset();
|
||||
if (offset) {
|
||||
var edgeTop = offset.top;
|
||||
var edgeTopAbsolute = edgeTop;
|
||||
}
|
||||
}
|
||||
|
||||
var top = this.$el.offset().top;
|
||||
var bottom = top + this.$el.height() - toolbarHeight;
|
||||
|
||||
var toStick = false;
|
||||
if (edgeTop > top && bottom > edgeTop) {
|
||||
toStick = true;
|
||||
}
|
||||
|
||||
if (toStick) {
|
||||
this.$toolbar.css({
|
||||
top: edgeTopAbsolute + 'px'
|
||||
});
|
||||
this.$toolbar.addClass('sticked');
|
||||
this.$area.css({
|
||||
marginTop: toolbarHeight + 'px',
|
||||
backgroundColor: ''
|
||||
});
|
||||
} else {
|
||||
this.$toolbar.css({
|
||||
top: ''
|
||||
});
|
||||
this.$toolbar.removeClass('sticked');
|
||||
this.$area.css({
|
||||
marginTop: ''
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
attachFile: function () {
|
||||
var $form = this.$el.closest('.record');
|
||||
$form.find('.field[data-name="'+this.params.attachmentField+'"] input.file').click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1970,6 +1970,12 @@ pre > code {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.note-editor .note-toolbar.sticked {
|
||||
z-index: 1;
|
||||
position: fixed;
|
||||
background-color: @white-color;
|
||||
}
|
||||
|
||||
@media screen and (min-width: @screen-sm-min) {
|
||||
#global-search-panel {
|
||||
margin-top: 5px;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "espocrm",
|
||||
"version": "5.2.0",
|
||||
"version": "5.2.2",
|
||||
"description": "",
|
||||
"main": "index.php",
|
||||
"repository": {
|
||||
|
||||
Reference in New Issue
Block a user