Skip to content

Commit bb6d01a

Browse files
committed
New version
1 parent c63ad22 commit bb6d01a

File tree

6 files changed

+163
-15
lines changed

6 files changed

+163
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"email": "[email protected]"
1212
}
1313
],
14-
"version": "0.1.3",
14+
"version": "0.2.0",
1515
"require": {
1616
"illuminate/html": "5.0.*@dev"
1717
},

src/Public/quickadmin/js/main.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
$(document).ready(function () {
2-
$('.datatable').dataTable();
2+
$('.datatable').dataTable({
3+
"iDisplayLength": 100,
4+
"aaSorting": []
5+
});
6+
$('.datepicker').datepicker({
7+
autoclose: true
8+
});
9+
$('.ckeditor').each(function () {
10+
CKEDITOR.replace($(this));
11+
})
312
});

src/Views/admin/partials/header.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
href="{{ url('quickadmin/css') }}/quickadmin-theme-default.css"/>
3030
<link rel="stylesheet"
3131
href="//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css"/>
32+
<link rel="stylesheet"
33+
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.standalone.min.css"/>
3234
</head>
3335

3436
<body class="page-header-fixed">
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
22
<script src="//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
3-
<script src="{{ url('quickadmin/js') }}/main.js"></script>
3+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.min.js"></script>
4+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/locales/bootstrap-datepicker.en-GB.min.js"></script>
5+
<script src="//cdn.ckeditor.com/4.5.4/full/ckeditor.js"></script>
6+
<script src="{{ url('quickadmin/js') }}/main.js"></script>
7+
8+
<script>
9+
10+
$('.datepicker').datepicker({
11+
autoclose: true,
12+
format: "{{ config('quickadmin.date_format_jquery') }}"
13+
});
14+
</script>

src/Views/qa/cruds/create.blade.php

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,20 @@
5050
</div>
5151
</div>
5252

53-
<hr />
53+
<hr/>
5454

5555
<h3>Add fields</h3>
5656

5757
<table class="table">
5858
<tbody id="generator">
59+
<tr>
60+
<td>Show in list</td>
61+
<td></td>
62+
<td></td>
63+
<td></td>
64+
<td></td>
65+
<td></td>
66+
</tr>
5967
@if(old('f_type'))
6068
@foreach(old('f_type') as $index => $fieldName)
6169
@include('tpl::crud_field_line', ['index' => $index])
@@ -68,11 +76,12 @@
6876

6977
<div class="form-group">
7078
<div class="col-md-12">
71-
<button type="button" id="addField" class="btn btn-success"><i class="fa fa-plus"></i> Add one more field</button>
79+
<button type="button" id="addField" class="btn btn-success"><i class="fa fa-plus"></i> Add one more field
80+
</button>
7281
</div>
7382
</div>
7483

75-
<hr />
84+
<hr/>
7685

7786
<div class="form-group">
7887
<div class="col-md-12">
@@ -88,32 +97,102 @@
8897
@include('tpl::crud_field_line', ['index' => ''])
8998
</tbody>
9099
</table>
100+
101+
<!-- Select for relationship column-->
102+
@foreach($models as $key => $model)
103+
<select name="f_relationship_field[{{ $key }}]" class="form-control relationship-field rf-{{ $key }}">
104+
<option value="">Select display field</option>
105+
@foreach($model as $key2 => $option)
106+
<option value="{{ $option }}"
107+
@if($option == old('f_relationship_field.'.$key)) selected @endif>{{ $option }}</option>
108+
@endforeach
109+
</select>
110+
@endforeach
111+
<!-- /Select for relationship column-->
91112
</div>
92113

93114
@endsection
94115

