Skip to content

Commit 0b91bdd

Browse files
committed
Update templates and fixes a bug in the boolean handling
1 parent 9ce2cc1 commit 0b91bdd

19 files changed

+119
-75
lines changed

src/Commands/FieldsFileCreateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static function getFields($input, $withoutPrimaryKey)
133133
$fields[] = $properties;
134134
}
135135

136-
return FieldTransformer::fieldsArray($fields, 'generic');
136+
return FieldTransformer::fromArray($fields, 'generic');
137137
}
138138

139139
/**

src/HtmlGenerators/StandardHtml.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ protected function getRawOptionValue($name, $value)
217217

218218
$valueString = is_null($value) ? 'null' : sprintf("'%s'", $value);
219219

220-
return sprintf("old('%s', isset(\$%s) ? \$%s->%s : %s)", $name, $modelName, $modelName, $name, $valueString);
220+
return sprintf("old('%s', isset(\$%s->%s) ? \$%s->%s : %s)", $name, $modelName, $name, $modelName, $name, $valueString);
221221
}
222222

223223
/**
@@ -238,7 +238,7 @@ protected function getMultipleRawOptionValue($name, $value)
238238
$valueString = starts_with('$', $value) ? sprintf("%s", $value) : sprintf("'%s'", $value);
239239
}
240240

241-
return sprintf("in_array(%s, old('%s', isset(\$%s) ? \$%s->%s : []))", $valueString, $name, $modelName, $modelName, $name);
241+
return sprintf("in_array(%s, old('%s', isset(\$%s->%s) ? \$%s->%s : []))", $valueString, $name, $modelName, $name, $modelName, $name);
242242
}
243243

244244
/**

src/Models/Field.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ public function getTrueBooleanOption()
709709
return null;
710710
}
711711

712-
$options = $this->getOptionsByLang();
712+
$options = $this->getOptionsByLang($this->defaultLang);
713713

714714
if (isset($options[1])) {
715715
return $options[1];
@@ -733,7 +733,7 @@ public function getFalseBooleanOption()
733733
return null;
734734
}
735735

736-
$options = $this->getOptionsByLang();
736+
$options = $this->getOptionsByLang($this->defaultLang);
737737

738738
if (isset($options[0])) {
739739
return $options[0];

src/Support/FieldTransformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function __construct($properties, $localeGroup)
149149
*
150150
* @return array Support\Field
151151
*/
152-
public static function text($fieldsString, $localeGroup)
152+
public static function fromText($fieldsString, $localeGroup)
153153
{
154154
$transformer = new self($fieldsString, $localeGroup);
155155

@@ -164,7 +164,7 @@ public static function text($fieldsString, $localeGroup)
164164
*
165165
* @return array
166166
*/
167-
public static function json($json, $localeGroup)
167+
public static function fromJson($json, $localeGroup)
168168
{
169169
if (empty($json) || ($fields = json_decode($json, true)) === null) {
170170
throw new Exception("The provided string is not a valid json.");
@@ -183,7 +183,7 @@ public static function json($json, $localeGroup)
183183
*
184184
* @return array
185185
*/
186-
public static function fieldsArray(array $collection, $localeGroup)
186+
public static function fromArray(array $collection, $localeGroup)
187187
{
188188
$transformer = new self($collection, $localeGroup);
189189

@@ -783,7 +783,7 @@ public static function transferOptionsToLabels(Field & $field, array $options, $
783783

784784
if (!is_array($option)) {
785785
// At this point the options are plain text without locale
786-
$finalOptions[] = new Label($option, $localeGroup, true, $lang);
786+
$finalOptions[] = new Label($option, $localeGroup, true, $lang, null, $value);
787787
continue;
788788
}
789789

src/Support/Helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public static function stringToBool($str)
156156
*/
157157
public static function getFields($fieldsLine, $langFile = 'generic')
158158
{
159-
return FieldTransformer::text($fieldsLine, $langFile);
159+
return FieldTransformer::fromText($fieldsLine, $langFile);
160160
}
161161

162162
/**
@@ -176,7 +176,7 @@ public static function getFieldsFromFile($fileName, $langFile = 'generic')
176176

177177
$file = File::get($fileFullname);
178178

179-
return FieldTransformer::json($file, $langFile);
179+
return FieldTransformer::fromJson($file, $langFile);
180180
}
181181

182182
/**

templates/default-collective/create.blade.stub

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<div class="panel-heading clearfix">
88

9-
<span class="pull-left">
10-
Create New [% model_name_class %]
11-
</span>
9+
<div class="pull-left">
10+
<h3 class="mt-2 mb-0">Create New [% model_name_class %]</h3>
11+
</div>
1212

13-
<div class="btn-group btn-group-xs pull-right" role="group">
13+
<div class="btn-group btn-group-sm pull-right" role="group">
1414

1515
<a href="{{ route('[% index_route_name %]') }}" class="btn btn-primary" title="Show all [% model_name_plural %]">
1616
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>

templates/default-collective/edit.blade.stub

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<div class="panel-heading clearfix">
88

9-
<span class="pull-left">
10-
{{ !empty([% model_header %]) ? [% model_header %] : '[% model_name %]'}}
11-
</span>
9+
<div class="pull-left">
10+
<h3 class="mt-2 mb-0">{{ !empty([% model_header %]) ? [% model_header %] : '[% model_name %]'}}</h3>
11+
</div>
1212

13-
<div class="btn-group btn-group-xs pull-right" role="group">
13+
<div class="btn-group btn-group-sm pull-right" role="group">
1414

1515
<a href="{{ route('[% index_route_name %]') }}" class="btn btn-primary" title="Show all [% model_name_plural %]">
1616
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[% form_fields_html %]
22
<div class="form-group">
33
<div class="col-md-offset-2 col-md-10">
4-
{!! Form::submit(isset($submitButtonLabel) ? $submitButtonLabel : 'Add', ['class' => 'btn btn-primary']) !!}
4+
{!! Form::submit(isset($submitButtonLabel) ? $submitButtonLabel : 'Add', ['class' => 'btn btn-success']) !!}
55
</div>
66
</div>

templates/default-collective/index.blade.stub

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
<div class="panel-heading clearfix">
2020

21-
<span class="pull-left">
22-
[% model_name_plural_cap %]
23-
</span>
21+
<div class="pull-left">
22+
<h3 class="mt-2 mb-0">[% model_name_plural_cap %]</h3>
23+
</div>
2424

25-
<div class="btn-group btn-group-xs pull-right" role="group">
25+
<div class="btn-group btn-group-sm pull-right" role="group">
2626

27-
<a href="{{ route('[% create_route_name %]') }}" class="btn btn-primary" title="Add [% model_name_class %]">
27+
<a href="{{ route('[% create_route_name %]') }}" class="btn btn-success" title="Add [% model_name_class %]">
2828
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
2929
</a>
3030

@@ -34,7 +34,7 @@
3434

3535
@if(count($[% model_name_plural %]) == 0)
3636
<div class="panel-body text-center">
37-
<h4>There are no records!</h4>
37+
<h4>There are no available records!</h4>
3838
</div>
3939
@else
4040
<div class="panel-body panel-body-with-table">
@@ -58,22 +58,23 @@
5858
'route' => ['[% destroy_route_name %]', $[% model_name %]->[% primary_key %]],
5959
'style' => 'display: inline;',
6060
]) !!}
61-
62-
<a href="{{ route('{{showRouteName}}', $[% model_name %]->[% primary_key %] ) }}" class="btn btn-success btn-xs" title="View [% model_name_class %]">
63-
<span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>
64-
</a>
65-
<a href="{{ route('[% edit_route_name %]', $[% model_name %]->[% primary_key %] ) }}" class="btn btn-primary btn-xs" title="Edit [% model_name_class %]">
66-
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
67-
</a>
68-
69-
{!! Form::button('<span class="glyphicon glyphicon-trash" aria-hidden="true" title="Delete [% model_name_class %]"></span>',
70-
[
71-
'type' => 'submit',
72-
'class' => 'btn btn-danger btn-xs',
73-
'title' => 'Delete [% model_name_class %]',
74-
'onclick' => 'return confirm("Confirm delete?")'
75-
])
76-
!!}
61+
<div class="btn-group btn-group-xs pull-right" role="group">
62+
<a href="{{ route('{{showRouteName}}', $[% model_name %]->[% primary_key %] ) }}" class="btn btn-info" title="View [% model_name_class %]">
63+
<span class="glyphicon glyphicon-open" aria-hidden="true"></span>
64+
</a>
65+
<a href="{{ route('[% edit_route_name %]', $[% model_name %]->[% primary_key %] ) }}" class="btn btn-primary" title="Edit [% model_name_class %]">
66+
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
67+
</a>
68+
69+
{!! Form::button('<span class="glyphicon glyphicon-trash" aria-hidden="true" title="Delete [% model_name_class %]"></span>',
70+
[
71+
'type' => 'submit',
72+
'class' => 'btn btn-danger',
73+
'title' => 'Delete [% model_name_class %]',
74+
'onclick' => 'return confirm("Confirm delete?")'
75+
])
76+
!!}
77+
</div>
7778
{!! Form::close() !!}
7879
</td>
7980
</tr>

templates/default-collective/layout-with-validation.stub

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@
4747
{
4848
padding: 0;
4949
}
50+
51+
.mt-2 {
52+
margin-top: 2px !important;
53+
}
5054

55+
.mb-0 {
56+
margin-bottom: 0 !important;
57+
}
5158
</style>
5259

5360
<!-- JavaScripts -->

0 commit comments

Comments
 (0)