Skip to content

Commit

Permalink
Field improvements, bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Terzi Eduard authored and endihunter committed Dec 25, 2020
1 parent bb064f5 commit b8b9462
Show file tree
Hide file tree
Showing 60 changed files with 1,036 additions and 926 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
},
"require-dev": {
"phpunit/phpunit": "^7.2",
"mockery/mockery": "^1.1"
"mockery/mockery": "^1.1",
"laravel/framework": "^8.20",
"laravel/laravel": "^8.5"
},
"autoload": {
"psr-4": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@
this.value = this.defaultValue || null;
}
}
</script>
</script>
3 changes: 0 additions & 3 deletions publishes/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
</div>
</div>
<div class="form-group">
<div class="pull-right">
<a href="#">Forgot password?</a>
</div>
<div class="pull-left">
<input name="remember_me" type="hidden" value="0"/>
<input type="checkbox" name="remember_me" value="1"/> {{ trans('administrator::buttons.remember_me') }}
Expand Down
2 changes: 1 addition & 1 deletion publishes/views/components/index/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="panel">
<div class="panel-body">
<form method="post" id="collection" action="{{ route('scaffold.batch', ['module' => $resource->url()]) }}">
<form method="post" id="collection" target="_self" action="{{ route('scaffold.batch', ['module' => $resource->url()]) }}">
<?php echo Form::hidden('batch_action', null, ['id' => 'batch_action']); ?>
<?php echo Form::token(); ?>

Expand Down
16 changes: 9 additions & 7 deletions publishes/views/components/table/row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
@endcomponent
@else
<tr>
<td style="width: 20%; min-width: 200px;">
{!! $label ?? '' !!}
@if (isset($description) && !empty($description))
<p class="small">{!! $description !!}</p>
@endif
</td>
<td>{!! $input ?? '' !!}</td>
@if(!empty($label))
<td style="width: 20%; min-width: 200px;">
{!! $label ?? '' !!}
@if (isset($description) && !empty($description))
<p class="small">{!! $description !!}</p>
@endif
</td>
@endif
<td {!! (!empty($label) ? '' : 'colspan="2"') !!}>{!! $input ?? '' !!}</td>
</tr>
@endif
6 changes: 3 additions & 3 deletions publishes/views/fields/belongs_to/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

@if ($searchable && $searchIn)
<instant-search
name="{{ $field->name() }}"
data-url="/cms/search/?searchable={{ $searchIn }}&field={{ $searchBy }}"
default-value="{{ (int) optional($field->value())->getKey() }}"
name="{{ $field->name() }}"
data-url="{{ $searchUrl }}"
default-value="{{ optional($field->value())->getKey() }}"
></instant-search>
@endif
8 changes: 7 additions & 1 deletion publishes/views/fields/enum/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{!! Form::select($field->name(), $options, $field->value(), $attributes) !!}
@if ('datalist' === $field->type)
{!! Form::text($field->name(), $field->value(), ['id' => $field->id(), 'class' => 'form-control', 'list' => "scaffold_{$field->id()}"]) !!}
{!! Form::datalist("scaffold_{$field->id()}", $field->options) !!}
@else
{{ Form::select($field->name(), $field->options ?? [], $field->value(), ['class' => 'form-control', 'multiple' => $field->isArray] + $field->getAttributes()) }}
@endif

2 changes: 1 addition & 1 deletion publishes/views/fields/enum/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span {!! ($color ? "class=\"label\" style=\"background-color: $color\"" : "" ) !!} >
{{ ($field->value() ? \Illuminate\Support\Arr::get($options, $field->value()) : '---') }}
{{ ($field->value() ? \Illuminate\Support\Arr::get($field->options, $field->value()) : '---') }}
</span>
2 changes: 1 addition & 1 deletion publishes/views/fields/has_many/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
asfa
<span class="warning">Not implemented</span>
6 changes: 3 additions & 3 deletions publishes/views/fields/has_many/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<span class="label label-success">
@if ($url)
<a href="{{ $url }}" style="color: white;">
<i class="fa fa-{{ $icon }}"></i>&nbsp;{{ $count }}
<i class="fa fa-{{ $field->icon }}"></i>&nbsp;{{ $count }}
</a>
@else
<i class="fa fa-{{ $icon }}"></i>&nbsp;{{ $count }}
<i class="fa fa-{{ $field->icon }}"></i>&nbsp;{{ $count }}
@endif
</span>
@endif
@endif
2 changes: 1 addition & 1 deletion publishes/views/fields/media/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id="{{ $field->id() }}"
:has-indicators="true"
:readonly="false"
conversion="{{ $conversion ?? 'default' }}"
conversion="{{ $field->conversion ?? 'default' }}"
:media="{{ $media }}"
:width="320"
></media-carousel>
4 changes: 2 additions & 2 deletions publishes/views/fields/media/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

