Skip to content

Commit

Permalink
Changed Active Window $alias property to $label. Use defaultLabel() in
Browse files Browse the repository at this point in the history
order to set a default label. #1574
  • Loading branch information
nadar committed Oct 25, 2017
1 parent 516f035 commit 628c709
Show file tree
Hide file tree
Showing 24 changed files with 282 additions and 148 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. This projec
- [#1522](https://github.com/luyadev/luya/issues/1522) Text and Textarea NgRest plugins auto encode input data after find.
- [#1505](https://github.com/luyadev/luya/issues/1505) Minor API Breaks and removed deprecated methods.
- [#1341](https://github.com/luyadev/luya/issues/1341) Changed signature of `changePassword($newPassword)` in `luya\admin\aws\ChangePasswordInterface`.
- [#1574](https://github.com/luyadev/luya/issues/1574) Changed Active Window $alias property to $label. Use defaultLabel() in order to set a default label.
- [#1567](https://github.com/luyadev/luya/issues/1567) Discontinue development of Exporter Module.

### Added
Expand Down
6 changes: 1 addition & 5 deletions docs/guide/lesson-activewindow.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ As stated in the [ActiveWindow Documentation]() we'll have to add the button for
public function ngRestActiveWindows()
{
return [
['class' => \app\modules\addressbook\admin\aws\GroupEmailActiveWindow::className(), 'alias' => 'Email to group', 'icon' => 'email'],
['class' => \app\modules\addressbook\admin\aws\GroupEmailActiveWindow::className(), 'label' => 'Email to group', 'icon' => 'email'],
];
}
```
Expand Down Expand Up @@ -78,10 +78,6 @@ class GroupEmailActiveWindow extends ActiveWindow
{
public $module = '@addressbookadmin';

public $alias = 'Group Email Active Window';

public $icon = 'extension';

public function index()
{
return $this->render('index', [
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/ngrest-activewindow.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ Working with callbacks

## Attaching the Class

In order to add an Active Window into your NgRest config, you have to add the config in the {{luya\admin\ngrest\base\NgRestModel::ngRestActiveWindows()}} method. As the Active Window contains the {{yii\base\Object}} as extend class you can configure all public properties while loading the class. Below an example of how to load an Active Window class and defined `alias` and `icon` public properties. The alias and icon propierties does exist in every Active Window an can always be overwritten.
In order to add an Active Window into your NgRest config, you have to add the config in the {{luya\admin\ngrest\base\NgRestModel::ngRestActiveWindows()}} method. As the Active Window contains the {{yii\base\Object}} as extend class you can configure all public properties while loading the class. Below an example of how to load an Active Window class and defined `label` and `icon` public properties. The alias and icon propierties does exist in every Active Window an can always be overwritten.

```php
public function ngRestActiveWindows()
{
return [
['class' => \luya\admin\aws\TestActiveWindow::className(), 'alias' => 'My Window Alias', 'icon' => 'extension'],
['class' => \luya\admin\aws\TestActiveWindow::className(), 'label' => 'My Window Alias', 'icon' => 'extension'],
];
}
```
Expand Down
12 changes: 8 additions & 4 deletions envs/dev/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions modules/admin/src/aws/ChangePasswordActiveWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ class ChangePasswordActiveWindow extends ActiveWindow
* @var string The name of the module where the active windows is located in order to finde the view path.
*/
public $module = 'admin';

/**
* @var string The icon name from goolges material icon set (https://material.io/icons/)
*/
public $icon = 'vpn_key';

/**
* @var integer The minimum length of the password.
*/
public $minCharLength = 8;

/**
* The default action which is going to be requested when clicking the active window.
*
Expand All @@ -42,6 +38,14 @@ public function index()
return $this->render('index');
}

/**
* @inheritdoc
*/
public function defaultIcon()
{
return 'vpn_key';
}

/**
* The method which is going to change the password on the current model.
*
Expand Down
28 changes: 17 additions & 11 deletions modules/admin/src/aws/CoordinatesActiveWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,7 @@ class CoordinatesActiveWindow extends ActiveWindow
* @var string The name of the module where the active windows is located in order to finde the view path.
*/
public $module = '@admin';

/**
* @var string The name of of the ActiveWindow. This is displayed in the CRUD list.
*/
public $alias = 'Coordinates';

/**
* @var string The icon name from goolges material icon set (https://material.io/icons/)
*/
public $icon = 'pin_drop';


/**
* @var string Register your maps application and enter your api key here
* while configure the active window (https://console.developers.google.com).
Expand All @@ -46,6 +36,22 @@ public function init()
}
}

/**
* @inheritdoc
*/
public function defaultLabel()
{
return 'Coordinates';
}

/**
* @inheritdoc
*/
public function defaultIcon()
{
return 'pin_drop';
}

/**
* Renders the index file of the ActiveWindow.
*
Expand Down
26 changes: 16 additions & 10 deletions modules/admin/src/aws/DetailViewActiveWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ class DetailViewActiveWindow extends ActiveWindow
*/
public $module = '@admin';

/**
* @var string The name of of the ActiveWindow. This is displayed in the CRUD list.
*/
public $alias = 'Detail';

/**
* @var string The icon name from goolges material icon set (https://material.io/icons/)
*/
public $icon = 'zoom_in';

/**
* @var array a list of attributes to be displayed in the detail view. Each array element
* represents the specification for displaying one particular attribute.
Expand Down Expand Up @@ -95,6 +85,22 @@ class DetailViewActiveWindow extends ActiveWindow
*/
public $attributes;

/**
* @inheritdoc
*/
public function defaultLabel()
{
return 'Detail';
}

/**
* @inheritdoc
*/
public function defaultIcon()
{
return 'zoom_in';
}

/**
* Renders the index file of the ActiveWindow.
*
Expand Down
32 changes: 19 additions & 13 deletions modules/admin/src/aws/FlowActiveWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* public function ngRestActiveWindows()
* {
* return [
* ['class' => \luya\admin\aws\FlowActiveWindow::class, 'alias' => 'My Gallery'],
* ['class' => \luya\admin\aws\FlowActiveWindow::class, 'label' => 'My Gallery'],
* ];
* }
* ```
Expand All @@ -43,14 +43,28 @@ class FlowActiveWindow extends ActiveWindow
public $module = '@admin';

/**
* @var string The name of of the ActiveWindow. This is displayed in the CRUD list.
* @inheritdoc
*/
public $alias = 'Flow Uploader';
public function index()
{
return $this->render('index');
}

/**
* @inheritdoc
*/
public function defaultLabel()
{
return 'Flow Uploader';
}

/**
* @var string The icon name from goolges material icon set (https://material.io/icons/)
* @inheritdoc
*/
public $icon = 'cloud_upload';
public function defaultIcon()
{
return 'cloud_upload';
}

/**
* @inheritdoc
Expand All @@ -66,14 +80,6 @@ public function getModel()
return $model;
}

/**
* @inheritdoc
*/
public function index()
{
return $this->render('index');
}

/**
* Returns a list of uploaded images.
*
Expand Down
38 changes: 33 additions & 5 deletions modules/admin/src/aws/GroupAuthActiveWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Yii;
use luya\admin\ngrest\base\ActiveWindow;
use luya\admin\Module;

/**
* Active Window to set permissions for a specific Group, used in groups ngrest model.
Expand All @@ -18,11 +19,6 @@ class GroupAuthActiveWindow extends ActiveWindow
*/
public $module = 'admin';

/**
* @var string The icon name from goolges material icon set (https://material.io/icons/)
*/
public $icon = 'verified_user';

/**
* The default action which is going to be requested when clicking the ActiveWindow.
*
Expand All @@ -32,7 +28,27 @@ public function index()
{
return $this->render('index');
}

/**
* @inheritdoc
*/
public function defaultLabel()
{
return Module::t('model_group_btn_aws_groupauth');
}

/**
* @inheritdoc
*/
public function defaultIcon()
{
return 'verified_user';
}

/**
*
* @return boolean[]
*/
public function callbackSaveRights()
{
$rights = Yii::$app->request->post('data', []);
Expand Down Expand Up @@ -60,6 +76,10 @@ public function callbackSaveRights()
return ['success' => true];
}

/**
*
* @return number[][][]|string[]|array[]
*/
public function callbackGetRights()
{
return [
Expand All @@ -68,6 +88,10 @@ public function callbackGetRights()
];
}

/**
*
* @return string|array
*/
private function getAuthData()
{
$data = (new \yii\db\Query())->select('*')->from('admin_auth')->orderBy('module_name, alias_name ASC')->all();
Expand All @@ -85,6 +109,10 @@ private function getAuthData()
return $data;
}

/**
*
* @return number[][]
*/
private function getRightsData()
{
$query = (new \yii\db\Query())->select('*')->from('admin_group_auth')->where(['group_id' => $this->getItemId()])->all();
Expand Down
13 changes: 8 additions & 5 deletions modules/admin/src/aws/ImageSelectCollectionActiveWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ class ImageSelectCollectionActiveWindow extends ActiveWindow
*/
public $module = 'admin';

/**
* @var string The icon name from goolges material icon set (https://material.io/icons/)
*/
public $icon = 'photo_library';

/**
* @inheritdoc
*/
Expand All @@ -99,6 +94,14 @@ public function index()
'sortIndexFieldName' => $this->sortIndexFieldName,
]);
}

/**
* @inheritdoc
*/
public function defaultIcon()
{
return 'photo_library';
}

/**
* Load all images.
Expand Down
Loading

0 comments on commit 628c709

Please sign in to comment.