wip - bookmark
This commit is contained in:
parent
0d4a17307d
commit
17938e608c
@ -609,6 +609,27 @@ private function generateActionButtons(Study $study): string
|
||||
case WorklistButton::Audit:
|
||||
$btns[] = $this->renderImageLink($study->hash, 'audit.png', 'show-audit', 'Audit Trail');
|
||||
break;
|
||||
case WorklistButton::Bookmark:
|
||||
if ($study->isBookmarkedBy()) {
|
||||
$btns[] = Blade::render('staff.worklist.partials.bookmarks._delete',
|
||||
[
|
||||
'study_id' => $study->id,
|
||||
'user_id' => me()->id,
|
||||
'url' => route('staff.bookmark.delete'),
|
||||
'img' => asset('imgs/bookmark-delete.png'),
|
||||
'tip' => 'Remove bookmark',
|
||||
]);
|
||||
} else {
|
||||
$btns[] = Blade::render('staff.worklist.partials.bookmarks._create',
|
||||
[
|
||||
'study_id' => $study->id,
|
||||
'user_id' => me()->id,
|
||||
'url' => route('staff.bookmark.create'),
|
||||
'img' => asset('imgs/bookmark.png'),
|
||||
'tip' => 'Bookmark study',
|
||||
]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,4 +26,5 @@ enum Permission: string
|
||||
case UnassignRadiologist = 'unassign_radiologist';
|
||||
case AccessAllWorklists = 'access_all_worklists';
|
||||
case AuditLogView = 'audit_log_view';
|
||||
case BookmarkCreate = 'bookmark_create';
|
||||
}
|
||||
|
@ -10,13 +10,16 @@ class BookmarkController extends Controller
|
||||
{
|
||||
public function create(BookmarkCrudRequest $request)
|
||||
{
|
||||
return StudyBookmark::create($request->validated());
|
||||
StudyBookmark::create($request->validated());
|
||||
|
||||
return redirect()->route('staff.worklist.index');
|
||||
}
|
||||
|
||||
public function delete(StudyBookmark $studyBookmark)
|
||||
public function delete(BookmarkCrudRequest $request)
|
||||
{
|
||||
$studyBookmark = StudyBookmark::where($request->validated())->firstOrFail();
|
||||
$studyBookmark->delete();
|
||||
|
||||
return response()->json();
|
||||
return redirect()->route('staff.worklist.index');
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ class BookmarkCrudRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'study_id' => ['required', 'exists:studies'],
|
||||
'user_id' => ['required', 'exists:users'],
|
||||
'study_id' => ['required', 'exists:studies,id'],
|
||||
'user_id' => ['required', 'exists:users,id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -443,6 +443,11 @@ public function isReadBy(User|int|null $user = null): bool
|
||||
return $this->reading_physician_id === me($user)->id;
|
||||
}
|
||||
|
||||
public function isBookmarkedBy(User|int|null $user = null): bool
|
||||
{
|
||||
return $this->bookmarkedByUsers()->where('user_id', me($user)->id)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if study has been locked by the given user or is unlocked. Returns false if the study was locked by another user.
|
||||
*/
|
||||
|
@ -11,4 +11,5 @@ enum WorklistButton: string
|
||||
case Assign = 'assign';
|
||||
case Report = 'report';
|
||||
case Audit = 'audit';
|
||||
case Bookmark = 'bookmark';
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ public static function worklistButtons(Study $study, User|int|null $usr = null):
|
||||
WorklistButton::StudyMetadata,
|
||||
WorklistButton::Notes,
|
||||
// WorklistButton::Audit,
|
||||
WorklistButton::Bookmark,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -75,6 +76,10 @@ public static function worklistButtons(Study $study, User|int|null $usr = null):
|
||||
$buttons->push(WorklistButton::Audit);
|
||||
}
|
||||
|
||||
if (may(Permission::BookmarkCreate)) {
|
||||
$buttons->push(WorklistButton::Bookmark);
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public function run(): void
|
||||
Permission::StudyNotesCreate,
|
||||
Permission::StudyNotesView,
|
||||
Permission::AttachmentDownload,
|
||||
Permission::BookmarkCreate,
|
||||
]);
|
||||
|
||||
$tech->givePermissionTo([
|
||||
@ -49,6 +50,7 @@ public function run(): void
|
||||
Permission::StudyArchive,
|
||||
Permission::ReportDownload,
|
||||
Permission::AuditLogView,
|
||||
Permission::BookmarkCreate,
|
||||
]);
|
||||
|
||||
$adm->givePermissionTo(SpatiePermission::all());
|
||||
|
BIN
resources/imgs/bookmark-delete.png
Normal file
BIN
resources/imgs/bookmark-delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 822 B |
BIN
resources/imgs/bookmark.png
Normal file
BIN
resources/imgs/bookmark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,7 @@
|
||||
@php
|
||||
$form_id = 'bm-creat-' . $study_id;
|
||||
@endphp
|
||||
<a href="#" onclick="document.getElementById('{{ $form_id }}').submit(); return false;">
|
||||
@include('_partials._img-tooltip', ['src' => $img, 'class' => $class ?? 'msg-icon', 'tip' => $tip])
|
||||
@include('staff.worklist.partials.bookmarks._form', ['form_id' => $form_id, 'url' => $url, 'study_id' => $study_id, 'user_id' => $user_id, 'delete' => false])
|
||||
</a>
|
@ -0,0 +1,7 @@
|
||||
@php
|
||||
$form_id = 'bm-del_' . $study_id;
|
||||
@endphp
|
||||
<a href="#" onclick="document.getElementById('{{ $form_id }}').submit(); return false;">
|
||||
@include('_partials._img-tooltip', ['src' => $img, 'class' => $class ?? 'msg-icon', 'tip' => $tip])
|
||||
@include('staff.worklist.partials.bookmarks._form', ['form_id' => $form_id, 'url' => $url, 'study_id' => $study_id, 'user_id' => $user_id, 'delete' => true])
|
||||
</a>
|
@ -0,0 +1,8 @@
|
||||
<form id="{{ $form_id }}" action="{{ $url }}" method="POST" style="display:none;">
|
||||
@csrf
|
||||
@if ($delete)
|
||||
@method('DELETE')
|
||||
@endif
|
||||
<input type="hidden" name="study_id" value="{{ $study_id }}">
|
||||
<input type="hidden" name="user_id" value="{{ $user_id }}">
|
||||
</form>
|
@ -89,7 +89,7 @@
|
||||
|
||||
Route::group(['prefix' => 'bookmark', 'as' => 'bookmark.'], function () {
|
||||
Route::post('/', [BookmarkController::class, 'create'])->name('create');
|
||||
Route::delete('{hashid}', [BookmarkController::class, 'delete'])->name('delete');
|
||||
Route::delete('/', [BookmarkController::class, 'delete'])->name('delete');
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user