Skip to content

Commit

Permalink
fix(Tinebase/js): enable filter panel syncFields feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheng-dev committed Mar 18, 2024
1 parent b8bd482 commit 6045e47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tine20/Calendar/js/MainScreenCenterPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Tine.Calendar.MainScreenCenterPanel = Ext.extend(Ext.Panel, {
];
this.filterToolbar = this.getFilterToolbar({
onFilterChange: this.refresh.createDelegate(this, [false]),
getAllFilterData: this.getAllFilterData.createDelegate(this)
getAllFilterData: this.getAllFilterData.createDelegate(this),
});

this.filterToolbar.getQuickFilterPlugin().criteriaIgnores.push(
Expand Down
21 changes: 11 additions & 10 deletions tine20/Tinebase/js/widgets/grid/FilterPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Ext.ns('Tine.widgets.grid');

Tine.widgets.grid.FilterPanel = function(config) {
this.filterToolbarConfig = config;
Ext.copyTo(this, config, 'useQuickFilter,quickFilterConfig');
Ext.copyTo(this, config, 'useQuickFilter, quickFilterConfig, syncFields');

// the plugins won't work there
delete this.filterToolbarConfig.plugins;
Expand Down Expand Up @@ -85,9 +85,10 @@ Ext.extend(Tine.widgets.grid.FilterPanel, Ext.Panel, {
*/
forceLayout: true,

syncFields: true,

initComponent: function() {

var filterPanel = this.addFilterPanel();
const filterPanel = this.addFilterPanel();
this.filterModelMap = filterPanel.filterModelMap;
this.activeFilterPanel = filterPanel;

Expand Down Expand Up @@ -119,12 +120,12 @@ Ext.extend(Tine.widgets.grid.FilterPanel, Ext.Panel, {
}];

Tine.widgets.grid.FilterPanel.superclass.initComponent.call(this);

if (this.useQuickFilter) {
this.quickFilterPlugin = new Tine.widgets.grid.FilterToolbarQuickFilterPlugin(Ext.apply({
syncFields: false,
syncFields: this.syncFields,
}, this.quickFilterConfig));
this.quickFilterPlugin.init(this);
this.quickFilterPlugin.init(filterPanel);
}
},

Expand Down Expand Up @@ -252,12 +253,12 @@ Ext.extend(Tine.widgets.grid.FilterPanel, Ext.Panel, {
},

getValue: function() {
var filters = [];
const filters = [];


for (var id in this.filterPanels) {
for (let id in this.filterPanels) {
if (this.filterPanels.hasOwnProperty(id) && this.filterPanels[id].isActive) {
filters.push({'condition': 'AND', 'filters': this.filterPanels[id].getValue(), 'id': id, label: Ext.util.Format.htmlDecode(this.filterPanels[id].title)});
const filterData = this.filterPanels[id].getValue();
filters.push({'condition': 'AND', 'filters': filterData, 'id': id, label: Ext.util.Format.htmlDecode(this.filterPanels[id].title)});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Tine.widgets.grid.FilterToolbarQuickFilterPlugin.prototype = {
*/
init: function(ftb) {
this.ftb = ftb;

if (this.syncFields) {
this.ftb.renderFilterRow = this.ftb.renderFilterRow.createSequence(this.onAddFilter, this);
this.ftb.onFieldChange = this.ftb.onFieldChange.createSequence(this.onFieldChange, this);
Expand Down Expand Up @@ -348,7 +349,7 @@ Tine.widgets.grid.FilterToolbarQuickFilterPlugin.prototype = {
},

onGetValue: function() {
var value = this.origGetValue.call(this.ftb);
const value = this.origGetValue.call(this.ftb);

if (! this.syncFields) {
value.push({field: this.quickFilterField, operator: 'contains', value: this.quickFilter.getValue(), id: 'quickFilter'});
Expand Down Expand Up @@ -423,7 +424,7 @@ Tine.widgets.grid.FilterToolbarQuickFilterPlugin.prototype = {
* @param {Ext.form.Field} field
*/
syncField: function(field) {
if (field == this.quickFilter) {
if (field === this.quickFilter) {
this.getQuickFilterRowField().formFields.value.setValue(this.quickFilter.getValue());
} else {
this.quickFilter.setValue(this.quickFilterRow.formFields.value.getValue());
Expand Down

0 comments on commit 6045e47

Please sign in to comment.