Commit ce1ee30b authored by Tobias Munk's avatar Tobias Munk

renamed widget WidgetContainer to Cell

parent b2165f30
......@@ -103,3 +103,11 @@ Example with `yii2-prototype-module`
```
For more examples, please see the [docs](./docs)
Upgrading
---------
### from 0.2 to 0.3
{{ cell_widget({id: 'header'}) }}
\ No newline at end of file
......@@ -10,6 +10,16 @@ use yii\helpers\ArrayHelper;
*/
class WidgetContent extends BaseWidget
{
public function rules()
{
return ArrayHelper::merge(
parent::rules(),
[
['name_id', 'match', 'pattern' => '/^[a-z0-9-]*$/i']
]
);
}
public static function optsWidgetTemplateId()
{
return ArrayHelper::merge(
......
......@@ -19,10 +19,12 @@ use yii\helpers\Html;
use yii\helpers\Json;
use yii\helpers\Url;
class WidgetContainer extends Widget
class Cell extends Widget
{
const CSS_PREFIX = 'hrzg-widget';
public $requestParam = 'pageId';
public function init()
{
\Yii::$app->trigger('registerMenuItems', new Event(['sender' => $this]));
......@@ -49,7 +51,7 @@ class WidgetContainer extends Widget
'WidgetContent' => [
'route' => $this->getRoute(),
'container_id' => $this->id,
'request_param' => \Yii::$app->request->get('id'),
'request_param' => \Yii::$app->request->get($this->requestParam),
'access_domain' => \Yii::$app->language,
],
],
......@@ -76,13 +78,13 @@ class WidgetContainer extends Widget
->orderBy('rank ASC')
->andFilterWhere(
[
'request_param' => \Yii::$app->request->get('id'),
'request_param' => \Yii::$app->request->get($this->requestParam),
]
)
->andWhere(
[
'container_id' => $this->id,
'route' => $this->getRoute(),
'route' => [$this->getRoute(), '*'],
'access_domain' => \Yii::$app->language,
])
->all();
......@@ -139,7 +141,7 @@ class WidgetContainer extends Widget
'WidgetContent' => [
'route' => $this->getRoute(),
'container_id' => $this->id,
'request_param' => \Yii::$app->request->get('id'),
'request_param' => \Yii::$app->request->get($this->requestParam),
'access_domain' => \Yii::$app->language,
]
],
......@@ -152,7 +154,7 @@ class WidgetContainer extends Widget
{
$html = Html::beginTag('div', ['class' => 'hrzg-widget-widget-controls btn-group', 'role' => 'group']);
$html .= Html::a(
FA::icon(FA::_PENCIL).' #'.$widget->id.' '.$widget->template->name.' <span class="label label-default">'.$widget->rank.'</span>',
FA::icon(FA::_PENCIL).' #'.$widget->id.' '.$widget->name_id.' '.$widget->template->name.' <span class="label label-default">'.$widget->rank.'</span>',
['/widgets/crud/widget/update', 'id' => $widget->id],
['class' => 'btn btn-xs btn-primary']
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment