Skip to content

Commit

Permalink
Merge pull request #40 from YouweGit/task/filteringAndBatchEditFieldC…
Browse files Browse the repository at this point in the history
…onfiguration

[TASK] Filtering and batch edit field configuration
  • Loading branch information
kjkooistra-youwe committed Jan 15, 2020
2 parents 767f9e5 + 77a25c1 commit ce17234
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 33 deletions.
52 changes: 47 additions & 5 deletions Model/DataObject/ClassDefinition/Data/ObjectBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,41 @@ class ObjectBridge extends ClassDefinition\Data\ObjectsMetadata
*
* @var string
*/

public $phpdocType = "\\Pimcore\\Model\\DataObject\\AbstractObject[]";

/** @var string */
public $sourceVisibleFieldDefinitions;

/** @var string */
public $bridgeVisibleFieldDefinitions;
/** @var bool */

/** @var bool */
public $autoResize;

/** @var bool */
/** @var bool */
public $newLineSplit;

/** @var int */
public $maxWidthResize;
/** @var bool */

/** @var bool */
public $enableFiltering;

/** @var bool */
public $enableBatchEdit;

/** @var bool */
public $allowCreate;

/** @var bool */
public $allowDelete;

/** @var string */
public $bridgePrefix;

/** @var string */
public $sourcePrefix;

/** @var string */
public $decimalPrecision;

Expand Down Expand Up @@ -1224,6 +1234,38 @@ public function setNewLineSplit($newLineSplit)
$this->newLineSplit = $newLineSplit;
}

/**
* @return bool
*/
public function getEnableFiltering()
{
return $this->enableFiltering;
}

/**
* @param bool $enableFiltering
*/
public function setEnableFiltering($enableFiltering)
{
$this->enableFiltering = $enableFiltering;
}

/**
* @return bool
*/
public function getEnableBatchEdit()
{
return $this->enableBatchEdit;
}

/**
* @param bool $enableBatchEdit
*/
public function setEnableBatchEdit($enableBatchEdit)
{
$this->enableBatchEdit = $enableBatchEdit;
}

/**
* @return boolean
*/
Expand Down Expand Up @@ -1319,7 +1361,7 @@ public function getdisableUpDown()
{
return $this->disableUpDown;
}


