From 03bcbab560a1612db6c9205155a147e1eb7799ad Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Tue, 28 May 2019 19:02:21 +0200 Subject: [PATCH] edit references in editor edit view --- .../Controllers/Publish/EditorController.php | 73 ++++++++++++++++++- .../Controllers/Publish/PublishController.php | 38 ---------- .../Controllers/Publish/SubmitController.php | 3 + app/Models/Dataset.php | 13 +++- .../views/settings/layouts/app.blade.php | 10 +-- .../views/workflow/editor/_form.blade.php | 46 +++++++++++- .../views/workflow/editor/index.blade.php | 4 +- .../{publish => editor}/publish.blade.php | 6 +- .../views/workflow/editor/reject.blade.php | 35 ++++++--- .../views/workflow/publish/index.blade.php | 2 +- .../views/workflow/review/index.blade.php | 15 +++- routes/web.php | 24 ++++-- 12 files changed, 191 insertions(+), 78 deletions(-) rename resources/views/workflow/{publish => editor}/publish.blade.php (93%) diff --git a/app/Http/Controllers/Publish/EditorController.php b/app/Http/Controllers/Publish/EditorController.php index e389d98..7cc9f18 100644 --- a/app/Http/Controllers/Publish/EditorController.php +++ b/app/Http/Controllers/Publish/EditorController.php @@ -10,6 +10,7 @@ use App\Models\License; use App\Models\User; use App\Models\Title; use App\Models\Description; +use App\Models\DatasetReference; use App\Models\Subject; use App\Models\File; use Illuminate\Http\RedirectResponse; @@ -91,7 +92,7 @@ class EditorController extends Controller public function edit($id): View { $dataset = Dataset::findOrFail($id); - $dataset->load('licenses', 'titles', 'abstracts', 'files', 'coverage', 'subjects'); + $dataset->load('licenses', 'titles', 'abstracts', 'files', 'coverage', 'subjects', 'references'); $projects = Project::pluck('label', 'id'); @@ -111,10 +112,27 @@ class EditorController extends Controller $checkeds = $dataset->licenses->pluck('id')->toArray(); $keywordTypes = ['uncontrolled' => 'uncontrolled', 'swd' => 'swd']; + $referenceTypes = ["rdr-id", "arXiv", "bibcode", "DOI", "EAN13", "EISSN", "Handle", "IGSN", "ISBN", "ISSN", "ISTC", "LISSN", "LSID", "PMID", "PURL", "UPC", "URL", "URN"]; + $referenceTypes = array_combine($referenceTypes, $referenceTypes); + + $relationTypes = ["IsCitedBy", "Cites", "IsSupplementTo", "IsSupplementedBy", "IsContinuedBy", "Continues", "HasMetadata", "IsMetadataFor","IsNewVersionOf", "IsPreviousVersionOf", "IsPartOf", "HasPart", "IsReferencedBy", "References"]; + // "IsDocumentedBy", "Documents", "IsCompiledBy", "Compiles", "IsVariantFormOf", "IsOriginalFormOf", "IsIdenticalTo", "IsReviewedBy", "Reviews", "IsDerivedFrom", "IsSourceOf"]; + $relationTypes = array_combine($relationTypes, $relationTypes); + return view( 'workflow.editor.edit', - compact('dataset', 'projects', 'options', 'checkeds', 'years', 'languages', 'keywordTypes') + compact( + 'dataset', + 'projects', + 'options', + 'checkeds', + 'years', + 'languages', + 'keywordTypes', + 'referenceTypes', + 'relationTypes' + ) ); } @@ -180,6 +198,19 @@ class EditorController extends Controller } } + //save the references: + $references = $request->input('references'); + if (is_array($references) && count($references) > 0) { + foreach ($references as $key => $formReference) { + $reference = DatasetReference::findOrFail($key); + $reference->value = $formReference['value']; + $reference->label = $formReference['label']; + $reference->type = $formReference['type']; + $reference->relation = $formReference['relation']; + $reference->save(); + } + } + //save the keywords: $keywords = $request->input('keywords'); if (is_array($keywords) && count($keywords) > 0) { @@ -314,4 +345,42 @@ class EditorController extends Controller } throw new GeneralException(trans('exceptions.publish.review.update_error')); } + + /** + * Display the specified dataset for publishing. + * + * @param int $id + * @return \Illuminate\View\View + */ + public function publish($id): View + { + $dataset = Dataset::query() + ->with([ + 'titles', + 'persons' => function ($query) { + $query->wherePivot('role', 'author'); + } + ])->findOrFail($id); + + return view('workflow.editor.publish', [ + 'dataset' => $dataset, + ]); + } + + public function publishUpdate(Request $request, $id) + { + $dataset = Dataset::findOrFail($id); + $input = $request->all(); + $input['server_state'] = 'published'; + $time = new \Illuminate\Support\Carbon(); + $input['server_date_published'] = $time; + + if ($dataset->update($input)) { + // event(new PageUpdated($page)); + return redirect() + ->route('publish.workflow.publish.index') + ->with('flash_message', 'You have successfully published the dataset!'); + } + throw new GeneralException(trans('exceptions.publish.publish.update_error')); + } } diff --git a/app/Http/Controllers/Publish/PublishController.php b/app/Http/Controllers/Publish/PublishController.php index 6c9db35..8e3c4d8 100644 --- a/app/Http/Controllers/Publish/PublishController.php +++ b/app/Http/Controllers/Publish/PublishController.php @@ -34,42 +34,4 @@ class PublishController extends Controller 'datasets' => $datasets, ]); } - - /** - * Display the specified dataset for publishing. - * - * @param int $id - * @return \Illuminate\View\View - */ - public function publish($id): View - { - $dataset = Dataset::query() - ->with([ - 'titles', - 'persons' => function ($query) { - $query->wherePivot('role', 'author'); - } - ])->findOrFail($id); - - return view('workflow.publish.publish', [ - 'dataset' => $dataset, - ]); - } - - public function publishUpdate(Request $request, $id) - { - $dataset = Dataset::findOrFail($id); - $input = $request->all(); - $input['server_state'] = 'published'; - $time = new \Illuminate\Support\Carbon(); - $input['server_date_published'] = $time; - - if ($dataset->update($input)) { - // event(new PageUpdated($page)); - return redirect() - ->route('publish.workflow.publish.index') - ->with('flash_message', 'You have successfully published the dataset!'); - } - throw new GeneralException(trans('exceptions.publish.publish.update_error')); - } } diff --git a/app/Http/Controllers/Publish/SubmitController.php b/app/Http/Controllers/Publish/SubmitController.php index 25056a4..732df07 100644 --- a/app/Http/Controllers/Publish/SubmitController.php +++ b/app/Http/Controllers/Publish/SubmitController.php @@ -76,6 +76,9 @@ class SubmitController extends Controller if ($dataset->reject_editor_note != null) { $input['reject_editor_note'] = null; } + if ($dataset->reject_reviewer_note != null) { + $input['reject_reviewer_note'] = null; + } if ($dataset->update($input)) { // event(new PageUpdated($page)); diff --git a/app/Models/Dataset.php b/app/Models/Dataset.php index 3442919..901a684 100644 --- a/app/Models/Dataset.php +++ b/app/Models/Dataset.php @@ -41,7 +41,8 @@ class Dataset extends Model 'preferred_reviewer_email', 'reviewer_id', 'reject_reviewer_note', - 'reject_editor_note' + 'reject_editor_note', + 'reviewer_note_visible' ]; //protected $guarded = []; /** @@ -301,4 +302,14 @@ class Dataset extends Model return ($embargoDate->gt($now) == true); } + + public function getRemainingTimeAttribute() + { + $dateDiff =$this->server_date_modified->addDays(14); + if ($this->server_state == "approved") { + return Carbon::now()->diffInDays($dateDiff, false); + } else { + return 0; + } + } } diff --git a/resources/views/settings/layouts/app.blade.php b/resources/views/settings/layouts/app.blade.php index 88c5115..3ed79b4 100644 --- a/resources/views/settings/layouts/app.blade.php +++ b/resources/views/settings/layouts/app.blade.php @@ -113,17 +113,11 @@ REVIEW PAGE: Approved datasets @endpermission - @permission('dataset-publish-list') + {{-- @permission('dataset-publish-list')
  • Publish PAGE: Reviewed datasets
  • - @endpermission - {{--
  • - Release pending datasets -
  • -
  • - Review/Publish unpublished datasets -
  • --}} + @endpermission --}} @endrole diff --git a/resources/views/workflow/editor/_form.blade.php b/resources/views/workflow/editor/_form.blade.php index 15434c0..7fd53f8 100644 --- a/resources/views/workflow/editor/_form.blade.php +++ b/resources/views/workflow/editor/_form.blade.php @@ -186,6 +186,50 @@ +
    + Dataset References + {{-- --}} + @if ($dataset->references->count() > 0) +
    + + + + + + + + + + + {{-- --}} + @foreach($dataset->references as $key => $reference) + + + + + + + + @endforeach + +
    Reference valueLabelTypeRelation
    + {{ Form::text('references['.$reference->id.'][value]', $reference->value, ['class' => 'form-control', 'placeholder' => '[REFERENCE VALUE]']) }} + + {{ Form::text('references['.$reference->id.'][label]', $reference->label, ['class' => 'form-control', 'placeholder' => '[REFERENCE LABEL]']) }} + + {!! Form::select('references['.$reference->id.'][type]', $referenceTypes, $reference->type, ['placeholder' => '[reference type]', 'v-model' => + 'item.type', "v-validate" => "'required'", 'data-vv-scope' => 'step-2']) !!} + + {!! Form::select('references['.$reference->id.'][relation]', $relationTypes, $reference->relation, ['placeholder' => '[relation type]', 'v-model' => + 'item.relation', "v-validate" => "'required'", 'data-vv-scope' => 'step-2']) !!} + + +
    + @else + ...there are no references + @endif +
    +
    Dataset Keywords {{-- --}} @@ -219,7 +263,7 @@
    @else - ...ther are no keywords + ...there are no keywords @endif
    diff --git a/resources/views/workflow/editor/index.blade.php b/resources/views/workflow/editor/index.blade.php index 5eef936..87a619a 100644 --- a/resources/views/workflow/editor/index.blade.php +++ b/resources/views/workflow/editor/index.blade.php @@ -40,7 +40,7 @@ {{ $dataset->titles()->first()->value }} @else no title - @endif + @endif {{ $dataset->id }} @@ -77,7 +77,7 @@ Reject @elseif ($dataset->server_state == "reviewed") - + Publish diff --git a/resources/views/workflow/publish/publish.blade.php b/resources/views/workflow/editor/publish.blade.php similarity index 93% rename from resources/views/workflow/publish/publish.blade.php rename to resources/views/workflow/editor/publish.blade.php index d5972e0..6e416ee 100644 --- a/resources/views/workflow/publish/publish.blade.php +++ b/resources/views/workflow/editor/publish.blade.php @@ -2,7 +2,7 @@ @section('content')

    - Review approved dataset + Publish reviewed dataset

    @@ -17,7 +17,7 @@
    - {!! Form::model($dataset, [ 'method' => 'POST', 'route' => ['publish.workflow.publish.publishUpdate', $dataset->id], + {!! Form::model($dataset, [ 'method' => 'POST', 'route' => ['publish.workflow.editor.publishUpdate', $dataset->id], 'id' => 'publishForm', 'class' => 'pure-form', 'enctype' => 'multipart/form-data', 'v-on:submit.prevent' => 'checkForm']) !!}
    @@ -47,7 +47,7 @@
    - Are you sure you want to accept the selected dataset? + Are you sure you want to publish the selected dataset?
    diff --git a/resources/views/workflow/editor/reject.blade.php b/resources/views/workflow/editor/reject.blade.php index d6d9775..ed3ad21 100644 --- a/resources/views/workflow/editor/reject.blade.php +++ b/resources/views/workflow/editor/reject.blade.php @@ -35,21 +35,36 @@
    - {!! Form::label('server_state', 'Status..') !!} - {!! Form::text('server_state', 'rejected_editor', ['class'=>'pure-u-23-24','readonly']) !!} - -
    - + {!! Form::label('server_state', 'Status..') !!} + {!! Form::text('server_state', 'rejected_editor', ['class'=>'pure-u-23-24','readonly']) !!} +
    +
    {!! Form::label('reject_editor_note', 'reject note:') !!} {!! Form::textarea('reject_editor_note',null, ['id' => 'reject_editor_note', 'class'=>'pure-u-23-24', 'placeholder' => '-- reject note for submitter --', 'size' => '70x6', 'v-model' => 'dataset.reject_editor_note', "v-validate" => "'required|min:10|max:255'"]) !!} - * - - - -
    + * + + + + @if ($dataset->reject_reviewer_note != null) +
    + {!! Form::label('reject_reviewer_note', 'Reviewer reject note..') !!} + {!! Form::text('reject_reviewer_note', null, ['class'=>'pure-u-23-24','readonly']) !!} +
    +
    + +
    + @else +
    + There is no reject note from the reviewer +
    + @endif diff --git a/resources/views/workflow/publish/index.blade.php b/resources/views/workflow/publish/index.blade.php index 8259bda..f54f0ed 100644 --- a/resources/views/workflow/publish/index.blade.php +++ b/resources/views/workflow/publish/index.blade.php @@ -56,7 +56,7 @@ - + + @@ -42,10 +43,16 @@ - @if ($dataset->server_state == "approved") + - @endif +
    @if ($dataset->server_state == "reviewed") - + Publish diff --git a/resources/views/workflow/review/index.blade.php b/resources/views/workflow/review/index.blade.php index 4027937..17c8e1e 100644 --- a/resources/views/workflow/review/index.blade.php +++ b/resources/views/workflow/review/index.blade.php @@ -14,7 +14,8 @@ Dataset Title ID Server StateEditorEditorremaining time {{ $dataset->server_state }} - editor: {{ optional($dataset->editor)->login }} + {{-- @php + $dateDiff = $dataset['server_date_modified']->addDays(14); + $remainingDays = Carbon\Carbon::now()->diffInDays($dateDiff, false); + @endphp --}} + + {{ $dataset->remaining_time . ' days' }} + @if ($dataset->server_state == "approved") diff --git a/routes/web.php b/routes/web.php index 44ab774..ea957a5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -109,6 +109,14 @@ Route::group( 'middleware' => ['permission:dataset-editor-reject'], 'as' => 'workflow.editor.rejectUpdate', 'uses' => 'EditorController@rejectUpdate', ]); + Route::get('workflow/editor/publish/{id}', [ + 'middleware' => ['permission:dataset-publish'], + 'as' => 'workflow.editor.publish', 'uses' => 'EditorController@publish', + ]); + Route::post('workflow/editor/publish/{id}', [ + 'middleware' => ['permission:dataset-publish'], + 'as' => 'workflow.editor.publishUpdate', 'uses' => 'EditorController@publishUpdate', + ]); //reviewer Route::get('workflow/review/index', [ @@ -137,14 +145,14 @@ Route::group( 'middleware' => ['permission:dataset-publish-list'], 'as' => 'workflow.publish.index', 'uses' => 'PublishController@index', ]); - Route::get('workflow/publish/{id}', [ - 'middleware' => ['permission:dataset-publish'], - 'as' => 'workflow.publish.publish', 'uses' => 'PublishController@publish', - ]); - Route::post('workflow/publish/{id}', [ - 'middleware' => ['permission:dataset-publish'], - 'as' => 'workflow.publish.publishUpdate', 'uses' => 'PublishController@publishUpdate', - ]); + // Route::get('workflow/publish/{id}', [ + // 'middleware' => ['permission:dataset-publish'], + // 'as' => 'workflow.publish.publish', 'uses' => 'PublishController@publish', + // ]); + // Route::post('workflow/publish/{id}', [ + // 'middleware' => ['permission:dataset-publish'], + // 'as' => 'workflow.publish.publishUpdate', 'uses' => 'PublishController@publishUpdate', + // ]); Route::get('workflow/changestate/{id}/changestate/{targetState}', [ 'as' => 'review.changestate', 'uses' => 'SubmitController@changestate',