ref
This commit is contained in:
@@ -26,95 +26,96 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/note/detail', ['views/main'], (Dep) => {
|
||||
import MainView from 'views/main';
|
||||
|
||||
class NoteDetailView extends MainView {
|
||||
|
||||
templateContent = `
|
||||
<div class="header page-header">{{{header}}}</div>
|
||||
<div class="record list-container list-container-panel block-center">{{{record}}}</div>
|
||||
`
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @name Class
|
||||
* @extends module:views/main
|
||||
* @memberOf module:views/note/detail
|
||||
* @private
|
||||
*/
|
||||
return Dep.extend(/** @lends module:views/note/detail.Class# */{
|
||||
isDeleted = false
|
||||
|
||||
templateContent: `
|
||||
<div class="header page-header">{{{header}}}</div>
|
||||
<div class="record list-container list-container-panel block-center">{{{record}}}</div>
|
||||
`,
|
||||
setup() {
|
||||
this.scope = this.model.entityType;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
isDeleted: false,
|
||||
this.setupHeader();
|
||||
this.setupRecord();
|
||||
|
||||
setup: function () {
|
||||
this.scope = this.model.entityType;
|
||||
this.listenToOnce(this.model, 'remove', () => {
|
||||
this.clearView('record');
|
||||
this.isDeleted = true;
|
||||
this.getHeaderView().reRender();
|
||||
});
|
||||
}
|
||||
|
||||
this.setupHeader();
|
||||
this.setupRecord();
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
setupHeader() {
|
||||
this.createView('header', 'views/header', {
|
||||
selector: '> .header',
|
||||
scope: this.scope,
|
||||
fontSizeFlexible: true,
|
||||
});
|
||||
}
|
||||
|
||||
this.listenToOnce(this.model, 'remove', () => {
|
||||
this.clearView('record');
|
||||
this.isDeleted = true;
|
||||
this.getHeaderView().reRender();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
setupRecord() {
|
||||
this.wait(
|
||||
this.getCollectionFactory().create(this.scope)
|
||||
.then(collection => {
|
||||
this.collection = collection;
|
||||
this.collection.add(this.model);
|
||||
|
||||
setupHeader: function () {
|
||||
this.createView('header', 'views/header', {
|
||||
selector: '> .header',
|
||||
scope: this.scope,
|
||||
fontSizeFlexible: true,
|
||||
});
|
||||
},
|
||||
this.createView('record', 'views/stream/record/list', {
|
||||
selector: '> .record',
|
||||
collection: this.collection,
|
||||
isUserStream: true,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
setupRecord: function () {
|
||||
this.wait(
|
||||
this.getCollectionFactory().create(this.scope)
|
||||
.then(collection => {
|
||||
this.collection = collection;
|
||||
this.collection.add(this.model);
|
||||
getHeader() {
|
||||
const parentType = this.model.get('parentType');
|
||||
const parentId = this.model.get('parentId');
|
||||
const parentName = this.model.get('parentName');
|
||||
const type = this.model.get('type');
|
||||
|
||||
this.createView('record', 'views/stream/record/list', {
|
||||
selector: '> .record',
|
||||
collection: this.collection,
|
||||
isUserStream: true,
|
||||
});
|
||||
})
|
||||
);
|
||||
},
|
||||
const $type = $('<span>')
|
||||
.text(this.getLanguage().translateOption(type, 'type', 'Note'));
|
||||
|
||||
getHeader: function () {
|
||||
let parentType = this.model.get('parentType');
|
||||
let parentId = this.model.get('parentId');
|
||||
let parentName = this.model.get('parentName');
|
||||
let type = this.model.get('type');
|
||||
|
||||
let $type = $('<span>')
|
||||
.text(this.getLanguage().translateOption(type, 'type', 'Note'));
|
||||
|
||||
if (this.model.get('deleted') || this.isDeleted) {
|
||||
$type.css('text-decoration', 'line-through');
|
||||
}
|
||||
|
||||
if (parentType && parentId) {
|
||||
return this.buildHeaderHtml([
|
||||
$('<a>')
|
||||
.attr('href', '#' + parentType)
|
||||
.text(this.translate(parentType, 'scopeNamesPlural')),
|
||||
$('<a>')
|
||||
.attr('href', '#' + parentType + '/view/' + parentId)
|
||||
.text(parentName || parentId),
|
||||
$('<span>')
|
||||
.text(this.translate('Stream', 'scopeNames')),
|
||||
$type,
|
||||
]);
|
||||
}
|
||||
if (this.model.get('deleted') || this.isDeleted) {
|
||||
$type.css('text-decoration', 'line-through');
|
||||
}
|
||||
|
||||
if (parentType && parentId) {
|
||||
return this.buildHeaderHtml([
|
||||
$('<a>')
|
||||
.attr('href', `#${parentType}`)
|
||||
.text(this.translate(parentType, 'scopeNamesPlural')),
|
||||
$('<a>')
|
||||
.attr('href', `#${parentType}/view/${parentId}`)
|
||||
.text(parentName || parentId),
|
||||
$('<span>')
|
||||
.text(this.translate('Stream', 'scopeNames')),
|
||||
$type,
|
||||
]);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return this.buildHeaderHtml([
|
||||
$('<span>')
|
||||
.text(this.translate('Stream', 'scopeNames')),
|
||||
$type,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteDetailView;
|
||||
|
||||
@@ -26,51 +26,48 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/note/fields/users', ['views/fields/link-multiple'], function (Dep) {
|
||||
import LinkMultipleFieldView from 'views/fields/link-multiple';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends LinkMultipleFieldView {
|
||||
|
||||
init: function () {
|
||||
this.messagePermission = this.getAcl().getPermissionLevel('message');
|
||||
this.portalPermission = this.getAcl().getPermissionLevel('portal');
|
||||
init() {
|
||||
this.messagePermission = this.getAcl().getPermissionLevel('message');
|
||||
this.portalPermission = this.getAcl().getPermissionLevel('portal');
|
||||
|
||||
if (this.messagePermission === 'no' && this.portalPermission === 'no') {
|
||||
this.readOnly = true;
|
||||
}
|
||||
if (this.messagePermission === 'no' && this.portalPermission === 'no') {
|
||||
this.readOnly = true;
|
||||
}
|
||||
|
||||
Dep.prototype.init.call(this);
|
||||
},
|
||||
super.init();
|
||||
}
|
||||
|
||||
getSelectBoolFilterList: function () {
|
||||
if (this.messagePermission === 'team') {
|
||||
return ['onlyMyTeam'];
|
||||
}
|
||||
|
||||
if (this.portalPermission === 'yes') {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
getSelectPrimaryFilterName: function () {
|
||||
if (this.portalPermission === 'yes' && this.messagePermission === 'no') {
|
||||
return 'activePortal';
|
||||
}
|
||||
|
||||
return 'active';
|
||||
},
|
||||
|
||||
getSelectFilterList: function () {
|
||||
|
||||
if (this.portalPermission === 'yes') {
|
||||
if (this.messagePermission === 'no') {
|
||||
return ['activePortal'];
|
||||
}
|
||||
|
||||
return ['active', 'activePortal'];
|
||||
}
|
||||
getSelectBoolFilterList() {
|
||||
if (this.messagePermission === 'team') {
|
||||
return ['onlyMyTeam'];
|
||||
}
|
||||
|
||||
if (this.portalPermission === 'yes') {
|
||||
return null;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
getSelectPrimaryFilterName() {
|
||||
if (this.portalPermission === 'yes' && this.messagePermission === 'no') {
|
||||
return 'activePortal';
|
||||
}
|
||||
|
||||
return 'active';
|
||||
}
|
||||
|
||||
getSelectFilterList() {
|
||||
if (this.portalPermission === 'yes') {
|
||||
if (this.messagePermission === 'no') {
|
||||
return ['activePortal'];
|
||||
}
|
||||
|
||||
return ['active', 'activePortal'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,32 +26,36 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/note/modals/edit', ['views/modals/edit'], function (Dep) {
|
||||
import EditModalView from 'views/modals/edit';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends EditModalView {
|
||||
|
||||
fullFormDisabled: true,
|
||||
fullFormDisabled = true
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
this.once('ready', () => {
|
||||
let recordView = this.getView('edit') || this.getView('record');
|
||||
this.once('ready', () => {
|
||||
const recordView = this.getView('edit') || this.getView('record');
|
||||
|
||||
if (recordView) {
|
||||
var fieldView = recordView.getFieldView('post');
|
||||
if (!recordView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fieldView) {
|
||||
this.listenTo(fieldView, 'add-files', files => {
|
||||
var attachmentsView = recordView.getFieldView('attachments');
|
||||
const fieldView = recordView.getFieldView('post');
|
||||
|
||||
if (attachmentsView) {
|
||||
recordView.getFieldView('attachments').uploadFiles(files);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!fieldView) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.listenTo(fieldView, 'add-files', files => {
|
||||
/** @type {import('views/fields/attachment-multiple').default} */
|
||||
const attachmentsView = recordView.getFieldView('attachments');
|
||||
|
||||
if (attachmentsView) {
|
||||
attachmentsView.uploadFiles(files);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,34 +26,28 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/note/record/edit', ['views/record/edit'], function (Dep) {
|
||||
import EditRecordView from 'views/record/edit';
|
||||
|
||||
return Dep.extend({
|
||||
export default class extends EditRecordView {
|
||||
|
||||
sideView: null,
|
||||
sideView = null
|
||||
isWide = true
|
||||
|
||||
isWide: true,
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
this.controlRequiredFields();
|
||||
|
||||
this.listenTo(this.model, 'change:attachmentsIds', () => {
|
||||
this.controlRequiredFields();
|
||||
});
|
||||
}
|
||||
|
||||
this.listenTo(this.model, 'change:attachmentsIds', () => {
|
||||
this.controlRequiredFields();
|
||||
});
|
||||
},
|
||||
|
||||
controlRequiredFields: function () {
|
||||
if (!(this.model.get('attachmentsIds') || []).length) {
|
||||
this.setFieldRequired('post');
|
||||
} else {
|
||||
this.setFieldNotRequired('post');
|
||||
}
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
},
|
||||
});
|
||||
});
|
||||
controlRequiredFields() {
|
||||
if (!(this.model.get('attachmentsIds') || []).length) {
|
||||
this.setFieldRequired('post');
|
||||
} else {
|
||||
this.setFieldNotRequired('post');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user