publication workflow

This commit is contained in:
Arno Kaimbacher 2019-01-24 16:56:39 +01:00
parent 32129363ef
commit 39623ff5a6
11 changed files with 153 additions and 139 deletions

View File

@ -9,6 +9,7 @@ use App\Models\File;
use App\Models\Person; use App\Models\Person;
use App\Models\Project; use App\Models\Project;
use App\Models\Title; use App\Models\Title;
use App\Models\Description;
use App\Rules\RdrFiletypes; use App\Rules\RdrFiletypes;
use App\Rules\RdrFilesize; use App\Rules\RdrFilesize;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -231,7 +232,7 @@ class IndexController extends Controller
// 'rights' => 'required|boolean|in:1', // 'rights' => 'required|boolean|in:1',
// ]); // ]);
$rules = [ $rules = [
'server_state' => 'required', // 'server_state' => 'required',
'type' => 'required|min:5', 'type' => 'required|min:5',
'rights' => 'required|boolean|in:1', 'rights' => 'required|boolean|in:1',
'belongs_to_bibliography' => 'required|boolean', 'belongs_to_bibliography' => 'required|boolean',
@ -267,8 +268,10 @@ class IndexController extends Controller
if ($validator->passes()) { if ($validator->passes()) {
//store dataset todo //store dataset todo
//$data = $request->all(); //$data = $request->all();
$input = $request->except('files', 'licenses', 'abstract_main', 'title_main', 'references'); $input = $request->except('files', 'licenses', 'abstract_main', 'title_main', 'references', 'titles');
// array_push($input, "Himbeere"); // array_push($input, "Himbeere");
// $input += ['server_state' => 'created' ];
$input['server_state'] = 'created';
$dataset = new Dataset($input); $dataset = new Dataset($input);
DB::beginTransaction(); //Start transaction! DB::beginTransaction(); //Start transaction!
@ -347,10 +350,18 @@ class IndexController extends Controller
$dataset->addMainTitle($title); $dataset->addMainTitle($title);
} }
//save additional titles
if (isset($data['titles'])) {
foreach ($request->get('titles') as $key => $title) {
$titleReference = new Title($title);
$dataset->titles()->save($titleReference);
}
}
//save main abstract: //save main abstract:
if (isset($data['abstract_main'])) { if (isset($data['abstract_main'])) {
$formAbstract = $request->input('abstract_main'); $formAbstract = $request->input('abstract_main');
$abstract = new Title(); $abstract = new Description();
$abstract->value = $formAbstract['value']; $abstract->value = $formAbstract['value'];
$abstract->language = $formAbstract['language']; $abstract->language = $formAbstract['language'];
$dataset->addMainAbstract($abstract); $dataset->addMainAbstract($abstract);

View File

@ -122,7 +122,7 @@ class DatasetController extends Controller
$languages = DB::table('languages') $languages = DB::table('languages')
->where('active', true) ->where('active', true)
->pluck('part2_t', 'part2_t'); ->pluck('part1', 'part1');
//$options = License::all(); //$options = License::all();
$options = License::all('id', 'name_long'); $options = License::all('id', 'name_long');

View File

@ -69,7 +69,7 @@ trait DatasetExtension
protected $fields = array(); protected $fields = array();
protected function _initFields() protected function initFields()
{ {
$fields = array( $fields = array(
"Id", "Id",
@ -176,7 +176,7 @@ trait DatasetExtension
public function fetchValues() public function fetchValues()
{ {
$this->_initFields(); $this->initFields();
foreach ($this->fields as $fieldname => $field) { foreach ($this->fields as $fieldname => $field) {
if (isset($this->externalFields[$fieldname]) === true) { if (isset($this->externalFields[$fieldname]) === true) {
$fetchmode = 'lazy'; $fetchmode = 'lazy';

View File

@ -7,7 +7,7 @@ use App\Models\Collection;
use App\Models\License; use App\Models\License;
use App\Models\Project; use App\Models\Project;
use App\Models\Description; use App\Models\Description;
use App\Models\Titel; use App\Models\Title;
use App\Models\Person; use App\Models\Person;
use App\Models\XmlCache; use App\Models\XmlCache;
use App\Models\File; use App\Models\File;
@ -28,6 +28,7 @@ class Dataset extends Model
protected $fillable = [ protected $fillable = [
'type', 'type',
'language',
'server_state', 'server_state',
'creating_corporation', 'creating_corporation',
'project_id', 'project_id',
@ -132,7 +133,7 @@ class Dataset extends Model
#region title table: #region title table:
public function titles() public function titles()
{ {
return $this->hasMany(Titel::class, 'document_id', 'id'); return $this->hasMany(Title::class, 'document_id', 'id');
} }
public function addMainTitle(Title $title) public function addMainTitle(Title $title)
@ -152,10 +153,10 @@ class Dataset extends Model
return $this->hasMany(Description::class, 'document_id', 'id'); return $this->hasMany(Description::class, 'document_id', 'id');
} }
public function addMainAbstract(Title $title) public function addMainAbstract(Description $title)
{ {
$title->type = 'abstract'; $title->type = 'abstract';
$this->titlesAbstracts()->save($title); $this->abstracts()->save($title);
// $this->abstracts()->save($title, ['type' => 'abstract']); // $this->abstracts()->save($title, ['type' => 'abstract']);
} }

View File

@ -11,6 +11,9 @@ class Title extends Model
protected $fillable = [ protected $fillable = [
'value',
'type',
'language'
]; ];
public function dataset() public function dataset()

View File

@ -16,6 +16,7 @@ return [
'unpublished' => 'unpublished', 'unpublished' => 'unpublished',
'deleted' => 'deleted', 'deleted' => 'deleted',
'temporary' => 'temporary', 'temporary' => 'temporary',
'created' => 'created',
], ],
'filetypes_allowed' => [ 'filetypes_allowed' => [
"pdf", "txt", "html", "htm", "png", "jpeg", "pdf", "txt", "html", "htm", "png", "jpeg",

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,7 @@ function initialState() {
project_id: "", project_id: "",
creating_corporation: "GBA Repository", creating_corporation: "GBA Repository",
language: "en",
embargo_date: "", embargo_date: "",
belongs_to_bibliography: 0, belongs_to_bibliography: 0,

View File

@ -169,7 +169,7 @@ const app = new Vue({
Additional POST Data Additional POST Data
*/ */
formData.append('type', this.dataset.type); formData.append('type', this.dataset.type);
formData.append('server_state', this.dataset.state); // formData.append('server_state', this.dataset.state);
formData.append('rights', Number(this.dataset.rights)); formData.append('rights', Number(this.dataset.rights));
formData.append('creating_corporation', this.dataset.creating_corporation); formData.append('creating_corporation', this.dataset.creating_corporation);
formData.append('project_id', this.dataset.project_id); formData.append('project_id', this.dataset.project_id);
@ -207,6 +207,13 @@ const app = new Vue({
formData.append('references[' + i + '][relation]', reference.relation); formData.append('references[' + i + '][relation]', reference.relation);
} }
for (var i = 0; i < this.dataset.titles.length; i++) {
let title = this.dataset.titles[i];
formData.append('titles[' + i + '][value]', title.value);
formData.append('titles[' + i + '][language]', title.language);
formData.append('titles[' + i + '][type]', title.type);
}
/* /*
Make the request to the POST /multiple-files URL Make the request to the POST /multiple-files URL
*/ */

View File

@ -57,7 +57,10 @@
</div> </div>
</div> </div>
</div> </div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleMain', 'Add additional title(s) ') !!}
<button class="pure-button button-small" @click.prevent="addTitle()">+</button> <button class="pure-button button-small" @click.prevent="addTitle()">+</button>
</div>
<table class="pure-table pure-table-horizontal" v-if="dataset.titles.length"> <table class="pure-table pure-table-horizontal" v-if="dataset.titles.length">
<thead> <thead>
<tr> <tr>
@ -77,8 +80,8 @@
['placeholder' => '[titleType]', 'v-model' => 'item.type', "v-validate" => "'required'", 'data-vv-scope' => 'step-1']) !!} ['placeholder' => '[titleType]', 'v-model' => 'item.type', "v-validate" => "'required'", 'data-vv-scope' => 'step-1']) !!}
</td> </td>
<td> <td>
{!! Form::select('Title[Relation]', $languages, null, {!! Form::select('Title[Language]', $languages, null,
['placeholder' => '[language]', 'v-model' => 'item.language', 'data-vv-scope' => 'step-1']) !!} ['placeholder' => '[language]', 'v-model' => 'item.language', "v-validate" => "'required'", 'data-vv-scope' => 'step-1']) !!}
</td> </td>
<td> <td>
<button class="pure-button button-small is-warning" @click.prevent="removeTitle(index)">-</button> <button class="pure-button button-small is-warning" @click.prevent="removeTitle(index)">-</button>
@ -88,7 +91,26 @@
</table> </table>
</fieldset> </fieldset>
<fieldset id="fieldset-general"> <fieldset id="fieldset-description">
<legend>Description</legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleAbstract', 'Main Abstract ') !!}
{{ Form::textarea('TitleAbstract[Value]', null, ['class' => 'pure-u-23-24',
'size' => '70x6', 'v-model' => 'dataset.abstract_main.value', "v-validate" => "'required|min:3'",
"data-vv-as" => "Main Abstract", 'data-vv-scope' => 'step-2']) }}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('AbstractLanguage', 'Abstract Language..') !!}
<div class="select pure-u-23-24">
{!! Form::select('TitleAbstract[Language]', $languages, null, ['placeholder' => '--no language--', 'v-model' => 'dataset.abstract_main.language',
"v-validate" => "'required'", "data-vv-as" => "Abstract Language", 'data-vv-scope' => 'step-2']) !!}
</div>
</div>
</div>
</fieldset>
<fieldset id="fieldset-creator">
<legend>Creator(s)</legend> <legend>Creator(s)</legend>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div"> <div class="pure-u-1 pure-u-md-1-2 pure-div">
@ -98,6 +120,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">
<div class="pure-control-group checkboxlist"> <div class="pure-control-group checkboxlist">
<input name="persons" v-model="dataset.checkedAuthors" type="hidden" class="form-check-input" v-validate="'required'" data-vv-as="Creator" data-vv-scope="step-1">
<label v-for="(person, index) in dataset.persons" :for="person.id" class="pure-checkbox"> <label v-for="(person, index) in dataset.persons" :for="person.id" class="pure-checkbox">
<input type="checkbox" name="persons" v-bind:value="person.id" v-model="dataset.checkedAuthors" class="form-check-input" data-vv-scope="step-1"> <input type="checkbox" name="persons" v-bind:value="person.id" v-model="dataset.checkedAuthors" class="form-check-input" data-vv-scope="step-1">
@{{ person.full_name }} @{{ person.full_name }}
@ -156,31 +179,17 @@
<div v-if="step === 2 && isInitial" data-vv-scope="step-2"> <div v-if="step === 2 && isInitial" data-vv-scope="step-2">
<h1>Step Two: Recommended Elements</h1> <h1>Step Two: Recommended Elements</h1>
<fieldset id="fieldset-general">
<legend>General</legend> <fieldset id="fieldset-subject">
<legend>Subject</legend>
<div class="pure-g"> <div class="pure-g">
<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('Type', 'Type..') !!}
<div class="select pure-u-23-24">
{!! Form::select('Type', Lang::get('doctypes'), null, ['id' => 'type', 'placeholder' => '-- select type --', 'v-model' =>
'dataset.type', "v-validate" => "'required'", 'data-vv-scope' => 'step-2']) !!}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('State', 'State..') !!}
{{-- {{ Form::text('State', null, ['class' => 'pure-u-23-24', 'placeholder' => trans('validation.attributes.backend.pages.title'),
'v-model' => 'dataset.state', "v-validate" => "'required'", 'data-vv-scope' => 'step-2', 'readonly' => 'true']) }} --}}
<div class="select pure-u-23-24"> <div class="select pure-u-23-24">
{!! Form::select( 'State', ['unpublished' => 'unpublished', 'inprogress' => 'inprogress'], null, ['id' => 'state', {!! Form::select( 'State', ['unpublished' => 'unpublished', 'inprogress' => 'inprogress'], null, ['id' => 'state',
'placeholder' => '-- select server state --', 'v-model' => 'dataset.state', "v-validate" => "'required'", 'data-vv-scope' => 'step-2'] ) !!} 'placeholder' => '-- select server state --', 'v-model' => 'dataset.state', "v-validate" => "'required'", 'data-vv-scope' => 'step-2'] ) !!}
</div> </div>
{{-- <div class="select pure-u-23-24">
{!! Form::select( 'State', array_except(Config::get('enums.server_states'),['published', 'deleted', 'temporary']), '',
['placeholder' => '-- select server state --', 'v-model' => 'dataset.state', "v-validate" => "'required'", 'data-vv-scope' => 'step-2'] ) !!}
</div> --}} </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('project_id', 'Project..') !!} {!! Form::label('project_id', 'Project..') !!}
@ -191,27 +200,40 @@
<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>
</fieldset>
<fieldset-dates>
<legend>Date(s)</legend>
<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('EmbargoDate', 'Embargo Date') !!} {!! Form::label('EmbargoDate', 'Embargo Date') !!}
{!! Form::date('EmbargoDate', null, ['placeholder' => date('y-m-d'), 'class' {!! Form::date('EmbargoDate', null, ['placeholder' => date('y-m-d'), 'class'
=> 'pure-u-23-24', 'v-model' => 'dataset.embargo_date', 'data-vv-scope' => 'step-2']) !!} => 'pure-u-23-24', 'v-model' => 'dataset.embargo_date', 'data-vv-scope' => 'step-2']) !!}
<small id="projectHelp" class="pure-form-message-inline">EmbargoDate is optional</small> <small id="projectHelp" class="pure-form-message-inline">EmbargoDate is optional</small>
</div> </div>
</fieldset-dates>
{{-- <div class="pure-u-1 pure-u-md-1 checkboxlist"> <fieldset id="fieldset-general">
<!-- checkboxes --> <legend>Contributors</legend>
<label for="BelongsToBibliography" class="pure-checkbox"> <div class="pure-g">
<input name="BelongsToBibliography" v-model="dataset.belongs_to_bibliography" data-vv-scope="step-2" true-value="1" <div class="pure-u-1 pure-u-md-1-2 pure-div">
false-value="0" type="checkbox" class="form-check-input"> <my-autocomplete title="searching active person table" @person="onAddContributor"></my-autocomplete>
Belongs To Bibliography? </div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<label v-for="(contributor, index) in dataset.contributors" :for="contributor.id" class="pure-checkbox">
<input type="checkbox" name="contributors" v-bind:value="contributor.id" v-model="dataset.checkedContributors" class="form-check-input" data-vv-scope="step-2">
@{{ contributor.full_name }}
</label> </label>
</div> --}} <br />
{{-- <span>Checked Contributors: @{{ dataset.checkedContributors }}</span> --}}
</div>
</div>
</div> </div>
</fieldset> </fieldset>
<fieldset id="fieldset-titles"> <fieldset id="fieldset-geolocation">
<legend>Bounding Box</legend> <legend>Geo Location</legend>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-md-1 pure-u-lg-1 pure-div"> <div class="pure-u-1 pure-u-md-1 pure-u-lg-1 pure-div">
<locations-map v-bind:geolocation="dataset.geolocation"></locations-map> <locations-map v-bind:geolocation="dataset.geolocation"></locations-map>
@ -236,58 +258,6 @@
</div> </div>
</fieldset> </fieldset>
<fieldset id="fieldset-titles">
<legend>Main Title & Abstract</legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleMain', 'Main Title ') !!}
{!! Form::text('TitleMain[Value]', null, ['class' => 'pure-u-23-24', 'v-model'
=> 'dataset.title_main.value', "v-validate" => "'required|min:3'", "data-vv-as" => "Main Title", 'data-vv-scope' => 'step-2']) !!}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleLanguage', 'Title Language..') !!}
<div class="select pure-u-23-24">
{!! Form::select('TitleMain[Language]', $languages, null, ['placeholder' => '--no language--', 'v-model' => 'dataset.title_main.language',
"v-validate" => "'required'", "data-vv-as" => "Title Language", 'data-vv-scope' => 'step-2']) !!}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('TitleAbstract', 'Main Abstract ') !!}
{{ Form::textarea('TitleAbstract[Value]', null, ['class' => 'pure-u-23-24',
'size' => '70x6', 'v-model' => 'dataset.abstract_main.value', "v-validate" => "'required|min:3'",
"data-vv-as" => "Main Abstract", 'data-vv-scope' => 'step-2']) }}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('AbstractLanguage', 'Abstract Language..') !!}
<div class="select pure-u-23-24">
{!! Form::select('TitleAbstract[Language]', $languages, null, ['placeholder' => '--no language--', 'v-model' => 'dataset.abstract_main.language',
"v-validate" => "'required'", "data-vv-as" => "Abstract Language", 'data-vv-scope' => 'step-2']) !!}
</div>
</div>
</div>
</fieldset>
<fieldset id="fieldset-licenses">
<legend>Licenses</legend>
<div class="pure-control-group checkboxlist">
@foreach ($licenses as $indexKey => $license)
<label for={{ "license". $license->id }} class="pure-checkbox">
@if ($loop->first)
<input name="licenses" value={{ $license->id }} v-model="dataset.checkedLicenses" type="radio" class="form-check-input" v-validate="'required'"
data-vv-as="Licence" data-vv-scope="step-2">
{{ $license->name_long }}
@else
<input name="licenses" value={{ $license->id }} v-model="dataset.checkedLicenses" type="radio" class="form-check-input" data-vv-scope="step-2">
{{ $license->name_long }}
@endif
</label>
@endforeach
<br>
<span>Checked license: @{{ dataset.checkedLicenses }}</span>
</div>
</fieldset>
<fieldset id="fieldset-references"> <fieldset id="fieldset-references">
<legend>Dataset references</legend> <legend>Dataset references</legend>
<button class="pure-button button-small" @click.prevent="addReference()">Add Reference</button> <button class="pure-button button-small" @click.prevent="addReference()">Add Reference</button>
@ -297,7 +267,7 @@
<th style="width: 20px;">Value of the identifier</th> <th style="width: 20px;">Value of the identifier</th>
<th>Type</th> <th>Type</th>
<th>Relation</th> <th>Relation</th>
<th>Display text of the identifier</th> <th>Label</th>
<th style="width: 130px;"></th> <th style="width: 130px;"></th>
</tr> </tr>
</thead> </thead>
@ -346,30 +316,44 @@
</div> </div>
<div v-if="step === 3 && isInitial" data-vv-scope="step-3"> <div v-if="step === 3 && isInitial" data-vv-scope="step-3">
<h1>Select contributors, submitters</h1> <h1>Step 3: Other Elements</h1>
<fieldset id="fieldset-general"> <fieldset id="fieldset-general">
<legend>Contributors</legend> <legend>Language</legend>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div"> <div class="pure-u-1 pure-u-md-1-2 pure-div">
<my-autocomplete title="searching active person table" @person="onAddContributor"></my-autocomplete> {!! Form::label('Language', 'Language..') !!}
{{-- <div class="select pure-u-23-24">
<my-autocomplete :items="[ 'Apple', 'Banana', 'Orange', 'Mango', 'Pear', 'Peach', 'Grape', 'Tangerine', 'Pineapple']"></my-autocomplete> --}} {!! Form::select('Language', $languages, null,
</div> ['placeholder' => '[language]', 'v-model' => 'dataset.language', "v-validate" => "'required'", 'data-vv-scope' => 'step-3']) !!}
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<label v-for="(contributor, index) in dataset.contributors" :for="contributor.id" class="pure-checkbox">
<input type="checkbox" name="contributors" v-bind:value="contributor.id" v-model="dataset.checkedContributors" class="form-check-input" data-vv-scope="step-3">
@{{ contributor.full_name }}
</label>
<br />
<span>Checked Contributors: @{{ dataset.checkedContributors }}</span>
</div> </div>
<small id="languageHelp" class="pure-form-message-inline">language is optional</small>
</div> </div>
</div> </div>
</fieldset> </fieldset>
<fieldset id="fieldset-general"> <fieldset id="fieldset-licenses">
<legend>Rights List</legend>
<div class="pure-control-group checkboxlist">
@foreach ($licenses as $indexKey => $license)
<label for={{ "license". $license->id }} class="pure-checkbox">
@if ($loop->first)
<input name="licenses" value={{ $license->id }} v-model="dataset.checkedLicenses" type="radio" class="form-check-input" v-validate="'required'"
data-vv-as="Licence" data-vv-scope="step-3">
{{ $license->name_long }}
@else
<input name="licenses" value={{ $license->id }} v-model="dataset.checkedLicenses" type="radio" class="form-check-input" data-vv-scope="step-3">
{{ $license->name_long }}
@endif
</label>
@endforeach
<br>
{{-- <span>Checked license: @{{ dataset.checkedLicenses }}</span> --}}
</div>
</fieldset>
<fieldset id="fieldset-submitters">
<legend>Submitters</legend> <legend>Submitters</legend>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div"> <div class="pure-u-1 pure-u-md-1-2 pure-div">
@ -399,6 +383,12 @@
<span>Review Dataset</span> <span>Review Dataset</span>
</button> </button>
</div> </div>
<div v-if="errors.items.length > 0">
<b>Please correct the following error(s):</b>
<ul class="alert validation-summary-errors">
<li style="margin-left:5px;" v-for="error in errors.items">@{{ error.msg }}</li>
</ul>
</div>
</div> </div>
<div v-if="step === 4 && (isInitial || isSaving)" data-vv-scope="step-4"> <div v-if="step === 4 && (isInitial || isSaving)" data-vv-scope="step-4">

View File

@ -13,7 +13,7 @@
<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('server_state', 'Status..') !!} {!! Form::label('server_state', 'Status..') !!}
<div class="select pure-u-23-24"> <div class="select pure-u-23-24">
{!! Form::select('server_state', Config::get('enums.server_states'), null, ['id' => 'server_state']) !!} {!! Form::select('server_state', Config::get('enums.server_states'), null, ['id' => 'server_state', 'placeholder' => '-- select server state --']) !!}
</div> </div>
</div> </div>