Skip to content

Commit

Permalink
Post saving improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
stanfortonski committed Jun 6, 2021
1 parent 1e02477 commit 534533d
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 39 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"lodash": "^4.17.21",
"perfect-scrollbar": "^1.5.1",
"resolve-url-loader": "^3.1.3",
"sass": "^1.34.1",
"sass": "~1.32.13",
"sass-loader": "^10.2.0",
"vue-template-compiler": "^2.6.13"
},
Expand Down
2 changes: 1 addition & 1 deletion public/js/admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bsCustomFileInput.init();
require('./scripts/tinymce');
require('./scripts/sidebar');
require('./scripts/proper-url');
require('./scripts/post-date');
16 changes: 16 additions & 0 deletions resources/js/scripts/post-date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const checkbox = document.querySelector('#is_visible');
const inputs = document.querySelector('#release-inputs');

function changeInputs(value){
if (value)
inputs.classList.add('d-none');
else inputs.classList.remove('d-none');
}

if (checkbox && inputs){
changeInputs(checkbox.checked);

checkbox.addEventListener('change', function(e){
changeInputs(e.target.checked);
});
}
20 changes: 10 additions & 10 deletions resources/views/admin/posts/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<thead class="thead-light">
<tr>
<th scope="col">{{ __('ID') }}</th>
<th scope="col">{{ __('Categories') }}</th>
<th scope="col">{{ __('thumbnail') }}</th>
<th scope="col">{{ __('title') }}</th>
<th scope="col">{{ __('description') }}</th>
<th scope="col">{{ __('Categories') }}</th>
<th scope="col">{{ __('Author') }}</th>
<th scope="col"></th>
</tr>
Expand All @@ -37,6 +37,15 @@
@php $content = $post->content()->first(); @endphp
<tr>
<th scope="row">{{ $post->id }}</th>
<td>
@if(!empty($post->thumbnail_path))
<img class="img-fluid" src="{{ $post->thumbnail }}" alt="{{ $content->title ?? '' }}" width="144" height="144">
@else
{{ __('No image') }}
@endif
</td>
<td>{{ $content->title ?? '' }}</td>
<td>{!! $content->description ?? '' !!}</td>
<td>
<ul class="list-unstyled">
@foreach($post->categories as $category)
Expand All @@ -49,15 +58,6 @@
@endforeach
<ul>
</td>
<td>
@if(!empty($post->thumbnail_path))
<img class="img-fluid" src="{{ $post->thumbnail }}" alt="{{ $content->title ?? '' }}" width="144" height="144">
@else
{{ __('No image') }}
@endif
</td>
<td>{{ $content->title ?? '' }}</td>
<td>{!! $content->description ?? '' !!}</td>
<td>{{ $post->author->full_name }}</td>
<td>
<div class="dropdown text-right">
Expand Down
48 changes: 25 additions & 23 deletions resources/views/admin/posts/save.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,6 @@
@endempty
</div>

<div class="form-group">
<div class="form-row">
<div class="col-md-8">
<label for="publish_at_date">{{ __('Publish At Date') }}</label>
<input type="date" id="publish_at_date" name="publish_at_date" class="form-control">{{ !empty($post->publish_at) ? $post->publish_at->format('Y-m-d') : '' }}
@error('publish_at_date')
<span class="form-text text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-md-4">
<label for="publish_at_time">{{ __('Publish At Time') }}</label>
<input type="time" id="publish_at_time" name="publish_at_time" class="form-control">{{ !empty($post->publish_at) ? $post->publish_at->format('H:i') : '' }}
@error('publish_at_time')
<span class="form-text text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
</div>

<div class="form-group">
<label for="tags">{{ __('Tags') }}</label>
<input type="text" id="tags" name="tags" class="form-control @error('tags') is-invalid @enderror" value="{{ $post->tags ?? old('tags') }}">
Expand All @@ -123,6 +100,31 @@
</div>
</div>

<div id="release-inputs">
<div class="form-group">
<div class="form-row">
<div class="col-md-8">
<label for="publish_at_date">{{ __('Publish At Date') }}</label>
<input type="date" id="publish_at_date" name="publish_at_date" class="form-control">{{ !empty($post->publish_at) ? $post->publish_at->format('Y-m-d') : '' }}
@error('publish_at_date')
<span class="form-text text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="col-md-4">
<label for="publish_at_time">{{ __('Publish At Time') }}</label>
<input type="time" id="publish_at_time" name="publish_at_time" class="form-control">{{ !empty($post->publish_at) ? $post->publish_at->format('H:i') : '' }}
@error('publish_at_time')
<span class="form-text text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
</div>
</div>

<div class="form-group">
<button type="submit" class="btn btn-primary">{{ $prefix }}</button>
</div>
Expand Down

0 comments on commit 534533d

Please sign in to comment.