Skip to content

Commit

Permalink
fixed issue introduced from beta7 bc break #877, closes #879
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed May 28, 2016
1 parent d5e3eb2 commit 446d0ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
17 changes: 17 additions & 0 deletions modules/admin/src/ngrest/base/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,23 @@ public function createListTag($ngModel)
return $this->createTag('span', null, ['ng-bind' => $ngModel]);
}

/**
* Create a tag for relation window toggler with directive crudLoader based on a ngrest model class.
*
* @param string $ngrestModelClass
* @return string The generated tag or null if permission does not exists
*/
public function createCrudLoaderTag($ngrestModelClass)
{
$menu = Yii::$app->adminmenu->getApiDetail($ngrestModelClass::ngRestApiEndpoint());

if ($menu) {
return $this->createTag('crud-loader', null, ['api' => str_replace('-', '/', $menu['route'])]);
}

return null;
}

// EVENTS

private $_events = [];
Expand Down
14 changes: 6 additions & 8 deletions modules/admin/src/ngrest/plugins/CheckboxRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function init()

public function setModel($className)
{
$this->_model = (!is_object($className)) ? Yii::createObject(['class' => $className]) : $className;
$this->_model = $className;
}

private $_modelPrimaryKey = null;
Expand All @@ -81,6 +81,10 @@ public function getModelPrimaryKey()

public function getModel()
{
if (!is_object($this->_model)) {
$this->_model = Yii::createObject(['class' => $this->_model]);
}

return $this->_model;
}

Expand Down Expand Up @@ -115,14 +119,8 @@ public function renderList($id, $ngModel)

public function renderCreate($id, $ngModel)
{
$menu = Yii::$app->adminmenu->getApiDetail($this->model->ngRestApiEndpoint());
$route = null;
if ($menu) {
$route = str_replace('-', '/', $menu['route']);
}

return [
$this->createTag('crud-loader', 'zalalim', ['api' => $route]),
$this->createCrudLoaderTag($this->model->className()),
$this->createFormTag('zaa-checkbox-array', $id, $ngModel, ['options' => $this->getServiceName('relationdata')]),
];
}
Expand Down
11 changes: 2 additions & 9 deletions modules/admin/src/ngrest/plugins/SelectModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,11 @@ public function getData()
}



public function renderCreate($id, $ngModel)
{

$menu = Yii::$app->adminmenu->getApiDetail($this->modelClass::ngRestApiEndpoint());

$route = null;
if ($menu) {
$route = str_replace('-', '/', $menu['route']);
}

return [
$this->createTag('crud-loader', 'zalalim', ['api' => $route]),
$this->createCrudLoaderTag($this->modelClass),
$this->createFormTag('zaa-select', $id, $ngModel, ['initvalue' => $this->initValue, 'options' => $this->getServiceName('selectdata')]),
];
}
Expand Down

0 comments on commit 446d0ab

Please sign in to comment.