edit page for editor:
- fields for coverage
This commit is contained in:
parent
fed2fafd55
commit
4c4c0760d8
|
@ -15,6 +15,8 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
// use App\Models\Coverage;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class EditorController extends Controller
|
class EditorController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -87,7 +89,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');
|
$dataset->load('licenses', 'titles', 'abstracts', 'files', 'coverage');
|
||||||
|
|
||||||
$projects = Project::pluck('label', 'id');
|
$projects = Project::pluck('label', 'id');
|
||||||
|
|
||||||
|
@ -123,17 +125,30 @@ class EditorController extends Controller
|
||||||
*/
|
*/
|
||||||
public function update(DocumentRequest $request, $id): RedirectResponse
|
public function update(DocumentRequest $request, $id): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$rules = [
|
||||||
|
'type' => 'required|min:5',
|
||||||
|
'coverage.xmin' => [
|
||||||
|
'nullable',
|
||||||
|
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
||||||
|
],
|
||||||
|
'coverage.ymin' => [
|
||||||
|
'nullable',
|
||||||
|
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
||||||
|
],
|
||||||
|
'coverage.xmax' => [
|
||||||
|
'nullable',
|
||||||
|
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
||||||
|
],
|
||||||
|
'coverage.ymax' => [
|
||||||
|
'nullable',
|
||||||
|
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$validator = Validator::make($request->all(), $rules);
|
||||||
|
if ($validator->passes()) {
|
||||||
$dataset = Dataset::findOrFail($id);
|
$dataset = Dataset::findOrFail($id);
|
||||||
//$input = $request->all();
|
$data = $request->all();
|
||||||
$input = $request->except('abstracts', 'licenses', 'titles', '_method', '_token');
|
$input = $request->except('abstracts', 'licenses', 'titles', 'coverage', '_method', '_token');
|
||||||
// foreach ($input as $key => $value) {
|
|
||||||
// $dataset[$key] = $value;
|
|
||||||
// }
|
|
||||||
//$dataset->update($input);
|
|
||||||
// $dataset->type = $input['type'];
|
|
||||||
// $dataset->thesis_year_accepted = $input['thesis_year_accepted'];
|
|
||||||
// $dataset->project_id = $input['project_id'];
|
|
||||||
// $dataset->save();
|
|
||||||
|
|
||||||
$licenses = $request->input('licenses');
|
$licenses = $request->input('licenses');
|
||||||
//$licenses = $input['licenses'];
|
//$licenses = $input['licenses'];
|
||||||
|
@ -161,6 +176,15 @@ class EditorController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save coverage
|
||||||
|
if (isset($data['coverage'])) {
|
||||||
|
$formCoverage = $request->input('coverage');
|
||||||
|
$coverage = $dataset->coverage()->updateOrCreate(
|
||||||
|
['dataset_id' => $dataset->id],
|
||||||
|
$formCoverage
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$dataset->isDirty(dataset::UPDATED_AT)) {
|
if (!$dataset->isDirty(dataset::UPDATED_AT)) {
|
||||||
$time = new \Illuminate\Support\Carbon();
|
$time = new \Illuminate\Support\Carbon();
|
||||||
$dataset->setUpdatedAt($time);
|
$dataset->setUpdatedAt($time);
|
||||||
|
@ -171,6 +195,17 @@ class EditorController extends Controller
|
||||||
session()->flash('flash_message', 'You have updated 1 dataset!');
|
session()->flash('flash_message', 'You have updated 1 dataset!');
|
||||||
return redirect()->route('publish.workflow.editor.index');
|
return redirect()->route('publish.workflow.editor.index');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//TODO Handle validation error
|
||||||
|
//pass validator errors as errors object for ajax response
|
||||||
|
// return response()->json([
|
||||||
|
// 'success' => false,
|
||||||
|
// 'errors' => $validator->errors()->all(),
|
||||||
|
// ], 422);
|
||||||
|
return back()
|
||||||
|
->withErrors($validator->errors()->all());
|
||||||
|
}
|
||||||
throw new GeneralException(trans('exceptions.backend.dataset.update_error'));
|
throw new GeneralException(trans('exceptions.backend.dataset.update_error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,19 +252,19 @@ class IndexController extends Controller
|
||||||
'title_main.language' => 'required',
|
'title_main.language' => 'required',
|
||||||
'abstract_main.value' => 'required|min:4',
|
'abstract_main.value' => 'required|min:4',
|
||||||
'abstract_main.language' => 'required',
|
'abstract_main.language' => 'required',
|
||||||
'geolocation.xmin' => [
|
'coverage.xmin' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
||||||
],
|
],
|
||||||
'geolocation.ymin' => [
|
'coverage.ymin' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
||||||
],
|
],
|
||||||
'geolocation.xmax' => [
|
'coverage.xmax' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
'regex:/^[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/'
|
||||||
],
|
],
|
||||||
'geolocation.ymax' => [
|
'coverage.ymax' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
'regex:/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?)$/'
|
||||||
],
|
],
|
||||||
|
|
10
composer.lock
generated
10
composer.lock
generated
|
@ -1180,16 +1180,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nikic/php-parser",
|
"name": "nikic/php-parser",
|
||||||
"version": "v4.2.1",
|
"version": "v4.2.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||||
"reference": "5221f49a608808c1e4d436df32884cbc1b821ac0"
|
"reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/5221f49a608808c1e4d436df32884cbc1b821ac0",
|
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bd73cc04c3843ad8d6b0bfc0956026a151fc420",
|
||||||
"reference": "5221f49a608808c1e4d436df32884cbc1b821ac0",
|
"reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1227,7 +1227,7 @@
|
||||||
"parser",
|
"parser",
|
||||||
"php"
|
"php"
|
||||||
],
|
],
|
||||||
"time": "2019-02-16T20:54:15+00:00"
|
"time": "2019-05-25T20:07:01+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "paragonie/random_compat",
|
"name": "paragonie/random_compat",
|
||||||
|
|
|
@ -9,20 +9,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
|
||||||
{!! Form::label('server_state', 'Status..') !!}
|
|
||||||
{{-- {!! Form::select('server_state', Config::get('enums.server_states'), null, ['id' => 'server_state', 'placeholder' => '-- select server state --']) !!} --}}
|
|
||||||
{!! Form::text('server_state', null, ['class'=>'pure-u-23-24','readonly']) !!}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
|
||||||
{!! Form::label('reject_reviewer_note', 'reviewer note..') !!}
|
|
||||||
{{-- {!! Form::select('server_state', Config::get('enums.server_states'), null, ['id' => 'server_state', 'placeholder' => '-- select server state --']) !!} --}}
|
|
||||||
{!! Form::textarea('reject_reviewer_note', null, ['class'=>'pure-u-23-24','readonly']) !!}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
{!! Form::label('project_id', 'Project..') !!}
|
{!! Form::label('project_id', 'Project..') !!}
|
||||||
<div class="select pure-u-23-24">
|
<div class="select pure-u-23-24">
|
||||||
|
@ -31,10 +17,19 @@
|
||||||
<small id="projectHelp" class="pure-form-message-inline">project is optional</small>
|
<small id="projectHelp" class="pure-form-message-inline">project is optional</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- <div class="pure-control-group">
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
{!! Form::label('shelf_id', 'Shelf..') !!}
|
{!! Form::label('server_state', 'Status..') !!}
|
||||||
{!! Form::select('shelf_id', $shelves, null, ['id' => 'shelf_id']) !!}
|
{{-- {!! Form::select('server_state', Config::get('enums.server_states'), null, ['id' => 'server_state', 'placeholder' => '-- select server state --']) !!} --}}
|
||||||
</div> --}}
|
{!! Form::text('server_state', null, ['class'=>'pure-u-23-24','readonly']) !!}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
|
{!! Form::label('reject_reviewer_note', 'reviewer reject note..') !!}
|
||||||
|
{{-- {!! Form::select('server_state', Config::get('enums.server_states'), null, ['id' => 'server_state', 'placeholder' => '-- select server state --']) !!} --}}
|
||||||
|
{!! Form::textarea('reject_reviewer_note', null, ['class'=>'pure-u-23-24','readonly']) !!}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
{!! Form::label('embargo_date', 'Embargo Date') !!}
|
{!! Form::label('embargo_date', 'Embargo Date') !!}
|
||||||
|
@ -44,6 +39,86 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset id="fieldset-geolocation">
|
||||||
|
<legend>Coverage: Geolocation, Elevation, Depth, Time</legend>
|
||||||
|
<div class="pure-g">
|
||||||
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
|
{!! Form::label('xmin', 'xmin: ') !!}
|
||||||
|
{!! Form::text('coverage[xmin]', null, ['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.xmin']) !!}
|
||||||
|
</div>
|
||||||
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
|
{!! Form::label('ymin', 'ymin: ') !!}
|
||||||
|
{!! Form::text('coverage[ymin]', null, ['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.ymin']) !!}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
|
{!! Form::label('xmax', 'xmax: ') !!}
|
||||||
|
{!! Form::text('coverage[xmax]', null, ['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.xmax']) !!}
|
||||||
|
</div>
|
||||||
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
|
{!! Form::label('ymax', 'ymax: ') !!}
|
||||||
|
{!! Form::text('coverage[ymax]', null, ['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.ymax']) !!}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (isset($dataset->elevation_absolut))
|
||||||
|
<div v-show="elevation === 'absolut'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('elevation_absolut', 'elevation absolut: ') !!}
|
||||||
|
{!! Form::text('coverage[elevation_absolut]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.elevation_absolut', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationAbsolut ? 'required|integer' : '' " ]) !!}
|
||||||
|
</div>
|
||||||
|
@elseif (isset($dataset->elevation_min) && isset($dataset->elevation_max))
|
||||||
|
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('elevation_min', 'elevation min: ') !!}
|
||||||
|
{!! Form::text('coverage[elevation_min]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.elevation_min', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
|
||||||
|
</div>
|
||||||
|
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('elevation_max', 'elevation max: ') !!}
|
||||||
|
{!! Form::text('coverage[elevation_max]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.elevation_max', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (isset($dataset->depth_absolut))
|
||||||
|
<div v-show="elevation === 'absolut'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('depth_absolut', 'depth absolut: ') !!}
|
||||||
|
{!! Form::text('coverage[depth_absolut]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.depth_absolut', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationAbsolut ? 'required|integer' : '' " ]) !!}
|
||||||
|
</div>
|
||||||
|
@elseif (isset($dataset->elevation_min) && isset($dataset->elevation_max))
|
||||||
|
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('depth_min', 'depth min: ') !!}
|
||||||
|
{!! Form::text('coverage[depth_min]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.depth_min', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
|
||||||
|
</div>
|
||||||
|
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('depth_max', 'depth max: ') !!}
|
||||||
|
{!! Form::text('coverage[depth_max]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.depth_max', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (isset($dataset->depth_absolut))
|
||||||
|
<div v-show="elevation === 'absolut'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('time_absolut', 'time absolut: ') !!}
|
||||||
|
{!! Form::text('coverage[time_absolut]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.time_absolut', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationAbsolut ? 'required|integer' : '' " ]) !!}
|
||||||
|
</div>
|
||||||
|
@elseif (isset($dataset->elevation_min) && isset($dataset->elevation_max))
|
||||||
|
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('time_min', 'time min: ') !!}
|
||||||
|
{!! Form::text('coverage[time_min]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.time_min', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
|
||||||
|
</div>
|
||||||
|
<div v-show="elevation === 'range'" class="pure-u-1 pure-u-md-1">
|
||||||
|
{!! Form::label('time_max', 'time max: ') !!}
|
||||||
|
{!! Form::text('coverage[time_max]', null,
|
||||||
|
['class' => 'pure-u-23-24', 'v-model' => 'dataset.coverage.time_max', 'data-vv-scope' => 'step-2', "v-validate" => "this.isElevationRange ? 'required|integer' : '' "]) !!}
|
||||||
|
</div>
|
||||||
|
@endif,
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset id="fieldset-titles">
|
<fieldset id="fieldset-titles">
|
||||||
<legend>Title</legend>
|
<legend>Title</legend>
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
|
@ -56,9 +131,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
{{ Form::label('language', 'Language..') }}
|
{{ Form::label('language', 'Language..') }}
|
||||||
<div class="select pure-u-23-24">
|
{{ Form::text('titles['.$title->id.'][language]', $title->language, ['placeholder' => '--no language--', 'class' => 'pure-u-23-24', 'readonly']) }}
|
||||||
{{ Form::select('titles['.$title->id.'][language]', $languages, $title->language, ['placeholder' => '--no language--']) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@ -77,9 +150,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
{{ Form::label('language', 'Language..') }}
|
{{ Form::label('language', 'Language..') }}
|
||||||
<div class="select pure-u-23-24">
|
{{ Form::text('abstracts['.$abstract->id.'][language]', $abstract->language, ['placeholder' => '--no language--', 'class' => 'pure-u-23-24', 'readonly']) }}
|
||||||
{{ Form::select('abstracts['.$abstract->id.'][language]', $languages, $abstract->language, ['placeholder' => '--no language--']) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user