/**
* @param $object
Expand Down
12 changes: 12 additions & 0 deletions Resources/public/js/pimcore/objects/classes/data/objectBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ pimcore.object.classes.data.objectBridge = Class.create(pimcore.object.classes.d
fieldLabel: t("max_width_resize"),
name: 'maxWidthResize',
value: this.datax.maxWidthResize
}, {
xtype: "checkbox",
fieldLabel: t("enable_filtering"),
name: "enableFiltering",
checked: this.datax.enableFiltering
}, {
xtype: "checkbox",
fieldLabel: t("enable_batch_edit"),
name: "enableBatchEdit",
checked: this.datax.enableBatchEdit
}, {
xtype: "checkbox",
fieldLabel: t("allow_create"),
Expand Down Expand Up @@ -683,6 +693,8 @@ pimcore.object.classes.data.objectBridge = Class.create(pimcore.object.classes.d
autoResize: source.datax.autoResize,
maxWidthResize: source.datax.maxWidthResize,
newLineSplit: source.datax.newLineSplit,
enableFiltering: source.datax.enableFiltering,
enableBatchEdit: source.datax.enableBatchEdit,
sourceAllowedClassName: source.datax.sourceAllowedClassName,
sourceVisibleFields: source.datax.sourceVisibleFields,
sourceHiddenFields: source.datax.sourceHiddenFields,
Expand Down
70 changes: 42 additions & 28 deletions Resources/public/js/pimcore/objects/tags/objectBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,20 @@ pimcore.object.tags.objectBridge = Class.create(pimcore.object.tags.objects, {
// it as soon as possible meaning all general stuff on bottom of
// this function will be passed directly to this column

if (this.fieldConfig.enableFiltering) {
filter.type = 'boolean';
} else {
filter = null;
}

var checkBoxColumn = Ext.create('Ext.grid.column.Check', {
text: layout.title,
width: 40,
align: 'left',
hidden: !!layout.hidden,
sortable: true,
dataIndex: classNameText + '_' + layout.name,
filter: {
// required configs
type: 'boolean'
},
filter: filter,
layout: layout
});

Expand Down Expand Up @@ -276,6 +279,10 @@ pimcore.object.tags.objectBridge = Class.create(pimcore.object.tags.objects, {
title = layout.title;
}

if (!this.fieldConfig.enableFiltering || filter.type === null) {
filter = null;
}

var column = Ext.create('Ext.grid.column.Column', {
text: title,
dataIndex: classNameText + '_' + layout.name,
Expand Down Expand Up @@ -461,6 +468,11 @@ pimcore.object.tags.objectBridge = Class.create(pimcore.object.tags.objects, {
}),'pimcore.gridfilters'
];

var selectionModel = 'Ext.selection.RowModel';
if (this.fieldConfig.enableBatchEdit) {
selectionModel = 'Ext.selection.CheckboxModel';
}

this.component = Ext.create('Ext.grid.Panel', {
store: this.store,
plugins: 'gridfilters',
Expand All @@ -469,7 +481,7 @@ pimcore.object.tags.objectBridge = Class.create(pimcore.object.tags.objects, {
enableDragDrop: true,
ddGroup: 'element',
trackMouseOver: true,
selModel: Ext.create('Ext.selection.CheckboxModel', {}),
selModel: Ext.create(selectionModel, {}),
columnLines: true,
stripeRows: true,
columns: columns,
Expand Down Expand Up @@ -534,30 +546,32 @@ pimcore.object.tags.objectBridge = Class.create(pimcore.object.tags.objects, {
}.bind(this)
});

// Add 'batch edit selected' menu item to column header menu
var batchEditSelectedMenuItem = new Ext.menu.Item({
text: t('batch_change_selected'),
iconCls: "pimcore_icon_table pimcore_icon_overlay_go",
handler: function (grid) {
if (this.fieldConfig.enableBatchEdit) {
// Add 'batch edit selected' menu item to column header menu
var batchEditSelectedMenuItem = new Ext.menu.Item({
text: t('batch_change_selected'),
iconCls: "pimcore_icon_table pimcore_icon_overlay_go",
handler: function (grid) {
var menu = grid.headerCt.getMenu();
var columnDataIndex = menu.activeHeader.fullColumnIndex;
this.batchOpen(columnDataIndex);
}.bind(this, this.component)
});
var menu = this.component.headerCt.getMenu();
menu.add(batchEditSelectedMenuItem);

// Only show batch edit for bridge data object columns and when at least 1 row is selected
menu.on('beforeshow', function (batchEditSelectedMenuItem, grid) {
var menu = grid.headerCt.getMenu();
var columnDataIndex = menu.activeHeader.fullColumnIndex;
this.batchOpen(columnDataIndex);
}.bind(this, this.component)
});
var menu = this.component.headerCt.getMenu();
menu.add(batchEditSelectedMenuItem);

// Only show batch edit for bridge data object columns and when at least 1 row is selected
menu.on('beforeshow', function (batchEditSelectedMenuItem, grid) {
var menu = grid.headerCt.getMenu();
var columnDataIndex = menu.activeHeader.dataIndex;

if (grid.getSelectionModel().hasSelection() && Ext.Array.contains(bridgeFieldDataIndices, columnDataIndex)) {
batchEditSelectedMenuItem.show();
} else {
batchEditSelectedMenuItem.hide();
}
}.bind(this, batchEditSelectedMenuItem, this.component));
var columnDataIndex = menu.activeHeader.dataIndex;

if (grid.getSelectionModel().hasSelection() && Ext.Array.contains(bridgeFieldDataIndices, columnDataIndex)) {
batchEditSelectedMenuItem.show();
} else {
batchEditSelectedMenuItem.hide();
}
}.bind(this, batchEditSelectedMenuItem, this.component));
}
}.bind(this));
}

Expand Down
2 changes: 2 additions & 0 deletions Resources/translations/admin.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ bridge_field: "Bridge field"
source_hidden_fields: "Source hidden fields"
bridge_hidden_fields: "Bridge hidden fields"
auto_resize: "Auto resize columns"
enable_filtering: "Enable filtering"
enable_batch_edit: "Enable batch edit"
new_line_split: "New line split"
max_width_resize: "Max width resize"
allow_create: "Allow create"
Expand Down

0 comments on commit ce17234

Please sign in to comment.