Skip to content

Commit 78cc3ba

Browse files
committed
guide
1 parent f29e213 commit 78cc3ba

File tree

5 files changed

+38
-36
lines changed

5 files changed

+38
-36
lines changed

docs/guide/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
+ [Forms in Blocks](lesson-blockform.md)
7474
+ [Image slider Block](lesson-imagesliderblock.md)
7575
+ [Admin and Frontend module](lesson-module.md)
76-
+ [Create an ActiveWindow](lesson-activewindow.md)
76+
+ [Create an Active Window](lesson-activewindow.md)
7777
+ [Custom Angular Controller and Admin View](lesson-admin-custom-angular-view.md)
7878
+ Developers
7979
+ [Create Package (ext/module)](luya-package-dev.md)

docs/guide/lesson-activewindow.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# How to create a LUYA ActiveWindow
1+
# How to create a LUYA Active Window
22

33
In this lesson we are going to add a special email function to the [address book](https://github.com/luyadev/luya-module-addressbook) which we have created in the [previous lesson](https://github.com/luyadev/luya/blob/master/docs/guide/lesson-module.md). We will extend the original CRUD view for the contact group list in the CMS with another button. This button will open a window overlay which will give us the possibility to freely add custom actions and views. In our case, we want to add the feature to send all contacts in the group list an email.
44

5-
We will learn how to add and integrate an [ActiveWindow](https://luya.io/guide/ngrest-activewindow) to an existing LUYA module.
5+
We will learn how to add and integrate an [Active Window](https://luya.io/guide/ngrest-activewindow) to an existing LUYA module.
66

7-
## Creating the ActiveWindow
7+
## Creating the Active Window
88

9-
As in the previous examples we will use a LUYA code wizard to create a generic base for our ActiveWindow:
9+
As in the previous examples we will use a LUYA code wizard to create a generic base for our Active Window:
1010

1111
```sh
1212
./vendor/bin/luya admin/active-window/create
1313
```
1414
See the GIF below:
1515

16-
![Creating an ActiveWindow](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aws-create.gif "Creating an ActiveWindow with LUYA code wizard")
16+
![Creating an Active Window](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aws-create.gif "Creating an Active Window with LUYA code wizard")
1717

18-
## Adding the ActiveWindow to our group model
18+
## Adding the Active Window to our group model
1919

20-
As stated in the [ActiveWindow Documentation]() we will have to add the button for opening the ActiveWindow view in the associated model file. As we want to send the emails for every group, we have to modify the `addressbook/model/Group.php` and add the function `ngRestConfig` as the declaration is missing in our case:
20+
As stated in the [Active Window Documentation]() we will have to add the button for opening the Active Window view in the associated model file. As we want to send the emails for every group, we have to modify the `addressbook/model/Group.php` and add the function `ngRestConfig` as the declaration is missing in our case:
2121

2222
```php
2323
public function ngRestActiveWindows()
@@ -29,7 +29,7 @@ public function ngRestActiveWindows()
2929
```
3030

3131
If the function is already defined, just add the `GroupEmailActiveWindow' entry as shown above.
32-
This includes linking to the correct class definition of the ActiveWindow, adding a text and a meaningful icon for the button.
32+
This includes linking to the correct class definition of the Active Window, adding a text and a meaningful icon for the button.
3333

3434
## Configuring the mail LUYA component
3535

@@ -53,17 +53,17 @@ The next step is to actual declare our functions which are needed to send the em
5353

5454
## Adding the email function
5555

56-
Next, we will define a callback function `CallbackSendMail` in our generated ActiveWindow class in `modules/addressbook/admin/aws/GroupEmailActiveWindow` which will be called by the view later. We will define `$subject` and `$text` as input parameters which will contain the email subject and text body. Additionally we will extend the call to the *index view* by adding the contact list as a parameter to the view call. Of course, this function have to be defined before in the `modules/addressbook/models/Group` model by adding:
56+
Next, we will define a callback function `CallbackSendMail` in our generated Active Window class in `modules/addressbook/admin/aws/GroupEmailActiveWindow` which will be called by the view later. We will define `$subject` and `$text` as input parameters which will contain the email subject and text body. Additionally we will extend the call to the *index view* by adding the contact list as a parameter to the view call. Of course, this function have to be defined before in the `modules/addressbook/models/Group` model by adding:
5757

5858
```php
5959
public function getContacts()
6060
{
6161
return $this->hasMany(Contact::class, ["group_id" => "id"]);
6262
}
6363
```
64-
Now we are able to use `$this->model->contacts` in our ActiveWindow class. It is important to note, that we can use `$this->model`, because we hooked the ActiveWindow in the *ngRestConfig* function. To fetch data it is highly advised to define additional function in the model class, like it has shown above and does not fall back to something like `Model::find()->select([...])->all()`.
64+
Now we are able to use `$this->model->contacts` in our Active Window class. It is important to note, that we can use `$this->model`, because we hooked the Active Window in the *ngRestConfig* function. To fetch data it is highly advised to define additional function in the model class, like it has shown above and does not fall back to something like `Model::find()->select([...])->all()`.
6565

66-
With this said, here is the complete code snippet for the ActiveWindow class:
66+
With this said, here is the complete code snippet for the Active Window class:
6767

6868
```php
6969
<?php
@@ -102,15 +102,15 @@ class GroupEmailActiveWindow extends ActiveWindow
102102
}
103103
```
104104

105-
By using `sendSuccess` and `sendError` we are able to use the CMS message system and trigger the closing of the ActiveWindow. See in the next chapter how we will use a special form option for this.
105+
By using `sendSuccess` and `sendError` we are able to use the CMS message system and trigger the closing of the Active Window. See in the next chapter how we will use a special form option for this.
106106

107107
Do not forget to include the used namespaces in the header.
108108
And please note, that we have stripped the comments from the generated file to minimize the code snippet.
109109

110-
## Creating the ActiveWindow view
110+
## Creating the Active Window view
111111

112112
The last step includes the creation of our needed `index.php` view file in `modules/addressbook/admin/views/aws/groupemail`.
113-
One of the main purpose of the concept of an ActiveWindow is to be able to define your own views and functionality outside the CRUD view.
113+
One of the main purpose of the concept of an Active Window is to be able to define your own views and functionality outside the CRUD view.
114114
In our view we will include an overview of all contacts in the group, similar to the CRUD view and add an embedded email form with the email subject input field and a textarea for the actual email text:
115115

116116
```php
@@ -148,12 +148,12 @@ use luya\admin\ngrest\aw\ActiveWindowFormWidget;
148148
<?php $form::end(); ?>
149149
```
150150

151-
As you can see, we have used the {{luya\admin\ngrest\aw\ActiveWindowFormWidget}}. Besides the {{luya\admin\ngrest\aw\CallbackButtonWidget}} it is mostly what you will need to create a simple ActiveWindow form with additional functionality.
151+
As you can see, we have used the {{luya\admin\ngrest\aw\ActiveWindowFormWidget}}. Besides the {{luya\admin\ngrest\aw\CallbackButtonWidget}} it is mostly what you will need to create a simple Active Window form with additional functionality.
152152

153-
We configured the widget to use our defined callback function in the ActiveWindow class and show a button label. We have also used the option to close the ActiveWindow when receiving a success message from the callback.
153+
We configured the widget to use our defined callback function in the Active Window class and show a button label. We have also used the option to close the Active Window when receiving a success message from the callback.
154154

155155
## Result
156156

157-
After saving the view file, we have successfully added an ActiveWindow to the *addressbook* module. As you can see, it is fully integrated in our CRUD view, utilizes the already defined [bootstrap table styles](https://getbootstrap.com/docs/4.0/content/tables/) and uses the LUYA CMS notification service:
157+
After saving the view file, we have successfully added an Active Window to the *addressbook* module. As you can see, it is fully integrated in our CRUD view, utilizes the already defined [bootstrap table styles](https://getbootstrap.com/docs/4.0/content/tables/) and uses the LUYA CMS notification service:
158158

159-
![Showing the ActiveWindow](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aws-result.gif "Showing the ActiveWindow")
159+
![Showing the Active Window](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aws-result.gif "Showing the Active Window")

docs/guide/luya-console.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Admin UI commands:
3838
|`admin/storage/cleanup`|Cleanup not existing files compare file system and database.
3939
|`admin/storage/cleanup-image-table`|Find if duplications are available in the image table (same filter and file id). If confirmed it will remove all duplications except of one, the first one created.
4040
|`admin/storage/process-thumbnails`|Create all thumbnails for filemanager preview. Otherwise they are created on request load.
41-
|`admin/active-window/create`|Generate a [new ActiveWindow](ngrest-activewindow.md) class file based on your configuration.
41+
|`admin/active-window/create`|Generate a [new Active Window](ngrest-activewindow.md) class file based on your configuration.
4242
|`admin/crud/create`|Create new [NgRest CRUD](ngrest-concept.md) with a wizzard.
4343
|`admin/crud/model`|Generates only the [NgRestModel](ngrest-model.md). Usage `./vendor/bin/luya admin/crud/model "app\models\Customer"`
4444

docs/guide/luya-guideline.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ This represents a guideline how words and proper nouns should be written in the
2727

2828
+ LUYA – always capitalized
2929
+ ActiveRecord
30-
+ ActiveWindow
30+
+ Active Window
31+
+ Active Button
32+
+ Active Selection
3133
+ admin UI – instead of Admin, admin module or Admin UI
3234
+ AJAX
3335
+ AngularJS

docs/guide/ngrest-activewindow.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# NgRest ActiveWindow
1+
# NgRest Active Window
22

3-
An *NgRest ActiveWindow* is a concept to attach a modal window into a [NgRest CRUD list](ngrest-concept.md). The ActiveWindow is always bound to an **ID** of an item and is represented as a button with an icon and/or an alias, e.g. a button in the CRUD list:
3+
An *NgRest ActiveWindow* is a concept to attach a modal window into a [NgRest CRUD list](ngrest-concept.md). The Active Window is always bound to an **ID** of an item and is represented as a button with an icon and/or an alias, e.g. a button in the CRUD list:
44

5-
![button](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aw_button.png "ActiveWindow button")
5+
![button](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aw_button.png "Active Window button")
66

7-
An example of an ActiveWindow (Change Password) when clicked:
7+
An example of an Active Window (Change Password) when clicked:
88

9-
![overlay-window](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aw_window.png "ActiveWindow overlay")
9+
![overlay-window](https://raw.githubusercontent.com/luyadev/luya/master/docs/guide/img/aw_window.png "Active Window overlay")
1010

11-
## Create an ActiveWindow
11+
## Create an Active Window
1212

13-
> Use the [`admin/active-window` console command](luya-console.md) to generate a new ActiveWindow.
13+
> Use the [`admin/active-window` console command](luya-console.md) to generate a new Active Window.
1414
1515
A very basic example class with the name *TestActiveWindow* just renders an index and contains a callback:
1616

@@ -33,7 +33,7 @@ class TestActiveWindow extends \luya\admin\ngrest\base\ActiveWindow
3333
}
3434
```
3535

36-
Some general information about ActiveWindows:
36+
Some general information about Active Windows:
3737

3838
+ The property `$module` is required and is used to determine the path for the views files.
3939
+ The `index()` method is required and will always be the default method which is rendered by clicking on the button in the CRUD grid list.
@@ -46,11 +46,11 @@ Working with callbacks
4646

4747
Calling the callbacks
4848

49-
+ When a ActiveWindow callback is called the lower camelcase prefix method e.g. `callbackHelloWorld` must be called as `hello-world`.
49+
+ When a Active Window callback is called the lower camelcase prefix method e.g. `callbackHelloWorld` must be called as `hello-world`.
5050

5151
## Attaching the class
5252

53-
In order to add an ActiveWindow into your NgRest config it has to be added in the {{luya\admin\ngrest\base\NgRestModel::ngRestActive Windows()}} method. As the ActiveWindow contains the {{yii\base\BaseObject}} as extend class you can configure all public properties while the class is loading. Below, an example of how to load an ActiveWindow class and define `label` and `icon` public properties. The alias and icon properties are present in every ActiveWindow and can always be overridden.
53+
In order to add an Active Window into your NgRest config it has to be added in the {{luya\admin\ngrest\base\NgRestModel::ngRestActive Windows()}} method. As the Active Window contains the {{yii\base\BaseObject}} as extend class you can configure all public properties while the class is loading. Below, an example of how to load an Active Window class and define `label` and `icon` public properties. The alias and icon properties are present in every Active Window and can always be overridden.
5454

5555
```php
5656
public function ngRestActiveWindows()
@@ -78,7 +78,7 @@ This `My Windows Alias` button will only be shown for if the row `firstname` equ
7878

7979
### View files
8080

81-
To render view files you can run the method `$this->render()` inside your ActiveWindow class. The render method will lookup for PHP view file based on the base path of your `$module` property. Lets assume we run `$this->render('index')` and have defined `admin` as your `$module` property and your ActiveWindow name is `TestActiveWindow` this will try to find the view file under the path `@admin/views/aws/test/index.php`.
81+
To render view files you can run the method `$this->render()` inside your Active Window class. The render method will lookup for PHP view file based on the base path of your `$module` property. Lets assume we run `$this->render('index')` and have defined `admin` as your `$module` property and your Active Window name is `TestActiveWindow` this will try to find the view file under the path `@admin/views/aws/test/index.php`.
8282

8383
## How to make a Button
8484

@@ -137,7 +137,7 @@ public function callbackPostData($firstname, $lastname)
137137

138138
## AngularJS in view files
139139

140-
As the admin UI is written in AngularJS which let´s you easily create inline AngularJS controllers to interact with your ActiveWindow class.
140+
As the admin UI is written in AngularJS which let´s you easily create inline AngularJS controllers to interact with your Active Window class.
141141

142142
The below view file shows an AngularJS controller which collects data from the the controller assigned into the view but uses `ng-repeat to display and render the data.
143143

@@ -161,7 +161,7 @@ zaa.bootstrap.register('InlineController', ['$scope', function($scope) {
161161
</div>
162162
```
163163
164-
After the ActiveWindow response from the function `addToList` has received the ActiveWindow will be reloaded. This is just a very quick integration example and it does not give the user a true AngularJS experience but shows you how to deliver solutions in a very short time.
164+
After the Active Window response from the function `addToList` has received the Active Window will be reloaded. This is just a very quick integration example and it does not give the user a true AngularJS experience but shows you how to deliver solutions in a very short time.
165165
166166
When working with angular you might want to trigger some of the functions of the CRUD, here a list of what functions are callable and what they do:
167167
@@ -206,9 +206,9 @@ To disable permission checks, you have to set the `permissionLevel` to am empty
206206
...
207207
```
208208
209-
## Existing reusable ActiveWindows
209+
## Existing reusable Active Windows
210210
211-
The admin UI of LUYA provides some basic reusable ActiveWindows which you can reuse and use out of the box. Just attach them to your NgRest config with the given configuration. Take a look at the API reference for more details in how to attach the specific ActiveWindow.
211+
The admin UI of LUYA provides some basic reusable Active Windows which you can reuse and use out of the box. Just attach them to your NgRest config with the given configuration. Take a look at the API reference for more details in how to attach the specific Active Window.
212212
213213
|Class|Description
214214
|--|--|

0 commit comments

Comments
 (0)