diff --git a/application/Espo/Modules/Crm/Resources/metadata/dashlets/Calendar.json b/application/Espo/Modules/Crm/Resources/metadata/dashlets/Calendar.json
index fbcc28690e..921dcfd6a5 100644
--- a/application/Espo/Modules/Crm/Resources/metadata/dashlets/Calendar.json
+++ b/application/Espo/Modules/Crm/Resources/metadata/dashlets/Calendar.json
@@ -2,6 +2,7 @@
"view":"crm:views/dashlets/calendar",
"aclScope": "Calendar",
"options": {
+ "view": "crm:views/dashlets/options/calendar",
"fields": {
"title": {
"type": "varchar",
@@ -19,7 +20,12 @@
},
"mode": {
"type": "enum",
- "options": ["basicWeek", "agendaWeek", "month"]
+ "options": ["basicWeek", "agendaWeek", "timeline", "month", "basicDay", "agendaDay"]
+ },
+ "users": {
+ "type": "linkMultiple",
+ "entity": "User",
+ "view": "views/fields/assigned-users"
}
},
"defaults": {
@@ -37,6 +43,10 @@
[
{"name": "mode"},
{"name": "enabledScopeList"}
+ ],
+ [
+ {"name": "users"},
+ false
]
]
}
diff --git a/application/Espo/Resources/i18n/en_US/DashletOptions.json b/application/Espo/Resources/i18n/en_US/DashletOptions.json
index 6063e5fec8..f11e7f176a 100644
--- a/application/Espo/Resources/i18n/en_US/DashletOptions.json
+++ b/application/Espo/Resources/i18n/en_US/DashletOptions.json
@@ -7,13 +7,17 @@
"displayRecords": "Display Records",
"isDoubleHeight": "Height 2x",
"mode": "Mode",
- "enabledScopeList": "What to display"
+ "enabledScopeList": "What to display",
+ "users": "Users"
},
"options": {
"mode": {
"agendaWeek": "Week (agenda)",
"basicWeek": "Week",
- "month": "Month"
+ "month": "Month",
+ "basicDay": "Day",
+ "agendaDay": "Day (agenda)",
+ "timeline": "Timeline"
}
}
}
diff --git a/client/modules/crm/src/views/calendar/timeline.js b/client/modules/crm/src/views/calendar/timeline.js
index d432312555..e9b1edd1d9 100644
--- a/client/modules/crm/src/views/calendar/timeline.js
+++ b/client/modules/crm/src/views/calendar/timeline.js
@@ -179,10 +179,14 @@ Espo.define('crm:views/calendar/timeline', ['view', 'lib!vis'], function (Dep, V
this.enabledScopeList = [];
}
- if (this.options.userId) {
- this.calendarType = 'single';
+ if (this.options.calendarType) {
+ this.calendarType = 'shared';
} else {
- this.calendarType = this.getStorage().get('calendar', 'timelineType') || 'single';
+ if (this.options.userId) {
+ this.calendarType = 'single';
+ } else {
+ this.calendarType = this.getStorage().get('calendar', 'timelineType') || 'single';
+ }
}
if (this.getAcl().get('userPermission' === 'no')) {
@@ -447,6 +451,7 @@ Espo.define('crm:views/calendar/timeline', ['view', 'lib!vis'], function (Dep, V
timeline.on('changed', function (e) {
if (this.calendarType === 'single') return;
+ if (this.options.userList) return;
var $title = this.$el.find('.vis-labelset .group-title');
if ($title.size() === 0) return;
@@ -457,15 +462,6 @@ Espo.define('crm:views/calendar/timeline', ['view', 'lib!vis'], function (Dep, V
this.orderUserList(list);
}.bind(this));
- timeline.on('groupDragged', function (e) {
- //console.log(e);
- /*var list = [];
- this.$el.find('.vis-labelset .group-title').each(function (i, el) {
- list.push($(el).attr('data-id'));
- });
- this.orderUserList(list);*/
- }.bind(this));
-
timeline.on('rangechanged', function (e) {
this.start = moment(e.start);
this.end = moment(e.end);
@@ -545,7 +541,7 @@ Espo.define('crm:views/calendar/timeline', ['view', 'lib!vis'], function (Dep, V
},
getGroupEditableOptions: function () {
- if (this.calendarType === 'single') {
+ if (this.calendarType === 'single' || this.options.userList) {
return {
add: false,
remove: false,
@@ -591,29 +587,39 @@ Espo.define('crm:views/calendar/timeline', ['view', 'lib!vis'], function (Dep, V
},
initUserList: function () {
- this.userList = [];
-
- if (this.calendarType === 'single') {
- if (this.options.userId) {
- this.userList.push({
- id: this.options.userId,
- name: this.options.userName || this.options.userId
- });
- } else {
+ if (this.options.userList) {
+ this.userList = Espo.Utils.clone(this.options.userList);
+ if (!this.userList.length) {
this.userList.push({
id: this.getUser().id,
name: this.getUser().get('name')
});
}
- }
+ } else {
+ this.userList = [];
- if (this.calendarType === 'shared') {
- this.getSharedCalenderUserList().forEach(function (item) {
- this.userList.push({
- id: item.id,
- name: item.name
- });
- }, this);
+ if (this.calendarType === 'single') {
+ if (this.options.userId) {
+ this.userList.push({
+ id: this.options.userId,
+ name: this.options.userName || this.options.userId
+ });
+ } else {
+ this.userList.push({
+ id: this.getUser().id,
+ name: this.getUser().get('name')
+ });
+ }
+ }
+
+ if (this.calendarType === 'shared') {
+ this.getSharedCalenderUserList().forEach(function (item) {
+ this.userList.push({
+ id: item.id,
+ name: item.name
+ });
+ }, this);
+ }
}
},
@@ -720,16 +726,10 @@ Espo.define('crm:views/calendar/timeline', ['view', 'lib!vis'], function (Dep, V
}
var html = '' + name + '';
- html += ' ';
+ if (!this.options.userList) {
+ html += ' ';
+ }
- /*html += '';
- html += '';
- html +=
- '';
- html += '';*/
return html;
},
diff --git a/client/modules/crm/src/views/dashlets/calendar.js b/client/modules/crm/src/views/dashlets/calendar.js
index 6e07c477c1..903e623cbf 100644
--- a/client/modules/crm/src/views/dashlets/calendar.js
+++ b/client/modules/crm/src/views/dashlets/calendar.js
@@ -42,20 +42,42 @@ Espo.define('crm:views/dashlets/calendar', 'views/dashlets/abstract/base', funct
},
afterRender: function () {
- this.createView('calendar', 'crm:views/calendar/calendar', {
- mode: this.getOption('mode'),
- el: this.options.el + ' > .calendar-container',
- header: false,
- enabledScopeList: this.getOption('enabledScopeList'),
- containerSelector: this.options.el
- }, function (view) {
- view.render();
- this.on('resize', function () {
- setTimeout(function() {
- view.adjustSize();
- }, 50);
- });
- }, this);
+ var mode = this.getOption('mode');
+ if (mode === 'timeline') {
+ var userList = [];
+ var userIdList = this.getOption('usersIds') || [];
+ var userNames = this.getOption('usersNames') || {};
+ userIdList.forEach(function (id) {
+ userList.push({
+ id: id,
+ name: userNames[id] || id
+ });
+ }, this);
+
+ this.createView('calendar', 'crm:views/calendar/timeline', {
+ el: this.options.el + ' > .calendar-container',
+ header: false,
+ calendarType: 'shared',
+ userList: userList
+ }, function (view) {
+ view.render();
+ }, this);
+ } else {
+ this.createView('calendar', 'crm:views/calendar/calendar', {
+ mode: mode,
+ el: this.options.el + ' > .calendar-container',
+ header: false,
+ enabledScopeList: this.getOption('enabledScopeList'),
+ containerSelector: this.options.el
+ }, function (view) {
+ view.render();
+ this.on('resize', function () {
+ setTimeout(function() {
+ view.adjustSize();
+ }, 50);
+ });
+ }, this);
+ }
}
});
});
diff --git a/client/modules/crm/src/views/dashlets/options/calendar.js b/client/modules/crm/src/views/dashlets/options/calendar.js
new file mode 100644
index 0000000000..3a9f87828c
--- /dev/null
+++ b/client/modules/crm/src/views/dashlets/options/calendar.js
@@ -0,0 +1,51 @@
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM - Open Source CRM application.
+ * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
+ * Website: http://www.espocrm.com
+ *
+ * EspoCRM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EspoCRM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
+ ************************************************************************/
+
+Espo.define('crm:views/dashlets/options/calendar', 'views/dashlets/options/base', function (Dep) {
+
+ return Dep.extend({
+
+ setup: function () {
+ Dep.prototype.setup.call(this);
+
+ this.manageUsersField();
+ this.listenTo(this.model, 'change:mode', this.manageUsersField, this);
+ },
+
+ manageUsersField: function () {
+ if (this.model.get('mode') === 'timeline') {
+ this.showField('users');
+ } else {
+ this.hideField('users');
+ }
+ }
+
+ });
+});
+
+
diff --git a/client/src/views/dashlets/options/base.js b/client/src/views/dashlets/options/base.js
index 9d19bdee3c..4e8d55ba50 100644
--- a/client/src/views/dashlets/options/base.js
+++ b/client/src/views/dashlets/options/base.js
@@ -146,6 +146,94 @@ Espo.define('views/dashlets/options/base', ['views/modal', 'views/record/detail'
this.trigger('save', attributes);
},
+
+ getFieldViews: function (withHidden) {
+ if (this.hasView('record')) {
+ return this.getView('record').getFieldViews(withHidden) || {};
+ }
+ return {};
+ },
+
+ getFieldView: function () {
+ return (this.getFieldViews(true) || {})[name] || null;
+ },
+
+ hideField: function (name, locked) {
+ this.recordHelper.setFieldStateParam(name, 'hidden', true);
+ if (locked) {
+ this.recordHelper.setFieldStateParam(name, 'hiddenLocked', true);
+ }
+
+ var processHtml = function () {
+ var 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 + '"]');
+
+ $field.addClass('hidden');
+ $label.addClass('hidden');
+ $cell.addClass('hidden-cell');
+ } else {
+ this.$el.find('.cell[data-name="' + name + '"]').addClass('hidden-cell');
+ this.$el.find('.field[data-name="' + name + '"]').addClass('hidden');
+ this.$el.find('label.control-label[data-name="' + name + '"]').addClass('hidden');
+ }
+ }.bind(this);
+ if (this.isRendered()) {
+ processHtml();
+ } else {
+ this.once('after:render', function () {
+ processHtml();
+ }, this);
+ }
+
+ var view = this.getFieldView(name);
+ if (view) {
+ view.setDisabled(locked);
+ }
+ },
+
+ showField: function (name) {
+ if (this.recordHelper.getFieldStateParam(name, 'hiddenLocked')) {
+ return;
+ }
+ this.recordHelper.setFieldStateParam(name, 'hidden', false);
+
+ var processHtml = function () {
+ var 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 + '"]');
+
+ $field.removeClass('hidden');
+ $label.removeClass('hidden');
+ $cell.removeClass('hidden-cell');
+ } else {
+ this.$el.find('.cell[data-name="' + name + '"]').removeClass('hidden-cell');
+ this.$el.find('.field[data-name="' + name + '"]').removeClass('hidden');
+ this.$el.find('label.control-label[data-name="' + name + '"]').removeClass('hidden');
+ }
+ }.bind(this);
+
+ if (this.isRendered()) {
+ processHtml();
+ } else {
+ this.once('after:render', function () {
+ processHtml();
+ }, this);
+ }
+
+ var view = this.getFieldView(name);
+ if (view) {
+ if (!view.disabledLocked) {
+ view.setNotDisabled();
+ }
+ }
+ }
});
});
diff --git a/client/src/views/fields/link-multiple.js b/client/src/views/fields/link-multiple.js
index 484c050efb..5a8fc7b5e9 100644
--- a/client/src/views/fields/link-multiple.js
+++ b/client/src/views/fields/link-multiple.js
@@ -83,7 +83,7 @@ Espo.define('views/fields/link-multiple', 'views/fields/base', function (Dep) {
this.nameHashName = this.name + 'Names';
this.idsName = this.name + 'Ids';
- this.foreignScope = this.options.foreignScope || this.foreignScope || this.model.defs.links[this.name].entity;
+ this.foreignScope = this.options.foreignScope || this.foreignScope || this.model.getFieldParam(this.name, 'entity') || this.model.getLinkParam(this.name, 'entity');
if ('createDisabled' in this.options) {
this.createDisabled = this.options.createDisabled;
diff --git a/client/src/views/fields/link.js b/client/src/views/fields/link.js
index de9b3962ae..cfe5507641 100644
--- a/client/src/views/fields/link.js
+++ b/client/src/views/fields/link.js
@@ -81,7 +81,7 @@ Espo.define('views/fields/link', 'views/fields/base', function (Dep) {
this.idName = this.name + 'Id';
this.foreignScope = this.options.foreignScope || this.foreignScope;
- this.foreignScope = this.foreignScope || this.model.getFieldParam(this.name, 'entity') || this.model.defs.links[this.name].entity;
+ this.foreignScope = this.foreignScope || this.model.getFieldParam(this.name, 'entity') || this.model.getLinkParam(this.name, 'entity');
if ('createDisabled' in this.options) {
this.createDisabled = this.options.createDisabled;