Skip to content

Commit 09739c2

Browse files
committed
new guide's content
1 parent 5ce8971 commit 09739c2

File tree

1 file changed

+104
-4
lines changed

1 file changed

+104
-4
lines changed

docs/guide/index.md

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ The second argument is a default value, which will be added to the localization
142142

143143
Further in the template we can see `create_button` section, which determines how "floating" action button looks like:
144144

145-
```php
145+
```html
146146
@section('create_button')
147147
<button class="frame__header-add" @click="AWES.emit('modal::leads.open')"><i class="icon icon-plus"></i></button>
148148
@endsection
@@ -158,9 +158,9 @@ Next goes `group filter` component:
158158

159159
If we click on one of the filters, we'll see that it modifies `is_public` URL's parameter to respective value. Our component will track these changes and send server requests to get filtered data. We will return to this topic when we'll create additional filters ourselves.
160160

161-
After filters, we can see one more very powerful component - context menu, which in this case, controls ordering our leads by their names.
161+
After filters, we can see one more very useful component - context menu, which in this case, controls ordering our leads by their names.
162162

163-
```php
163+
```html
164164
<context-menu button-class="filter__slink" right>
165165
<template slot="toggler">
166166
<span>{{ _p('pages.filter.sort_by', 'Sort by') }}</span>
@@ -174,7 +174,7 @@ Sorting is another topic we'll analyze in the future, when we'll build our custo
174174

175175
Next is the button to open main filters panel, for now, it only displays one parameter, but we'll add more, later:
176176

177-
```php
177+
```html
178178
<button class="filter__slink" @click="$refs.filter.toggle()">
179179
<i class="icon icon-filter" v-if="">
180180
<span class="icn-dot" v-if="$awesFilters.state.active['leads']"></span>
@@ -193,3 +193,103 @@ Next is the button to open main filters panel, for now, it only displays one par
193193
</slide-up-down>
194194
```
195195
<img src="https://static.awes.io/docs/guide/03_main_filters.png" alt="Awes.io">
196+
197+
Next, we see the usage of one of our most powerful component - Table Builder, which powers `@table` blade component for easy interactive tables set up:
198+
199+
```php
200+
@table([
201+
'name' => 'leads',
202+
'row_url' => route('leads.index') . '/{id}',
203+
'scope_api_url' => route('leads.scope'),
204+
'scope_api_params' => ['orderBy', 'is_public', 'name'],
205+
'default_data' => $leads
206+
])
207+
...
208+
```
209+
210+
And the last one is the modal window with leads creation form:
211+
212+
```html
213+
<modal-window name="leads" class="modal_formbuilder" title="Create">
214+
<form-builder url="" :disabled-dialog="true">
215+
<fb-input name="name" label="{{ _p('pages.leads.modal_add.name', 'Name') }}"></fb-input>
216+
</form-builder>
217+
</modal-window>
218+
```
219+
220+
We'll inspect Modal Window and Form Builder components in greater detail later when we'll update our current project.
221+
222+
# Let's build something new
223+
224+
We got a closer look at the general structure of a generated section. It's time to build something new and get into the platform's details.
225+
226+
## Improving existing filters
227+
228+
Let's go back to our group filter and update it to display leads with different statuses.
229+
230+
Firstly we need to create new migration and add the `status` column to our `leads` table:
231+
232+
```php
233+
// database/migrations/XXXX_XX_XX_XXXXXX_add_status_to_leads_table.php
234+
...
235+
Schema::table('leads', function (Blueprint $table) {
236+
$table->string('status');
237+
});
238+
...
239+
```
240+
After migrating, let's add directly to database table couple records with statuses `new` and `closed`:
241+
242+
<img src="https://static.awes.io/docs/guide/04_leads_with_statuses.png" alt="Awes.io">
243+
244+
Now if we refresh `/leads` page, we'll see that we need to add a new column to the table in order to see which status lead currently has:
245+
246+
<img src="https://static.awes.io/docs/guide/05_leads_without_statuses_table.png" alt="Awes.io">
247+
248+
It's time to slightly dive into `table-builder` package functionality. Firstly let's add new `status` column:
249+
250+
```html
251+
<tb-column name="name" label="{{ _p('pages.leads.table.col.name', 'Name') }}"></tb-column>
252+
<tb-column name="status" label="{{ _p('pages.leads.table.col.status', 'Status') }}"></tb-column>
253+
```
254+
255+
As you can see, we added a new `tb-column` tag. `Name` parameter is a key in the data object, which is just our `status` column name. And we're passing new language string to a label property, as we discussed earlier.
256+
257+
Now if we refresh lead's page, we'll see their statuses:
258+
259+
<img src="https://static.awes.io/docs/guide/06_leads_with_statuses_table.png" alt="Awes.io">
260+
261+
Let's go back to the group filter and slightly edit it to retrieve records by status:
262+
263+
```php
264+
// @filtergroup(['filter' => ['' => 'All', '1' => 'Public', '0' => 'Private'], 'variable' => 'is_public'])
265+
@filtergroup(['filter' => ['' => 'All', 'new' => 'New', 'closed' => 'Closed'], 'variable' => 'status'])
266+
```
267+
268+
Normally we'd have to implement some filtering logic, but thanks to `awes-io/repository` package, all we need to do is to add `status` parameter to `searchable` property in `App\Sections\Leads\Repositories\LeadRepository`:
269+
270+
```php
271+
protected $searchable = ['status'];
272+
```
273+
274+
and add `status` to `@table`'s `scope_api_params` property (this will allow the component to track any changes in parameter value and handle them respectively):
275+
276+
```php
277+
// 'scope_api_params' => ['orderBy', 'is_public', 'name'],
278+
'scope_api_params' => ['orderBy', 'is_public', 'name', 'status'],
279+
```
280+
281+
now if we click on filter option, request with `status` parameter will be sent to the server and `repository` package will filter data and return it for `table-builder` to render:
282+
283+
<img src="https://static.awes.io/docs/guide/07_group_filter_by_status.png" alt="Awes.io">
284+
285+
It's that easy, more info on filtering can be found in [awes-io/repository documentation](https://github.com/awes-io/repository).
286+
287+
## Implementing new filters
288+
289+
We've updated the existing filter, but what if we want to build a custom filter of some kind for our lead management UI?
290+
291+
## New sorting
292+
293+
## Customizing table
294+
295+
## Creating and updating leads

0 commit comments

Comments
 (0)