<media-library
id="{{ $field->id() }}"
collection="{{ ($collection ?? 'default') }}"
collection="{{ ($field->collection ?? 'default') }}"
endpoint="{{ $endpoint }}"
></media-library>
></media-library>
2 changes: 1 addition & 1 deletion publishes/views/fields/radio/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@foreach($options as $optionValue => $optionLabel)
@foreach($field->options as $optionValue => $optionLabel)
<label for="{{ $id = \Illuminate\Support\Str::slug($field->id().'-'.$optionValue) }}" style="margin-right: 10px;">
{!! Form::radio($field->name(), $optionValue, null, ['id' => $id]) !!}
<span>{{ $optionLabel }}</span>
Expand Down
2 changes: 1 addition & 1 deletion publishes/views/fields/text/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{!! Form::text($field->name(), $field->value(), $attributes) !!}
{!! Form::text($field->name(), $field->value(), $attributes) !!}
8 changes: 7 additions & 1 deletion publishes/views/filters/enum.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{{ Form::select($field->name(), ['' => "&mdash;"] + ($options ?? []), $field->value(), ['class' => 'form-control']) }}
@if ('datalist' === $field->type)
{!! Form::text($field->name(), $field->value(), ['id' => $field->id(), 'class' => 'form-control', 'list' => "scaffold_{$field->id()}"]) !!}
{!! Form::datalist("scaffold_{$field->id()}", $field->options) !!}
@else
{{ Form::select($field->name(), ($field->isArray ? [] : ['' => "&mdash;"]) + ($field->options ?? []), $field->value(), ['class' => 'form-control', 'multiple' => $field->isArray] + $attributes) }}
@endif

2 changes: 1 addition & 1 deletion publishes/views/filters/number.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ Form::number($field->name(), $field->value(), ['class' => 'form-control']) }}
{{ Form::number($field->name(), $field->value(), ['class' => 'form-control'] + $attributes) }}
28 changes: 28 additions & 0 deletions publishes/views/layouts/print.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@inject('config', 'scaffold.config')

<!DOCTYPE html>
<html lang="en">
<head ng-app="Architector">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}">

<title>
{{ strip_tags($config->get('title')) }}
@if (isset($resource) && ($title = $resource->title()))
&raquo; {{ $title }}
@endif
</title>

@include('administrator::partials.styles')
@stack('scaffold.css')
<link rel="stylesheet" href="{{ mix('print.css', 'admin') }}">
</head>
<body style="background: white">
<div id="app">
<div class="contentpanel">
@yield('scaffold.content')
</div>
</div>
</body>
</html>
4 changes: 3 additions & 1 deletion publishes/views/view/model.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
{!! $element->render(\Terranet\Administrator\Scaffolding::PAGE_VIEW) !!}
@else
@component('administrator::components.table.row')
@slot('label', Form::label($element->id(), $element->title()))
@if(!$element->isHiddenLabel())
@slot('label', Form::label($element->id(), $element->title()))
@endif
@slot('description', $element->getDescription())
@slot('input', $element->render(\Terranet\Administrator\Scaffolding::PAGE_VIEW))
@endcomponent
Expand Down
35 changes: 18 additions & 17 deletions src/AdminRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ public function rules()
return [];
}

/**
* Resolve resource based on router parameters.
*
* @return null|Module
*/
public function resource(): ?Module
{
return once(function () {
return tap(Architect::resourceForKey($this->route()->parameter('module')), function ($resource) {
abort_if(is_null($resource), 404);
});
});
}

/**
* Resolve current model.
*
Expand All @@ -42,14 +28,29 @@ public function resource(): ?Module
public function resolveModel($id): ?Model
{
return once(function () use ($id) {
/** @var Finder $finder */
$finder = $this->resource()->finder();
if ($item = app('scaffold.model')) {
return $item;
}

if ($finder) {
if ($finder = $this->resource()->finder()) {
abort_unless($item = $finder->find($id), 404);
}

return $item ?? null;
});
}

/**
* Resolve resource based on router parameters.
*
* @return null|Module
*/
public function resource(): ?Module
{
return once(function () {
return tap(Architect::resourceForKey($this->route()->parameter('module')), function ($resource) {
abort_if(is_null($resource), 404);
});
});
}
}
Loading

0 comments on commit b8b9462

Please sign in to comment.