Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
add feature collapse at header title form
Browse files Browse the repository at this point in the history
  • Loading branch information
fherryfherry committed Aug 8, 2016
1 parent 7d0183b commit 3034777
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 32 deletions.
24 changes: 13 additions & 11 deletions app/Http/Controllers/ControllerMaster/ModulsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function __construct() {
$this->col[] = array("label"=>"Group","field"=>"id_cms_moduls_group","join"=>"cms_moduls_group,nama_group");
$this->col[] = array("label"=>"Active","field"=>"is_active","callback_php"=>"(%field%)?'<span class=\"label label-success\">Active</span>':'<span class=\"label label-default\">Not Active</span>'");

$this->form = array();
$this->form = array();
$this->form[] = ['label'=>'Basic Configuration','type'=>'header'];
$this->form[] = array("label"=>"Name","name"=>"name","placeholder"=>"Enter a module name",);

$tables = DB::select('SHOW TABLES');
Expand All @@ -57,16 +58,18 @@ public function __construct() {



$this->form[] = array("label"=>"Table Name","name"=>"table_name","type"=>"select","dataenum"=>$tables_list);
$this->form[] = array("label"=>"Table Name","name"=>"table_name","type"=>"select","dataenum"=>$tables_list);


$this->form[] = ['label'=>'Advanced Configuration','type'=>'header',"collapsed"=>false];
$this->form[] = array("label"=>"Icon","name"=>"icon","type"=>"radio","dataenum"=>array(
"fa fa-bars|<i class='fa fa-bars'></i>",
"fa fa-cog|<i class='fa fa-cog'></i>",
"fa fa-comment|<i class='fa fa-comment'></i>",
"fa fa-users|<i class='fa fa-users'></i>",
"fa fa-file|<i class='fa fa-file'></i>",
"fa fa-database|<i class='fa fa-database'></i>",
"fa fa-bank|<i class='fa fa-bank'></i>",
"fa fa-bars|<i class='fa fa-bars'></i>",
"fa fa-bank|<i class='fa fa-bank'></i>",
"fa fa-check-square|<i class='fa fa-check-square'></i>",
"fa fa-car|<i class='fa fa-car'></i>",
"fa fa-eye|<i class='fa fa-eye'></i>",
Expand Down Expand Up @@ -98,16 +101,15 @@ public function __construct() {
$this->form[] = ['label'=>"Limit Data","name"=>"limit_data","type"=>"text","placeholder"=>"Example : 10"];
$this->form[] = array("label"=>"Delete Data Mode","name"=>"is_softdelete","type"=>"radio","dataenum"=>['1|Soft Delete','0|Permanent Delete'],"help"=>"Soft Delete Note : Please make sure you have column 'deleted_at' with data type TIMESTAMP","value"=>0);
$this->form[] = array("label"=>"Group","name"=>"id_cms_moduls_group","required"=>"required","type"=>"select","datatable"=>"cms_moduls_group,nama_group");
$this->form[] = array("label"=>"Active ?","name"=>"is_active","type"=>"select","dataenum"=>array("1|Active","0|Not Active"),"value"=>1);
$this->form[] = array("label"=>"Active ?","help"=>"Active to visible at sidebar menu, Not Active to unvisible","name"=>"is_active","type"=>"select","dataenum"=>array("1|Active","0|Not Active"),"value"=>1);

$url_find_sorting = action('ModulsController@getFindLastSorting');
$this->form[] = array("label"=>"Sorting","name"=>"sorting","jquery"=>"
$('#id_cms_moduls_group').change(function() {
var id = $(this).val();
$.get('$url_find_sorting/'+id,function(resp) {
$('#sorting').val(resp);
});
})
var id = '{{Request::segment(4)}}';
$.get('$url_find_sorting/'+id,function(resp) {
resp = parseInt(resp) + 1;
$('#sorting').val(resp);
});
","help"=>"Integer/Number");


Expand Down
87 changes: 66 additions & 21 deletions resources/views/admin/default/form_body.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,54 @@
margin-bottom: 10px;
border-bottom:1px solid #dddddd;
}
.header-title {
cursor: pointer;
}
</style>
<script type="text/javascript">
$(function() {
if (typeof event_header_click === 'undefined') {
event_header_click = true;
$(document).on("click",".header-title",function() {
console.log("header title click");
var index = $(this).attr('id').replace("header","");
var handel = $(this);
var parent = $(this).parent('.box-body');
var first_group = parent.find(".header-group-"+index+":first").is(":hidden");
if(first_group) {
parent.find(".header-group-"+index).slideDown(function() {
handel.find(".icon i").attr('class','fa fa-minus-square-o');
handel.attr("title","Click here to slide up");
});
}else{
parent.find(".header-group-"+index).slideUp(function() {
handel.find(".icon i").attr('class','fa fa-plus-square-o');
handel.attr("title","Click here to expand");
});
}
})
$(".header-title").each(function() {
var data_collapsed = $(this).attr('data-collapsed');
console.log("header title "+data_collapsed);
if(data_collapsed == 'false') {
console.log("collapsed false");
$(this).click();
}
})
}
})
</script>

<?php if(count($forms)==0):?>
<div class='callout callout-danger'>
<h4>Oops Sorry !</h4>
<p>Sorry this modul there is no feature for add new data</p>
</div>

<?php endif;?>
<?php

foreach($forms as $form):
<?php
$header_group_class = "";
foreach($forms as $index=>$form):
$name = $form['name'];
@$join = $form['join'];
Expand Down Expand Up @@ -67,11 +102,21 @@
if(Request::segment(3)=='edit' && $priv->is_edit==0) {
$disabled = 'disabled';
}
if($type=='header') {
$header_group_class = "header-group-$index";
}else{
$header_group_class = ($header_group_class)?:"header-group-$index";
}
?>

@if($type=='header' || $type=='heading')
<div class='form-divider'>
<h4><strong><i class='{{$form['icon']?:"fa fa-check-square-o"}}'></i> {{$form['label']}}</strong></h4>
<div id='header{{$index}}' data-collapsed="{{ ($form['collapsed']===false)?'false':'true' }}" class='header-title form-divider'>
<h4>
<strong><i class='{{$form['icon']?:"fa fa-check-square-o"}}'></i> {{$form['label']}}</strong>
<span class='pull-right icon'><i class='fa fa-minus-square-o'></i></span>
</h4>
</div>
@endif

Expand Down Expand Up @@ -124,7 +169,7 @@
font-weight: 300;
}
</style>
<div class='form-group peta'>
<div class='form-group peta {{$header_group_class}}'>
<input id="pac-input" class="controls" autofocus type="text"
placeholder="Enter a location">
<div id="type-selector" class="controls">
Expand Down Expand Up @@ -252,7 +297,7 @@ function setupClickListener(id, types) {
@endif

@if(@$type=='html')
<div class='form-group'>
<div class='form-group {{$header_group_class}}'>
{!!$form['html']!!}
</div>
@endif
Expand All @@ -276,14 +321,14 @@ function setupClickListener(id, types) {
})
</script>
<div class='form-group'>
<div class='form-group {{$header_group_class}}'>
<label>{{$form['label']}}</label>
<div id='qrcode_{{$name}}'></div>
</div>
@endif

@if(@$type=='checkbox')
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<?php
$value = explode(";",$value);
Expand Down Expand Up @@ -362,7 +407,7 @@ function setupClickListener(id, types) {


@if(@$type=='text' || @!$type)
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<input type='text' title="{{$form['label']}}" {{$required}} {{$readonly}} {!!$placeholder!!} {{$disabled}} class='form-control' @if($readonly=='') name="{{$name}}" @endif id="{{$name}}" value='{{$value}}'/>
<div class="text-danger">{{ $errors->first($name) }}</div>
Expand All @@ -371,7 +416,7 @@ function setupClickListener(id, types) {
@endif

@if(@$type=='browse')
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<div class="input-group">
<input type="text" class="form-control" id="{{$name.'_label'}}" {{$required}} readonly placeholder="Please browse data...">
Expand Down Expand Up @@ -469,7 +514,7 @@ function setupClickListener(id, types) {
@endif

@if(@$type=='date' || @$type=='datepicker')
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<div class="input-group">
<span class="input-group-addon"><i class='fa fa-calendar'></i></span>
Expand Down Expand Up @@ -498,7 +543,7 @@ function setupClickListener(id, types) {
})
</script>
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<div class='row'>
<div class='col-sm-3'>
Expand Down Expand Up @@ -531,7 +576,7 @@ function setupClickListener(id, types) {
@endif

@if(@$type=='textarea')
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<textarea name="{{$form['name']}}" id="{{$name}}" {{$required}} {{$readonly}} {!!$placeholder!!} {{$disabled}} class='form-control' rows='5'>{{ $value}}</textarea>
<div class="text-danger">{{ $errors->first($name) }}</div>
Expand All @@ -541,7 +586,7 @@ function setupClickListener(id, types) {


@if(@$type=='wysiwyg')
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script>
Expand All @@ -567,7 +612,7 @@ function setupClickListener(id, types) {
@endif

@if(@$type=='password')
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<input type='password' title="{{$form['label']}}" id="{{$name}}" {{$required}} {!!$placeholder!!} {{$readonly}} {{$disabled}} class='form-control' name="{{$name}}"/>
<div class="text-danger">{{ $errors->first($name) }}</div>
Expand Down Expand Up @@ -608,7 +653,7 @@ function setupClickListener(id, types) {
<?php
endif;
?>
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<select class='form-control' id="{{$name}}" data-value='{{$value}}' {{$required}} {!!$placeholder!!} {{$readonly}} {{$disabled}} name="{{$name}}">
<option value=''>** Please Select a {{$form['label']}}</option>
Expand Down Expand Up @@ -739,7 +784,7 @@ function setupClickListener(id, types) {
})
</script>
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
<select class='form-control' id="{{$name}}" {{$required}} {{$readonly}} {!!$placeholder!!} {{$disabled}} name="{{$name}}">

Expand All @@ -751,7 +796,7 @@ function setupClickListener(id, types) {


@if(@$type=='radio')
<div class='form-group' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label><br/>
<?php foreach($form['dataenum'] as $d):
$val = $lab = '';
Expand All @@ -776,7 +821,7 @@ function setupClickListener(id, types) {


@if(@$type=='upload')
<div class='form-group' id='form-group-{{$name}}' style="{{@$form['style']}}">
<div class='form-group {{$header_group_class}}' id='form-group-{{$name}}' style="{{@$form['style']}}">
<label>{{$form['label']}}</label>
@if($value)
<?php
Expand Down

0 comments on commit 3034777

Please sign in to comment.