edit references in editor edit view

This commit is contained in:
Arno Kaimbacher 2019-05-28 19:02:21 +02:00
parent 4d6664ce3a
commit 03bcbab560
12 changed files with 191 additions and 78 deletions

View File

@ -10,6 +10,7 @@ use App\Models\License;
use App\Models\User; use App\Models\User;
use App\Models\Title; use App\Models\Title;
use App\Models\Description; use App\Models\Description;
use App\Models\DatasetReference;
use App\Models\Subject; use App\Models\Subject;
use App\Models\File; use App\Models\File;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
@ -91,7 +92,7 @@ class EditorController extends Controller
public function edit($id): View public function edit($id): View
{ {
$dataset = Dataset::findOrFail($id); $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'); $projects = Project::pluck('label', 'id');
@ -111,10 +112,27 @@ class EditorController extends Controller
$checkeds = $dataset->licenses->pluck('id')->toArray(); $checkeds = $dataset->licenses->pluck('id')->toArray();
$keywordTypes = ['uncontrolled' => 'uncontrolled', 'swd' => 'swd']; $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( return view(
'workflow.editor.edit', '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: //save the keywords:
$keywords = $request->input('keywords'); $keywords = $request->input('keywords');
if (is_array($keywords) && count($keywords) > 0) { if (is_array($keywords) && count($keywords) > 0) {
@ -314,4 +345,42 @@ class EditorController extends Controller
} }
throw new GeneralException(trans('exceptions.publish.review.update_error')); 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'));
}
} }

View File

@ -34,42 +34,4 @@ class PublishController extends Controller
'datasets' => $datasets, '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'));
}
} }

View File

