Skip to content

Commit

Permalink
Merge pull request crocodic-studio#1676 from renzocastillo/datamodal-…
Browse files Browse the repository at this point in the history
…features

datamodal height and datamodal pagination
  • Loading branch information
fherryfherry authored Jun 18, 2021
2 parents 0bce1b9 + 379cec7 commit d967d31
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions docs/en/form-datamodal.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ $this->form[] = ['label'=>'Product Name','name'=>'products_id','type'=>'datamoda
| datamodal_columns_alias (Required) | E.g : `Name,Description,Price` | alias of fields |
| datamodal_where | E.g : `id != 1` | Sql query where |
| datamodal_size | E.g : `large` or `default` | popup size |
| datamodal_height | E.g : `500px` | modal height |
| datamodal_paginate | E.g : `10` | results pagination |

## What's Next
- [Form Input Type: date](./form-date.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/en/how-to-make-a-child-form.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $this->form[] = ['label'=>'Orders Detail','name'=>'orders_detail','type'=>'child
| select | datatable - e.g : 'tableName,fieldName' |
| radio | dataenum - e.g : ['a','b','c [, ...]] |
| upload | upload_type - (image,file) |
| datamodal | datamodal_table,datamodal_columns,datamodal_select_to,datamodal_where,datamodal_size |
| datamodal | datamodal_table,datamodal_columns,datamodal_select_to,datamodal_where,datamodal_size,datamodal_height,datamodal_paginate |

## What's Next
- [How To Make The Graded Select Boxes (Parent Select -> Child Select -> Etc..)](./how-make-graded-select-box.md)
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/CBController.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ public function getModalData()
$where = urldecode($where);
$columns = request('columns');
$columns = explode(",", $columns);

$paginate=request('paginate');
$paginate = urldecode($paginate);
$table = CRUDBooster::parseSqlTable($table)['table'];
$tablePK = CB::pk($table);
$result = DB::table($table);
Expand All @@ -730,7 +731,7 @@ public function getModalData()

$result->orderby($tablePK, 'desc');

$data['result'] = $result->paginate(6);
$data['result'] = $result->paginate($paginate?:6);
$data['columns'] = $columns;

return view('crudbooster::default.type_components.datamodal.browser', $data);
Expand Down
4 changes: 2 additions & 2 deletions src/views/default/type_components/child/component.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class='fa fa-search'></i> {{cbLang('datamodal_browse_data')}}</button>

@push('bottom')
<script type="text/javascript">
var url_{{$name_column}} = "{{CRUDBooster::mainpath('modal-data')}}?table={{$col['datamodal_table']}}&columns=id,{{$col['datamodal_columns']}}&name_column={{$name_column}}&where={{urlencode($col['datamodal_where'])}}&select_to={{ urlencode($col['datamodal_select_to']) }}&columns_name_alias={{urlencode($col['datamodal_columns_alias'])}}";
var url_{{$name_column}} = "{{CRUDBooster::mainpath('modal-data')}}?table={{$col['datamodal_table']}}&columns=id,{{$col['datamodal_columns']}}&name_column={{$name_column}}&where={{urlencode($col['datamodal_where'])}}&select_to={{ urlencode($col['datamodal_select_to']) }}&columns_name_alias={{urlencode($col['datamodal_columns_alias'])}}&paginate={{urlencode($col['datamodal_paginate'])}}";
var url_is_setted_{{$name_column}} = false;
function showModal{{$name_column}}() {
Expand Down Expand Up @@ -121,7 +121,7 @@ class='fa fa-search'></i> {{cbLang('datamodal_browse_data')}} {{$col['label']}}
</h4>
</div>
<div class="modal-body">
<iframe id='iframe-modal-{{$name_column}}' style="border:0;height: 430px;width: 100%"
<iframe id='iframe-modal-{{$name_column}}' style="border:0;height:{{$col['datamodal_height']?: "430px"}};width: 100%"
src=""></iframe>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class='fa fa-edit'></i> {{$form['label']}}</a>

@push('bottom')
<script type="text/javascript">
var url_{{$name}} = "{{CRUDBooster::mainpath('modal-data')}}?table={{$form['datamodal_table']}}&columns=id,{{$form['datamodal_columns']}}&name_column={{$name}}&where={{urlencode($form['datamodal_where'])}}&select_to={{ urlencode($form['datamodal_select_to']) }}&columns_name_alias={{ urlencode($form['datamodal_columns_alias']) }}";
var url_{{$name}} = "{{CRUDBooster::mainpath('modal-data')}}?table={{$form['datamodal_table']}}&columns=id,{{$form['datamodal_columns']}}&name_column={{$name}}&where={{urlencode($form['datamodal_where'])}}&select_to={{ urlencode($form['datamodal_select_to']) }}&columns_name_alias={{ urlencode($form['datamodal_columns_alias']) }}&paginate={{urlencode($form['datamodal_paginate'])}}";
function showModal{{$name}}() {
$('#iframe-modal-{{$name}}').attr('src', url_{{$name}});
Expand Down Expand Up @@ -68,7 +68,7 @@ function selectAdditionalData{{$name}}(select_to_json) {
<h4 class="modal-title"><i class='fa fa-search'></i> {{cbLang('datamodal_browse_data')}} | {{$form['label']}}</h4>
</div>
<div class="modal-body">
<iframe id='iframe-modal-{{$name}}' style="border:0;height: 430px;width: 100%" src=""></iframe>
<iframe id='iframe-modal-{{$name}}' style="border:0;height:{{$form['datamodal_height']?: "430px"}};width: 100%" src=""></iframe>
</div>

</div><!-- /.modal-content -->
Expand Down

0 comments on commit d967d31

Please sign in to comment.