v0.5.11 - Changed CKEditor to TinyMCEditor / Removed Monday-Thursday in menu_plans and added a TinyMCEditor instead.

This commit is contained in:
Anders 2020-08-07 12:20:15 +02:00
parent c268440021
commit 9a6d1b64c1
6 changed files with 52 additions and 49 deletions

View File

@ -59,10 +59,7 @@ class MenuPlanController extends Controller
{
$requestMenuPlanCreate = $request->validate([
"week" => "required|max:2",
"monday" => "required|max:255",
"tuesday" => "required|max:255",
"wednesday" => "required|max:255",
"thursday" => "required|max:255"
"menu" => "required",
]);
$menuPlan = new MenuPlan($requestMenuPlanCreate);
@ -79,7 +76,7 @@ class MenuPlanController extends Controller
$news = new News();
$news->name = "Ny menuplan Uge " . $menuPlan->week;
$news->content = "";
$news->content = $menuPlan->menu;
$news->save();
}
@ -139,7 +136,7 @@ class MenuPlanController extends Controller
$news = new News();
$news->name = "Opdateret menuplan Uge " . $menuplan->week;
$news->content = "";
$news->content = $menuplan->menu;
$news->save();
}

View File

@ -15,6 +15,6 @@ class MenuPlan extends Model
{
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [
'week', 'monday', "tuesday", 'wednesday', 'thursday'
'week', 'menu'
];
}

View File

@ -18,10 +18,7 @@ class CreateMenuPlans extends Migration
Schema::create('menu_plans', function (Blueprint $table) {
$table->id();
$table->string('week', 2);
$table->string('monday', 255);
$table->string('tuesday', 255);
$table->string('wednesday', 255);
$table->string('thursday', 255);
$table->longText('menu');
$table->unique('week');
$table->timestamps();
//$table->text('description');

View File

@ -17,14 +17,26 @@
.toggle__text::before {
border-color: black;
}
.tox-notification {
display: none !important;
}
.tox {
border-radius: 4px !important;
margin-bottom: 1rem;
}
</style>
<script src="https://cdn.ckeditor.com/ckeditor5/21.0.0/classic/ckeditor.js"></script>
<script src="https://cdn.tiny.cloud/1/ikwmbvigw8ass90tn37xiql6mk1gjoks77t3m6tld60hdjov/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<h1>Opret Menuplan:</h1>
<form action="{{ action('MenuPlanController@store') }}" method="post">
@csrf
<label for="week">Uge nr.</label>
<input type="number" name="week" id="week" min="1" max="53" placeholder="1" required>
<textarea name="menuPlan" id="editor"></textarea>
<textarea name="menu" id="editor"><p style="text-align: center;"><span style="color: #00788a; font-size: 24px; font-weight: bold; text-align: center;">Mandag:<br /></span><span style="text-align: center;">{Mandag}</span></p>
<p style="text-align: center;"><span style="color: #00788a; font-size: 24px; font-weight: bold; text-align: center;">Tirsdag:<br /></span><span style="text-align: center;">{Tirsdag}</span></p>
<p style="text-align: center;"><span style="color: #00788a; font-size: 24px; font-weight: bold; text-align: center;">Onsdag:<br /></span><span style="text-align: center;">{Onsdag}</span></p>
<p style="text-align: center;"><span style="color: #00788a; font-size: 24px; font-weight: bold; text-align: center;">Torsdag:<br /></span><span style="text-align: center;">{Torsdag}</span></p></textarea>
<label class="toggle">
<input class="toggle__input" type="checkbox" name="newsoption">
<span class="toggle__label">
@ -34,16 +46,14 @@
<input type="submit" class="btn btn-dark text-white" value="Opret Menuplan">
</form>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
tinymce.init({
selector: 'textarea',
setup: function (editor) {
editor.on('change', function () {
tinymce.triggerSave();
});
}
});
</script>
@endsection

View File

@ -17,21 +17,24 @@
.toggle__text::before {
border-color: black;
}
.tox-notification {
display: none !important;
}
.tox {
border-radius: 4px !important;
margin-bottom: 1rem;
}
</style>
<script src="https://cdn.tiny.cloud/1/ikwmbvigw8ass90tn37xiql6mk1gjoks77t3m6tld60hdjov/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<h1>Rediger Menuplan:</h1>
<form method="post" action="{{ route("menu-plans.update", [ "menu_plan" => $menuplan ]) }}">
@csrf
@method("PUT")
<label for="mandag">Uge:</label>
<input type="number" name="week" id="week" min="1" max="53" value="{{ $menuplan->week }}" required>
<label for="mandag">Mandag:</label>
<input type="text" name="monday" id="mandag" value="{{ $menuplan->monday }}" required>
<label for="tirsdag">Tirsdag:</label>
<input type="text" name="tuesday" id="tirsdag" value="{{ $menuplan->tuesday }}" required>
<label for="onsdag">Onsdag:</label>
<input type="text" name="wednesday" id="onsdag" value="{{ $menuplan->wednesday }}" required>
<label for="torsdag">Torsdag:</label>
<input type="text" name="thursday" id="torsdag" value="{{ $menuplan->thursday }}" required>
<textarea name="menu" id="editor">{!! $menuplan->menu !!}</textarea>
<label class="toggle">
<input class="toggle__input" type="checkbox" name="newsoption">
<span class="toggle__label">
@ -40,4 +43,15 @@
</label>
<input type="submit" class="btn btn-dark text-white" value="Rediger Menuplan">
</form>
<script>
tinymce.init({
selector: 'textarea',
setup: function (editor) {
editor.on('change', function () {
tinymce.triggerSave();
});
}
});
</script>
@endsection

View File

@ -12,24 +12,9 @@
@foreach($menuPlans as $menuplan)
@if($menuplan->week == $Week)
<h1 class="text-center sde-blue mb-0">{{ __('msg.menuplan') }}</h1>
<span class="text-center sde-black-80 bold">{{ __('msg.uge') }}: {{$menuplan->week}}</span>
<div class="col w-100 mt-auto text-center">
<div class="w-100" id="mandag">
<h3 class="sde-blue bold mb-0">{{ __('msg.mandag') }}</h3>
<p>{{$menuplan->monday}}</p>
</div>
<div class="w-100" id="tirsdag">
<h3 class="sde-blue bold mb-0">{{ __('msg.tirsdag') }}</h3>
<p>{{$menuplan->tuesday}}</p>
</div>
<div class="w-100" id="onsdag">
<h3 class="sde-blue bold mb-0">{{ __('msg.onsdag') }}</h3>
<p>{{$menuplan->wednesday}}</p>
</div>
<div class="w-100" id="torsdag">
<h3 class="sde-blue bold mb-0">{{ __('msg.torsdag') }}</h3>
<p>{{$menuplan->thursday}}</p>
</div>
<span class="text-center sde-black-80 bold">{{ __('msg.ugestor') }}: {{$menuplan->week}}</span>
<div class="col w-100 mt-auto">
{!! $menuplan->menu !!}
</div>
@endif
@endforeach