@ -76,6 +76,9 @@ class SubmitController extends Controller
if ($dataset->reject_editor_note != null) { if ($dataset->reject_editor_note != null) {
$input['reject_editor_note'] = null; $input['reject_editor_note'] = null;
} }
if ($dataset->reject_reviewer_note != null) {
$input['reject_reviewer_note'] = null;
}
if ($dataset->update($input)) { if ($dataset->update($input)) {
// event(new PageUpdated($page)); // event(new PageUpdated($page));

View File

@ -41,7 +41,8 @@ class Dataset extends Model
'preferred_reviewer_email', 'preferred_reviewer_email',
'reviewer_id', 'reviewer_id',
'reject_reviewer_note', 'reject_reviewer_note',
'reject_editor_note' 'reject_editor_note',
'reviewer_note_visible'
]; ];
//protected $guarded = []; //protected $guarded = [];
/** /**
@ -301,4 +302,14 @@ class Dataset extends Model
return ($embargoDate->gt($now) == true); 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;
}
}
} }

View File

@ -113,17 +113,11 @@
<a class="pure-menu-link" href="{{ URL::route('publish.workflow.review.index') }}"><i class="fas fa-list"></i> REVIEW PAGE: Approved datasets</a> <a class="pure-menu-link" href="{{ URL::route('publish.workflow.review.index') }}"><i class="fas fa-list"></i> REVIEW PAGE: Approved datasets</a>
</li> </li>
@endpermission @endpermission
@permission('dataset-publish-list') {{-- @permission('dataset-publish-list')
<li class="pure-menu-item {{ Route::is('publish.workflow.publish*') ? 'active' : '' }}"> <li class="pure-menu-item {{ Route::is('publish.workflow.publish*') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('publish.workflow.publish.index') }}"><i class="fas fa-list"></i> Publish PAGE: Reviewed datasets</a> <a class="pure-menu-link" href="{{ URL::route('publish.workflow.publish.index') }}"><i class="fas fa-list"></i> Publish PAGE: Reviewed datasets</a>
</li> </li>
@endpermission @endpermission --}}
{{-- <li class="pure-menu-item {{ Route::is('publish.workflow.release') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('publish.workflow.release') }}"><i class="fa fa-upload"></i> Release pending datasets</a>
</li>
<li class="pure-menu-item {{ Route::is('publish.workflow.review') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('publish.workflow.review') }}"><i class="fa fa-upload"></i> Review/Publish unpublished datasets</a>
</li> --}}
</ul> </ul>
</li> </li>
@endrole @endrole

View File

@ -186,6 +186,50 @@
</div> </div>
</fieldset> </fieldset>
<fieldset id="fieldset-references">
<legend>Dataset References</legend>
{{-- <table class="table table-hover" v-if="dataset.keywords.length"> --}}
@if ($dataset->references->count() > 0)
<table id="references" class="pure-table pure-table-horizontal">
<thead>
<tr>
<th style="width: 20px;">Reference value</th>
<th style="width: 20px;">Label</th>
<th>Type</th>
<th>Relation</th>
<th style="width: 130px;"></th>
</tr>
</thead>
<tbody>
{{-- <tr v-for="(item, index) in dataset.keywords"> --}}
@foreach($dataset->references as $key => $reference)
<tr>
<td>
{{ Form::text('references['.$reference->id.'][value]', $reference->value, ['class' => 'form-control', 'placeholder' => '[REFERENCE VALUE]']) }}
</td>
<td>
{{ Form::text('references['.$reference->id.'][label]', $reference->label, ['class' => 'form-control', 'placeholder' => '[REFERENCE LABEL]']) }}
</td>
<td>
{!! Form::select('references['.$reference->id.'][type]', $referenceTypes, $reference->type, ['placeholder' => '[reference type]', 'v-model' =>
'item.type', "v-validate" => "'required'", 'data-vv-scope' => 'step-2']) !!}
</td>
<td>
{!! Form::select('references['.$reference->id.'][relation]', $relationTypes, $reference->relation, ['placeholder' => '[relation type]', 'v-model' =>
'item.relation', "v-validate" => "'required'", 'data-vv-scope' => 'step-2']) !!}
</td>
<td>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<span>...there are no references</span>
@endif
</fieldset>
<fieldset id="fieldset-keywords"> <fieldset id="fieldset-keywords">
<legend>Dataset Keywords</legend> <legend>Dataset Keywords</legend>
{{-- <table class="table table-hover" v-if="dataset.keywords.length"> --}} {{-- <table class="table table-hover" v-if="dataset.keywords.length"> --}}
@ -219,7 +263,7 @@
</tbody> </tbody>
</table> </table>
@else @else
<span>...ther are no keywords</span> <span>...there are no keywords</span>
@endif @endif
</fieldset> </fieldset>

View File

@ -40,7 +40,7 @@
{{ $dataset->titles()->first()->value }} {{ $dataset->titles()->first()->value }}
@else @else
no title no title
@endif @endif
</td> </td>
<td> <td>
{{ $dataset->id }} {{ $dataset->id }}
@ -77,7 +77,7 @@
<span>Reject</span> <span>Reject</span>
</a> </a>
@elseif ($dataset->server_state == "reviewed") @elseif ($dataset->server_state == "reviewed")
<a href="{{ URL::route('publish.workflow.publish.publishUpdate', $dataset->id) }}" class="pure-button"> <a href="{{ URL::route('publish.workflow.editor.publishUpdate', $dataset->id) }}" class="pure-button">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
<span>Publish</span> <span>Publish</span>
</a> </a>

View File

@ -2,7 +2,7 @@
@section('content') @section('content')
<div class="header"> <div class="header">
<h3 class="header-title"> <h3 class="header-title">
<i class="fa fa-share"></i> Review approved dataset <i class="fa fa-share"></i> Publish reviewed dataset
</h3> </h3>
</div> </div>
@ -17,7 +17,7 @@
</div> </div>
<div id="app1"> <div id="app1">
{!! 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']) 'id' => 'publishForm', 'class' => 'pure-form', 'enctype' => 'multipart/form-data', 'v-on:submit.prevent' => 'checkForm'])
!!} !!}
<fieldset id="fieldset-General"> <fieldset id="fieldset-General">
@ -47,7 +47,7 @@
</tbody> </tbody>
</table> </table>
<div class="instruction"> <div class="instruction">
Are you sure you want to accept the selected dataset? Are you sure you want to publish the selected dataset?
</div> </div>
<table> <table>
<tbody><tr> <tbody><tr>

View File

@ -35,21 +35,36 @@
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-md-1-1 pure-div"> <div class="pure-u-1 pure-u-md-1-1 pure-div">
{!! Form::label('server_state', 'Status..') !!} {!! Form::label('server_state', 'Status..') !!}
{!! Form::text('server_state', 'rejected_editor', ['class'=>'pure-u-23-24','readonly']) !!} {!! Form::text('server_state', 'rejected_editor', ['class'=>'pure-u-23-24','readonly']) !!}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-1 pure-div"> <div class="pure-u-1 pure-u-md-1-1 pure-div">
{!! Form::label('reject_editor_note', 'reject note:') !!} {!! Form::label('reject_editor_note', 'reject note:') !!}
{!! Form::textarea('reject_editor_note',null, ['id' => 'reject_editor_note', 'class'=>'pure-u-23-24', {!! Form::textarea('reject_editor_note',null, ['id' => 'reject_editor_note', 'class'=>'pure-u-23-24',
'placeholder' => '-- reject note for submitter --', 'size' => '70x6', 'placeholder' => '-- reject note for submitter --', 'size' => '70x6',
'v-model' => 'dataset.reject_editor_note', "v-validate" => "'required|min:10|max:255'"]) !!} 'v-model' => 'dataset.reject_editor_note', "v-validate" => "'required|min:10|max:255'"]) !!}
<em>*</em> <em>*</em>
<span class="help is-danger" v-if="errors.has('reject_editor_note')" v-text="errors.first('reject_editor_note')"></span>
<span class="help is-danger" v-if="errors.has('reject_editor_note')" v-text="errors.first('reject_editor_note')"></span> </div>
</div> @if ($dataset->reject_reviewer_note != null)
<div class="pure-u-1 pure-u-md-1-1">
{!! Form::label('reject_reviewer_note', 'Reviewer reject note..') !!}
{!! Form::text('reject_reviewer_note', null, ['class'=>'pure-u-23-24','readonly']) !!}
</div>
<div class="pure-u-1 pure-u-md-1-1">
<label for="BelongsToBibliography" class="pure-checkbox">
<input type="hidden" name="reviewer_note_visible" value="0">
<input name="reviewer_note_visible" value="1" type="checkbox" class="form-check-input">
should reviewer note be visible to submitter?
</label>
</div>
@else
<div class="pure-u-1 pure-u-md-1-1">
<span class="help is-info">There is no reject note from the reviewer</span>
</div>
@endif
</div> </div>
</fieldset> </fieldset>

View File

@ -56,7 +56,7 @@
<td> <td>
@if ($dataset->server_state == "reviewed") @if ($dataset->server_state == "reviewed")
<a href="{{ URL::route('publish.workflow.publish.publish', $dataset->id) }}" class="pure-button"> <a href="{{ URL::route('publish.workflow.editor.publish', $dataset->id) }}" class="pure-button">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
<span>Publish</span> <span>Publish</span>
</a> </a>

View File

@ -14,7 +14,8 @@
<th>Dataset Title</th> <th>Dataset Title</th>
<th>ID</th> <th>ID</th>
<th>Server State</th> <th>Server State</th>
<th>Editor</th> <th>Editor</th>
<th>remaining time</th>
<th></th> <th></th>
</thead> </thead>
@ -42,10 +43,16 @@
</td> </td>
<td> <td>
{{ $dataset->server_state }} {{ $dataset->server_state }}
</td> </td>
@if ($dataset->server_state == "approved")
<td>editor: {{ optional($dataset->editor)->login }}</td> <td>editor: {{ optional($dataset->editor)->login }}</td>
@endif <td>
{{-- @php
$dateDiff = $dataset['server_date_modified']->addDays(14);
$remainingDays = Carbon\Carbon::now()->diffInDays($dateDiff, false);
@endphp --}}
{{ $dataset->remaining_time . ' days' }}
</td>
<td> <td>
@if ($dataset->server_state == "approved") @if ($dataset->server_state == "approved")

View File

@ -109,6 +109,14 @@ Route::group(
'middleware' => ['permission:dataset-editor-reject'], 'middleware' => ['permission:dataset-editor-reject'],
'as' => 'workflow.editor.rejectUpdate', 'uses' => 'EditorController@rejectUpdate', '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 //reviewer
Route::get('workflow/review/index', [ Route::get('workflow/review/index', [
@ -137,14 +145,14 @@ Route::group(
'middleware' => ['permission:dataset-publish-list'], 'middleware' => ['permission:dataset-publish-list'],
'as' => 'workflow.publish.index', 'uses' => 'PublishController@index', 'as' => 'workflow.publish.index', 'uses' => 'PublishController@index',
]); ]);
Route::get('workflow/publish/{id}', [ // Route::get('workflow/publish/{id}', [
'middleware' => ['permission:dataset-publish'], // 'middleware' => ['permission:dataset-publish'],
'as' => 'workflow.publish.publish', 'uses' => 'PublishController@publish', // 'as' => 'workflow.publish.publish', 'uses' => 'PublishController@publish',
]); // ]);
Route::post('workflow/publish/{id}', [ // Route::post('workflow/publish/{id}', [
'middleware' => ['permission:dataset-publish'], // 'middleware' => ['permission:dataset-publish'],
'as' => 'workflow.publish.publishUpdate', 'uses' => 'PublishController@publishUpdate', // 'as' => 'workflow.publish.publishUpdate', 'uses' => 'PublishController@publishUpdate',
]); // ]);
Route::get('workflow/changestate/{id}/changestate/{targetState}', [ Route::get('workflow/changestate/{id}/changestate/{targetState}', [
'as' => 'review.changestate', 'uses' => 'SubmitController@changestate', 'as' => 'review.changestate', 'uses' => 'SubmitController@changestate',