dynamicLogic string dev

This commit is contained in:
yuri
2016-09-02 17:17:31 +03:00
parent 96ac275970
commit dcae13f4dc
18 changed files with 365 additions and 34 deletions
@@ -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"
}
]
}
]
}
@@ -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": "∈"
}
}
}
@@ -0,0 +1,4 @@
<div>{{translate 'not' category='logicalOperators' scope='Admin'}} (
<div data-view-key="{{viewKey}}" style="margin-left: 15px;">{{{var viewKey this}}}</div>
)</div>
@@ -0,0 +1,2 @@
{{translate field category='fields' scope=scope}} {{{operatorString}}}
({{#each valueViewDataList}}<span data-name="{{key}}">{{{var key ../this}}}</span>{{#unless isEnd}}, {{/unless}}{{/each}})
@@ -0,0 +1 @@
{{translate field category='fields' scope=scope}} {{{operatorString}}} {{translateOption dateValue field='dateSearchRanges'}}
+1 -1
View File
@@ -1 +1 @@
{{value}}
{{value}}
@@ -1 +1 @@
<span class="text-{{style}}">{{translateOption value scope=scope field=name}}</span>
<span class="text-{{style}}">{{translateOption value scope=scope field=name}}</span>
+1 -1
View File
@@ -1 +1 @@
{{translateOption value scope=scope field=name translatedOptions=translatedOptions}}
{{translateOption value scope=scope field=name translatedOptions=translatedOptions}}
+2 -4
View File
@@ -1,5 +1,3 @@
{{#if isNotEmpty}}
{{value}}
{{else}}
{{#if isNotEmpty}}{{value}}{{else}}
{{translate 'None'}}
{{/if}}
{{/if}}
+21 -4
View File
@@ -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;
},
@@ -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']);
@@ -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;
}
});
});
@@ -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,
@@ -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'
});
});
@@ -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'
});
});
@@ -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'
});
});
@@ -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);
},
});
});
@@ -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;
},
});
});