v1.4.4 Made news expiration date, add category to app homepages, made small css things

This commit is contained in:
victor 2020-10-07 15:27:29 +02:00
parent f70d6a7a95
commit 22694bd0fb
15 changed files with 83 additions and 81 deletions

56
package-lock.json generated
View File

@ -1,57 +1,3 @@
{ {
"requires": true, "lockfileVersion": 1
"lockfileVersion": 1,
"dependencies": {
"@ckeditor/ckeditor5-alignment": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@ckeditor/ckeditor5-alignment/-/ckeditor5-alignment-21.0.0.tgz",
"integrity": "sha512-jtUc7g+9TKgNS819UD23tJSTJosp+VAk/fk+p1HJEgrq5YuH/F3djVwW4fyyJRuepbvYOObhOa2YHET1gtOuFw==",
"requires": {
"@ckeditor/ckeditor5-core": "^21.0.0",
"@ckeditor/ckeditor5-ui": "^21.0.0"
}
},
"@ckeditor/ckeditor5-core": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@ckeditor/ckeditor5-core/-/ckeditor5-core-21.0.0.tgz",
"integrity": "sha512-qoBLE0dGaxYHN6zetYe5ct/w9E3+iX9T2oCgHNbCD/zaYhxfNTQ9uHp7x6Hn4Zq0xyieUhNIeq+ZR9CJlBEMwA==",
"requires": {
"@ckeditor/ckeditor5-engine": "^21.0.0",
"@ckeditor/ckeditor5-utils": "^21.0.0",
"lodash-es": "^4.17.15"
}
},
"@ckeditor/ckeditor5-engine": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@ckeditor/ckeditor5-engine/-/ckeditor5-engine-21.0.0.tgz",
"integrity": "sha512-wa0Fmn62o1i4Jw0vHnCvtwqM2ARkIU2V2/6MUgWAez5gpAIFwSGu4kjUGeIbuHISAIGKIwtRIVAdL9EtqsTV/A==",
"requires": {
"@ckeditor/ckeditor5-utils": "^21.0.0",
"lodash-es": "^4.17.15"
}
},
"@ckeditor/ckeditor5-ui": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@ckeditor/ckeditor5-ui/-/ckeditor5-ui-21.0.0.tgz",
"integrity": "sha512-oACL96HUbHhQ5Me5WpOYq9qZ+zJw0Hfqe+f8/UtCfQ99zHcrfZ2odvNHSPdn16cZ5f8ED+zLJNHb8b8IMWwy2Q==",
"requires": {
"@ckeditor/ckeditor5-core": "^21.0.0",
"@ckeditor/ckeditor5-utils": "^21.0.0",
"lodash-es": "^4.17.15"
}
},
"@ckeditor/ckeditor5-utils": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@ckeditor/ckeditor5-utils/-/ckeditor5-utils-21.0.0.tgz",
"integrity": "sha512-JDEFO/bC8uP/K6xHEJdN/Pm1G7EO2WG363CY3qGZc49eNvYeXrluniLHIh7pL3kUSIr0yqLjJGGdPKc/sZYsHQ==",
"requires": {
"lodash-es": "^4.17.15"
}
},
"lodash-es": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.15.tgz",
"integrity": "sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ=="
}
}
} }

View File

@ -80,6 +80,7 @@ class GuideController extends Controller
$news->subname = $guide->name; $news->subname = $guide->name;
$news->arrangement_id = $guide->id; $news->arrangement_id = $guide->id;
$news->type_id = '4'; $news->type_id = '4';
$news->news_expiration_date = $request->input("news_expiration_date");
$news->content = $guide->guide_articles; $news->content = $guide->guide_articles;

View File