95116
@section('javascript')
96117
<script>
118+
function typeChange(e) {
119+
var val = $(e).val();
120+
// Hide all possible outputs
121+
$(e).parent().parent().find('.value').hide();
122+
$(e).parent().parent().find('.default_c').hide();
123+
$(e).parent().parent().find('.relationship').hide();
124+
$(e).parent().parent().find('.title').show().val('');
125+
$(e).parent().parent().find('.texteditor').hide();
126+
$(e).parent().parent().find('.size').hide();
127+
128+
// Show a checbox which enables/disables showing in list
129+
$(e).parent().parent().parent().find('.show2').show();
130+
$(e).parent().parent().parent().find('.show_hid').val(1);
131+
switch (val) {
132+
case 'radio':
133+
$(e).parent().parent().find('.value').show();
134+
break;
135+
case 'checkbox':
136+
$(e).parent().parent().find('.default_c').show();
137+
break;
138+
case 'relationship':
139+
$(e).parent().parent().find('.relationship').show();
140+
$(e).parent().parent().find('.title').hide().val('-');
141+
break;
142+
case 'textarea':
143+
$(e).parent().parent().find('.show2').hide();
144+
$(e).parent().parent().find('.show_hid').val(0);
145+
$(e).parent().parent().find('.texteditor').show();
146+
break;
147+
case 'file':
148+
$(e).parent().parent().find('.size').show();
149+
break;
150+
}
151+
}
152+
153+
function relationshipChange(e) {
154+
var val = $(e).val();
155+
$(e).parent().parent().find('.relationship-field').remove();
156+
var select = $('.rf-' + val).clone();
157+
$(e).parent().parent().find('.relationship-holder').html(select);
158+
}
159+
97160
$(document).ready(function () {
161+
$('.type').each(function () {
162+
typeChange($(this))
163+
});
164+
$('.relationship').each(function () {
165+
relationshipChange($(this))
166+
});
167+
168+
$('.show2').change(function () {
169+
var checked = $(this).is(":checked");
170+
if (checked) {
171+
$(this).parent().find('.show_hid').val(1);
172+
} else {
173+
$(this).parent().find('.show_hid').val(0);
174+
}
175+
});
176+
98177
// Add new row to the table of fields
99178
$('#addField').click(function () {
100179
var line = $('#line').html();
101180
var table = $('#generator');
102181
table.append(line);
103182
});
183+
104184
// Remove row from the table of fields
105185
$(document).on('click', '.rem', function () {
106186
$(this).parent().parent().remove();
107187
});
108188
109189
$(document).on('change', '.type', function () {
110-
var val = $(this).val();
111-
if(val == 'radio' || val == 'checkbox') {
112-
$(this).parent().parent().find('.value').show();
113-
}else{
114-
$(this).parent().parent().find('.value').hide();
115-
}
190+
typeChange($(this))
191+
});
192+
$(document).on('change', '.relationship', function () {
193+
relationshipChange($(this))
116194
});
117195
});
196+
118197
</script>
119198
@stop

src/Views/templates/crud_field_line.blade.php

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<tr>
2+
<td>
3+
<input type="hidden" name="f_show[]" value="1" class="show_hid">
4+
<input type="checkbox" value="1" checked class="show2">
5+
</td>
26
<td>
37
<select name="f_type[]" class="form-control type" required="required">
48
@foreach($fieldTypes as $key => $option)
@@ -7,13 +11,56 @@
711
@endforeach
812
</select>
913
<td>
10-
<input type="text" name="f_title[]" value="{{ old('f_title.'.$index) }}" class="form-control"
14+
<input type="text" name="f_title[]" value="{{ old('f_title.'.$index) }}" class="form-control title"
1115
required="required" placeholder="Field DB name">
16+
17+
<!-- File size limit -->
18+
<label class="size">File size limit (in MB):</label>
19+
<input type="text" name="f_size[]" value="{{ old('f_size.'.$index, '2') }}" class="form-control size"
20+
placeholder="File size limit (in MB)" style="display: none;">
21+
<!-- /File size limit -->
22+
23+
<!-- Value for radio button -->
1224
<input type="text" name="f_value[]" value="{{ old('f_value.'.$index) }}" class="form-control value"
1325
placeholder="Value" style="display: none;">
26+
<!-- /Value for radio button -->
27+
28+
<!-- Default value of a checkbox -->
29+
<select name="f_default[]" class="form-control default_c" style="display: none;">
30+
@foreach($defaultValuesCbox as $key => $option)
31+
<option value="{{ $key }}"
32+
@if($key == old('f_default.'.$index)) selected @endif>{{ $option }}</option>
33+
@endforeach
34+
</select>
35+
<!-- /Default value of a checkbox -->
36+
37+
<!-- Use ckeditor on textarea field -->
38+
<select name="f_texteditor[]" class="form-control texteditor" style="display: none;">
39+
<option>Use CKEDITOR</option>
40+
<option value="1"
41+
@if($key == old('f_texteditor.'.$index)) selected @endif>Yes
42+
</option>
43+
<option value="0"
44+
@if($key == old('f_texteditor.'.$index)) selected @endif>No
45+
</option>
46+
</select>
47+
<!-- /Use ckeditor on textarea field -->
48+
49+
<!-- Select for relationship -->
50+
<select name="f_relationship[]" class="form-control relationship" style="display: none;">
51+
<option value="">Select relationship</option>
52+
@foreach($crudsSelect as $key => $option)
53+
<option value="{{ $key }}"
54+
@if($key == old('f_relationship.'.$index)) selected @endif>{{ $option }}</option>
55+
@endforeach
56+
</select>
57+
<!-- /Select for relationship -->
58+
<div class="relationship-holder"></div>
59+
</td>
60+
<td>
61+
<input type="text" name="f_label[]" value="{{ old('f_label.'.$index) }}" class="form-control"
62+
required="required" placeholder="Field visual title">
1463
</td>
15-
<td><input type="text" name="f_label[]" value="{{ old('f_label.'.$index) }}" class="form-control"
16-
required="required" placeholder="Field visual title"></td>
1764
<td>
1865
<select name="f_validation[]" class="form-control" required="required">
1966
@foreach($fieldValidation as $key => $option)

0 commit comments

Comments
 (0)