implement column edit api, except sort
This commit is contained in:
+15
-6
@@ -71,7 +71,7 @@ class Column implements JsonSerializable, Arrayable
|
||||
foreach ((array)$columnObject as $key => $value) {
|
||||
if ($value != $this->$key) {
|
||||
$this->modified_attribs[] = $key;
|
||||
$this->orig_attribs[] = $this->$key;
|
||||
$this->orig_attribs[$key] = $this->$key;
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
@@ -123,16 +123,21 @@ class Column implements JsonSerializable, Arrayable
|
||||
/**
|
||||
* Create from object or array
|
||||
*
|
||||
* @param $obj
|
||||
* @param object|array $obj
|
||||
*/
|
||||
public function __construct($obj)
|
||||
public function __construct($obj, $allowEmptyName=false)
|
||||
{
|
||||
$b = objBag($obj);
|
||||
|
||||
if (!$b->has('name') || $b->name == '') throw new NotApplicableException('Missing name in column');
|
||||
if (!$b->has('type')) throw new NotApplicableException('Missing type in column');
|
||||
if (!$allowEmptyName && (!$b->has('name') || $b->name == '')) {
|
||||
throw new NotApplicableException('Missing name in column');
|
||||
}
|
||||
|
||||
if ($b->name[0] == '_') { // global row ID
|
||||
if (!$b->has('type')) {
|
||||
throw new NotApplicableException('Missing type in column');
|
||||
}
|
||||
|
||||
if ($b->name[0] == '_') { // would cause problems with selects (see: _id / GRID)
|
||||
throw new NotApplicableException("Column name can't start with underscore.");
|
||||
}
|
||||
|
||||
@@ -156,6 +161,10 @@ class Column implements JsonSerializable, Arrayable
|
||||
'name' => $this->name,
|
||||
'title' => $this->title,
|
||||
'type' => $this->type,
|
||||
'_new' => $this->isNew,
|
||||
'_remove' => $this->toRemove,
|
||||
'_changed' => $this->modified_attribs,
|
||||
'_orig' => $this->orig_attribs,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user