@ -11,6 +11,8 @@ use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
date_default_timezone_set('Europe/Copenhagen');
class NewsController extends Controller class NewsController extends Controller
{ {
public function __construct() public function __construct()
@ -31,6 +33,11 @@ class NewsController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$news = News::query()->where('news_expiration_date', '<=', date('Y-m-d').'T'.date('H:i') )->get();
foreach ($news as $new) {
$new->delete();
}
$news = News::query()->orderBy('id', 'desc')->get(); $news = News::query()->orderBy('id', 'desc')->get();
return Response::detect("news.index", [ "news" => $news ]); return Response::detect("news.index", [ "news" => $news ]);
@ -56,7 +63,8 @@ class NewsController extends Controller
{ {
$data = $request->validate([ $data = $request->validate([
"subname" => "required", "subname" => "required",
"content" => "required" "content" => "required",
"news_expiration_date" => ""
]); ]);
$news = new News($data); $news = new News($data);
@ -116,7 +124,8 @@ class NewsController extends Controller
{ {
$data = $request->validate([ $data = $request->validate([
"subname" => "required", "subname" => "required",
"content" => "required" "content" => "required",
"news_expiration_date" => ""
]); ]);
$news->update($data); $news->update($data);

View File

@ -7,6 +7,8 @@ use App\News;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
date_default_timezone_set('Europe/Copenhagen');
class RootController extends Controller class RootController extends Controller
{ {
function __construct() function __construct()
@ -18,6 +20,13 @@ class RootController extends Controller
public function index() { public function index() {
$perPage = 5; $perPage = 5;
//Delete news Articels
$news = News::query()->where('news_expiration_date', '<=', date('Y-m-d').'T'.date('H:i'))->get();
foreach ($news as $new) {
$new->delete();
}
//All news //All news
$newsCollection = News::query()->orderBy('id', 'desc')->get(); $newsCollection = News::query()->orderBy('id', 'desc')->get();
@ -34,12 +43,12 @@ class RootController extends Controller
if(Response::detect("root.index")->name() == "admin.root.index") if(Response::detect("root.index")->name() == "admin.root.index")
return view("admin.root.index"); return view("admin.root.index");
else { else {
$news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->orderBy('news.id', 'desc')->get(); $news = News::query()->select(['news_types.type', 'news.subname', 'news.id', 'news.resource_id', 'news.created_at', 'news.arrangement_id', 'news.content' ])->join('news_types', 'news_types.id', '=', 'news.type_id')->orderBy('news.id', 'desc')->get();
return view("app.root.index", ["news" => $news]); return view("app.root.index", ["news" => $news]);
} }
} }
else { else {
$news = News::query()->join('news_types', 'news_types.id', '=', 'news.type_id')->orderBy('news.id', 'desc')->get(); $news = News::query()->select(['news_types.type', 'news.subname', 'news.id', 'news.resource_id', 'news.created_at' ])->join('news_types', 'news_types.id', '=', 'news.type_id')->orderBy('news.id', 'desc')->get();
return Response::detect('root.index', ["news" => $news]); return Response::detect('root.index', ["news" => $news]);
} }

View File

@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class News extends Model class News extends Model
{ {
protected $fillable = [ protected $fillable = [
'name', 'subname', 'content', 'resource_id', 'arrangement_id', 'type' 'name', 'subname', 'news_expiration_date', 'content', 'resource_id', 'arrangement_id', 'type'
]; ];
} }

View File

@ -67,7 +67,7 @@ return [
| |
*/ */
'timezone' => 'UTC', 'timezone' => 'Europe/Copenhagen',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -17,6 +17,7 @@ class CreateNewsTable extends Migration
$table->id(); $table->id();
$table->string("name"); $table->string("name");
$table->string('subname'); $table->string('subname');
$table->date('news_expiration_date')->nullable();
$table->text("content"); $table->text("content");
$table->foreignId('resource_id')->nullable()->constrained('resources', 'id'); $table->foreignId('resource_id')->nullable()->constrained('resources', 'id');
$table->integer("arrangement_id")->nullable(); //Gets ID from given event, menu, guide or news $table->integer("arrangement_id")->nullable(); //Gets ID from given event, menu, guide or news

View File

@ -80,15 +80,6 @@ select {
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.select2-container--default, .select2-search, .selection, .select2-selection--single, .select2-results__options * {
color: white !important;
background-color: #2F3136 !important;
}
.select2-selection__rendered {
color: white !important;
}
input.appinput { input.appinput {
border: none; border: none;
border-bottom: white solid 2px; border-bottom: white solid 2px;

View File

@ -75,5 +75,7 @@ return[
"ris" => "Ris", "ris" => "Ris",
"andet" => "Andet", "andet" => "Andet",
"besked" => "Besked", "besked" => "Besked",
"send" => "Send besked" "send" => "Send besked",
"kategori" => "Kategori",
"opret" => "Oprettet den: "
]; ];

View File

@ -81,5 +81,7 @@ return[
"ros" => "Positive", "ros" => "Positive",
"andet" => "Other", "andet" => "Other",
"besked" => "Messages", "besked" => "Messages",
"send" => "Send messeags" "send" => "Send messeags",
"kategori" => "Category",
"opret" => "Created at: "
]; ];

View File

@ -41,11 +41,15 @@
<div id="editor"></div> <div id="editor"></div>
<textarea name="guide_articles" class="d-none" id="hiddenArea"></textarea> <textarea name="guide_articles" class="d-none" id="hiddenArea"></textarea>
<label class="toggle"> <label class="toggle">
<input class="toggle__input" type="checkbox" name="newsoption"> <input id="isNews" class="toggle__input" type="checkbox" name="newsoption" onclick="change()">
<span class="toggle__label"> <span class="toggle__label">
<span class="toggle__text">Opret som nyhed</span> <span class="toggle__text">Opret som nyhed</span>
</span> </span>
</label> </label>
<div class="form-group" style="display: flex; flex-direction: column" id="delete_event">
<label for="date">Dato til når nyheden skal slettes (valgfri):</label>
<input type="datetime-local" name="news_expiration_date" id="date">
</div>
<label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Valgfri):</label> <label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Valgfri):</label>
<input id="fileuploade" type="file" name="resource" accept="image/*"> <input id="fileuploade" type="file" name="resource" accept="image/*">
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
@ -144,5 +148,16 @@
}) })
function change() {
if ($('#isNews').is(":checked"))
{
$('#delete_event').show(400);
}else {
$('#delete_event').hide(400);
}
}
change();
</script> </script>
@endsection @endsection

View File

@ -22,6 +22,8 @@
<label for="title">Titel nyheden:</label> <label for="title">Titel nyheden:</label>
<label hidden id="error" for="errormesseages">Dette navn findes allerede</label> <label hidden id="error" for="errormesseages">Dette navn findes allerede</label>
<input type="text" name="subname" id="title" placeholder="OBS: Menuplanen er ændret" required> <input type="text" name="subname" id="title" placeholder="OBS: Menuplanen er ændret" required>
<label for="date">Dato til når nyheden skal slettes (valgfri)</label>
<input type="datetime-local" name="news_expiration_date" id="date">
<div id="editor"></div> <div id="editor"></div>
<textarea name="content" class="d-none" id="hiddenArea"></textarea> <textarea name="content" class="d-none" id="hiddenArea"></textarea>
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">

View File

@ -23,6 +23,8 @@
<label for="title">Navn</label> <label for="title">Navn</label>
<label hidden id="error" for="errormesseages">Dette navn findes allerede</label> <label hidden id="error" for="errormesseages">Dette navn findes allerede</label>
<input value="{{$news->subname}}" type="text" name="subname" id="title" required> <input value="{{$news->subname}}" type="text" name="subname" id="title" required>
<label for="date">Rediger datoen til når nyheden skal slettes (Hvis nyheden ikke skal slettes efter en bestemt dato, slet ALT i dato felete, det er tomt!)</label>
<input type="datetime-local" value="{{$news->news_expiration_date}}" name="news_expiration_date" id="date">
<div id="editor">{!! $news->content !!}</div> <div id="editor">{!! $news->content !!}</div>
<textarea name="content" class="d-none" id="hiddenArea"></textarea> <textarea name="content" class="d-none" id="hiddenArea"></textarea>
<input id="disable" type="submit" class="btn btn-dark text-white" value="Rediger"> <input id="disable" type="submit" class="btn btn-dark text-white" value="Rediger">

View File

@ -18,6 +18,7 @@
<table class="tbl" id="table_id"> <table class="tbl" id="table_id">
<thead> <thead>
<th>Navn</th> <th>Navn</th>
<th>Udløbsdato</th>
@if(auth()->user()->can('news.edit')) @if(auth()->user()->can('news.edit'))
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th> <th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
@endif @endif
@ -29,6 +30,11 @@
@foreach($news as $new) @foreach($news as $new)
<tr> <tr>
<td>{{$new->subname}}</td> <td>{{$new->subname}}</td>
@if($new->news_expiration_date !== null)
<td>{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($new->news_expiration_date))->format('d/m/Y \k\l\. H:i') }}</td>
@else
<td>Ingen udløbsdato</td>
@endif
@if(auth()->user()->can('news.edit')) @if(auth()->user()->can('news.edit'))
<td><a href="{{ route("news.edit", [ "news" => $new ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td> <td><a href="{{ route("news.edit", [ "news" => $new ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
@endif @endif

View File

@ -41,11 +41,13 @@
padding: 10px 10px; padding: 10px 10px;
font-size: 22px; font-size: 22px;
line-height: 30px; line-height: 30px;
display: flex;
flex-direction: column;
} }
.img{ .img{
width: 1em; width: 2em;
height: calc(1em + 20px); height: calc(2em + 20px);
margin-top: 5px; margin-top: 5px;
margin-bottom: 5px; margin-bottom: 5px;
margin-left: 5px; margin-left: 5px;
@ -61,7 +63,7 @@
} }
.img > a { .img > a {
width: 100%; width: 75%;
height: 100%; height: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -103,12 +105,18 @@
</style> </style>
<main style="justify-content: unset; padding: 0"> <main style="justify-content: unset; padding: 0">
<?php
date_default_timezone_set('Europe/Copenhagen');
?>
@foreach($news as $new) @foreach($news as $new)
<!--Code to list events--> <!--Code to list events-->
@if($new->type == 'News')<!--Code that prints news--> @if($new->type == 'News')<!--Code that prints news-->
<div class="card"> <div class="card">
<div class="img"><img src="{{URL::asset('/images/icons/news.svg')}}" alt="News:"></div> <div class="img"><img src="{{URL::asset('/images/icons/news.svg')}}" alt="News:"></div>
<div class="title">{{ $new->subname }}</div> <div class="title">
{{ $new->subname }}
<span class="createdat">{{__('msg.opret')}}{{ date('Y-m-d H:i:s', strtotime($new->created_at))}}</span>
</div>
@if($new->resource_id !== null) @if($new->resource_id !== null)
<div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div> <div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div>
@endif @endif
@ -120,7 +128,10 @@
@elseif($new->type == 'Menu')<!--Code that prints menuplan --> @elseif($new->type == 'Menu')<!--Code that prints menuplan -->
<div class="card"> <div class="card">
<div class="img"><a href="{{ route('menu-plans.index') }}"><img src="{{URL::asset('/images/icons/Menuplan.svg')}}" alt="Menuplan:"></a></div> <div class="img"><a href="{{ route('menu-plans.index') }}"><img src="{{URL::asset('/images/icons/Menuplan.svg')}}" alt="Menuplan:"></a></div>
<div class="title">{{ $new->subname }}</div> <div class="title">
{{ $new->subname }}
<span class="createdat">{{__('msg.opret')}}{{ date('Y-m-d H:i:s', strtotime($new->created_at))}}</span>
</div>
@if($new->resource_id !== null) @if($new->resource_id !== null)
<div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div> <div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div>
@endif @endif
@ -128,14 +139,16 @@
@if ($new->type_id == 1 || $new->type_id == 2) {{-- If it's a news or menu then display the whole message --}} @if ($new->type_id == 1 || $new->type_id == 2) {{-- If it's a news or menu then display the whole message --}}
{!! $new->content !!} {!! $new->content !!}
@else {{-- If it's a menu, guide or event. Then display up to 300 characters of text --}} @else {{-- If it's a menu, guide or event. Then display up to 300 characters of text --}}
{!! \App\Helpers::closetags(substr($new->content, 0, 300) ) !!} {!! \App\Helpers::closetags(substr($new->content, 0, 500) ) !!}
@endif @endif
</div> </div>
</div> </div>
@elseif($new->type == 'Activity')<!--Code that prints events--> @elseif($new->type == 'Activity')<!--Code that prints events-->
<div class="card"> <div class="card">
<div class="img"><a href="{{ route('events.index') }}"><img src="{{URL::asset('/images/icons/Aktiviteter.svg')}}" alt="Aktiviteter:"></a></div> <div class="img"><a href="{{ route('events.index') }}"><img src="{{URL::asset('/images/icons/Aktiviteter.svg')}}" alt="Aktiviteter:"></a></div>
<div class="title">{{ $new->subname }}</div> <div class="title">{{ $new->subname }}
<span class="createdat">{{__('msg.opret')}}{{ date('Y-m-d H:i:s', strtotime($new->created_at))}}</span>
</div>
@if($new->resource_id !== null) @if($new->resource_id !== null)
<div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div> <div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div>
<div class="information">{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime(\App\Event::query()->where('id', '=', $new->arrangement_id)->first()->date))->format('d/m/Y \k\l\. H:i') }} | {{\App\Event::query()->where('id', '=', $new->arrangement_id)->first()->accountable}} </div> <div class="information">{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime(\App\Event::query()->where('id', '=', $new->arrangement_id)->first()->date))->format('d/m/Y \k\l\. H:i') }} | {{\App\Event::query()->where('id', '=', $new->arrangement_id)->first()->accountable}} </div>
@ -170,9 +183,12 @@
@else<!--Code that prints guides--> @else<!--Code that prints guides-->
<div class="card"> <div class="card">
<div class="img"><a href="{{ route('guides.index') }}"><img src="{{URL::asset('/images/icons/Vejledninger.svg')}}" alt="Vejledninger:"></a></div> <div class="img"><a href="{{ route('guides.index') }}"><img src="{{URL::asset('/images/icons/Vejledninger.svg')}}" alt="Vejledninger:"></a></div>
<div class="title">{{ $new->subname }}</div> <div class="title">{{ $new->subname }}
<span class="createdat">{{__('msg.opret')}}{{ date('Y-m-d H:i:s', strtotime($new->created_at))}}</span>
</div>
@if($new->resource_id !== null) @if($new->resource_id !== null)
<div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div> <div class="header" style="background-size: cover; background-position: center; background-image: url('{{ asset(\App\Resource::query()->where("id", "=", $new->resource_id)->first()->filename) }}');"></div>
<div class="information">{{__('msg.kategori')}}: {{\App\GuidesCategory::query()->where('id', '=', \App\Guide::query()->where('id','=', $new->arrangement_id)->first()->guide_category_id)->first()->guidesCategoryName}}</div>
@endif @endif
<div class="container" style="margin-top: 8px;"> <div class="container" style="margin-top: 8px;">