better edit page for editor
This commit is contained in:
parent
4c4c0760d8
commit
4d6664ce3a
|
@ -10,6 +10,8 @@ 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\Subject;
|
||||||
|
use App\Models\File;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
@ -89,7 +91,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');
|
$dataset->load('licenses', 'titles', 'abstracts', 'files', 'coverage', 'subjects');
|
||||||
|
|
||||||
$projects = Project::pluck('label', 'id');
|
$projects = Project::pluck('label', 'id');
|
||||||
|
|
||||||
|
@ -107,10 +109,12 @@ class EditorController extends Controller
|
||||||
//$options = License::all();
|
//$options = License::all();
|
||||||
$options = License::all('id', 'name_long');
|
$options = License::all('id', 'name_long');
|
||||||
$checkeds = $dataset->licenses->pluck('id')->toArray();
|
$checkeds = $dataset->licenses->pluck('id')->toArray();
|
||||||
|
$keywordTypes = ['uncontrolled' => 'uncontrolled', 'swd' => 'swd'];
|
||||||
|
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'workflow.editor.edit',
|
'workflow.editor.edit',
|
||||||
compact('dataset', 'projects', 'options', 'checkeds', 'years', 'languages')
|
compact('dataset', 'projects', 'options', 'checkeds', 'years', 'languages', 'keywordTypes')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +180,27 @@ class EditorController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//save the keywords:
|
||||||
|
$keywords = $request->input('keywords');
|
||||||
|
if (is_array($keywords) && count($keywords) > 0) {
|
||||||
|
foreach ($keywords as $key => $formKeyword) {
|
||||||
|
$subject = Subject::findOrFail($key);
|
||||||
|
$subject->value = $formKeyword['value'];
|
||||||
|
$subject->type = $formKeyword['type'];
|
||||||
|
$subject->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//save the files:
|
||||||
|
$files = $request->input('files');
|
||||||
|
if (is_array($files) && count($files) > 0) {
|
||||||
|
foreach ($files as $key => $formFile) {
|
||||||
|
$file = File::findOrFail($key);
|
||||||
|
$file->label = $formFile['label'];
|
||||||
|
$file->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// save coverage
|
// save coverage
|
||||||
if (isset($data['coverage'])) {
|
if (isset($data['coverage'])) {
|
||||||
$formCoverage = $request->input('coverage');
|
$formCoverage = $request->input('coverage');
|
||||||
|
@ -195,8 +220,7 @@ 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 {
|
||||||
else {
|
|
||||||
//TODO Handle validation error
|
//TODO Handle validation error
|
||||||
//pass validator errors as errors object for ajax response
|
//pass validator errors as errors object for ajax response
|
||||||
// return response()->json([
|
// return response()->json([
|
||||||
|
|
2
public/css/app1.css
vendored
2
public/css/app1.css
vendored
File diff suppressed because one or more lines are too long
|
@ -30,3 +30,7 @@
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pure-form select {
|
||||||
|
height: 2.5em;
|
||||||
|
}
|
|
@ -36,6 +36,13 @@
|
||||||
{!! Form::date('embargo_date', null, ['placeholder' => date('y-m-d'), 'class' => 'pure-u-23-24']) !!}
|
{!! Form::date('embargo_date', null, ['placeholder' => date('y-m-d'), 'class' => 'pure-u-23-24']) !!}
|
||||||
<small id="projectHelp" class="pure-form-message-inline">embargo_date is optional</small>
|
<small id="projectHelp" class="pure-form-message-inline">embargo_date is optional</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
|
{!! Form::label('creating_corporation', 'Creating Corporation') !!}
|
||||||
|
{!! Form::text('creating_corporation', null, ['class' =>
|
||||||
|
'pure-u-23-24', 'v-model' => 'dataset.creating_corporation', "v-validate" => "'required'", 'data-vv-scope' => 'step-1']) !!}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
@ -179,8 +186,44 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset id="fieldset-keywords">
|
||||||
|
<legend>Dataset Keywords</legend>
|
||||||
|
{{-- <table class="table table-hover" v-if="dataset.keywords.length"> --}}
|
||||||
|
@if ($dataset->subjects->count() > 0)
|
||||||
|
<table id="keywords" class="pure-table pure-table-horizontal">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 20px;">Keyword</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th style="width: 130px;"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{-- <tr v-for="(item, index) in dataset.keywords"> --}}
|
||||||
|
@foreach($dataset->subjects as $key => $keyword)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{-- <input name="Keyword Value" class="form-control" placeholder="[KEYWORD VALUE]" v-model="item.value" v-validate="'required'"
|
||||||
|
data-vv-scope="step-2" /> --}}
|
||||||
|
{{ Form::text('keywords['.$keyword->id.'][value]', $keyword->value, ['class' => 'form-control', 'placeholder' => '[KEYWORD VALUE]']) }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{!! Form::select('keywords['.$keyword->id.'][type]', $keywordTypes, $keyword->type, ['placeholder' => '[keyword type]', 'v-model' =>
|
||||||
|
'item.type', "v-validate" => "'required'", 'data-vv-scope' => 'step-2']) !!}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{-- <button class="pure-button button-small is-warning" @click.prevent="removeKeyword(index)">Remove</button> --}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@else
|
||||||
|
<span>...ther are no keywords</span>
|
||||||
|
@endif
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset id="fieldset-abstracts">
|
<fieldset id="fieldset-files">
|
||||||
<legend>Files</legend>
|
<legend>Files</legend>
|
||||||
<table id="items" class="pure-table pure-table-horizontal">
|
<table id="items" class="pure-table pure-table-horizontal">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -199,7 +242,10 @@
|
||||||
<span class="alert">missing file: {{ $file->path_name }}</span>
|
<span class="alert">missing file: {{ $file->path_name }}</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td> {{ $file->label }} </td>
|
<td>
|
||||||
|
{{-- {{ $file->label }} --}}
|
||||||
|
{{ Form::text('files['.$file->id.'][label]', $file->label, ['class' => 'form-control', 'placeholder' => '[FILE LABEL]']) }}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user