This commit is contained in:
Yuri Kuznetsov
2023-12-23 12:58:01 +02:00
parent 3edf3936ab
commit a5ebc959e5
19 changed files with 346 additions and 316 deletions
+2
View File
@@ -33,6 +33,8 @@
*
* @typedef {Object} module:search-manager~data
*
* @property {string} [presetName] A preset.
* @property {string} [textFilter] A text filter.
* @property {string} [primary] A primary filter.
* @property {Object.<string, boolean>} [bool] Bool filters.
* @property {{string: module:search-manager~advancedFilter}} [advanced] Advanced filters (field filters).
+1 -1
View File
@@ -277,7 +277,7 @@ Espo.Utils = {
/**
* Check access to an action.
*
* @param {Espo.Utils~AccessDefs[]} dataList List of definitions.
* @param {module:utils~AccessDefs[]} dataList List of definitions.
* @param {module:acl-manager} acl An ACL manager.
* @param {module:models/user} user A user.
* @param {module:model|null} [entity] A model.
@@ -26,11 +26,12 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/record/deleted-detail-side', ['views/record/detail-side'], function (Dep) {
import DetailSideRecordView from 'views/record/detail-side';
return Dep.extend({
class DeletedDetailSideRecordView extends DetailSideRecordView {
additionalPanelsDisabled: true,
additionalPanelsDisabled = true
}
});
});
// noinspection JSUnusedGlobalSymbols
export default DeletedDetailSideRecordView;
+23 -21
View File
@@ -26,37 +26,39 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/record/deleted-detail', ['views/record/detail'], function (Dep) {
import DetailRecordView from 'views/record/detail';
return Dep.extend({
class DeletedDetailRecordView extends DetailRecordView {
bottomView: null,
bottomView = null
sideView: 'views/record/deleted-detail-side',
sideView = 'views/record/deleted-detail-side'
setupBeforeFinal: function () {
Dep.prototype.setupBeforeFinal.call(this);
setupBeforeFinal() {
super.setupBeforeFinal();
this.buttonList = [];
this.dropdownItemList = [];
this.buttonList = [];
this.dropdownItemList = [];
this.addDropdownItem({
name: 'restoreDeleted',
label: 'Restore'
});
},
this.addDropdownItem({
name: 'restoreDeleted',
label: 'Restore'
});
}
actionRestoreDeleted: function () {
Espo.Ui.notify(' ... ');
// noinspection JSUnusedGlobalSymbols
actionRestoreDeleted() {
Espo.Ui.notify(' ... ');
Espo.Ajax.postRequest(this.model.entityType + '/action/restoreDeleted', {
id: this.model.id
}).then(() => {
Espo.Ajax
.postRequest(this.model.entityType + '/action/restoreDeleted', {id: this.model.id})
.then(() => {
Espo.Ui.notify(false);
this.model.set('deleted', false);
this.model.trigger('after:restore-deleted');
});
},
});
});
}
}
export default DeletedDetailRecordView;
+13 -11
View File
@@ -48,7 +48,7 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
/** @inheritDoc */
setupPanels() {
let scope = this.scope;
const scope = this.scope;
this.panelList = Espo.Utils.clone(
this.getMetadata()
@@ -142,7 +142,7 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
);
})
]).then(() => {
let panelNameList = [];
const panelNameList = [];
this.panelList = this.panelList.filter(p => {
panelNameList.push(p.name);
@@ -163,15 +163,15 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
});
if (this.relationshipPanels) {
let linkDefs = (this.model.defs || {}).links || {};
const linkDefs = (this.model.defs || {}).links || {};
if (this.layoutData) {
for (let name in this.layoutData) {
for (const name in this.layoutData) {
if (!linkDefs[name]) {
continue;
}
let p = this.layoutData[name];
const p = this.layoutData[name];
if (!~panelNameList.indexOf(name) && !p.disabled) {
this.addRelationshipPanel(name, p);
@@ -181,7 +181,7 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
}
this.panelList = this.panelList.map((p) => {
let item = Espo.Utils.clone(p);
const item = Espo.Utils.clone(p);
if (this.recordHelper.getPanelStateParam(p.name, 'hidden') !== null) {
item.hidden = this.recordHelper.getPanelStateParam(p.name, 'hidden');
@@ -214,8 +214,8 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
/** @private */
addRelationshipPanel(name, item) {
let scope = this.scope;
let scopesDefs = this.getMetadata().get('scopes') || {};
const scope = this.scope;
const scopesDefs = this.getMetadata().get('scopes') || {};
let p;
@@ -227,6 +227,7 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
}
p.name = p.name || name;
if (!p.name) {
return;
}
@@ -235,13 +236,13 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
name = p.name;
let links = (this.model.defs || {}).links || {};
const links = (this.model.defs || {}).links || {};
if (!(name in links)) {
return;
}
let foreignScope = links[name].entity;
const foreignScope = links[name].entity;
if ((scopesDefs[foreignScope] || {}).disabled) {
return;
@@ -252,9 +253,10 @@ class DetailBottomRecordView extends PanelsContainerRecordView {
}
let defs = this.getMetadata().get(['clientDefs', scope, 'relationshipPanels', name]) || {};
defs = Espo.Utils.clone(defs);
for (let i in defs) {
for (const i in defs) {
if (i in p) {
continue;
}
+18 -17
View File
@@ -70,7 +70,7 @@ class DetailMiddleRecordView extends View {
this.$el.find('.panel[data-name="'+name+'"]').removeClass('hidden');
}
let wasShown = !this.recordHelper.getPanelStateParam(name, 'hidden');
const wasShown = !this.recordHelper.getPanelStateParam(name, 'hidden');
if (
!wasShown &&
@@ -78,7 +78,7 @@ class DetailMiddleRecordView extends View {
this.options.panelFieldListMap[name]
) {
this.options.panelFieldListMap[name].forEach(field => {
var view = this.getFieldView(field);
const view = this.getFieldView(field);
if (!view) {
return;
@@ -118,13 +118,13 @@ class DetailMiddleRecordView extends View {
hideField(name) {
this.recordHelper.setFieldStateParam(name, 'hidden', true);
var processHtml = () => {
var fieldView = this.getFieldView(name);
const processHtml = () => {
const fieldView = this.getFieldView(name);
if (fieldView) {
var $field = fieldView.$el;
var $cell = $field.closest('.cell[data-name="' + name + '"]');
var $label = $cell.find('label.control-label[data-name="' + name + '"]');
const $field = fieldView.$el;
const $cell = $field.closest('.cell[data-name="' + name + '"]');
const $label = $cell.find('label.control-label[data-name="' + name + '"]');
$field.addClass('hidden');
$label.addClass('hidden');
@@ -146,7 +146,7 @@ class DetailMiddleRecordView extends View {
});
}
var view = this.getFieldView(name);
const view = this.getFieldView(name);
if (view) {
view.setDisabled();
@@ -165,13 +165,13 @@ class DetailMiddleRecordView extends View {
this.recordHelper.setFieldStateParam(name, 'hidden', false);
var processHtml = () => {
var fieldView = this.getFieldView(name);
const processHtml = () => {
const fieldView = this.getFieldView(name);
if (fieldView) {
var $field = fieldView.$el;
var $cell = $field.closest('.cell[data-name="' + name + '"]');
var $label = $cell.find('label.control-label[data-name="' + name + '"]');
const $field = fieldView.$el;
const $cell = $field.closest('.cell[data-name="' + name + '"]');
const $label = $cell.find('label.control-label[data-name="' + name + '"]');
$field.removeClass('hidden');
$label.removeClass('hidden');
@@ -193,7 +193,7 @@ class DetailMiddleRecordView extends View {
});
}
var view = this.getFieldView(name);
const view = this.getFieldView(name);
if (view) {
if (!view.disabledLocked) {
@@ -215,10 +215,11 @@ class DetailMiddleRecordView extends View {
* @return {Object.<string, module:views/fields/base>}
*/
getFieldViews() {
let fieldViews = {};
const fieldViews = {};
for (let viewKey in this.nestedViews) {
let name = this.nestedViews[viewKey].name;
for (const viewKey in this.nestedViews) {
// noinspection JSUnresolvedReference
const name = this.nestedViews[viewKey].name;
fieldViews[name] = this.nestedViews[viewKey];
}
+2 -2
View File
@@ -103,7 +103,7 @@ class DetailSideRecordView extends PanelsContainerRecordView {
this.setupPanels();
if (!this.additionalPanelsDisabled) {
let additionalPanels = this.getMetadata()
const additionalPanels = this.getMetadata()
.get(['clientDefs', this.scope, 'sidePanels', this.type]) || [];
additionalPanels.forEach((panel) => {
@@ -128,7 +128,7 @@ class DetailSideRecordView extends PanelsContainerRecordView {
});
this.panelList = this.panelList.map((p) => {
let item = Espo.Utils.clone(p);
const item = Espo.Utils.clone(p);
if (this.recordHelper.getPanelStateParam(p.name, 'hidden') !== null) {
item.hidden = this.recordHelper.getPanelStateParam(p.name, 'hidden');
+3 -3
View File
@@ -90,7 +90,7 @@ class EditRecordView extends DetailRecordView {
actionSave(data) {
data = data || {};
let isNew = this.isNew;
const isNew = this.isNew;
return this.save(data.options)
.then(() => {
@@ -183,7 +183,7 @@ class EditRecordView extends DetailRecordView {
actionSaveAndNew(data) {
data = data || {};
let proceedCallback = () => {
const proceedCallback = () => {
Espo.Ui.success(this.translate('Created'));
this.getRouter().dispatch(this.scope, 'create', {
@@ -219,7 +219,7 @@ class EditRecordView extends DetailRecordView {
e.preventDefault();
e.stopPropagation();
let focusedFieldView = this.getFocusedFieldView();
const focusedFieldView = this.getFocusedFieldView();
if (focusedFieldView) {
this.model.set(focusedFieldView.fetch());
+8 -6
View File
@@ -49,10 +49,10 @@ class KanbanRecordItem extends View {
this.layoutDataList = [];
this.itemLayout.forEach((item, i) => {
let name = item.name;
let key = name + 'Field';
const name = item.name;
const key = name + 'Field';
let o = {
const o = {
name: name,
isAlignRight: item.align === 'right',
isLarge: item.isLarge,
@@ -62,9 +62,11 @@ class KanbanRecordItem extends View {
this.layoutDataList.push(o);
var viewName = item.view || this.model.getFieldParam(name, 'view');
let viewName = item.view || this.model.getFieldParam(name, 'view');
if (!viewName) {
var type = this.model.getFieldType(name) || 'base';
const type = this.model.getFieldType(name) || 'base';
viewName = this.getFieldManager().getViewName(type);
}
@@ -84,7 +86,7 @@ class KanbanRecordItem extends View {
});
if (!this.rowActionsDisabled) {
let acl = {
const acl = {
edit: this.getAcl().checkModel(this.model, 'edit'),
delete: this.getAcl().checkModel(this.model, 'delete'),
};
+97 -94
View File
@@ -79,12 +79,12 @@ class KanbanRecordView extends ListRecordView {
e.preventDefault();
let id = $(e.currentTarget).data('id');
let model = this.collection.get(id);
const id = $(e.currentTarget).data('id');
const model = this.collection.get(id);
let scope = this.getModelScope(id);
const scope = this.getModelScope(id);
let options = {
const options = {
id: id,
model: model,
};
@@ -98,9 +98,9 @@ class KanbanRecordView extends ListRecordView {
},
/** @this KanbanRecordView */
'click [data-action="groupShowMore"]': function (e) {
let $target = $(e.currentTarget);
const $target = $(e.currentTarget);
let group = $target.data('name');
const group = $target.data('name');
this.groupShowMore(group);
},
@@ -113,19 +113,19 @@ class KanbanRecordView extends ListRecordView {
},
/** @this KanbanRecordView */
'mouseenter th.group-header': function (e) {
let group = $(e.currentTarget).attr('data-name');
const group = $(e.currentTarget).attr('data-name');
this.showPlus(group);
},
/** @this KanbanRecordView */
'mouseleave th.group-header': function (e) {
let group = $(e.currentTarget).attr('data-name');
const group = $(e.currentTarget).attr('data-name');
this.hidePlus(group);
},
/** @this KanbanRecordView */
'click [data-action="createInGroup"]': function (e) {
let group = $(e.currentTarget).attr('data-group');
const group = $(e.currentTarget).attr('data-group');
this.actionCreateInGroup(group);
},
@@ -139,15 +139,15 @@ class KanbanRecordView extends ListRecordView {
},
/** @this KanbanRecordView */
'auxclick a.link': function (e) {
let isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
if (!isCombination) {
return;
}
let $target = $(e.currentTarget);
const $target = $(e.currentTarget);
let id = $target.attr('data-id');
const id = $target.attr('data-id');
if (!id) {
return;
@@ -157,7 +157,7 @@ class KanbanRecordView extends ListRecordView {
return;
}
let $quickView = $target.parent().closest(`[data-id="${id}"]`)
const $quickView = $target.parent().closest(`[data-id="${id}"]`)
.find(`ul.list-row-dropdown-menu[data-id="${id}"] a[data-action="quickView"]`);
if (!$quickView.length) {
@@ -171,7 +171,9 @@ class KanbanRecordView extends ListRecordView {
},
}
// noinspection JSCheckFunctionSignatures
data() {
// noinspection JSValidateTypes
return {
scope: this.scope,
header: this.header,
@@ -265,7 +267,7 @@ class KanbanRecordView extends ListRecordView {
['entityDefs', this.scope, 'fields', this.statusField, 'options'])
);
let statusIgnoreList = this.getMetadata().get(['scopes', this.scope, 'kanbanStatusIgnoreList']) || [];
const statusIgnoreList = this.getMetadata().get(['scopes', this.scope, 'kanbanStatusIgnoreList']) || [];
this.statusList = this.statusList.filter((item) => {
if (~statusIgnoreList.indexOf(item)) {
@@ -324,7 +326,7 @@ class KanbanRecordView extends ListRecordView {
}
afterRender() {
let $window = $(window);
const $window = $(window);
this.$listKanban = this.$el.find('.list-kanban');
this.$content = $('#content');
@@ -351,7 +353,7 @@ class KanbanRecordView extends ListRecordView {
this.plusElementMap = {};
this.statusList.forEach(status => {
let value = status.replace(/"/g, '\\"');
const value = status.replace(/"/g, '\\"');
this.plusElementMap[status] = this.$el
.find('.kanban-head .create-button[data-group="' + value + '"]');
@@ -359,15 +361,15 @@ class KanbanRecordView extends ListRecordView {
}
initStickableHeader() {
let $container = this.$headContainer = this.$el.find('.kanban-head-container');
let topBarHeight = this.getThemeManager().getParam('navbarHeight') || 30;
const $container = this.$headContainer = this.$el.find('.kanban-head-container');
const topBarHeight = this.getThemeManager().getParam('navbarHeight') || 30;
let screenWidthXs = this.getThemeManager().getParam('screenWidthXs');
const screenWidthXs = this.getThemeManager().getParam('screenWidthXs');
let $middle = this.$el.find('.kanban-columns-container');
let $window = $(window);
const $middle = this.$el.find('.kanban-columns-container');
const $window = $(window);
let $block = $('<div>')
const $block = $('<div>')
.addClass('kanban-head-placeholder')
.html('&nbsp;')
.hide()
@@ -381,8 +383,8 @@ class KanbanRecordView extends ListRecordView {
$window.off('resize.kanban-' + this.cid);
$window.on('resize.kanban-' + this.cid, () => controlSticking());
let controlSticking = () => {
let width = $middle.width();
const controlSticking = () => {
const width = $middle.width();
if ($(window.document).width() < screenWidthXs) {
$container.removeClass('sticked');
@@ -396,14 +398,14 @@ class KanbanRecordView extends ListRecordView {
return;
}
let stickTop = this.$listKanban.offset().top - topBarHeight;
const stickTop = this.$listKanban.offset().top - topBarHeight;
let edge = $middle.offset().top + $middle.outerHeight(true);
let scrollTop = $window.scrollTop();
const edge = $middle.offset().top + $middle.outerHeight(true);
const scrollTop = $window.scrollTop();
if (scrollTop < edge) {
if (scrollTop > stickTop) {
let containerWidth = this.$container.width() - 3;
const containerWidth = this.$container.width() - 3;
$container.children().css('width', width);
@@ -440,15 +442,15 @@ class KanbanRecordView extends ListRecordView {
}
initSortable() {
let $list = this.$groupColumnList;
const $list = this.$groupColumnList;
$list.find('> .item').on('touchstart', (e) => {
e.originalEvent.stopPropagation();
});
let orderDisabled = this.orderDisabled;
const orderDisabled = this.orderDisabled;
let $groupColumnList = this.$el.find('.group-column-list');
const $groupColumnList = this.$el.find('.group-column-list');
$list.sortable({
distance: 10,
@@ -490,21 +492,21 @@ class KanbanRecordView extends ListRecordView {
this.sortIsStarted = false;
this.$draggable = null;
let $item = $(ui.item);
const $item = $(ui.item);
this.$el.find('.group-column-list').removeClass('drop-active');
let group = $item.closest('.group-column-list').data('name');
let id = $item.data('id');
const group = $item.closest('.group-column-list').data('name');
const id = $item.data('id');
let draggedGroupFrom = this.draggedGroupFrom;
const draggedGroupFrom = this.draggedGroupFrom;
this.draggedGroupFrom = null;
this.$showMore.removeClass('hidden');
if (group !== draggedGroupFrom) {
let model = this.collection.get(id);
const model = this.collection.get(id);
if (!model) {
$list.sortable('cancel');
@@ -512,7 +514,7 @@ class KanbanRecordView extends ListRecordView {
return;
}
let attributes = {};
const attributes = {};
attributes[this.statusField] = group;
@@ -569,7 +571,7 @@ class KanbanRecordView extends ListRecordView {
* @return {Promise}
*/
storeGroupOrder(group, id) {
let ids = this.getGroupOrderFromDom(group);
const ids = this.getGroupOrderFromDom(group);
if (id) {
ids.unshift(id);
@@ -587,9 +589,9 @@ class KanbanRecordView extends ListRecordView {
* @return {string[]}
*/
getGroupOrderFromDom(group) {
let ids = [];
const ids = [];
let $group = this.$el.find('.group-column-list[data-name="'+group+'"]');
const $group = this.$el.find('.group-column-list[data-name="' + group + '"]');
$group.children().each((i, el) => {
ids.push($(el).data('id'));
@@ -602,10 +604,10 @@ class KanbanRecordView extends ListRecordView {
* @param {string} group
*/
reOrderGroup(group) {
let groupCollection = this.getGroupCollection(group);
let ids = this.getGroupOrderFromDom(group);
const groupCollection = this.getGroupCollection(group);
const ids = this.getGroupOrderFromDom(group);
let modelMap = {};
const modelMap = {};
groupCollection.models.forEach((m) => {
modelMap[m.id] = m;
@@ -616,7 +618,7 @@ class KanbanRecordView extends ListRecordView {
}
ids.forEach(id => {
let model = modelMap[id];
const model = modelMap[id];
if (!model) {
return;
@@ -630,7 +632,7 @@ class KanbanRecordView extends ListRecordView {
this.groupDataList.forEach(item => {
item.dataList = [];
for (let model of item.collection.models) {
for (const model of item.collection.models) {
item.dataList.push({
key: model.id,
id: model.id,
@@ -670,7 +672,7 @@ class KanbanRecordView extends ListRecordView {
let height = this.getHelper()
.calculateContentContainerHeight(this.$el.find('.kanban-columns-container'));
let containerEl = this.$container.get(0);
const containerEl = this.$container.get(0);
if (containerEl.scrollWidth > containerEl.clientWidth) {
height -= 18;
@@ -711,7 +713,8 @@ class KanbanRecordView extends ListRecordView {
}
buildRows(callback) {
let groupList = (this.collection.dataAdditional || {}).groupList || [];
// noinspection JSUnresolvedReference
const groupList = (this.collection.dataAdditional || {}).groupList || [];
this.collection.reset();
@@ -728,7 +731,7 @@ class KanbanRecordView extends ListRecordView {
this.listLayout = listLayout;
groupList.forEach((item, i) => {
let collection = this.seedCollection.clone();
const collection = this.seedCollection.clone();
this.listenTo(collection, 'destroy', (model, attributes, o) => {
if (o.fromList) {
@@ -763,7 +766,7 @@ class KanbanRecordView extends ListRecordView {
this.collection.add(collection.models);
let itemDataList = [];
const itemDataList = [];
collection.models.forEach(model => {
count ++;
@@ -782,16 +785,15 @@ class KanbanRecordView extends ListRecordView {
'style', groupList[i + 1].name]);
}
let o = {
const o = {
name: item.name,
label: this.getLanguage().translateOption(item.name, this.statusField, this.scope),
dataList: itemDataList,
collection: collection,
isLast: i === groupList.length - 1,
hasShowMore: collection.total > collection.length || collection.total === -1,
style: this.getMetadata().get(
['entityDefs', this.scope, 'fields', this.statusField, 'style', item.name]
),
style: this.getMetadata()
.get(['entityDefs', this.scope, 'fields', this.statusField, 'style', item.name]),
nextStyle: nextStyle,
};
@@ -810,7 +812,7 @@ class KanbanRecordView extends ListRecordView {
this.groupDataList.forEach(groupItem => {
groupItem.dataList.forEach((item, j) => {
let model = groupItem.collection.get(item.id);
const model = groupItem.collection.get(item.id);
this.buildRow(j, model, () => {
loadedCount++;
@@ -829,7 +831,7 @@ class KanbanRecordView extends ListRecordView {
}
buildRow(i, model, callback) {
let key = model.id;
const key = model.id;
this.createView(key, this.itemViewName, {
model: model,
@@ -866,9 +868,9 @@ class KanbanRecordView extends ListRecordView {
}
});
for (let groupItem of this.groupDataList) {
for (const groupItem of this.groupDataList) {
for (let j = 0; j < groupItem.dataList.length; j++) {
let item = groupItem.dataList[j];
const item = groupItem.dataList[j];
if (item.id !== id) {
continue;
@@ -889,8 +891,8 @@ class KanbanRecordView extends ListRecordView {
}
onChangeGroup(model, value, o) {
let id = model.id;
let group = model.get(this.statusField);
const id = model.id;
const group = model.get(this.statusField);
this.collection.subCollectionList.forEach((collection) => {
if (collection.get(id)) {
@@ -904,9 +906,9 @@ class KanbanRecordView extends ListRecordView {
let dataItem;
for (let groupItem of this.groupDataList) {
for (const groupItem of this.groupDataList) {
for (let j = 0; j < groupItem.dataList.length; j++) {
let item = groupItem.dataList[j];
const item = groupItem.dataList[j];
if (item.id === id) {
dataItem = item;
@@ -925,7 +927,7 @@ class KanbanRecordView extends ListRecordView {
return;
}
for (let groupItem of this.groupDataList) {
for (const groupItem of this.groupDataList) {
if (groupItem.name !== group) {
continue;
}
@@ -941,8 +943,8 @@ class KanbanRecordView extends ListRecordView {
}
}
let $item = this.$el.find('.item[data-id="' + id + '"]');
let $column = this.$el.find('.group-column[data-name="' + group + '"] .group-column-list');
const $item = this.$el.find('.item[data-id="' + id + '"]');
const $column = this.$el.find('.group-column[data-name="' + group + '"] .group-column-list');
if ($column.length) {
$column.prepend($item);
@@ -958,7 +960,7 @@ class KanbanRecordView extends ListRecordView {
groupShowMore(group) {
let groupItem;
for (let i in this.groupDataList) {
for (const i in this.groupDataList) {
groupItem = this.groupDataList[i];
if (groupItem.name === group) {
@@ -972,10 +974,10 @@ class KanbanRecordView extends ListRecordView {
return;
}
let collection = groupItem.collection;
const collection = groupItem.collection;
let $list = this.$el.find('.group-column-list[data-name="'+group+'"]');
let $showMore = this.$el.find('.group-column[data-name="'+group+'"] .show-more');
const $list = this.$el.find('.group-column-list[data-name="' + group + '"]');
const $showMore = this.$el.find('.group-column[data-name="' + group + '"] .show-more');
collection.data.select = this.collection.data.select;
@@ -1010,7 +1012,7 @@ class KanbanRecordView extends ListRecordView {
// noinspection JSUnusedGlobalSymbols
actionMoveOver(data) {
let model = this.collection.get(data.id);
const model = this.collection.get(data.id);
this.createView('moveOverDialog', 'views/modals/kanban-move-over', {
model: model,
@@ -1041,7 +1043,7 @@ class KanbanRecordView extends ListRecordView {
* @param {string} group
*/
showPlus(group) {
let $el = this.plusElementMap[group];
const $el = this.plusElementMap[group];
if (!$el) {
return;
@@ -1054,7 +1056,7 @@ class KanbanRecordView extends ListRecordView {
* @param {string} group
*/
hidePlus(group) {
let $el = this.plusElementMap[group];
const $el = this.plusElementMap[group];
if (!$el) {
return;
@@ -1067,14 +1069,14 @@ class KanbanRecordView extends ListRecordView {
* @param {string} group
*/
actionCreateInGroup(group) {
let attributes = {};
const attributes = {};
attributes[this.statusField] = group;
let viewName = this.getMetadata().get('clientDefs.' + this.scope + '.modalViews.edit') ||
const viewName = this.getMetadata().get('clientDefs.' + this.scope + '.modalViews.edit') ||
'views/modals/edit';
let options = {
const options = {
attributes: attributes,
scope: this.scope,
};
@@ -1100,18 +1102,19 @@ class KanbanRecordView extends ListRecordView {
initBackDrag(e) {
this.backDragStarted = true;
let containerEl = this.$container.get(0);
const containerEl = this.$container.get(0);
containerEl.style.cursor = 'grabbing';
containerEl.style.userSelect = 'none';
let $document = $(document);
const $document = $(document);
let startLeft = containerEl.scrollLeft;
let startX = e.clientX;
const startLeft = containerEl.scrollLeft;
const startX = e.clientX;
$document.on('mousemove.' + this.cid, (e) => {
let dx = e.originalEvent.clientX - startX;
// noinspection JSUnresolvedReference
const dx = e.originalEvent.clientX - startX;
containerEl.scrollLeft = startLeft - dx;
@@ -1147,37 +1150,37 @@ class KanbanRecordView extends ListRecordView {
return;
}
let draggableRect = this.$draggable.get(0).getBoundingClientRect();
const draggableRect = this.$draggable.get(0).getBoundingClientRect();
let itemLeft = draggableRect.left;
let itemRight = draggableRect.right;
const itemLeft = draggableRect.left;
const itemRight = draggableRect.right;
let containerEl = this.$container.get(0);
const containerEl = this.$container.get(0);
let rect = containerEl.getBoundingClientRect();
const rect = containerEl.getBoundingClientRect();
let marginSens = 70;
const marginSens = 70;
let step = 2;
let interval = 5;
let marginSensStepRatio = 4;
let stepRatio = 3;
const interval = 5;
const marginSensStepRatio = 4;
const stepRatio = 3;
let isRight = rect.right - marginSens < itemRight &&
const isRight = rect.right - marginSens < itemRight &&
containerEl.scrollLeft + containerEl.offsetWidth < containerEl.scrollWidth;
let isLeft = rect.left + marginSens > itemLeft &&
const isLeft = rect.left + marginSens > itemLeft &&
containerEl.scrollLeft > 0;
this.$groupColumnList.sortable('refreshPositions');
if (isRight && this.sortWasCentered) {
let margin = rect.right - itemRight;
const margin = rect.right - itemRight;
if (margin < marginSens / marginSensStepRatio) {
step *= stepRatio;
}
let stepActual = Math.min(step, containerEl.offsetWidth - containerEl.scrollLeft);
const stepActual = Math.min(step, containerEl.offsetWidth - containerEl.scrollLeft);
containerEl.scrollLeft = containerEl.scrollLeft + stepActual;
@@ -1197,13 +1200,13 @@ class KanbanRecordView extends ListRecordView {
}
if (isLeft && this.sortWasCentered) {
let margin = - (rect.left - itemLeft);
const margin = -(rect.left - itemLeft);
if (margin < marginSens / marginSensStepRatio) {
step *= stepRatio;
}
let stepActual = Math.min(step, containerEl.scrollLeft);
const stepActual = Math.min(step, containerEl.scrollLeft);
containerEl.scrollLeft = containerEl.scrollLeft - stepActual;
+17 -17
View File
@@ -49,7 +49,7 @@ class ListExpandedRecordView extends ListRecordView {
super.setup();
this.on('after:save', model => {
let view = this.getView(model.id);
const view = this.getView(model.id);
if (!view) {
return;
@@ -63,7 +63,7 @@ class ListExpandedRecordView extends ListRecordView {
}
_loadListLayout(callback) {
let type = this.type + 'Expanded';
const type = this.type + 'Expanded';
this.layoutLoadCallbackList.push(callback);
@@ -86,20 +86,20 @@ class ListExpandedRecordView extends ListRecordView {
_convertLayout(listLayout, model) {
model = model || this.collection.prepareModel();
let layout = {
const layout = {
rows: [],
right: false,
};
for (let i in listLayout.rows) {
let row = listLayout.rows[i];
let layoutRow = [];
for (const i in listLayout.rows) {
const row = listLayout.rows[i];
const layoutRow = [];
for (let j in row) {
let rowItem = row[j];
let type = rowItem.type || model.getFieldType(rowItem.name) || 'base';
for (const j in row) {
const rowItem = row[j];
const type = rowItem.type || model.getFieldType(rowItem.name) || 'base';
let item = {
const item = {
name: rowItem.name + 'Field',
field: rowItem.name,
view: rowItem.view ||
@@ -115,7 +115,7 @@ class ListExpandedRecordView extends ListRecordView {
};
if (rowItem.options) {
for (let optionName in rowItem.options) {
for (const optionName in rowItem.options) {
if (typeof item.options[optionName] !== 'undefined') {
continue;
}
@@ -136,7 +136,7 @@ class ListExpandedRecordView extends ListRecordView {
if ('right' in listLayout) {
if (listLayout.right) {
let name = listLayout.right.name || 'right';
const name = listLayout.right.name || 'right';
layout.right = {
field: name,
@@ -166,7 +166,7 @@ class ListExpandedRecordView extends ListRecordView {
}
getItemEl(model, item) {
let name = item.field || item.columnName;
const name = item.field || item.columnName;
return this.getSelector() + ' li[data-id="' + model.id + '"] .cell[data-name="' + name+ '"]';
}
@@ -179,7 +179,7 @@ class ListExpandedRecordView extends ListRecordView {
}
prepareInternalLayout(internalLayout, model) {
let rows = internalLayout.rows || [];
const rows = internalLayout.rows || [];
rows.forEach((row) => {
row.forEach((col) => {
@@ -193,7 +193,7 @@ class ListExpandedRecordView extends ListRecordView {
}
fetchAttributeListFromLayout() {
var list = [];
const list = [];
if (this.listLayout.rows) {
this.listLayout.rows.forEach((row) => {
@@ -202,9 +202,9 @@ class ListExpandedRecordView extends ListRecordView {
return;
}
var field = item.name;
const field = item.name;
var fieldType = this.getMetadata().get(['entityDefs', this.scope, 'fields', field, 'type']);
const fieldType = this.getMetadata().get(['entityDefs', this.scope, 'fields', field, 'type']);
if (!fieldType) {
return;
@@ -43,7 +43,7 @@ class ListNestedCategoriesRecordView extends View {
}
data() {
let data = {};
const data = {};
if (!this.isLoading) {
data.list = this.getDataList();
@@ -59,7 +59,7 @@ class ListNestedCategoriesRecordView extends View {
data.showEditLink = this.options.showEditLink;
data.hasNavigationPanel = this.options.hasNavigationPanel;
let categoryData = this.collection.categoryData || {};
const categoryData = this.collection.categoryData || {};
data.upperLink = categoryData.upperId ?
'#' + this.subjectEntityType + '/list/categoryId=' + categoryData.upperId:
@@ -69,10 +69,10 @@ class ListNestedCategoriesRecordView extends View {
}
getDataList() {
var list = [];
const list = [];
this.collection.forEach(model => {
let o = {
const o = {
id: model.id,
name: model.get('name'),
recordCount: model.get('recordCount'),
@@ -94,6 +94,7 @@ class ListNestedCategoriesRecordView extends View {
this.subjectEntityType = this.options.subjectEntityType;
}
// noinspection JSUnusedGlobalSymbols
actionShowMore() {
this.$el.find('.category-item.show-more').addClass('hidden');
@@ -104,4 +105,5 @@ class ListNestedCategoriesRecordView extends View {
}
}
// noinspection JSUnusedGlobalSymbols
export default ListNestedCategoriesRecordView;
+2 -3
View File
@@ -33,8 +33,8 @@ define('views/record/list-pagination', ['view'], function (Dep) {
template: 'record/list-pagination',
data: function () {
var previous = this.collection.offset > 0;
var next = this.collection.total - this.collection.offset > this.collection.maxSize ||
const previous = this.collection.offset > 0;
const next = this.collection.total - this.collection.offset > this.collection.maxSize ||
this.collection.total === -1;
return {
@@ -46,6 +46,5 @@ define('views/record/list-pagination', ['view'], function (Dep) {
noTotal: this.collection.total === -1 || this.collection.total === -2,
};
},
});
});
+10 -10
View File
@@ -75,8 +75,8 @@ class ListTreeRecordItemView extends View {
this.isSelected = true;
this.selectedData.id = this.model.id;
let path = this.selectedData.path;
let names = this.selectedData.names;
const path = this.selectedData.path;
const names = this.selectedData.names;
path.length = 0;
@@ -122,7 +122,7 @@ class ListTreeRecordItemView extends View {
this.isUnfolded = false;
var childCollection = this.model.get('childCollection');
const childCollection = this.model.get('childCollection');
if ((childCollection && childCollection.length === 0) || this.model.isEnd) {
if (this.createDisabled) {
@@ -154,7 +154,7 @@ class ListTreeRecordItemView extends View {
}
createChildren() {
let childCollection = this.model.get('childCollection');
const childCollection = this.model.get('childCollection');
let callback = null;
@@ -185,16 +185,16 @@ class ListTreeRecordItemView extends View {
Espo.Ajax
.getRequest(this.collection.entityType + '/action/lastChildrenIdList', {parentId: this.model.id})
.then(idList =>{
let childrenView = this.getChildrenView();
const childrenView = this.getChildrenView();
idList.forEach(id => {
var model = this.model.get('childCollection').get(id);
const model = this.model.get('childCollection').get(id);
if (model) {
model.isEnd = true;
}
var itemView = childrenView.getView(id);
const itemView = childrenView.getView(id);
if (!itemView) {
return;
@@ -218,7 +218,7 @@ class ListTreeRecordItemView extends View {
});
}
let childCollection = this.model.get('childCollection');
const childCollection = this.model.get('childCollection');
if (childCollection !== null) {
this.createChildren();
@@ -281,7 +281,7 @@ class ListTreeRecordItemView extends View {
}
if (!this.readOnly) {
let $remove = this.$el.find('> .cell [data-action="remove"]');
const $remove = this.$el.find('> .cell [data-action="remove"]');
this.$el.find('> .cell').on('mouseenter', function () {
$remove.removeClass('hidden');
@@ -314,7 +314,7 @@ class ListTreeRecordItemView extends View {
getCurrentPath() {
let pointer = this;
let path = [];
const path = [];
while (true) {
path.unshift(pointer.model.id);
+10 -9
View File
@@ -50,8 +50,9 @@ class ListTreeRecordView extends ListRecordView {
level = 0
itemViewName = 'views/record/list-tree-item'
// noinspection JSCheckFunctionSignatures
data() {
let data = super.data();
const data = super.data();
data.createDisabled = this.createDisabled;
@@ -163,7 +164,7 @@ class ListTreeRecordView extends ListRecordView {
}
this.rowList.forEach(key => {
let view = /** @type module:views/record/list-tree-item */this.getView(key);
const view = /** @type module:views/record/list-tree-item */this.getView(key);
if (view.model.id === id) {
view.setIsSelected();
@@ -185,12 +186,12 @@ class ListTreeRecordView extends ListRecordView {
if (this.collection.length > 0) {
this.wait(true);
let modelList = this.collection.models;
let count = modelList.length;
const modelList = this.collection.models;
const count = modelList.length;
let built = 0;
modelList.forEach(model => {
let key = model.id;
const key = model.id;
this.rowList.push(key);
@@ -244,7 +245,7 @@ class ListTreeRecordView extends ListRecordView {
actionCreate(data, e) {
e.stopPropagation();
let attributes = this.getCreateAttributes();
const attributes = this.getCreateAttributes();
let maxOrder = 0;
@@ -264,9 +265,9 @@ class ListTreeRecordView extends ListRecordView {
attributes.parentName = this.model.get('name');
}
let scope = this.collection.entityType;
const scope = this.collection.entityType;
let viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') ||
const viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') ||
'views/modals/edit';
this.createView('quickCreate', viewName, {
@@ -278,7 +279,7 @@ class ListTreeRecordView extends ListRecordView {
this.listenToOnce(view, 'after:save', model => {
view.close();
let collection = /** @type module:collections/tree */ this.collection;
const collection = /** @type module:collections/tree */ this.collection;
model.set('childCollection', collection.createSeed());
-1
View File
@@ -2311,7 +2311,6 @@ class ListRecordView extends View {
/**
* @protected
* @param {function(module:views/record/list~columnDefs[]): void} callback A callback.
* @private
*/
_loadListLayout(callback) {
this.layoutLoadCallbackList.push(callback);
+1 -1
View File
@@ -49,7 +49,7 @@ class PanelActionsView extends View {
}
getButtonList() {
let list = [];
const list = [];
this.buttonList.forEach(item => {
if (item.hidden) {
+45 -45
View File
@@ -138,7 +138,7 @@ class PanelsContainerRecordView extends View {
mode = 'detail'
data() {
let tabDataList = this.hasTabs ? this.getTabDataList() : [];
const tabDataList = this.hasTabs ? this.getTabDataList() : [];
return {
panelList: this.panelList,
@@ -150,14 +150,14 @@ class PanelsContainerRecordView extends View {
events = {
'click .action': function (e) {
let $target = $(e.currentTarget);
let panel = $target.data('panel');
const $target = $(e.currentTarget);
const panel = $target.data('panel');
if (!panel) {
return;
}
let panelView = this.getView(panel);
const panelView = this.getView(panel);
if (!panelView) {
return;
@@ -200,7 +200,7 @@ class PanelsContainerRecordView extends View {
'click .panels-show-more-delimiter [data-action="showMorePanels"]': 'actionShowMorePanels',
/** @this module:views/record/panels-container */
'click .tabs > button': function (e) {
let tab = parseInt($(e.currentTarget).attr('data-tab'));
const tab = parseInt($(e.currentTarget).attr('data-tab'));
this.selectTab(tab);
},
@@ -215,21 +215,21 @@ class PanelsContainerRecordView extends View {
return;
}
let $panels = this.$el.find('> .panel');
const $panels = this.$el.find('> .panel');
$panels
.removeClass('first')
.removeClass('last')
.removeClass('in-middle');
let $visiblePanels = $panels.filter(`:not(.tab-hidden):not(.hidden)`);
const $visiblePanels = $panels.filter(`:not(.tab-hidden):not(.hidden)`);
let groups = [];
const groups = [];
let currentGroup = [];
let inTab = false;
$visiblePanels.each((i, el) => {
let $el = $(el);
const $el = $(el);
let breakGroup = false;
@@ -304,7 +304,7 @@ class PanelsContainerRecordView extends View {
this.applyAccessToActions(item.actionList);
if (this.isRendered()) {
let actionsView = this.getView(item.actionsViewKey);
const actionsView = this.getView(item.actionsViewKey);
if (actionsView) {
actionsView.reRender();
@@ -352,7 +352,7 @@ class PanelsContainerRecordView extends View {
*/
setupPanelViews() {
this.panelList.forEach(p => {
let name = p.name;
const name = p.name;
let options = {
model: this.model,
@@ -422,7 +422,7 @@ class PanelsContainerRecordView extends View {
let fields = {};
this.panelList.forEach(p => {
let panelView = this.getView(p.name);
const panelView = this.getView(p.name);
if ((!panelView.disabled || withHidden) && 'getFieldViews' in panelView) {
fields = _.extend(fields, panelView.getFieldViews());
@@ -450,7 +450,7 @@ class PanelsContainerRecordView extends View {
let data = {};
this.panelList.forEach(p => {
let panelView = this.getView(p.name);
const panelView = this.getView(p.name);
if (!panelView.disabled && 'fetch' in panelView) {
data = _.extend(data, panelView.fetch());
@@ -509,8 +509,8 @@ class PanelsContainerRecordView extends View {
}
showPanelFinalize(name, callback, wasShown) {
let process = (wasRendered) => {
let view = this.getView(name);
const process = (wasRendered) => {
const view = this.getView(name);
if (view) {
view.$el.closest('.panel').removeClass('hidden');
@@ -520,10 +520,10 @@ class PanelsContainerRecordView extends View {
view.trigger('panel-show-propagated');
if (wasRendered && !wasShown && view.getFieldViews) {
let fields = view.getFieldViews();
const fields = view.getFieldViews();
if (fields) {
for (let i in fields) {
for (const i in fields) {
fields[i].reRender();
}
}
@@ -550,7 +550,7 @@ class PanelsContainerRecordView extends View {
hidePanelFinalize(name, callback) {
if (this.isRendered()) {
let view = this.getView(name);
const view = this.getView(name);
if (view) {
view.$el.closest('.panel').addClass('hidden');
@@ -584,18 +584,18 @@ class PanelsContainerRecordView extends View {
}
if (softLockedType) {
let param = 'hidden' + Espo.Utils.upperCaseFirst(softLockedType) + 'Locked';
const param = 'hidden' + Espo.Utils.upperCaseFirst(softLockedType) + 'Locked';
this.recordHelper.setPanelStateParam(name, param, false);
for (let i = 0; i < this.panelSoftLockedTypeList.length; i++) {
let iType = this.panelSoftLockedTypeList[i];
const iType = this.panelSoftLockedTypeList[i];
if (iType === softLockedType) {
continue;
}
let iParam = 'hidden' + Espo.Utils.upperCaseFirst(iType) + 'Locked';
const iParam = 'hidden' + Espo.Utils.upperCaseFirst(iType) + 'Locked';
if (this.recordHelper.getPanelStateParam(name, iParam)) {
return;
@@ -603,7 +603,7 @@ class PanelsContainerRecordView extends View {
}
}
let wasShown = this.recordHelper.getPanelStateParam(name, 'hidden') === false;
const wasShown = this.recordHelper.getPanelStateParam(name, 'hidden') === false;
this.recordHelper.setPanelStateParam(name, 'hidden', false);
@@ -622,7 +622,7 @@ class PanelsContainerRecordView extends View {
}
if (softLockedType) {
let param = 'hidden' + Espo.Utils.upperCaseFirst(softLockedType) + 'Locked';
const param = 'hidden' + Espo.Utils.upperCaseFirst(softLockedType) + 'Locked';
this.recordHelper.setPanelStateParam(name, param, true);
}
@@ -633,12 +633,12 @@ class PanelsContainerRecordView extends View {
alterPanels(layoutData) {
layoutData = layoutData || this.layoutData || {};
let tabBreakIndexList = [];
const tabBreakIndexList = [];
let tabDataList = [];
const tabDataList = [];
for (let name in layoutData) {
let item = layoutData[name];
for (const name in layoutData) {
const item = layoutData[name];
if (name === '_delimiter_') {
this.panelList.push({
@@ -666,7 +666,7 @@ class PanelsContainerRecordView extends View {
return !this.recordHelper.getPanelStateParam(item.name, 'hiddenLocked');
});
let newList = [];
const newList = [];
this.panelList.forEach((item, i) => {
item.index = ('index' in item) ? item.index : i;
@@ -674,7 +674,7 @@ class PanelsContainerRecordView extends View {
let allowedInLayout = false;
if (item.name) {
let itemData = layoutData[item.name] || {};
const itemData = layoutData[item.name] || {};
if (itemData.disabled) {
return;
@@ -684,7 +684,7 @@ class PanelsContainerRecordView extends View {
allowedInLayout = true;
}
for (let i in itemData) {
for (const i in itemData) {
item[i] = itemData[i];
}
}
@@ -705,7 +705,7 @@ class PanelsContainerRecordView extends View {
newList.sort((v1, v2) => v1.index - v2.index);
let firstTabIndex = newList.findIndex(item => item.tabNumber !== -1);
const firstTabIndex = newList.findIndex(item => item.tabNumber !== -1);
if (firstTabIndex !== -1) {
newList[firstTabIndex].isTabsBeginning = true;
@@ -732,7 +732,7 @@ class PanelsContainerRecordView extends View {
this.panelList = newList;
if (this.recordViewObject && this.recordViewObject.dynamicLogic) {
let dynamicLogic = this.recordViewObject.dynamicLogic;
const dynamicLogic = this.recordViewObject.dynamicLogic;
this.panelList.forEach(item => {
if (item.dynamicLogicVisible) {
@@ -836,7 +836,7 @@ class PanelsContainerRecordView extends View {
label = this.translate(label.substring(1), 'tabs', this.scope);
}
let hidden = this.panelList
const hidden = this.panelList
.filter(panel => panel.tabNumber === i)
.findIndex(panel => !this.recordHelper.getPanelStateParam(panel.name, 'hidden')) === -1;
@@ -866,7 +866,7 @@ class PanelsContainerRecordView extends View {
this.panelList
.filter(item => item.tabNumber === tab && item.name)
.forEach(item => {
let view = this.getView(item.name);
const view = this.getView(item.name);
if (view) {
view.trigger('tab-show');
@@ -880,7 +880,7 @@ class PanelsContainerRecordView extends View {
this.panelList
.filter(item => item.tabNumber !== tab && item.name)
.forEach(item => {
let view = this.getView(item.name);
const view = this.getView(item.name);
if (view) {
view.trigger('tab-hide');
@@ -896,8 +896,8 @@ class PanelsContainerRecordView extends View {
/** @private */
storeTab() {
let key = 'tab_' + this.name;
let keyRecord = 'tab_' + this.name + '_record';
const key = 'tab_' + this.name;
const keyRecord = 'tab_' + this.name + '_record';
this.getSessionStorage().set(key, this.currentTab);
this.getSessionStorage().set(keyRecord, this.entityType + '_' + this.model.id);
@@ -905,16 +905,16 @@ class PanelsContainerRecordView extends View {
/** @private */
isStoredTabForThisRecord() {
let keyRecord = 'tab_' + this.name + '_record';
const keyRecord = 'tab_' + this.name + '_record';
return this.getSessionStorage().get(keyRecord) === this.entityType + '_' + this.model.id;
}
/** @private */
selectStoredTab() {
let key = 'tab_' + this.name;
const key = 'tab_' + this.name;
let tab = this.getSessionStorage().get(key);
const tab = this.getSessionStorage().get(key);
if (tab > 0) {
this.selectTab(tab);
@@ -948,24 +948,24 @@ class PanelsContainerRecordView extends View {
return;
}
let panelList = this.panelList.filter(panel => panel.tabNumber === tab);
const panelList = this.panelList.filter(panel => panel.tabNumber === tab);
let allIsHidden = panelList
const allIsHidden = panelList
.findIndex(panel => !this.recordHelper.getPanelStateParam(panel.name, 'hidden')) === -1;
if (!allIsHidden) {
return;
}
let $tab = this.$el.find(`.tabs > [data-tab="${tab.toString()}"]`);
const $tab = this.$el.find(`.tabs > [data-tab="${tab.toString()}"]`);
$tab.addClass('hidden');
if (this.currentTab === tab) {
let firstVisiblePanel = this.panelList
const firstVisiblePanel = this.panelList
.find(panel => panel.tabNumber > -1 && !panel.hidden);
let firstVisibleTab = firstVisiblePanel ?
const firstVisibleTab = firstVisiblePanel ?
firstVisiblePanel.tabNumber : 0;
this.selectTab(firstVisibleTab);
+82 -66
View File
@@ -31,6 +31,14 @@
import View from 'view';
import StoredTextSearch from 'helpers/misc/stored-text-search';
/**
* @typedef {Object} module:views/record/search~boolFilterDefs
* @property {boolean} [inPortalDisabled]
* @property {boolean} [isPortalOnly]
* @property {boolean} [aux]
* @property {module:utils~AccessDefs[]} [accessDataList]
*/
/**
* A search panel view.
*/
@@ -41,15 +49,19 @@ class SearchView extends View {
scope = ''
entityType = ''
/** @type {module:search-manager} */
searchManager = null
searchManager
fieldFilterList = null
/** @type {Object.<string, string>|null}*/
fieldFilterTranslations = null
textFilter = ''
/**
* @type {string|null}
*/
primary = null
presetFilterList = null
advanced = null
/** @type {{string: module:search-manager~advancedFilter}} */
advanced
bool = null
disableSavePreset = false
@@ -118,7 +130,7 @@ class SearchView extends View {
this.boolFilterList = Espo.Utils
.clone(this.getMetadata().get(['clientDefs', this.scope, 'boolFilterList']) || [])
.filter(item => {
.filter(/** module:views/record/search~boolFilterDefs|string */item => {
if (typeof item === 'string') {
return true;
}
@@ -157,7 +169,7 @@ class SearchView extends View {
this.fieldFilterTranslations = {};
let forbiddenFieldList = this.getAcl().getScopeForbiddenFieldList(this.entityType) || [];
const forbiddenFieldList = this.getAcl().getScopeForbiddenFieldList(this.entityType) || [];
this.wait(
new Promise(resolve => {
@@ -178,10 +190,10 @@ class SearchView extends View {
})
);
let filterList = this.options.filterList ||
const filterList = this.options.filterList ||
this.getMetadata().get(['clientDefs', this.scope, 'filterList']) || [];
this.presetFilterList = Espo.Utils.clone(filterList).filter((item) => {
this.presetFilterList = Espo.Utils.clone(filterList).filter(item => {
if (typeof item === 'string') {
return true;
}
@@ -227,10 +239,10 @@ class SearchView extends View {
if (this.presetName) {
let hasPresetListed = false;
for (let i in this.presetFilterList) {
let item = this.presetFilterList[i] || {};
for (const i in this.presetFilterList) {
const item = this.presetFilterList[i] || {};
let name = (typeof item === 'string') ? item : item.name;
const name = (typeof item === 'string') ? item : item.name;
if (name === this.presetName) {
hasPresetListed = true;
@@ -265,10 +277,10 @@ class SearchView extends View {
return [];
}
let list = [];
const list = [];
this.viewModeList.forEach(item => {
let o = {
const o = {
name: item,
title: this.translate(item, 'listViewModes'),
iconClass: this.viewModeIconClassMap[item]
@@ -317,7 +329,7 @@ class SearchView extends View {
createFilters(callback) {
let i = 0;
let count = Object.keys(this.advanced || {}).length;
const count = Object.keys(this.advanced || {}).length;
if (count === 0) {
if (typeof callback === 'function') {
@@ -325,7 +337,7 @@ class SearchView extends View {
}
}
for (let field in this.advanced) {
for (const field in this.advanced) {
this.createFilter(field, this.advanced[field], () => {
i++;
@@ -341,7 +353,7 @@ class SearchView extends View {
events = {
/** @this SearchView */
'keydown input[data-name="textFilter"]': function (e) {
let key = Espo.Utils.getKeyFromKeyEvent(e);
const key = Espo.Utils.getKeyFromKeyEvent(e);
if (e.code === 'Enter' || key === 'Enter' || key === 'Control+Enter') {
this.search();
@@ -367,8 +379,8 @@ class SearchView extends View {
},
/** @this SearchView */
'click a[data-action="addFilter"]': function (e) {
let $target = $(e.currentTarget);
let name = $target.data('name');
const $target = $(e.currentTarget);
const name = $target.data('name');
$target.closest('li').addClass('hidden');
@@ -376,9 +388,9 @@ class SearchView extends View {
},
/** @this SearchView */
'click .advanced-filters a.remove-filter': function (e) {
let $target = $(e.currentTarget);
const $target = $(e.currentTarget);
let name = $target.data('name');
const name = $target.data('name');
this.removeFilter(name);
},
@@ -392,9 +404,9 @@ class SearchView extends View {
},
/** @this SearchView */
'click a[data-action="selectPreset"]': function (e) {
let $target = $(e.currentTarget);
const $target = $(e.currentTarget);
let presetName = $target.data('name') || null;
const presetName = $target.data('name') || null;
this.selectPreset(presetName);
},
@@ -418,7 +430,7 @@ class SearchView extends View {
},
/** @this SearchView */
'click .dropdown-menu a[data-action="removePreset"]': function () {
let id = this.presetName;
const id = this.presetName;
this.confirm(this.translate('confirmation', 'messages'), () => {
this.removePreset(id);
@@ -433,7 +445,7 @@ class SearchView extends View {
},
/** @this SearchView */
'click [data-action="switchViewMode"]': function (e) {
let mode = $(e.currentTarget).data('name');
const mode = $(e.currentTarget).data('name');
if (mode === this.viewMode) {
return;
@@ -462,7 +474,7 @@ class SearchView extends View {
removeFilter(name) {
this.$el.find('ul.filter-list li[data-name="' + name + '"]').removeClass('hidden');
let container = this.getView('filter-' + name).$el.closest('div.filter');
const container = this.getView('filter-' + name).$el.closest('div.filter');
this.clearView('filter-' + name);
@@ -529,15 +541,15 @@ class SearchView extends View {
}
selectPreset(presetName, forceClearAdvancedFilters) {
let wasPreset = !(this.primary === this.presetName);
const wasPreset = !(this.primary === this.presetName);
this.presetName = presetName;
let advanced = this.getPresetData();
const advanced = this.getPresetData();
this.primary = this.getPrimaryFilterName();
let isPreset = !(this.primary === this.presetName);
const isPreset = !(this.primary === this.presetName);
if (forceClearAdvancedFilters || wasPreset || isPreset || Object.keys(advanced).length) {
this.removeFilters();
@@ -550,8 +562,10 @@ class SearchView extends View {
this.createFilters(() => {
this.reRender()
.then(() => {
// noinspection JSUnresolvedReference
this.$el.find('.filters-button')
.get(0).focus({preventScroll: true});
.get(0)
.focus({preventScroll: true});
})
});
@@ -561,7 +575,7 @@ class SearchView extends View {
removeFilters() {
this.$advancedFiltersPanel.empty();
for (let name in this.advanced) {
for (const name in this.advanced) {
this.clearView('filter-' + name);
}
}
@@ -574,25 +588,23 @@ class SearchView extends View {
this.textFilter = '';
this.selectPreset(this.presetName, true);
this.hideApplyFiltersButton();
this.trigger('update-ui');
}
savePreset(name) {
let id = 'f' + (Math.floor(Math.random() * 1000001)).toString();
const id = 'f' + (Math.floor(Math.random() * 1000001)).toString();
this.fetch();
this.updateSearch();
let presetFilters = this.getPreferences().get('presetFilters') || {};
const presetFilters = this.getPreferences().get('presetFilters') || {};
if (!(this.scope in presetFilters)) {
presetFilters[this.scope] = [];
}
let data = {
const data = {
id: id,
name: id,
label: name,
@@ -615,7 +627,7 @@ class SearchView extends View {
}
removePreset(id) {
let presetFilters = this.getPreferences().get('presetFilters') || {};
const presetFilters = this.getPreferences().get('presetFilters') || {};
if (!(this.scope in presetFilters)) {
presetFilters[this.scope] = [];
@@ -654,7 +666,7 @@ class SearchView extends View {
}
updateAddFilterButton() {
let $ul = this.$el.find('ul.filter-list');
const $ul = this.$el.find('ul.filter-list');
if (
$ul.children()
@@ -704,7 +716,9 @@ class SearchView extends View {
let preventCloseOnBlur = false;
let options = {
// noinspection JSUnusedGlobalSymbols
const options = {
minChars: 0,
noCache: true,
triggerSelectOnValidInput: false,
@@ -725,7 +739,7 @@ class SearchView extends View {
e.stopPropagation();
e.preventDefault();
let text = e.currentTarget.getAttribute('data-value');
const text = e.currentTarget.getAttribute('data-value');
this.storedTextSearchHelper.remove(text);
@@ -748,7 +762,7 @@ class SearchView extends View {
.get(0).innerHTML;
},
lookup: (text, done) => {
let suggestions = this.storedTextSearchHelper.match(text, this.autocompleteLimit)
const suggestions = this.storedTextSearchHelper.match(text, this.autocompleteLimit)
.map(item => {
return {value: item};
});
@@ -786,7 +800,7 @@ class SearchView extends View {
setTimeout(() => {
this.$fieldQuickSearch.focus();
let width = this.$fieldQuickSearch.outerWidth();
const width = this.$fieldQuickSearch.outerWidth();
this.$fieldQuickSearch.css('minWidth', width);
}, 1);
@@ -819,8 +833,8 @@ class SearchView extends View {
return true;
}
let presetName = this.presetName || null;
let primary = this.primary;
const presetName = this.presetName || null;
const primary = this.primary;
if (!presetName || presetName === primary) {
if (Object.keys(this.advanced).length) {
@@ -850,7 +864,7 @@ class SearchView extends View {
managePresetFilters() {
let presetName = this.presetName || null;
let primary = this.primary;
const primary = this.primary;
this.$el.find('ul.filter-menu a.preset span').remove();
@@ -898,8 +912,8 @@ class SearchView extends View {
}
if (primary) {
let label = this.translate(primary, 'presetFilters', this.entityType);
let style = this.getPrimaryFilterStyle();
const label = this.translate(primary, 'presetFilters', this.entityType);
const style = this.getPrimaryFilterStyle();
filterLabel = label;
filterStyle = style;
@@ -927,7 +941,7 @@ class SearchView extends View {
manageBoolFilters() {
(this.boolFilterList || []).forEach((item) => {
if (this.bool[item]) {
let label = this.translate(item, 'boolFilters', this.entityType);
const label = this.translate(item, 'boolFilters', this.entityType);
this.currentFilterLabelList.push(label);
}
@@ -949,9 +963,9 @@ class SearchView extends View {
}
getFilterDataList() {
let list = [];
const list = [];
for (let field in this.advanced) {
for (const field in this.advanced) {
list.push({
key: 'filter-' + field,
name: field,
@@ -975,7 +989,7 @@ class SearchView extends View {
}
getPresetFilterList() {
let arr = [];
const arr = [];
this.presetFilterList.forEach((item) => {
if (typeof item == 'string') {
@@ -1030,7 +1044,7 @@ class SearchView extends View {
}
loadSearchData() {
let searchData = this.searchManager.get();
const searchData = this.searchManager.get();
this.textFilter = searchData.textFilter;
@@ -1108,7 +1122,7 @@ class SearchView extends View {
let toShowApply = this.isSearchedWithAdvancedFilter;
if (!toShowApply) {
let data = view.getView('field').fetchSearch();
const data = view.getView('field').fetchSearch();
if (data) {
toShowApply = true;
@@ -1140,8 +1154,9 @@ class SearchView extends View {
.prop('checked');
});
for (let field in this.advanced) {
let view = this.getView('filter-' + field).getView('field');
for (const field in this.advanced) {
const view = /** @type {module:views/fields/base} */
this.getView('filter-' + field).getView('field');
this.advanced[field] = view.fetchSearch();
@@ -1160,12 +1175,12 @@ class SearchView extends View {
}
getFilterFieldDataList() {
let defs = [];
const defs = [];
for (let i in this.fieldFilterList) {
let field = this.fieldFilterList[i];
for (const i in this.fieldFilterList) {
const field = this.fieldFilterList[i];
let o = {
const o = {
name: field,
checked: (field in this.advanced),
label: this.fieldFilterTranslations[field] || field,
@@ -1205,7 +1220,7 @@ class SearchView extends View {
}
selectPreviousPreset() {
let list = Espo.Utils.clone(this.getPresetFilterList());
const list = Espo.Utils.clone(this.getPresetFilterList());
list.unshift({name: null});
@@ -1213,19 +1228,19 @@ class SearchView extends View {
return;
}
let index = list.findIndex(item => item.name === this.presetName) - 1;
const index = list.findIndex(item => item.name === this.presetName) - 1;
if (index < 0) {
return;
}
let preset = list[index];
const preset = list[index];
this.selectPreset(preset.name);
}
selectNextPreset() {
let list = Espo.Utils.clone(this.getPresetFilterList());
const list = Espo.Utils.clone(this.getPresetFilterList());
list.unshift({name: null});
@@ -1233,13 +1248,13 @@ class SearchView extends View {
return;
}
let index = list.findIndex(item => item.name === this.presetName) + 1;
const index = list.findIndex(item => item.name === this.presetName) + 1;
if (index >= list.length) {
return;
}
let preset = list[index];
const preset = list[index];
this.selectPreset(preset.name);
}
@@ -1253,7 +1268,7 @@ class SearchView extends View {
text = text.toLowerCase();
/** @type {JQuery} */
let $li = this.$filterList.find('li.filter-item');
const $li = this.$filterList.find('li.filter-item');
if (text === '') {
$li.removeClass('search-hidden');
@@ -1267,7 +1282,7 @@ class SearchView extends View {
let label = this.fieldFilterTranslations[field] || field;
label = label.toLowerCase();
let wordList = label.split(' ');
const wordList = label.split(' ');
let matched = label.indexOf(text) === 0;
@@ -1289,13 +1304,13 @@ class SearchView extends View {
}
addFirstFieldFilter() {
let $first = this.$filterList.find('li.filter-item:not(.hidden):not(.search-hidden)').first();
const $first = this.$filterList.find('li.filter-item:not(.hidden):not(.search-hidden)').first();
if (!$first.length) {
return;
}
let name = $first.attr('data-name');
const name = $first.attr('data-name');
$first.addClass('hidden');
@@ -1305,6 +1320,7 @@ class SearchView extends View {
}
closeAddFieldDropdown() {
// noinspection JSUnresolvedReference
this.$addFilterButton.parent()
.find('[data-toggle="dropdown"]')
.dropdown('toggle');