edit.blade.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. @extends('admin.partial.template-full')
  2. @section('section')
  3. </div>
  4. <div class="header bg-primary pb-3 mt-n4">
  5. <div class="container-fluid">
  6. <div class="header-body">
  7. <div class="row align-items-center py-4">
  8. <div class="col-lg-6 col-7">
  9. <p class="display-1 text-white mb-0">Newsroom - Edit</p>
  10. <p class="lead text-white my-0">Editing #{{$news->id}}</p>
  11. </div>
  12. <div class="col-lg-6 col-5">
  13. <div class="text-right">
  14. <button class="btn btn-danger px-4 mr-3 mb-1" style="font-size:13px;" id="btn-delete">Delete</button>
  15. @if($news->published_at)
  16. <a class="btn btn-dark px-4 mr-3 mb-1" style="font-size:13px;" href="{{$news->permalink()}}">View</a>
  17. @endif
  18. <button class="btn btn-success px-5 mb-1" style="font-size:13px;" onclick="saveForm()">Save</button>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="container-fluid mt-4">
  26. <div class="row justify-content-center">
  27. <div class="col-md-6 col-12">
  28. <div>
  29. <form method="post" id="editForm">
  30. @csrf
  31. <div class="form-group">
  32. <label for="title" class="small font-weight-bold text-muted text-uppercase">Title</label>
  33. <input type="text" class="form-control" id="title" name="title" value="{{$news->title}}">
  34. <p class="help-text mb-0 small font-weight-bold text-lighter">We recommend titles shorter than 80 characters.</p>
  35. </div>
  36. <div class="form-group">
  37. <label for="summary" class="small font-weight-bold text-muted text-uppercase">Summary</label>
  38. <textarea class="form-control" id="summary" name="summary" rows="3">{{$news->summary}}</textarea>
  39. </div>
  40. <div class="form-group">
  41. <label for="body" class="small font-weight-bold text-muted text-uppercase">Body</label>
  42. <textarea class="form-control" id="body" name="body" rows="6">{{$news->body}}</textarea>
  43. </div>
  44. <div class="form-group">
  45. <label for="category" class="small font-weight-bold text-muted text-uppercase">Category</label>
  46. <input type="text" class="form-control" id="category" name="category" value="{{$news->category}}">
  47. </div>
  48. <div class="form-group">
  49. <div class="custom-control custom-switch ml-5">
  50. <input type="checkbox" class="custom-control-input" id="published" name="published" {{$news->published_at ? 'checked="checked"' : ''}}>
  51. <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="published">Published</label>
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <div class="custom-control custom-switch ml-5">
  56. <input type="checkbox" class="custom-control-input" id="show_timeline" name="show_timeline" {{$news->show_timeline ? 'checked="checked"' : ''}}>
  57. <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="show_timeline">Show On Timelines</label>
  58. </div>
  59. </div>
  60. <div class="form-group">
  61. <div class="custom-control custom-switch ml-5">
  62. <input type="checkbox" class="custom-control-input" id="auth_only" name="auth_only" {{$news->auth_only ? 'checked="checked"' : ''}}>
  63. <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="auth_only">Logged in users only</label>
  64. </div>
  65. </div>
  66. <div class="form-group">
  67. <div class="custom-control custom-switch ml-5">
  68. <input type="checkbox" class="custom-control-input" id="show_link" name="show_link" {{$news->show_link ? 'checked="checked"' : ''}}>
  69. <label class="custom-control-label font-weight-bold text-uppercase text-muted" for="show_link">Show Read More Link</label>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <form id="delete-form" method="post">
  78. @method('delete')
  79. @csrf
  80. </form>
  81. @endsection
  82. @push('scripts')
  83. <script type="text/javascript">
  84. function saveForm() {
  85. if(!window.confirm('Are you sure you want to save?')) {
  86. return;
  87. }
  88. document.getElementById('editForm').submit();
  89. }
  90. $('#title').on('change keyup paste',function(e) {
  91. let el = $(this);
  92. let title = el.val()
  93. $('#preview_title').text(title);
  94. });
  95. $('#summary').on('change keyup paste',function(e) {
  96. let el = $(this);
  97. let title = el.val()
  98. $('#preview_summary').text(title);
  99. });
  100. $('#btn-delete').on('click', function(e) {
  101. e.preventDefault();
  102. if(window.confirm('Are you sure you want to delete this post?') == true) {
  103. document.getElementById('delete-form').submit();
  104. }
  105. })
  106. </script>
  107. @endpush