diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Task.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Task.json index 7958bbd4da..420e4ccedd 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Task.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Task.json @@ -17,25 +17,6 @@ "type": "equals", "attribute": "status", "value": "Completed" - }, - { - "type": "or", - "value": [ - { - "type": "notEquals", - "attribute": "status", - "value": "Not Started" - }, - { - "type": "notEquals", - "attribute": "status", - "value": "Canceled" - }, - { - "type": "isNotEmpty", - "attribute": "status" - } - ] } ] } diff --git a/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json b/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json index 69c1ef1afa..1e3aff7dae 100644 --- a/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json +++ b/application/Espo/Resources/metadata/clientDefs/DynamicLogic.json @@ -43,6 +43,26 @@ "isNotEmpty": { "view": "views/admin/dynamic-logic/conditions-string/item-operator-only-base", "operatorString": "≠ ∅" + }, + "in": { + "view": "views/admin/dynamic-logic/conditions-string/item-multiple-values-base", + "operatorString": "∈" + }, + "notIn": { + "view": "views/admin/dynamic-logic/conditions-string/item-multiple-values-base", + "operatorString": "∉" + }, + "isToday": { + "view": "views/admin/dynamic-logic/conditions-string/item-is-today", + "operatorString": "=" + }, + "inFuture": { + "view": "views/admin/dynamic-logic/conditions-string/item-in-future", + "operatorString": "∈" + }, + "inPast": { + "view": "views/admin/dynamic-logic/conditions-string/item-in-past", + "operatorString": "∈" } } } \ No newline at end of file diff --git a/client/res/templates/admin/dynamic-logic/conditions-string/group-not.tpl b/client/res/templates/admin/dynamic-logic/conditions-string/group-not.tpl new file mode 100644 index 0000000000..4f1dbca114 --- /dev/null +++ b/client/res/templates/admin/dynamic-logic/conditions-string/group-not.tpl @@ -0,0 +1,4 @@ + +
{{translate 'not' category='logicalOperators' scope='Admin'}} ( +
{{{var viewKey this}}}
+ )
diff --git a/client/res/templates/admin/dynamic-logic/conditions-string/item-multiple-values-base.tpl b/client/res/templates/admin/dynamic-logic/conditions-string/item-multiple-values-base.tpl new file mode 100644 index 0000000000..8c74fe0096 --- /dev/null +++ b/client/res/templates/admin/dynamic-logic/conditions-string/item-multiple-values-base.tpl @@ -0,0 +1,2 @@ +{{translate field category='fields' scope=scope}} {{{operatorString}}} +({{#each valueViewDataList}}{{{var key ../this}}}{{#unless isEnd}}, {{/unless}}{{/each}}) \ No newline at end of file diff --git a/client/res/templates/admin/dynamic-logic/conditions-string/item-operator-only-date.tpl b/client/res/templates/admin/dynamic-logic/conditions-string/item-operator-only-date.tpl new file mode 100644 index 0000000000..57f749e29a --- /dev/null +++ b/client/res/templates/admin/dynamic-logic/conditions-string/item-operator-only-date.tpl @@ -0,0 +1 @@ +{{translate field category='fields' scope=scope}} {{{operatorString}}} {{translateOption dateValue field='dateSearchRanges'}} \ No newline at end of file diff --git a/client/res/templates/fields/base/detail.tpl b/client/res/templates/fields/base/detail.tpl index 672f203a93..b26a2350dc 100644 --- a/client/res/templates/fields/base/detail.tpl +++ b/client/res/templates/fields/base/detail.tpl @@ -1 +1 @@ -{{value}} +{{value}} \ No newline at end of file diff --git a/client/res/templates/fields/enum-styled/detail.tpl b/client/res/templates/fields/enum-styled/detail.tpl index 97bd811fc4..5e9de9aedd 100644 --- a/client/res/templates/fields/enum-styled/detail.tpl +++ b/client/res/templates/fields/enum-styled/detail.tpl @@ -1 +1 @@ -{{translateOption value scope=scope field=name}} +{{translateOption value scope=scope field=name}} \ No newline at end of file diff --git a/client/res/templates/fields/enum/detail.tpl b/client/res/templates/fields/enum/detail.tpl index 8f4e0c69f8..638afb78b2 100644 --- a/client/res/templates/fields/enum/detail.tpl +++ b/client/res/templates/fields/enum/detail.tpl @@ -1 +1 @@ -{{translateOption value scope=scope field=name translatedOptions=translatedOptions}} +{{translateOption value scope=scope field=name translatedOptions=translatedOptions}} \ No newline at end of file diff --git a/client/res/templates/fields/int/detail.tpl b/client/res/templates/fields/int/detail.tpl index eefa5dd012..f6b34e1b68 100644 --- a/client/res/templates/fields/int/detail.tpl +++ b/client/res/templates/fields/int/detail.tpl @@ -1,5 +1,3 @@ -{{#if isNotEmpty}} - {{value}} -{{else}} +{{#if isNotEmpty}}{{value}}{{else}} {{translate 'None'}} -{{/if}} +{{/if}} \ No newline at end of file diff --git a/client/src/dynamic-logic.js b/client/src/dynamic-logic.js index 74aab67853..76fc56ab6c 100644 --- a/client/src/dynamic-logic.js +++ b/client/src/dynamic-logic.js @@ -170,6 +170,7 @@ Espo.define('dynamic-logic', [], function () { return !~value.indexOf(setValue); } else if (type === 'isToday') { var dateTime = this.recordView.getDateTime(); + if (!setValue) return; if (setValue) { if (setValue.length > 10) { return dateTime.toMoment(setValue).isSame(dateTime.getNowMoment(), 'day'); @@ -177,10 +178,26 @@ Espo.define('dynamic-logic', [], function () { return dateTime.toMomentDate(setValue).isSame(dateTime.getNowMoment(), 'day'); } } - } else if (type === 'isFuture') { - - } else if (type === 'isPast') { - + } else if (type === 'inFuture') { + var dateTime = this.recordView.getDateTime(); + if (!setValue) return; + if (setValue) { + if (setValue.length > 10) { + return dateTime.toMoment(setValue).isAfter(dateTime.getNowMoment(), 'day'); + } else { + return dateTime.toMomentDate(setValue).isAfter(dateTime.getNowMoment(), 'day'); + } + } + } else if (type === 'inPast') { + var dateTime = this.recordView.getDateTime(); + if (!setValue) return; + if (setValue) { + if (setValue.length > 10) { + return dateTime.toMoment(setValue).isBefore(dateTime.getNowMoment(), 'day'); + } else { + return dateTime.toMomentDate(setValue).isBefore(dateTime.getNowMoment(), 'day'); + } + } } return false; }, diff --git a/client/src/views/admin/dynamic-logic/conditions-string/group-base.js b/client/src/views/admin/dynamic-logic/conditions-string/group-base.js index cbee85883e..a2362b23c1 100644 --- a/client/src/views/admin/dynamic-logic/conditions-string/group-base.js +++ b/client/src/views/admin/dynamic-logic/conditions-string/group-base.js @@ -72,6 +72,8 @@ Espo.define('views/admin/dynamic-logic/conditions-string/group-base', 'view', fu createItemView: function (number, key, item) { this.viewList.push(key); + item = item || {}; + var type = item.type || 'equals'; var viewName = this.getMetadata().get(['clientDefs', 'DynamicLogic', 'itemTypes', type, 'view']); diff --git a/client/src/views/admin/dynamic-logic/conditions-string/group-not.js b/client/src/views/admin/dynamic-logic/conditions-string/group-not.js new file mode 100644 index 0000000000..c1ccbd6f19 --- /dev/null +++ b/client/src/views/admin/dynamic-logic/conditions-string/group-not.js @@ -0,0 +1,63 @@ +/************************************************************************ + * 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('views/admin/dynamic-logic/conditions-string/group-not', 'views/admin/dynamic-logic/conditions-string/group-base', function (Dep) { + + return Dep.extend({ + + template: 'admin/dynamic-logic/conditions-string/group-not', + + data: function () { + return { + viewKey: this.viewKey, + operator: this.operator + }; + }, + + setup: function () { + this.level = this.options.level || 0; + this.number = this.options.number || 0; + this.scope = this.options.scope; + + this.operator = this.options.operator || this.operator; + + this.itemData = this.options.itemData || {}; + this.viewList = []; + + + var i = 0; + var key = 'view-' + this.level.toString() + '-' + this.number.toString() + '-' + i.toString(); + + this.createItemView(i, key, this.itemData.value); + this.viewKey = key; + } + + }); + +}); + diff --git a/client/src/views/admin/dynamic-logic/conditions-string/item-base.js b/client/src/views/admin/dynamic-logic/conditions-string/item-base.js index f110627c04..54364028b3 100644 --- a/client/src/views/admin/dynamic-logic/conditions-string/item-base.js +++ b/client/src/views/admin/dynamic-logic/conditions-string/item-base.js @@ -61,8 +61,7 @@ Espo.define('views/admin/dynamic-logic/conditions-string/item-base', 'view', fun this.getModelFactory().create(this.scope, function (model) { this.model = model; - model.set(this.itemData.attribute, this.itemData.value); - model.set(this.additionalData.values || {}) + this.populateValues(); this.createValueFieldView(); @@ -70,6 +69,11 @@ Espo.define('views/admin/dynamic-logic/conditions-string/item-base', 'view', fun }, this); }, + populateValues: function () { + this.model.set(this.itemData.attribute, this.itemData.value); + this.model.set(this.additionalData.values || {}); + }, + getValueViewKey: function () { return 'view-' + this.level.toString() + '-' + this.number.toString() + '-0'; }, @@ -77,8 +81,8 @@ Espo.define('views/admin/dynamic-logic/conditions-string/item-base', 'view', fun createValueFieldView: function () { var key = this.getValueViewKey(); - var fieldType = this.getMetadata().get(['entityDefs', this.scope, this.field, 'type']) || 'base'; - var viewName = this.getMetadata().get(['entityDefs', this.scope, this.field, 'view']) || this.getFieldManager().getViewName(fieldType); + var fieldType = this.getMetadata().get(['entityDefs', this.scope, 'fields', this.field, 'type']) || 'base'; + var viewName = this.getMetadata().get(['entityDefs', this.scope, 'fields', this.field, 'view']) || this.getFieldManager().getViewName(fieldType); this.createView('value', viewName, { model: this.model, diff --git a/client/src/views/admin/dynamic-logic/conditions-string/item-in-future.js b/client/src/views/admin/dynamic-logic/conditions-string/item-in-future.js new file mode 100644 index 0000000000..57845e0237 --- /dev/null +++ b/client/src/views/admin/dynamic-logic/conditions-string/item-in-future.js @@ -0,0 +1,38 @@ +/************************************************************************ + * 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('views/admin/dynamic-logic/conditions-string/item-in-future', 'views/admin/dynamic-logic/conditions-string/item-operator-only-date', function (Dep) { + + return Dep.extend({ + + dateValue: 'future' + + }); + +}); + diff --git a/client/src/views/admin/dynamic-logic/conditions-string/item-in-past.js b/client/src/views/admin/dynamic-logic/conditions-string/item-in-past.js new file mode 100644 index 0000000000..a2ecc2e9e7 --- /dev/null +++ b/client/src/views/admin/dynamic-logic/conditions-string/item-in-past.js @@ -0,0 +1,38 @@ +/************************************************************************ + * 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('views/admin/dynamic-logic/conditions-string/item-in-past', 'views/admin/dynamic-logic/conditions-string/item-operator-only-date', function (Dep) { + + return Dep.extend({ + + dateValue: 'past' + + }); + +}); + diff --git a/client/src/views/admin/dynamic-logic/conditions-string/item-is-today.js b/client/src/views/admin/dynamic-logic/conditions-string/item-is-today.js new file mode 100644 index 0000000000..7e1efde545 --- /dev/null +++ b/client/src/views/admin/dynamic-logic/conditions-string/item-is-today.js @@ -0,0 +1,38 @@ +/************************************************************************ + * 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('views/admin/dynamic-logic/conditions-string/item-is-today', 'views/admin/dynamic-logic/conditions-string/item-operator-only-date', function (Dep) { + + return Dep.extend({ + + dateValue: 'today' + + }); + +}); + diff --git a/client/src/views/admin/dynamic-logic/conditions-string/item-multiple-values-base.js b/client/src/views/admin/dynamic-logic/conditions-string/item-multiple-values-base.js new file mode 100644 index 0000000000..c927affc70 --- /dev/null +++ b/client/src/views/admin/dynamic-logic/conditions-string/item-multiple-values-base.js @@ -0,0 +1,81 @@ +/************************************************************************ + * 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('views/admin/dynamic-logic/conditions-string/item-multiple-values-base', 'views/admin/dynamic-logic/conditions-string/item-base', function (Dep) { + + return Dep.extend({ + + template: 'admin/dynamic-logic/conditions-string/item-multiple-values-base', + + data: function () { + return { + valueViewDataList: this.valueViewDataList, + scope: this.scope, + operator: this.operator, + operatorString: this.operatorString, + field: this.field + }; + }, + + populateValues: function () { + }, + + + getValueViewKey: function (i) { + return 'view-' + this.level.toString() + '-' + this.number.toString() + '-' + i.toString(); + }, + + createValueFieldView: function () { + var valueList = this.itemData.value || []; + + var fieldType = this.getMetadata().get(['entityDefs', this.scope, 'fields', this.field, 'type']) || 'base'; + var viewName = this.getMetadata().get(['entityDefs', this.scope, 'fields', this.field, 'view']) || this.getFieldManager().getViewName(fieldType); + + this.valueViewDataList = []; + valueList.forEach(function (value, i) { + var model = this.model.clone(); + model.set(this.itemData.attribute, value); + + var key = this.getValueViewKey(i); + this.valueViewDataList.push({ + key: key, + isEnd: i === valueList.length - 1 + }); + + this.createView(key, viewName, { + model: model, + name: this.field, + el: '[data-view-key="'+key+'"]' + }); + }, this); + }, + + }); + +}); + diff --git a/client/src/views/admin/dynamic-logic/conditions-string/item-operator-only-date.js b/client/src/views/admin/dynamic-logic/conditions-string/item-operator-only-date.js new file mode 100644 index 0000000000..eaf84db73d --- /dev/null +++ b/client/src/views/admin/dynamic-logic/conditions-string/item-operator-only-date.js @@ -0,0 +1,44 @@ +/************************************************************************ + * 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('views/admin/dynamic-logic/conditions-string/item-operator-only-date', 'views/admin/dynamic-logic/conditions-string/item-operator-only-base', function (Dep) { + + return Dep.extend({ + + template: 'admin/dynamic-logic/conditions-string/item-operator-only-date', + + data: function () { + var data = Dep.prototype.data.call(this); + data.dateValue = this.dateValue; + return data; + }, + + }); + +}); +