code for review update
This commit is contained in:
parent
53e43b7bbf
commit
5193e4f5b5
|
@ -51,16 +51,16 @@ class EditorController extends Controller
|
|||
* @param int $id
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function accept($id): View
|
||||
public function receive($id): View
|
||||
{
|
||||
$dataset = Dataset::with('user:id,login')->findOrFail($id);
|
||||
|
||||
return view('workflow.editor.accept', [
|
||||
return view('workflow.editor.receive', [
|
||||
'dataset' => $dataset,
|
||||
]);
|
||||
}
|
||||
|
||||
public function acceptUpdate(Request $request, $id)
|
||||
public function receiveUpdate(Request $request, $id)
|
||||
{
|
||||
$dataset = Dataset::findOrFail($id);
|
||||
|
||||
|
@ -191,6 +191,7 @@ class EditorController extends Controller
|
|||
'reviewers' => $reviewers,
|
||||
]);
|
||||
}
|
||||
|
||||
public function approveUpdate(Request $request, $id)
|
||||
{
|
||||
// $dataset = Dataset::findOrFail($id);
|
||||
|
|
|
@ -32,6 +32,111 @@ class ReviewController extends Controller
|
|||
->where('server_state', 'approved')
|
||||
->where('reviewer_id', $userId)
|
||||
->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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,8 @@ class SubmitController extends Controller
|
|||
|
||||
$builder = Dataset::query();
|
||||
$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)
|
||||
->with('user:id,login')
|
||||
->get();
|
||||
|
|
|
@ -43,7 +43,7 @@ trait DatasetExtension
|
|||
'pivot' => array('role' => 'author'),
|
||||
//'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
|
||||
//'sort_field' => 'SortOrder',
|
||||
'relation' => 'authors',
|
||||
'relation' => 'persons',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'PersonContributor' => array(
|
||||
|
@ -52,7 +52,7 @@ trait DatasetExtension
|
|||
'pivot' => array('role' => 'contributor'),
|
||||
// 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
|
||||
//'sort_field' => 'SortOrder',
|
||||
'relation' => 'contributors',
|
||||
'relation' => 'persons',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'Subject' => array(
|
||||
|
@ -85,14 +85,9 @@ trait DatasetExtension
|
|||
{
|
||||
$fields = array(
|
||||
"Id",
|
||||
"CompletedDate", "CompletedYear",
|
||||
"ContributingCorporation",
|
||||
"CreatingCorporation",
|
||||
"ThesisDateAccepted", "ThesisYearAccepted",
|
||||
"Edition",
|
||||
"Issue",
|
||||
"Language",
|
||||
"PageFirst", "PageLast", "PageNumber",
|
||||
"PublishedDate", "PublishedYear",
|
||||
"PublisherName", "PublisherPlace",
|
||||
"PublicationState",
|
||||
|
@ -102,7 +97,6 @@ trait DatasetExtension
|
|||
"ServerDateDeleted",
|
||||
"ServerState",
|
||||
"Type",
|
||||
"Volume",
|
||||
"BelongsToBibliography",
|
||||
"EmbargoDate"
|
||||
);
|
||||
|
@ -121,7 +115,7 @@ trait DatasetExtension
|
|||
// Initialize available date fields and set up date validator
|
||||
// if the particular field is present
|
||||
$dateFields = array(
|
||||
'ServerDateCreated', 'CompletedDate', 'PublishedDate',
|
||||
'ServerDateCreated', 'PublishedDate',
|
||||
'ServerDateModified', 'ServerDatePublished', 'ServerDateDeleted', 'EmbargoDate'
|
||||
);
|
||||
foreach ($dateFields as $fieldName) {
|
||||
|
|
|
@ -70,6 +70,37 @@ class Strategy
|
|||
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)
|
||||
{
|
||||
$fields = $model->describe();
|
||||
|
|
|
@ -126,7 +126,7 @@ class XmlModel
|
|||
return $domDocument;
|
||||
}
|
||||
|
||||
//create xml:
|
||||
//$domDocument == null -> create xml:
|
||||
$domDocument = $this->strategy->getDomDocument();
|
||||
//if caching is not desired, return domDocument
|
||||
if (is_null($this->cache)) {
|
||||
|
|
9
public/backend/style.css
vendored
9
public/backend/style.css
vendored
|
@ -957,6 +957,10 @@ textarea.large, input.large {
|
|||
color: whitesmoke;
|
||||
|
||||
}
|
||||
.pure-table tr.reviewed {
|
||||
padding: 0.8em;
|
||||
background-color: #ffed4a;
|
||||
}
|
||||
|
||||
[v-cloak] > * { display:none; }
|
||||
[v-cloak]::before { content: "loading..."; }
|
||||
|
@ -964,10 +968,13 @@ textarea.large, input.large {
|
|||
|
||||
.help {
|
||||
display: block;
|
||||
font-size: 0.75rem;
|
||||
font-size: 12px;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
.help.is-danger {
|
||||
color: #ff3860;
|
||||
}
|
||||
.help.is-info {
|
||||
color: #4dc0b5;
|
||||
}
|
||||
|
|
@ -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>
|
||||
<system.webServer>
|
||||
<rewrite>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<div class="pure-controls">
|
||||
<button :disabled="errors.any()" type="submit" class="pure-button">
|
||||
<i class="fa fa-share"></i>
|
||||
<span>Approve</span>
|
||||
<span>Set Approved</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -52,14 +52,14 @@
|
|||
|
||||
<td>
|
||||
@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>
|
||||
<span>Accept editor task</span>
|
||||
<span>Receive editor task</span>
|
||||
</a>
|
||||
@elseif ($dataset->server_state == "editor_accepted")
|
||||
<a href="{{ URL::route('publish.workflow.editor.edit', $dataset->id) }}" class="pure-button">
|
||||
<i class="fa fa-edit"></i>
|
||||
<span>Improve/Edit</span>
|
||||
<span>Edit</span>
|
||||
</a>
|
||||
<a href="{{ URL::route('publish.workflow.editor.approve', $dataset->id) }}" class="pure-button">
|
||||
<i class="fa fa-share"></i>
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
@section('content')
|
||||
<div class="header">
|
||||
<h3 class="header-title">
|
||||
<i class="fa fa-share"></i> Accept released dataset
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<h3 class="header-title">
|
||||
Release your dataset for Editor
|
||||
<i class="fa fa-share"></i> Receive released dataset
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
|
@ -32,7 +26,7 @@
|
|||
$message = 'If you are not the desired editor, you can still accept the dataset!!';
|
||||
@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']) !!}
|
||||
<fieldset id="fieldset-General">
|
||||
<legend>General</legend>
|
||||
|
@ -66,7 +60,7 @@
|
|||
<div class="pure-controls">
|
||||
<button type="submit" class="pure-button">
|
||||
<i class="fa fa-share"></i>
|
||||
<span>Accept</span>
|
||||
<span>Set Received</span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
<td>
|
||||
@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>
|
||||
<span>Review</span>
|
||||
</a>
|
||||
|
|
77
resources/views/workflow/review/review.blade.php
Normal file
77
resources/views/workflow/review/review.blade.php
Normal 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
|
|
@ -31,6 +31,8 @@
|
|||
$rowclass = 'editor_accepted';
|
||||
} elseif ($dataset->server_state == 'approved') {
|
||||
$rowclass = 'approved';
|
||||
} elseif ($dataset->server_state == 'reviewed') {
|
||||
$rowclass = 'reviewed';
|
||||
}
|
||||
@endphp
|
||||
<tr class="{{ $rowclass }}">
|
||||
|
|
|
@ -77,13 +77,13 @@ Route::group(
|
|||
'middleware' => ['permission:dataset-editor-list'],
|
||||
'as' => 'workflow.editor.index', 'uses' => 'EditorController@index',
|
||||
]);
|
||||
Route::get('workflow/accept/{id}', [
|
||||
'middleware' => ['permission:dataset-accept'],
|
||||
'as' => 'workflow.accept', 'uses' => 'EditorController@accept',
|
||||
Route::get('workflow/receive/{id}', [
|
||||
'middleware' => ['permission:dataset-receive'],
|
||||
'as' => 'workflow.receive', 'uses' => 'EditorController@receive',
|
||||
]);
|
||||
Route::post('workflow/accept/{id}', [
|
||||
'middleware' => ['permission:dataset-accept'],
|
||||
'as' => 'workflow.acceptUpdate', 'uses' => 'EditorController@acceptUpdate',
|
||||
Route::post('workflow/receive/{id}', [
|
||||
'middleware' => ['permission:dataset-receive'],
|
||||
'as' => 'workflow.receiveUpdate', 'uses' => 'EditorController@receiveUpdate',
|
||||
]);
|
||||
Route::get('workflow/edit/{id}', [
|
||||
'middleware' => ['permission:dataset-editor-update'],
|
||||
|
@ -107,6 +107,14 @@ Route::group(
|
|||
'middleware' => ['permission:dataset-review-list'],
|
||||
'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}', [
|
||||
'as' => 'review.changestate', 'uses' => 'SubmitController@changestate',
|
||||
|
|
Loading…
Reference in New Issue
Block a user