Filtrowanie po kliknięciu ikonki przy wpisie. #39

Merged
krzysiej merged 2 commits from issue-26 into master 2018-07-05 08:40:36 +02:00
4 changed files with 47 additions and 7 deletions
Showing only changes of commit 0b3d25d013 - Show all commits

View File

@@ -136,6 +136,33 @@ class Main extends Controller
]); ]);
} }
/**
* get:/
* @param Request $request
* @param null $filter
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function filterView(Request $request, $filter = 'empty')
{
$notes = DB::select('SELECT *, CASE WHEN icon IS NULL
THEN \'empty\'
ELSE icon
END AS new_icon FROM note WHERE type = "note" AND new_icon = :icon ORDER BY updated_at DESC', ['icon' => $filter]);
$templates = DB::select('SELECT *, CASE WHEN icon IS NULL
THEN \'empty\'
ELSE icon
END AS new_icon FROM note WHERE type = "template" AND new_icon = :icon ORDER BY updated_at DESC', ['icon' => $filter]);
return view('list', [
'filter' => $filter,
'notes' => $notes,
'templates' => $templates,
'title' => $request->old('title'),
'text' => $request->old('text'),
'icon_selected' => $request->old('icon'),
'icons' => $this->paper->getIcons()
]);
}
/** /**
* post::/print/{id} * post::/print/{id}
* @param Request $request * @param Request $request

10
public/css/app.css vendored
View File

@@ -20,6 +20,14 @@ textarea.content {
} }
.note-title {
line-height: 32px;
}
h1.header span.icon.display-inline-block {
display: inline-block;
}
form { form {
margin-bottom: 0; margin-bottom: 0;
} }
@@ -32,9 +40,11 @@ form {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.flex.space-between { .flex.space-between {
justify-content: space-between; justify-content: space-between;
} }
.flex.header { .flex.header {
margin-bottom: 1rem; margin-bottom: 1rem;
} }

View File

@@ -47,22 +47,24 @@
</div> </div>
<div class="ui container"> <div class="ui container">
<h1 class="ui header">Lista notatek</h1> <h1 class="ui header"> @if(isset($filter)) <a href="/">Lista notatek</a> z ikonką <span
class="icon {{ $filter }} display-inline-block"></span>@else Lista notatek @endif</h1>
<div class="ui middle aligned divided list"> <div class="ui middle aligned divided list">
@foreach($notes as $note) @foreach($notes as $note)
<div class="item"> <div class="item">
<div class="left floated content">
<a href="/filter/{{ $note->icon }}" class="left floated"><span
class="icon @if($note->icon){{ $note->icon }} @else empty @endif "
title="{{ $note->icon }}"></span></a><a class="note-title"
href="/edit/{{ $note->id }}/{{ $note->topic_slug?$note->topic_slug:str_limit($note->text, 30, '...') }}">{{ $note->topic?$note->topic:str_limit($note->text, 30, '...') }}
</a>
</div>
<div class="right floated content"> <div class="right floated content">
<form method="post" action="/print/{{ $note->id }}"> <form method="post" action="/print/{{ $note->id }}">
{{ csrf_field() }} {{ csrf_field() }}
<button type="primary" class="ui tiny button primary">Drukuj</button> <button type="primary" class="ui tiny button primary">Drukuj</button>
</form> </form>
</div> </div>
<div class="content">
<a href="/edit/{{ $note->id }}/{{ $note->topic_slug?$note->topic_slug:str_limit($note->text, 30, '...') }}"><span
class="icon @if($note->icon){{ $note->icon }} @else empty @endif "
title="{{ $note->icon }}"></span>{{ $note->topic?$note->topic:str_limit($note->text, 30, '...') }}
</a>
</div>
</div> </div>
@endforeach @endforeach
</div> </div>

View File

@@ -12,6 +12,7 @@
*/ */
Route::get('/', 'Main@listView')->name('list'); Route::get('/', 'Main@listView')->name('list');
Route::get('/filter/{icon?}', 'Main@filterView');
Route::get('/settings', 'Settings@mainView')->name('settingsList'); Route::get('/settings', 'Settings@mainView')->name('settingsList');
Route::post('/settings', 'Settings@save'); Route::post('/settings', 'Settings@save');
//Route::post('/', 'Main@listView'); //Route::post('/', 'Main@listView');