Commit 8e6289a2 authored by Tobias Munk's avatar Tobias Munk

code-formatting

parent cdf334ba
......@@ -17,7 +17,7 @@ class Module extends \yii\base\Module
public function beforeAction($action)
{
parent::beforeAction($action);
\Yii::$app->controller->view->params['breadcrumbs'][] = ['label' => 'Widget', 'url'=>['/widgets']];
\Yii::$app->controller->view->params['breadcrumbs'][] = ['label' => 'Widget', 'url' => ['/widgets']];
return true;
}
}
......@@ -11,6 +11,6 @@ class DefaultController extends Controller
{
$searchModel = new WidgetTemplate;
$dataProvider = $searchModel->search([]);
return $this->render('index', ['templatesDataProvider'=>$dataProvider]);
return $this->render('index', ['templatesDataProvider' => $dataProvider]);
}
}
......@@ -21,7 +21,8 @@ class WidgetController extends \hrzg\widget\controllers\crud\base\WidgetControll
*
* @return mixed
*/
public function actionCreateFromTemplate($templateId = null) {
public function actionCreateFromTemplate($templateId = null)
{
$model = new WidgetContent();
try {
......@@ -31,7 +32,7 @@ class WidgetController extends \hrzg\widget\controllers\crud\base\WidgetControll
$model->load($_GET);
}
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
$msg = (isset($e->errorInfo[2])) ? $e->errorInfo[2] : $e->getMessage();
$model->addError('_exception', $msg);
}
return $this->render('create', ['model' => $model]);
......
......@@ -16,33 +16,37 @@ use yii\helpers\ArrayHelper;
class WidgetController extends \yii\rest\ActiveController
{
public $modelClass = 'hrzg\widget\models\crud\Widget';
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return ArrayHelper::merge(
parent::behaviors(),
[
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
]
);
}
public $modelClass = 'hrzg\widget\models\crud\Widget';
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors()
{
return ArrayHelper::merge(
parent::behaviors(),
[
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {
return \Yii::$app->user->can($this->module->id.'_'.$this->id.'_'.$action->id,
['route' => true]);
},
]
]
]
]
);
}
}
......@@ -16,33 +16,37 @@ use yii\helpers\ArrayHelper;
class WidgetTemplateController extends \yii\rest\ActiveController
{
public $modelClass = 'hrzg\widget\models\crud\WidgetTemplate';
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return ArrayHelper::merge(
parent::behaviors(),
[
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
]
);
}
public $modelClass = 'hrzg\widget\models\crud\WidgetTemplate';
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors()
{
return ArrayHelper::merge(
parent::behaviors(),
[
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {
return \Yii::$app->user->can($this->module->id.'_'.$this->id.'_'.$action->id,
['route' => true]);
},
]
]
]
]
);
}
}
......@@ -25,168 +25,181 @@ use dmstr\bootstrap\Tabs;
class WidgetController extends Controller
{
/**
*
* @var boolean whether to enable CSRF validation for the actions in this controller.
* CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true.
*/
public $enableCsrfValidation = false;
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
];
}
/**
* Lists all Widget models.
*
* @return mixed
*/
public function actionIndex() {
$searchModel = new WidgetSearch;
$dataProvider = $searchModel->search($_GET);
Tabs::clearLocalStorage();
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
/**
* Displays a single Widget model.
*
* @param integer $id
* @return mixed
*/
public function actionView($id) {
\Yii::$app->session['__crudReturnUrl'] = Url::previous();
Url::remember();
Tabs::rememberActiveState();
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Widget model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate() {
$model = new WidgetContent;
try {
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} elseif (!\Yii::$app->request->isPost) {
$model->load($_GET);
}
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
$model->addError('_exception', $msg);
}
return $this->render('create', ['model' => $model]);
}
/**
* Updates an existing Widget model.
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$model = $this->findModel($id);
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Widget model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
try {
$this->findModel($id)->delete();
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
\Yii::$app->getSession()->addFlash('error', $msg);
return $this->redirect(Url::previous());
}
// TODO: improve detection
$isPivot = strstr('$id', ',');
if ($isPivot == true) {
return $this->redirect(Url::previous());
} elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') {
Url::remember(null);
$url = \Yii::$app->session['__crudReturnUrl'];
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->redirect($url);
} else {
return $this->redirect(['index']);
}
}
/**
* Finds the Widget model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @throws HttpException if the model cannot be found
*
*@param integer $id
*
*@return WidgetContent the loaded model
*/
protected function findModel($id) {
if (($model = WidgetContent::findOne($id)) !== null) {
return $model;
} else {
throw new HttpException(404, 'The requested page does not exist.');
}
}
/**
*
* @var boolean whether to enable CSRF validation for the actions in this controller.
* CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true.
*/
public $enableCsrfValidation = false;
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {
return \Yii::$app->user->can($this->module->id.'_'.$this->id.'_'.$action->id,
['route' => true]);
},
]
]
]
];
}
/**
* Lists all Widget models.
*
* @return mixed
*/
public function actionIndex()
{
$searchModel = new WidgetSearch;
$dataProvider = $searchModel->search($_GET);
Tabs::clearLocalStorage();
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
/**
* Displays a single Widget model.
*
* @param integer $id
*
* @return mixed
*/
public function actionView($id)
{
\Yii::$app->session['__crudReturnUrl'] = Url::previous();
Url::remember();
Tabs::rememberActiveState();
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Widget model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate()
{
$model = new WidgetContent;
try {
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} elseif (!\Yii::$app->request->isPost) {
$model->load($_GET);
}
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2])) ? $e->errorInfo[2] : $e->getMessage();
$model->addError('_exception', $msg);
}
return $this->render('create', ['model' => $model]);
}
/**
* Updates an existing Widget model.
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
*
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Widget model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
*
* @return mixed
*/
public function actionDelete($id)
{
try {
$this->findModel($id)->delete();
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2])) ? $e->errorInfo[2] : $e->getMessage();
\Yii::$app->getSession()->addFlash('error', $msg);
return $this->redirect(Url::previous());
}
// TODO: improve detection
$isPivot = strstr('$id', ',');
if ($isPivot == true) {
return $this->redirect(Url::previous());
} elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') {
Url::remember(null);
$url = \Yii::$app->session['__crudReturnUrl'];
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->redirect($url);
} else {
return $this->redirect(['index']);
}
}
/**
* Finds the Widget model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @throws HttpException if the model cannot be found
*
* @param integer $id
*
* @return WidgetContent the loaded model
*/
protected function findModel($id)
{
if (($model = WidgetContent::findOne($id)) !== null) {
return $model;
} else {
throw new HttpException(404, 'The requested page does not exist.');
}
}
}
......@@ -25,166 +25,181 @@ use dmstr\bootstrap\Tabs;
class WidgetTemplateController extends Controller
{
/**
*
* @var boolean whether to enable CSRF validation for the actions in this controller.
* CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true.
*/
public $enableCsrfValidation = false;
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {return \Yii::$app->user->can($this->module->id . '_' . $this->id . '_' . $action->id, ['route' => true]);},
]
]
]
];
}
/**
* Lists all WidgetTemplate models.
*
* @return mixed
*/
public function actionIndex() {
$searchModel = new WidgetTemplateSearch;
$dataProvider = $searchModel->search($_GET);
Tabs::clearLocalStorage();
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
/**
* Displays a single WidgetTemplate model.
*
* @param integer $id
* @return mixed
*/
public function actionView($id) {
\Yii::$app->session['__crudReturnUrl'] = Url::previous();
Url::remember();
Tabs::rememberActiveState();
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new WidgetTemplate model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate() {
$model = new WidgetTemplate;
try {
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} elseif (!\Yii::$app->request->isPost) {
$model->load($_GET);
}
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
$model->addError('_exception', $msg);
}
return $this->render('create', ['model' => $model]);
}
/**
* Updates an existing WidgetTemplate model.
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
* @return mixed
*/
public function actionUpdate($id) {
$model = $this->findModel($id);
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing WidgetTemplate model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
* @return mixed
*/
public function actionDelete($id) {
try {
$this->findModel($id)->delete();
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage();
\Yii::$app->getSession()->addFlash('error', $msg);
return $this->redirect(Url::previous());
}
// TODO: improve detection
$isPivot = strstr('$id', ',');
if ($isPivot == true) {
return $this->redirect(Url::previous());
} elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') {
Url::remember(null);
$url = \Yii::$app->session['__crudReturnUrl'];
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->redirect($url);
} else {
return $this->redirect(['index']);
}
}
/**
* Finds the WidgetTemplate model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @throws HttpException if the model cannot be found
* @param integer $id
* @return WidgetTemplate the loaded model
*/
protected function findModel($id) {
if (($model = WidgetTemplate::findOne($id)) !== null) {
return $model;
} else {
throw new HttpException(404, 'The requested page does not exist.');
}
}
/**
*
* @var boolean whether to enable CSRF validation for the actions in this controller.
* CSRF validation is enabled only when both this property and [[Request::enableCsrfValidation]] are true.
*/
public $enableCsrfValidation = false;
/**
*
* @inheritdoc
* @return unknown
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
/**
*
*/
'matchCallback' => function ($rule, $action) {
return \Yii::$app->user->can($this->module->id.'_'.$this->id.'_'.$action->id,
['route' => true]);
},
]
]
]
];
}
/**
* Lists all WidgetTemplate models.
*
* @return mixed
*/
public function actionIndex()
{
$searchModel = new WidgetTemplateSearch;
$dataProvider = $searchModel->search($_GET);
Tabs::clearLocalStorage();
Url::remember();
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
/**
* Displays a single WidgetTemplate model.
*
* @param integer $id
*
* @return mixed
*/
public function actionView($id)
{
\Yii::$app->session['__crudReturnUrl'] = Url::previous();
Url::remember();
Tabs::rememberActiveState();
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new WidgetTemplate model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return mixed
*/
public function actionCreate()
{
$model = new WidgetTemplate;
try {
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} elseif (!\Yii::$app->request->isPost) {
$model->load($_GET);
}
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2])) ? $e->errorInfo[2] : $e->getMessage();
$model->addError('_exception', $msg);
}
return $this->render('create', ['model' => $model]);
}
/**
* Updates an existing WidgetTemplate model.
* If update is successful, the browser will be redirected to the 'view' page.
*
* @param integer $id
*
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load($_POST) && $model->save()) {
return $this->redirect(Url::previous());
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing WidgetTemplate model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
* @param integer $id
*
* @return mixed
*/
public function actionDelete($id)
{
try {
$this->findModel($id)->delete();
} catch (\Exception $e) {
$msg = (isset($e->errorInfo[2])) ? $e->errorInfo[2] : $e->getMessage();
\Yii::$app->getSession()->addFlash('error', $msg);
return $this->redirect(Url::previous());
}
// TODO: improve detection
$isPivot = strstr('$id', ',');
if ($isPivot == true) {
return $this->redirect(Url::previous());
} elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') {
Url::remember(null);
$url = \Yii::$app->session['__crudReturnUrl'];
\Yii::$app->session['__crudReturnUrl'] = null;
return $this->redirect($url);
} else {
return $this->redirect(['index']);
}
}
/**
* Finds the WidgetTemplate model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
* @throws HttpException if the model cannot be found
*
* @param integer $id
*
* @return WidgetTemplate the loaded model
*/
protected function findModel($id)
{
if (($model = WidgetTemplate::findOne($id)) !== null) {
return $model;
} else {
throw new HttpException(404, 'The requested page does not exist.');
}
}
}
......@@ -2,8 +2,8 @@
namespace hrzg\widget\models\crud;
use hrzg\widget\models\crud\base\Widget as BaseWidget;
use Yii;
use \hrzg\widget\models\crud\base\Widget as BaseWidget;
use yii\helpers\ArrayHelper;
/**
......@@ -19,7 +19,8 @@ class WidgetContent extends BaseWidget
);
}
public function getTemplate(){
public function getTemplate()
{
return $this->hasOne(WidgetTemplate::className(), ['id' => 'widget_template_id']);
}
......
......@@ -2,8 +2,8 @@
namespace hrzg\widget\models\crud;
use hrzg\widget\models\crud\base\WidgetTemplate as BaseWidgetTemplate;
use Yii;
use \hrzg\widget\models\crud\base\WidgetTemplate as BaseWidgetTemplate;
/**
* This is the model class for table "app_hrzg_widget_template".
......
......@@ -31,7 +31,6 @@ abstract class Widget extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
......@@ -40,16 +39,25 @@ abstract class Widget extends \yii\db\ActiveRecord
return 'app_hrzg_widget_content';
}
/**
* @inheritdoc
* @return \hrzg\widget\models\crud\query\WidgetQuery the active query used by this AR class.
*/
public static function find()
{
return new \hrzg\widget\models\crud\query\WidgetQuery(get_called_class());
}
/**
* Alias name of table for crud viewsLists all Area models.
* Change the alias name manual if needed later
* @return string
*/
public function getAliasModel($plural=false)
public function getAliasModel($plural = false)
{
if($plural){
if ($plural) {
return Yii::t('app', 'Widgets');
}else{
} else {
return Yii::t('app', 'Widget');
}
}
......@@ -105,35 +113,24 @@ abstract class Widget extends \yii\db\ActiveRecord
return array_merge(
parent::attributeHints(),
[
'id' => Yii::t('app', 'ID'),
'status' => Yii::t('app', 'Status'),
'widget_template_id' => Yii::t('app', 'Class Name'),
'default_properties_json' => Yii::t('app', 'Default Properties Json'),
'name_id' => Yii::t('app', 'Name Id'),
'container_id' => Yii::t('app', 'Container Id'),
'rank' => Yii::t('app', 'Rank'),
'route' => Yii::t('app', 'Route'),
'request_param' => Yii::t('app', 'Request Param'),
'access_owner' => Yii::t('app', 'Access Owner'),
'access_domain' => Yii::t('app', 'Access Domain'),
'access_read' => Yii::t('app', 'Access Read'),
'access_update' => Yii::t('app', 'Access Update'),
'access_delete' => Yii::t('app', 'Access Delete'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
'id' => Yii::t('app', 'ID'),
'status' => Yii::t('app', 'Status'),
'widget_template_id' => Yii::t('app', 'Class Name'),
'default_properties_json' => Yii::t('app', 'Default Properties Json'),
'name_id' => Yii::t('app', 'Name Id'),
'container_id' => Yii::t('app', 'Container Id'),
'rank' => Yii::t('app', 'Rank'),
'route' => Yii::t('app', 'Route'),
'request_param' => Yii::t('app', 'Request Param'),
'access_owner' => Yii::t('app', 'Access Owner'),
'access_domain' => Yii::t('app', 'Access Domain'),
'access_read' => Yii::t('app', 'Access Read'),
'access_update' => Yii::t('app', 'Access Update'),
'access_delete' => Yii::t('app', 'Access Delete'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
]);
}
/**
* @inheritdoc
* @return \hrzg\widget\models\crud\query\WidgetQuery the active query used by this AR class.
*/
public static function find()
{
return new \hrzg\widget\models\crud\query\WidgetQuery(get_called_class());
}
}
......@@ -18,7 +18,6 @@ abstract class WidgetTemplate extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
......@@ -27,16 +26,25 @@ abstract class WidgetTemplate extends \yii\db\ActiveRecord
return 'app_hrzg_widget_template';
}
/**
* @inheritdoc
* @return \hrzg\widget\models\crud\query\WidgetTemplateQuery the active query used by this AR class.
*/
public static function find()
{
return new \hrzg\widget\models\crud\query\WidgetTemplateQuery(get_called_class());
}
/**
* Alias name of table for crud viewsLists all Area models.
* Change the alias name manual if needed later
* @return string
*/
public function getAliasModel($plural=false)
public function getAliasModel($plural = false)
{
if($plural){
if ($plural) {
return Yii::t('app', 'WidgetTemplates');
}else{
} else {
return Yii::t('app', 'WidgetTemplate');
}
}
......@@ -74,23 +82,12 @@ abstract class WidgetTemplate extends \yii\db\ActiveRecord
return array_merge(
parent::attributeHints(),
[
'id' => Yii::t('app', 'ID'),
'name' => Yii::t('app', 'Name'),
'json_schema' => Yii::t('app', 'Json Schema'),
'twig_template' => Yii::t('app', 'Template'),
'id' => Yii::t('app', 'ID'),
'name' => Yii::t('app', 'Name'),
'json_schema' => Yii::t('app', 'Json Schema'),
'twig_template' => Yii::t('app', 'Template'),
]);
}
/**
* @inheritdoc
* @return \hrzg\widget\models\crud\query\WidgetTemplateQuery the active query used by this AR class.
*/
public static function find()
{
return new \hrzg\widget\models\crud\query\WidgetTemplateQuery(get_called_class());
}
}
......@@ -19,74 +19,97 @@ use hrzg\widget\models\crud\WidgetContent as WidgetModel;
class WidgetContent extends WidgetModel
{
/**
*
* @inheritdoc
* @return unknown
*/
public function rules() {
return [
[['id'], 'integer'],
[['status', 'widget_template_id', 'default_properties_json','name_id', 'container_id', 'rank', 'route', 'request_param', 'access_owner', 'access_domain', 'access_read', 'access_update', 'access_delete', 'created_at', 'updated_at'], 'safe'],
];
}
/**
*
* @inheritdoc
* @return unknown
*/
public function scenarios() {
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
*
* @param array $params
* @return ActiveDataProvider
*/
public function search($params) {
$query = WidgetModel::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'status', $this->status])
->andFilterWhere(['like', 'widget_template_id', $this->widget_template_id])
->andFilterWhere(['like', 'default_properties_json', $this->default_properties_json])
->andFilterWhere(['like', 'name_id', $this->name_id])
->andFilterWhere(['like', 'container_id', $this->container_id])
->andFilterWhere(['like', 'rank', $this->rank])
->andFilterWhere(['like', 'route', $this->route])
->andFilterWhere(['like', 'request_param', $this->request_param])
->andFilterWhere(['like', 'access_owner', $this->access_owner])
->andFilterWhere(['like', 'access_domain', $this->access_domain])
->andFilterWhere(['like', 'access_read', $this->access_read])
->andFilterWhere(['like', 'access_update', $this->access_update])
->andFilterWhere(['like', 'access_delete', $this->access_delete]);
return $dataProvider;
}
/**
*
* @inheritdoc
* @return unknown
*/
public function rules()
{
return [
[['id'], 'integer'],
[
[
'status',
'widget_template_id',
'default_properties_json',
'name_id',
'container_id',
'rank',
'route',
'request_param',
'access_owner',
'access_domain',
'access_read',
'access_update',
'access_delete',
'created_at',
'updated_at'
],
'safe'
],
];
}
/**
*
* @inheritdoc
* @return unknown
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = WidgetModel::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'status', $this->status])
->andFilterWhere(['like', 'widget_template_id', $this->widget_template_id])
->andFilterWhere(['like', 'default_properties_json', $this->default_properties_json])
->andFilterWhere(['like', 'name_id', $this->name_id])
->andFilterWhere(['like', 'container_id', $this->container_id])
->andFilterWhere(['like', 'rank', $this->rank])
->andFilterWhere(['like', 'route', $this->route])
->andFilterWhere(['like', 'request_param', $this->request_param])
->andFilterWhere(['like', 'access_owner', $this->access_owner])
->andFilterWhere(['like', 'access_domain', $this->access_domain])
->andFilterWhere(['like', 'access_read', $this->access_read])
->andFilterWhere(['like', 'access_update', $this->access_update])
->andFilterWhere(['like', 'access_delete', $this->access_delete]);
return $dataProvider;
}
}
......@@ -19,62 +19,66 @@ use hrzg\widget\models\crud\WidgetTemplate as WidgetTemplateModel;
class WidgetTemplate extends WidgetTemplateModel
{
/**
*
* @inheritdoc
* @return unknown
*/
public function rules() {
return [
[['id'], 'integer'],
[['name', 'json_schema', 'twig_template'], 'safe'],
];
}
/**
*
* @inheritdoc
* @return unknown
*/
public function scenarios() {
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
*
* @param array $params
* @return ActiveDataProvider
*/
public function search($params) {
$query = WidgetTemplateModel::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'json_schema', $this->json_schema])
->andFilterWhere(['like', 'twig_template', $this->twig_template]);
return $dataProvider;
}
/**
*
* @inheritdoc
* @return unknown
*/
public function rules()
{
return [
[['id'], 'integer'],
[['name', 'json_schema', 'twig_template'], 'safe'],
];
}
/**
*
* @inheritdoc
* @return unknown
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = WidgetTemplateModel::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'json_schema', $this->json_schema])
->andFilterWhere(['like', 'twig_template', $this->twig_template]);
return $dataProvider;
}
}
......@@ -6,9 +6,9 @@
*/
use yii\helpers\Html;
use dmstr\bootstrap\Tabs;
use yii\bootstrap\ActiveForm;
use \dmstr\bootstrap\Tabs;
use yii\helpers\Html;
/**
*
......
......@@ -20,18 +20,18 @@ use yii\widgets\ActiveForm;
<div class="widget-template-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
'action' => ['index'],
'method' => 'get',
]); ?>
<?php echo $form->field($model, 'id') ?>
<?php echo $form->field($model, 'id') ?>
<?php echo $form->field($model, 'name') ?>
<?php echo $form->field($model, 'name') ?>
<?php echo $form->field($model, 'json_schema') ?>
<?php echo $form->field($model, 'json_schema') ?>
<?php echo $form->field($model, 'twig_template') ?>
<?php echo $form->field($model, 'twig_template') ?>
<div class="form-group">
<?php echo Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
......
......@@ -20,21 +20,22 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="giiant-crud widget-template-create">
<h1>
<?php echo $model->getAliasModel() ?> <small>
<?php echo $model->name ?> </small>
<?php echo $model->getAliasModel() ?>
<small>
<?php echo $model->name ?> </small>
</h1>
<div class="clearfix crud-navigation">
<div class="pull-left">
<?php echo Html::a(
Yii::t('app', 'Cancel'),
\yii\helpers\Url::previous(),
['class' => 'btn btn-default']) ?>
<?php echo Html::a(
Yii::t('app', 'Cancel'),
\yii\helpers\Url::previous(),
['class' => 'btn btn-default']) ?>
</div>
</div>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
'model' => $model,
]); ?>
</div>
......@@ -6,9 +6,9 @@
*/
use yii\grid\GridView;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
/**
*
......@@ -23,72 +23,80 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="giiant-crud widget-template-index">
<?php // echo $this->render('_search', ['model' =>$searchModel]);
?>
?>
<?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>
<?php \yii\widgets\Pjax::begin([
'id' => 'pjax-main',
'enableReplaceState' => false,
'linkSelector' => '#pjax-main ul.pagination a, th a',
'clientOptions' => ['pjax:success' => 'function(){alert("yo")}']
]) ?>
<h1>
<?php echo $searchModel->getAliasModel(true) ?> <small>
<?php echo $searchModel->getAliasModel(true) ?>
<small>
List
</small>
</h1>
<div class="clearfix crud-navigation">
<div class="pull-left">
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'New'), ['create'], ['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> '.Yii::t('app', 'New'), ['create'],
['class' => 'btn btn-success']) ?>
</div>
<div class="pull-right">
<?php echo
\yii\bootstrap\ButtonDropdown::widget(
[
'id' => 'giiant-relations',
'encodeLabel' => false,
'label' => '<span class="glyphicon glyphicon-paperclip"></span> ' . Yii::t('app', 'Relations'),
'dropdown' => [
'options' => [
'class' => 'dropdown-menu-right'
],
'encodeLabels' => false,
'items' => []
],
'options' => [
'class' => 'btn-default'
]
]
);
?> </div>
\yii\bootstrap\ButtonDropdown::widget(
[
'id' => 'giiant-relations',
'encodeLabel' => false,
'label' => '<span class="glyphicon glyphicon-paperclip"></span> '.Yii::t('app', 'Relations'),
'dropdown' => [
'options' => [
'class' => 'dropdown-menu-right'
],
'encodeLabels' => false,
'items' => []
],
'options' => [
'class' => 'btn-default'
]
]
);
?> </div>
</div>
<div class="table-responsive">
<?php echo GridView::widget([
'layout' => '{summary}{pager}{items}{pager}',
'dataProvider' => $dataProvider,
'pager' => [
'class' => yii\widgets\LinkPager::className(),
'firstPageLabel' => Yii::t('app', 'First'),
'lastPageLabel' => Yii::t('app', 'Last') ],
'filterModel' => $searchModel,
'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
'headerRowOptions' => ['class'=>'x'],
'columns' => [
[
'class' => 'yii\grid\ActionColumn',
'urlCreator' => function($action, $model, $key, $index) {
// using the column name as key, not mapping to 'id' like the standard generator
$params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
$params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id . '/' . $action : $action;
return Url::toRoute($params);
},
'contentOptions' => ['nowrap'=>'nowrap']
],
'name',
],
]); ?>
'layout' => '{summary}{pager}{items}{pager}',
'dataProvider' => $dataProvider,
'pager' => [
'class' => yii\widgets\LinkPager::className(),
'firstPageLabel' => Yii::t('app', 'First'),
'lastPageLabel' => Yii::t('app', 'Last')
],
'filterModel' => $searchModel,
'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
'headerRowOptions' => ['class' => 'x'],
'columns' => [
[
'class' => 'yii\grid\ActionColumn',
'urlCreator' => function ($action, $model, $key, $index) {
// using the column name as key, not mapping to 'id' like the standard generator
$params = is_array($key) ? $key : [$model->primaryKey()[0] => (string)$key];
$params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id.'/'.$action : $action;
return Url::toRoute($params);
},
'contentOptions' => ['nowrap' => 'nowrap']
],
'name',
],
]); ?>
</div>
</div>
......
......@@ -13,7 +13,7 @@ use yii\helpers\Html;
* @var yii\web\View $this
* @var hrzg\widget\models\crud\WidgetTemplate $model
*/
$this->title = $model->getAliasModel() . $model->name . ', ' . Yii::t('app', 'Edit');
$this->title = $model->getAliasModel().$model->name.', '.Yii::t('app', 'Edit');
$this->params['breadcrumbs'][] = ['label' => $model->getAliasModel(true), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => (string)$model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Edit');
......@@ -21,16 +21,18 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'Edit');
<div class="giiant-crud widget-template-update">
<h1>
<?php echo $model->getAliasModel() ?> <small>
<?php echo $model->name ?> </small>
<?php echo $model->getAliasModel() ?>
<small>
<?php echo $model->name ?> </small>
</h1>
<div class="crud-navigation">
<?php echo Html::a('<span class="glyphicon glyphicon-eye-open"></span> ' . Yii::t('app', 'View'), ['view', 'id' => $model->id], ['class' => 'btn btn-default']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-eye-open"></span> '.Yii::t('app', 'View'),
['view', 'id' => $model->id], ['class' => 'btn btn-default']) ?>
</div>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
'model' => $model,
]); ?>
</div>
......@@ -6,12 +6,9 @@
*/
use dmstr\bootstrap\Tabs;
use dmstr\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
use yii\widgets\DetailView;
use yii\widgets\Pjax;
use dmstr\bootstrap\Tabs;
/**
*
......@@ -20,7 +17,7 @@ use dmstr\bootstrap\Tabs;
*/
$copyParams = $model->attributes;
$this->title = $model->getAliasModel() . $model->name;
$this->title = $model->getAliasModel().$model->name;
$this->params['breadcrumbs'][] = ['label' => $model->getAliasModel(true), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => (string)$model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'View');
......@@ -37,7 +34,8 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'View');
<?php endif; ?>
<h1>
<?php echo $model->getAliasModel() ?> <small>
<?php echo $model->getAliasModel() ?>
<small>
<?php echo $model->name ?> </small>
</h1>
......@@ -45,12 +43,17 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'View');
<div class="clearfix crud-navigation">
<!-- menu buttons -->
<div class='pull-left'>
<?php echo Html::a('<span class="glyphicon glyphicon-pencil"></span> ' . Yii::t('app', 'Edit'), ['update', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-copy"></span> ' . Yii::t('app', 'Copy'), ['create', 'id' => $model->id, 'WidgetTemplate '=>$copyParams], ['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'New'), ['create'], ['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-pencil"></span> '.Yii::t('app', 'Edit'),
['update', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-copy"></span> '.Yii::t('app', 'Copy'),
['create', 'id' => $model->id, 'WidgetTemplate ' => $copyParams],
['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> '.Yii::t('app', 'New'), ['create'],
['class' => 'btn btn-success']) ?>
</div>
<div class="pull-right">
<?php echo Html::a('<span class="glyphicon glyphicon-list"></span> ' . Yii::t('app', 'Full list'), ['index'], ['class'=>'btn btn-default']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-list"></span> '.Yii::t('app', 'Full list'), ['index'],
['class' => 'btn btn-default']) ?>
</div>
</div>
......@@ -60,39 +63,42 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'View');
<?php echo DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'model' => $model,
'attributes' => [
'id',
'name',
'php_class',
'json_schema:ntext',
'twig_template:ntext',
],
]); ?>
'json_schema:ntext',
'twig_template:ntext',
],
]); ?>
<hr/>
<?php echo Html::a('<span class="glyphicon glyphicon-trash"></span> ' . Yii::t('app', 'Delete'), ['delete', 'id' => $model->id],
[
'class' => 'btn btn-danger',
'data-confirm' => '' . Yii::t('app', 'Are you sure to delete this item?') . '',
'data-method' => 'post',
]); ?>
<?php echo Html::a('<span class="glyphicon glyphicon-trash"></span> '.Yii::t('app', 'Delete'),
['delete', 'id' => $model->id],
[
'class' => 'btn btn-danger',
'data-confirm' => ''.Yii::t('app', 'Are you sure to delete this item?').'',
'data-method' => 'post',
]); ?>
<?php $this->endBlock(); ?>
<?php echo Tabs::widget(
[
'id' => 'relation-tabs',
'encodeLabels' => false,
'items' => [ [
'label' => '<b class=""># '.$model->id.'</b>',
'content' => $this->blocks['hrzg\widget\models\crud\WidgetTemplate'],
'active' => true,
], ]
]
);
?>
[
'id' => 'relation-tabs',
'encodeLabels' => false,
'items' => [
[
'label' => '<b class=""># '.$model->id.'</b>',
'content' => $this->blocks['hrzg\widget\models\crud\WidgetTemplate'],
'active' => true,
],
]
]
);
?>
</div>
......@@ -6,9 +6,9 @@
*/
use yii\helpers\Html;
use dmstr\bootstrap\Tabs;
use yii\bootstrap\ActiveForm;
use \dmstr\bootstrap\Tabs;
use yii\helpers\Html;
/**
*
......
......@@ -20,41 +20,41 @@ use yii\widgets\ActiveForm;
<div class="widget-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
'action' => ['index'],
'method' => 'get',
]); ?>
<?php echo $form->field($model, 'id') ?>
<?php echo $form->field($model, 'id') ?>
<?php echo $form->field($model, 'status') ?>
<?php echo $form->field($model, 'status') ?>
<?php echo $form->field($model, 'widget_template_id') ?>
<?php echo $form->field($model, 'widget_template_id') ?>
<?php echo $form->field($model, 'default_properties_json') ?>
<?php // echo $form->field($model, 'name_id') ?>
<?php echo $form->field($model, 'default_properties_json') ?>
<?php // echo $form->field($model, 'container_id') ?>
<?php // echo $form->field($model, 'name_id') ?>
<?php // echo $form->field($model, 'rank') ?>
<?php // echo $form->field($model, 'container_id') ?>
<?php // echo $form->field($model, 'route') ?>
<?php // echo $form->field($model, 'rank') ?>
<?php // echo $form->field($model, 'request_param') ?>
<?php // echo $form->field($model, 'route') ?>
<?php // echo $form->field($model, 'access_owner') ?>
<?php // echo $form->field($model, 'request_param') ?>
<?php // echo $form->field($model, 'access_domain') ?>
<?php // echo $form->field($model, 'access_owner') ?>
<?php // echo $form->field($model, 'access_read') ?>
<?php // echo $form->field($model, 'access_domain') ?>
<?php // echo $form->field($model, 'access_update') ?>
<?php // echo $form->field($model, 'access_read') ?>
<?php // echo $form->field($model, 'access_delete') ?>
<?php // echo $form->field($model, 'access_update') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'access_delete') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?php echo Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
......
......@@ -20,21 +20,22 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="giiant-crud widget-create">
<h1>
<?php echo $model->getAliasModel() ?> <small>
<?php echo $model->name_id ?> </small>
<?php echo $model->getAliasModel() ?>
<small>
<?php echo $model->name_id ?> </small>
</h1>
<div class="clearfix crud-navigation">
<div class="pull-left">
<?php echo Html::a(
Yii::t('app', 'Cancel'),
\yii\helpers\Url::previous(),
['class' => 'btn btn-default']) ?>
<?php echo Html::a(
Yii::t('app', 'Cancel'),
\yii\helpers\Url::previous(),
['class' => 'btn btn-default']) ?>
</div>
</div>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
'model' => $model,
]); ?>
</div>
......@@ -6,9 +6,9 @@
*/
use yii\grid\GridView;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
/**
*
......@@ -23,83 +23,91 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="giiant-crud widget-index">
<?php // echo $this->render('_search', ['model' =>$searchModel]);
?>
?>
<?php \yii\widgets\Pjax::begin(['id'=>'pjax-main', 'enableReplaceState'=> false, 'linkSelector'=>'#pjax-main ul.pagination a, th a', 'clientOptions' => ['pjax:success'=>'function(){alert("yo")}']]) ?>
<?php \yii\widgets\Pjax::begin([
'id' => 'pjax-main',
'enableReplaceState' => false,
'linkSelector' => '#pjax-main ul.pagination a, th a',
'clientOptions' => ['pjax:success' => 'function(){alert("yo")}']
]) ?>
<h1>
<?php echo $searchModel->getAliasModel(true) ?> <small>
<?php echo $searchModel->getAliasModel(true) ?>
<small>
List
</small>
</h1>
<div class="clearfix crud-navigation">
<div class="pull-left">
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'New'), ['create'], ['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> '.Yii::t('app', 'New'), ['create'],
['class' => 'btn btn-success']) ?>
</div>
<div class="pull-right">
<?php echo
\yii\bootstrap\ButtonDropdown::widget(
[
'id' => 'giiant-relations',
'encodeLabel' => false,
'label' => '<span class="glyphicon glyphicon-paperclip"></span> ' . Yii::t('app', 'Relations'),
'dropdown' => [
'options' => [
'class' => 'dropdown-menu-right'
],
'encodeLabels' => false,
'items' => []
],
'options' => [
'class' => 'btn-default'
]
]
);
?> </div>
\yii\bootstrap\ButtonDropdown::widget(
[
'id' => 'giiant-relations',
'encodeLabel' => false,
'label' => '<span class="glyphicon glyphicon-paperclip"></span> '.Yii::t('app', 'Relations'),
'dropdown' => [
'options' => [
'class' => 'dropdown-menu-right'
],
'encodeLabels' => false,
'items' => []
],
'options' => [
'class' => 'btn-default'
]
]
);
?> </div>
</div>
<div class="table-responsive">
<?php echo GridView::widget([
'layout' => '{summary}{pager}{items}{pager}',
'dataProvider' => $dataProvider,
'pager' => [
'class' => yii\widgets\LinkPager::className(),
'firstPageLabel' => Yii::t('app', 'First'),
'lastPageLabel' => Yii::t('app', 'Last') ],
'filterModel' => $searchModel,
'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
'headerRowOptions' => ['class'=>'x'],
'columns' => [
[
'class' => 'yii\grid\ActionColumn',
'urlCreator' => function($action, $model, $key, $index) {
// using the column name as key, not mapping to 'id' like the standard generator
$params = is_array($key) ? $key : [$model->primaryKey()[0] => (string) $key];
$params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id . '/' . $action : $action;
return Url::toRoute($params);
},
'contentOptions' => ['nowrap'=>'nowrap']
],
'status',
'widget_template_id',
'container_id',
'route',
'name_id',
'rank',
'access_owner',
/*'request_param'*/
/*'access_read'*/
/*'access_update'*/
/*'access_delete'*/
/*'access_domain'*/
],
]); ?>
'layout' => '{summary}{pager}{items}{pager}',
'dataProvider' => $dataProvider,
'pager' => [
'class' => yii\widgets\LinkPager::className(),
'firstPageLabel' => Yii::t('app', 'First'),
'lastPageLabel' => Yii::t('app', 'Last')
],
'filterModel' => $searchModel,
'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'],
'headerRowOptions' => ['class' => 'x'],
'columns' => [
[
'class' => 'yii\grid\ActionColumn',
'urlCreator' => function ($action, $model, $key, $index) {
// using the column name as key, not mapping to 'id' like the standard generator
$params = is_array($key) ? $key : [$model->primaryKey()[0] => (string)$key];
$params[0] = \Yii::$app->controller->id ? \Yii::$app->controller->id.'/'.$action : $action;
return Url::toRoute($params);
},
'contentOptions' => ['nowrap' => 'nowrap']
],
'status',
'widget_template_id',
'container_id',
'route',
'name_id',
'rank',
'access_owner',
/*'request_param'*/
/*'access_read'*/
/*'access_update'*/
/*'access_delete'*/
/*'access_domain'*/
],
]); ?>
</div>
</div>
......
......@@ -13,7 +13,7 @@ use yii\helpers\Html;
* @var yii\web\View $this
* @var hrzg\widget\models\crud\WidgetContent $model
*/
$this->title = $model->getAliasModel() . $model->id . ', ' . Yii::t('app', 'Edit');
$this->title = $model->getAliasModel().$model->id.', '.Yii::t('app', 'Edit');
$this->params['breadcrumbs'][] = ['label' => $model->getAliasModel(true), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => (string)$model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Edit');
......@@ -21,16 +21,18 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'Edit');
<div class="giiant-crud widget-update">
<h1>
<?php echo $model->getAliasModel() ?> <small>
<?php echo $model->name_id ?> </small>
<?php echo $model->getAliasModel() ?>
<small>
<?php echo $model->name_id ?> </small>
</h1>
<div class="crud-navigation">
<?php echo Html::a('<span class="glyphicon glyphicon-eye-open"></span> ' . Yii::t('app', 'View'), ['view', 'id' => $model->id], ['class' => 'btn btn-default']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-eye-open"></span> '.Yii::t('app', 'View'),
['view', 'id' => $model->id], ['class' => 'btn btn-default']) ?>
</div>
<?php echo $this->render('_form', [
'model' => $model,
]); ?>
'model' => $model,
]); ?>
</div>
......@@ -6,12 +6,9 @@
*/
use dmstr\bootstrap\Tabs;
use dmstr\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
use yii\widgets\DetailView;
use yii\widgets\Pjax;
use dmstr\bootstrap\Tabs;
/**
*
......@@ -20,7 +17,7 @@ use dmstr\bootstrap\Tabs;
*/
$copyParams = $model->attributes;
$this->title = $model->getAliasModel() . $model->id;
$this->title = $model->getAliasModel().$model->id;
$this->params['breadcrumbs'][] = ['label' => $model->getAliasModel(true), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => (string)$model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'View');
......@@ -37,7 +34,8 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'View');
<?php endif; ?>
<h1>
<?php echo $model->getAliasModel() ?> <small>
<?php echo $model->getAliasModel() ?>
<small>
<?php echo $model->name_id ?> </small>
</h1>
......@@ -45,12 +43,16 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'View');
<div class="clearfix crud-navigation">
<!-- menu buttons -->
<div class='pull-left'>
<?php echo Html::a('<span class="glyphicon glyphicon-pencil"></span> ' . Yii::t('app', 'Edit'), ['update', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-copy"></span> ' . Yii::t('app', 'Copy'), ['create', 'id' => $model->id, 'Widget '=>$copyParams], ['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'New'), ['create'], ['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-pencil"></span> '.Yii::t('app', 'Edit'),
['update', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-copy"></span> '.Yii::t('app', 'Copy'),
['create', 'id' => $model->id, 'Widget ' => $copyParams], ['class' => 'btn btn-success']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-plus"></span> '.Yii::t('app', 'New'), ['create'],
['class' => 'btn btn-success']) ?>
</div>
<div class="pull-right">
<?php echo Html::a('<span class="glyphicon glyphicon-list"></span> ' . Yii::t('app', 'Full list'), ['index'], ['class'=>'btn btn-default']) ?>
<?php echo Html::a('<span class="glyphicon glyphicon-list"></span> '.Yii::t('app', 'Full list'), ['index'],
['class' => 'btn btn-default']) ?>
</div>
</div>
......@@ -60,50 +62,53 @@ $this->params['breadcrumbs'][] = Yii::t('app', 'View');
<?php echo DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'status',
'widget_template_id',
'default_properties_json:ntext',
'name_id',
'container_id',
'rank',
'route',
'request_param',
'access_owner',
'access_domain',
'access_read',
'access_update',
'access_delete',
'created_at',
'updated_at',
],
]); ?>
'model' => $model,
'attributes' => [
'id',
'status',
'widget_template_id',
'default_properties_json:ntext',
'name_id',
'container_id',
'rank',
'route',
'request_param',
'access_owner',
'access_domain',
'access_read',
'access_update',
'access_delete',
'created_at',
'updated_at',
],
]); ?>
<hr/>
<?php echo Html::a('<span class="glyphicon glyphicon-trash"></span> ' . Yii::t('app', 'Delete'), ['delete', 'id' => $model->id],
[
'class' => 'btn btn-danger',
'data-confirm' => '' . Yii::t('app', 'Are you sure to delete this item?') . '',
'data-method' => 'post',
]); ?>
<?php echo Html::a('<span class="glyphicon glyphicon-trash"></span> '.Yii::t('app', 'Delete'),
['delete', 'id' => $model->id],
[
'class' => 'btn btn-danger',
'data-confirm' => ''.Yii::t('app', 'Are you sure to delete this item?').'',
'data-method' => 'post',
]); ?>
<?php $this->endBlock(); ?>
<?php echo Tabs::widget(
[
'id' => 'relation-tabs',
'encodeLabels' => false,
'items' => [ [
'label' => '<b class=""># '.$model->id.'</b>',
'content' => $this->blocks['hrzg\widget\models\crud\Widget'],
'active' => true,
], ]
]
);
?>
[
'id' => 'relation-tabs',
'encodeLabels' => false,
'items' => [
[
'label' => '<b class=""># '.$model->id.'</b>',
'content' => $this->blocks['hrzg\widget\models\crud\Widget'],
'active' => true,
],
]
]
);
?>
</div>
......@@ -2,7 +2,6 @@
namespace _;
use insolita\wgadminlte\Box;
use yii\helpers\Html;
?>
......
......@@ -16,19 +16,23 @@ class TwigTemplate extends Widget
private $_view;
private $_properties;
public function run(){
public function run()
{
return $this->renderFile($this->_view, $this->_properties);
}
public function setProperties($value){
$this->_properties = $value;
public function getProperties()
{
return $this->_properties;
}
public function getProperties(){
return $this->_properties;
public function setProperties($value)
{
$this->_properties = $value;
}
public function setView($value){
public function setView($value)
{
$this->_view = $value;
}
}
......@@ -16,22 +16,25 @@ use yii\helpers\Json;
class WidgetContainer extends Widget
{
public function run(){
public function run()
{
\Yii::$app->params['backend.menuItems'][] = [
'label' => 'Edit widget',
'url' => ['/widgets/crud/widget/create']
];
#return "Widget";
return $this->renderWidgets();
}
private function queryWidgets(){
private function queryWidgets()
{
$models = WidgetContent::find()->all();
return $models;
}
private function renderWidgets(){
private function renderWidgets()
{
$html = '';
foreach ($this->queryWidgets() AS $widget) {
$properties = Json::decode($widget->default_properties_json);
......@@ -45,7 +48,8 @@ class WidgetContainer extends Widget
return $html;
}
private function createWidget(){
private function createWidget()
{
}
}
\ No newline at end of file
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