code for review update

This commit is contained in:
Arno Kaimbacher 2019-04-17 16:01:38 +02:00
parent 53e43b7bbf
commit 5193e4f5b5
15 changed files with 262 additions and 37 deletions

View File

@ -51,16 +51,16 @@ class EditorController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\View\View * @return \Illuminate\View\View
*/ */
public function accept($id): View public function receive($id): View
{ {
$dataset = Dataset::with('user:id,login')->findOrFail($id); $dataset = Dataset::with('user:id,login')->findOrFail($id);
return view('workflow.editor.accept', [ return view('workflow.editor.receive', [
'dataset' => $dataset, 'dataset' => $dataset,
]); ]);
} }
public function acceptUpdate(Request $request, $id) public function receiveUpdate(Request $request, $id)
{ {
$dataset = Dataset::findOrFail($id); $dataset = Dataset::findOrFail($id);
@ -191,6 +191,7 @@ class EditorController extends Controller
'reviewers' => $reviewers, 'reviewers' => $reviewers,
]); ]);
} }
public function approveUpdate(Request $request, $id) public function approveUpdate(Request $request, $id)
{ {
// $dataset = Dataset::findOrFail($id); // $dataset = Dataset::findOrFail($id);

View File

@ -32,6 +32,111 @@ class ReviewController extends Controller
->where('server_state', 'approved') ->where('server_state', 'approved')
->where('reviewer_id', $userId) ->where('reviewer_id', $userId)
->get(); ->get();
return view('workflow.review.index', compact('datasets')); return view('workflow.review.index', [
'datasets' => $datasets
]);
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\View\View
*/
public function review($id): View
{
$dataset = Dataset::with('user:id,login')->findOrFail($id);
$dataset->fetchValues();
$fieldnames = $dataset->describe();
$fields = [];
foreach ($fieldnames as $fieldName) {
$field = $dataset->getField($fieldName);
$modelClass = $field->getValueModelClass();
$fieldValues = $field->getValue($fieldName);
$value = "";
if (null === $modelClass) {
$value = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', "\xEF\xBF\xBD ", $fieldValues);
} else {
// $fieldName = $field->getName();
if (!is_array($fieldValues)) {
$fieldValues = array($fieldValues);
}
foreach ($fieldValues as $fieldValue) {
// if a field has no value then is nothing more to do
// TODO maybe must be there an other solution
// FIXME remove code duplication (duplicates Opus_Model_Xml_Version*)
if (is_null($fieldValue)) {
continue;
}
if ($fieldValue instanceof \Illuminate\Database\Eloquent\Model) {
//$this->_mapModelAttributes($value, $dom, $childNode);
$attributes = array_keys($fieldValue->getAttributes());
foreach ($attributes as $property_name) {
$fieldName = self::convertColumnToFieldname($property_name);
// $field = new Field($fieldName);
$fieldval = $fieldValue->{$property_name};
$value = $value . $fieldName . ": " . $fieldval . "; ";
}
} elseif ($fieldValue instanceof \Carbon\Carbon) {
$value = $value . " Year " . $fieldValue->year;
$value = $value . " Month " . $fieldValue->month;
$value = $value . " Day " . $fieldValue->day;
$value = $value . " Hour " . $fieldValue->hour;
$value = $value . " Minute " . $fieldValue->minute;
$value = $value . " Second " . $fieldValue->second;
$value = $value . " UnixTimestamp " . $fieldValue->timestamp;
$value = $value . " Timezone " . $fieldValue->tzName;
} elseif (is_array($fieldValue)) {
$attributes = $fieldValue;
$value = "<ul>";
foreach ($attributes as $property_name => $subValue) {
// $fieldName = $property_name;
// $fieldval = $subValue;
$value = $value . "<li>" . $property_name . " : " . $subValue . "</li>";
}
$value = $value . "</ul>";
}
}
}
if ($value != "") {
$fields[$fieldName] = $value;
}
}
return view('workflow.review.review', [
'dataset' => $dataset,
'fields' => $fields
]);
}
public function reviewUpdate(Request $request, $id)
{
$dataset = Dataset::findOrFail($id);
$input = $request->all();
$input['server_state'] = 'reviewed';
if ($dataset->update($input)) {
// event(new PageUpdated($page));
return redirect()
->route('publish.workflow.review.index')
->with('flash_message', 'You have successfully reviewed one dataset!');
}
throw new GeneralException(trans('exceptions.publish.review.update_error'));
}
//snakeToCamel
public static function convertColumnToFieldname($columnname)
{
//return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $columnname))));
return ucwords(str_replace(['-', '_'], ' ', $columnname));
} }
} }

