mirror of
https://github.com/UndefinedOffset/SortableGridField.git
synced 2024-10-22 17:05:38 +02:00
More adjustments to how ManyManyThroughLists are handled
Fixed issue causing the alert to be empty when an error occurs on the server
This commit is contained in:
parent
aef0a8acc1
commit
35775ad2ce
@ -107,7 +107,7 @@
|
|||||||
dataType: 'html',
|
dataType: 'html',
|
||||||
success: callback,
|
success: callback,
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
alert(ss.i18n._t('GRIDFIELD.ERRORINTRANSACTION'));
|
alert(ss.i18n._t('Admin.ERRORINTRANSACTION', 'An error occured while fetching data from the server\n Please try again later.'));
|
||||||
}
|
}
|
||||||
}, ajaxOpts));
|
}, ajaxOpts));
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
'Checked' => ($state->sortableToggle == true ? ' checked = "checked"' : ''),
|
'Checked' => ($state->sortableToggle == true ? ' checked = "checked"' : ''),
|
||||||
'List' => $dataList);
|
'List' => $dataList);
|
||||||
|
|
||||||
$forTemplate = new arrayData($data);
|
$forTemplate = new ArrayData($data);
|
||||||
|
|
||||||
Requirements::css('undefinedoffset/sortablegridfield:css/GridFieldSortableRows.css');
|
Requirements::css('undefinedoffset/sortablegridfield:css/GridFieldSortableRows.css');
|
||||||
Requirements::javascript('undefinedoffset/sortablegridfield:javascript/GridFieldSortableRows.js');
|
Requirements::javascript('undefinedoffset/sortablegridfield:javascript/GridFieldSortableRows.js');
|
||||||
@ -230,15 +230,10 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
return $query;
|
return $query;
|
||||||
});
|
});
|
||||||
|
|
||||||
$many_many = ($list instanceof ManyManyList);
|
$many_many = ($list instanceof ManyManyList || $list instanceof ManyManyThroughList);
|
||||||
if (!$many_many) {
|
if (!$many_many) {
|
||||||
if($list instanceof ManyManyThroughList) {
|
$sng = singleton($gridField->getModelClass());
|
||||||
$fieldType = $list->getExtraFields();
|
$fieldType = $sng->config()->db[$this->sortColumn];
|
||||||
$fieldType = $fieldType[$this->sortColumn];
|
|
||||||
} else {
|
|
||||||
$sng = singleton($gridField->getModelClass());
|
|
||||||
$fieldType = $sng->config()->db[$this->sortColumn];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$fieldType || !($fieldType == 'Int' || $fieldType == 'SilverStripe\\ORM\\FieldType\\DBInt' || is_subclass_of($fieldType, 'SilverStripe\\ORM\\FieldType\\DBInt'))) {
|
if (!$fieldType || !($fieldType == 'Int' || $fieldType == 'SilverStripe\\ORM\\FieldType\\DBInt' || is_subclass_of($fieldType, 'SilverStripe\\ORM\\FieldType\\DBInt'))) {
|
||||||
if (is_array($fieldType)) {
|
if (is_array($fieldType)) {
|
||||||
@ -265,7 +260,12 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
$componentField=$componentDetails['childField'];
|
$componentField=$componentDetails['childField'];
|
||||||
$table=$componentDetails['join'];
|
$table=$componentDetails['join'];
|
||||||
|
|
||||||
$extraFields = $schema->manyManyExtraFieldsForComponent(get_class($owner), (!empty($this->custom_relation_name) ? $this->custom_relation_name : $gridField->getName()));
|
//For ManyManyThroughLists get the right join table
|
||||||
|
if ($list instanceof ManyManyThroughList && class_exists($table)) {
|
||||||
|
$table=$schema->tableName($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
$extraFields = $list->getExtraFields();
|
||||||
|
|
||||||
if (!$extraFields || !array_key_exists($this->sortColumn, $extraFields) || !($extraFields[$this->sortColumn] == 'Int' || $extraFields[$this->sortColumn] == 'SilverStripe\\ORM\\FieldType\\DBInt' || is_subclass_of('SilverStripe\\ORM\\FieldType\\DBInt', $extraFields[$this->sortColumn]))) {
|
if (!$extraFields || !array_key_exists($this->sortColumn, $extraFields) || !($extraFields[$this->sortColumn] == 'Int' || $extraFields[$this->sortColumn] == 'SilverStripe\\ORM\\FieldType\\DBInt' || is_subclass_of('SilverStripe\\ORM\\FieldType\\DBInt', $extraFields[$this->sortColumn]))) {
|
||||||
user_error('Sort column ' . $this->sortColumn . ' must be an SilverStripe\\ORM\\FieldType\\DBInt, column is of type ' . $extraFields[$this->sortColumn], E_USER_ERROR);
|
user_error('Sort column ' . $this->sortColumn . ' must be an SilverStripe\\ORM\\FieldType\\DBInt, column is of type ' . $extraFields[$this->sortColumn], E_USER_ERROR);
|
||||||
@ -470,7 +470,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
$className = $gridField->getModelClass();
|
$className = $gridField->getModelClass();
|
||||||
$owner = $gridField->Form->getRecord();
|
$owner = $gridField->Form->getRecord();
|
||||||
$items = clone $gridField->getList();
|
$items = clone $gridField->getList();
|
||||||
$many_many = ($items instanceof ManyManyList);
|
$many_many = ($items instanceof ManyManyList || $items instanceof ManyManyThroughList);
|
||||||
$sortColumn = $this->sortColumn;
|
$sortColumn = $this->sortColumn;
|
||||||
$pageOffset = 0;
|
$pageOffset = 0;
|
||||||
|
|
||||||
@ -489,6 +489,11 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
$parentField=$componentDetails['parentField'];
|
$parentField=$componentDetails['parentField'];
|
||||||
$componentField=$componentDetails['childField'];
|
$componentField=$componentDetails['childField'];
|
||||||
$table=$componentDetails['join'];
|
$table=$componentDetails['join'];
|
||||||
|
|
||||||
|
//For ManyManyThroughLists get the right join table
|
||||||
|
if ($items instanceof ManyManyThroughList && class_exists($table)) {
|
||||||
|
$table=$schema->tableName($table);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//Find table containing the sort column
|
//Find table containing the sort column
|
||||||
$table = false;
|
$table = false;
|
||||||
@ -612,7 +617,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
/** @var DataList $items */
|
/** @var DataList $items */
|
||||||
$items = clone $gridField->getList();
|
$items = clone $gridField->getList();
|
||||||
|
|
||||||
$many_many = ($items instanceof ManyManyList);
|
$many_many = ($items instanceof ManyManyList || $items instanceof ManyManyThroughList);
|
||||||
$sortColumn = $this->sortColumn;
|
$sortColumn = $this->sortColumn;
|
||||||
$targetItem = $items->byID(intval($data['ItemID']));
|
$targetItem = $items->byID(intval($data['ItemID']));
|
||||||
|
|
||||||
@ -633,6 +638,11 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
$parentField=$componentDetails['parentField'];
|
$parentField=$componentDetails['parentField'];
|
||||||
$componentField=$componentDetails['childField'];
|
$componentField=$componentDetails['childField'];
|
||||||
$table=$componentDetails['join'];
|
$table=$componentDetails['join'];
|
||||||
|
|
||||||
|
//For ManyManyThroughLists get the right join table
|
||||||
|
if ($items instanceof ManyManyThroughList && class_exists($table)) {
|
||||||
|
$table=$schema->tableName($table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data['Target'] == 'previouspage') {
|
if ($data['Target'] == 'previouspage') {
|
||||||
|
Loading…
Reference in New Issue
Block a user