View File

@ -25,7 +25,8 @@ class SubmitController extends Controller
$builder = Dataset::query(); $builder = Dataset::query();
$myDatasets = $builder $myDatasets = $builder
->whereIn('server_state', ['inprogress', 'released', 'editor_accepted', 'approved']) ->orderBy('server_state')
->whereIn('server_state', ['inprogress', 'released', 'editor_accepted', 'approved', 'reviewed'])
->where('account_id', $user_id) ->where('account_id', $user_id)
->with('user:id,login') ->with('user:id,login')
->get(); ->get();

View File

@ -43,7 +43,7 @@ trait DatasetExtension
'pivot' => array('role' => 'author'), 'pivot' => array('role' => 'author'),
//'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list. //'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
//'sort_field' => 'SortOrder', //'sort_field' => 'SortOrder',
'relation' => 'authors', 'relation' => 'persons',
'fetch' => 'eager' 'fetch' => 'eager'
), ),
'PersonContributor' => array( 'PersonContributor' => array(
@ -52,7 +52,7 @@ trait DatasetExtension
'pivot' => array('role' => 'contributor'), 'pivot' => array('role' => 'contributor'),
// 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list. // 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
//'sort_field' => 'SortOrder', //'sort_field' => 'SortOrder',
'relation' => 'contributors', 'relation' => 'persons',
'fetch' => 'eager' 'fetch' => 'eager'
), ),
'Subject' => array( 'Subject' => array(
@ -85,14 +85,9 @@ trait DatasetExtension
{ {
$fields = array( $fields = array(
"Id", "Id",
"CompletedDate", "CompletedYear",
"ContributingCorporation", "ContributingCorporation",
"CreatingCorporation", "CreatingCorporation",
"ThesisDateAccepted", "ThesisYearAccepted",
"Edition",
"Issue",
"Language", "Language",
"PageFirst", "PageLast", "PageNumber",
"PublishedDate", "PublishedYear", "PublishedDate", "PublishedYear",
"PublisherName", "PublisherPlace", "PublisherName", "PublisherPlace",
"PublicationState", "PublicationState",
@ -102,7 +97,6 @@ trait DatasetExtension
"ServerDateDeleted", "ServerDateDeleted",
"ServerState", "ServerState",
"Type", "Type",
"Volume",
"BelongsToBibliography", "BelongsToBibliography",
"EmbargoDate" "EmbargoDate"
); );
@ -121,7 +115,7 @@ trait DatasetExtension
// Initialize available date fields and set up date validator // Initialize available date fields and set up date validator
// if the particular field is present // if the particular field is present
$dateFields = array( $dateFields = array(
'ServerDateCreated', 'CompletedDate', 'PublishedDate', 'ServerDateCreated', 'PublishedDate',
'ServerDateModified', 'ServerDatePublished', 'ServerDateDeleted', 'EmbargoDate' 'ServerDateModified', 'ServerDatePublished', 'ServerDateDeleted', 'EmbargoDate'
); );
foreach ($dateFields as $fieldName) { foreach ($dateFields as $fieldName) {

View File

@ -70,6 +70,37 @@ class Strategy
return $this->_config->dom; return $this->_config->dom;
} }
public function getModelFieldValues(Dataset $model)
{
$fields = $model->describe();
$excludeFields = $this->getConfig()->excludeFields;
if (count($excludeFields) > 0) {
$fieldsDiff = array_diff($fields, $excludeFields);
} else {
$fieldsDiff = $fields;
}
foreach ($fieldsDiff as $fieldname) {
$field = $model->getField($fieldname);
$fieldValue = $this->getFieldValue($field);
}
}
protected function getFieldValue(Field $field): string
{
$modelClass = $field->getValueModelClass();
$fieldValues = $field->getValue();
if (null === $modelClass) {
$fieldName = $field->getName();
$fieldValues = $this->getFieldValues($field);
// Replace invalid XML-1.0-Characters by UTF-8 replacement character.
$fieldValues = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', "\xEF\xBF\xBD ", $fieldValues);
}
return fieldValues;
}
protected function _mapModel(Dataset $model, \DOMDocument $dom, \DOMNode $rootNode) protected function _mapModel(Dataset $model, \DOMDocument $dom, \DOMNode $rootNode)
{ {
$fields = $model->describe(); $fields = $model->describe();

View File

@ -126,7 +126,7 @@ class XmlModel
return $domDocument; return $domDocument;
} }
//create xml: //$domDocument == null -> create xml:
$domDocument = $this->strategy->getDomDocument(); $domDocument = $this->strategy->getDomDocument();
//if caching is not desired, return domDocument //if caching is not desired, return domDocument
if (is_null($this->cache)) { if (is_null($this->cache)) {

View File

@ -957,6 +957,10 @@ textarea.large, input.large {
color: whitesmoke; color: whitesmoke;
} }
.pure-table tr.reviewed {
padding: 0.8em;
background-color: #ffed4a;
}
[v-cloak] > * { display:none; } [v-cloak] > * { display:none; }
[v-cloak]::before { content: "loading..."; } [v-cloak]::before { content: "loading..."; }
@ -964,10 +968,13 @@ textarea.large, input.large {
.help { .help {
display: block; display: block;
font-size: 0.75rem; font-size: 12px;
margin-top: 0.25rem; margin-top: 0.25rem;
} }
.help.is-danger { .help.is-danger {
color: #ff3860; color: #ff3860;
} }
.help.is-info {
color: #4dc0b5;
}

View File

@ -1,3 +1,8 @@
<!--
Rewrites requires Microsoft URL Rewrite Module for IIS
Download: https://www.microsoft.com/en-us/download/details.aspx?id=47337
Debug Help: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
-->
<configuration> <configuration>
<system.webServer> <system.webServer>
<rewrite> <rewrite>

View File

@ -38,7 +38,7 @@
<div class="pure-controls"> <div class="pure-controls">
<button :disabled="errors.any()" type="submit" class="pure-button"> <button :disabled="errors.any()" type="submit" class="pure-button">
<i class="fa fa-share"></i> <i class="fa fa-share"></i>
<span>Approve</span> <span>Set Approved</span>
</button> </button>
</div> </div>

View File

@ -52,14 +52,14 @@
<td> <td>
@if ($dataset->server_state == "released") @if ($dataset->server_state == "released")
<a href="{{ URL::route('publish.workflow.accept', $dataset->id) }}" class="pure-button"> <a href="{{ URL::route('publish.workflow.receive', $dataset->id) }}" class="pure-button">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
<span>Accept editor task</span> <span>Receive editor task</span>
</a> </a>
@elseif ($dataset->server_state == "editor_accepted") @elseif ($dataset->server_state == "editor_accepted")
<a href="{{ URL::route('publish.workflow.editor.edit', $dataset->id) }}" class="pure-button"> <a href="{{ URL::route('publish.workflow.editor.edit', $dataset->id) }}" class="pure-button">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
<span>Improve/Edit</span> <span>Edit</span>
</a> </a>
<a href="{{ URL::route('publish.workflow.editor.approve', $dataset->id) }}" class="pure-button"> <a href="{{ URL::route('publish.workflow.editor.approve', $dataset->id) }}" class="pure-button">
<i class="fa fa-share"></i> <i class="fa fa-share"></i>

View File

@ -2,13 +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> Accept released dataset <i class="fa fa-share"></i> Receive released dataset
</h3>
</div>
<div class="header">
<h3 class="header-title">
Release your dataset for Editor
</h3> </h3>
</div> </div>
@ -32,7 +26,7 @@
$message = 'If you are not the desired editor, you can still accept the dataset!!'; $message = 'If you are not the desired editor, you can still accept the dataset!!';
@endphp @endphp
{!! Form::model($dataset, [ 'method' => 'POST', 'route' => ['publish.workflow.acceptUpdate', $dataset->id], 'id' => 'acceptForm', {!! Form::model($dataset, [ 'method' => 'POST', 'route' => ['publish.workflow.receiveUpdate', $dataset->id], 'id' => 'acceptForm',
'class' => 'pure-form', 'enctype' => 'multipart/form-data', 'v-on:submit.prevent' => 'checkForm']) !!} 'class' => 'pure-form', 'enctype' => 'multipart/form-data', 'v-on:submit.prevent' => 'checkForm']) !!}
<fieldset id="fieldset-General"> <fieldset id="fieldset-General">
<legend>General</legend> <legend>General</legend>
@ -66,7 +60,7 @@
<div class="pure-controls"> <div class="pure-controls">
<button type="submit" class="pure-button"> <button type="submit" class="pure-button">
<i class="fa fa-share"></i> <i class="fa fa-share"></i>
<span>Accept</span> <span>Set Received</span>
</button> </button>
</div> </div>

View File

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

View File

@ -0,0 +1,77 @@
@extends('settings.layouts.app')
@section('content')
<div class="header">
<h3 class="header-title">
<i class="fa fa-share"></i> Review approved dataset
</h3>
</div>
<div class="pure-g box-content">
<div class="pure-u-1 pure-u-md-1">
<div>
<a href="{{ route('publish.workflow.editor.index') }}" class="pure-button button-small">
<i class="fa fa-chevron-left"></i>
<span>BACK</span>
</a>
</div>
<div id="app1">
@php
// if ($dataset->editor->id == Auth::user()->id) {
// $userIsDesiredEditor = true;
// } else {
// $userIsDesiredEditor = false;
// $message = 'you are not the desired editor, but you can still accept the dataset';
// }
$message = 'If you are not the desired editor, you can still accept the dataset!!';
@endphp
{!! Form::model($dataset, [ 'method' => 'POST', 'route' => ['publish.workflow.review.reviewUpdate', $dataset->id], 'id' => 'reviewForm',
'class' => 'pure-form', 'enctype' => 'multipart/form-data', 'v-on:submit.prevent' => 'checkForm']) !!}
<fieldset id="fieldset-General">
<legend>Values</legend>
<div class="pure-g">
{{-- <div class="pure-u-1 pure-u-md-1-1 pure-div">
{!! Form::label('title', 'dataset title:') !!}
@if ($dataset->titles()->first())
{{ $dataset->titles()->first()->value }}
@endif
</div>
<div class="pure-u-1 pure-u-md-1-1 pure-div">
{!! Form::label('editor', 'editor:') !!}
{!! $dataset->editor->login !!}
</div>
<div class="pure-u-1 pure-u-md-1-1 pure-div">
{!! Form::label('owner', 'dataset owner:') !!}
{!! $dataset->user->login !!}
</div> --}}
@foreach($fields as $field => $fieldValue)
<div class="pure-u-1 pure-u-md-1-1 pure-div">
{{ Form::label($field, $field . ": ") }}
<span class="help is-info"> {!! $fieldValue !!} </span>
</div>
@endforeach
</div>
</fieldset>
<br />
<div class="pure-controls">
<button type="submit" class="pure-button">
<i class="fa fa-share"></i>
<span>Set reviewed</span>
</button>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@stop
@section('after-scripts')
@stop

View File

@ -31,6 +31,8 @@
$rowclass = 'editor_accepted'; $rowclass = 'editor_accepted';
} elseif ($dataset->server_state == 'approved') { } elseif ($dataset->server_state == 'approved') {
$rowclass = 'approved'; $rowclass = 'approved';
} elseif ($dataset->server_state == 'reviewed') {
$rowclass = 'reviewed';
} }
@endphp @endphp
<tr class="{{ $rowclass }}"> <tr class="{{ $rowclass }}">

View File

@ -77,13 +77,13 @@ Route::group(
'middleware' => ['permission:dataset-editor-list'], 'middleware' => ['permission:dataset-editor-list'],
'as' => 'workflow.editor.index', 'uses' => 'EditorController@index', 'as' => 'workflow.editor.index', 'uses' => 'EditorController@index',
]); ]);
Route::get('workflow/accept/{id}', [ Route::get('workflow/receive/{id}', [
'middleware' => ['permission:dataset-accept'], 'middleware' => ['permission:dataset-receive'],
'as' => 'workflow.accept', 'uses' => 'EditorController@accept', 'as' => 'workflow.receive', 'uses' => 'EditorController@receive',
]); ]);
Route::post('workflow/accept/{id}', [ Route::post('workflow/receive/{id}', [
'middleware' => ['permission:dataset-accept'], 'middleware' => ['permission:dataset-receive'],
'as' => 'workflow.acceptUpdate', 'uses' => 'EditorController@acceptUpdate', 'as' => 'workflow.receiveUpdate', 'uses' => 'EditorController@receiveUpdate',
]); ]);
Route::get('workflow/edit/{id}', [ Route::get('workflow/edit/{id}', [
'middleware' => ['permission:dataset-editor-update'], 'middleware' => ['permission:dataset-editor-update'],
@ -107,6 +107,14 @@ Route::group(
'middleware' => ['permission:dataset-review-list'], 'middleware' => ['permission:dataset-review-list'],
'as' => 'workflow.review.index', 'uses' => 'ReviewController@index', 'as' => 'workflow.review.index', 'uses' => 'ReviewController@index',
]); ]);
Route::get('workflow/review/{id}', [
'middleware' => ['permission:dataset-review'],
'as' => 'workflow.review.review', 'uses' => 'ReviewController@review',
]);
Route::post('workflow/review/{id}', [
'middleware' => ['permission:dataset-review'],
'as' => 'workflow.review.reviewUpdate', 'uses' => 'ReviewController@reviewUpdate',
]);
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',