add contributors to dataset

This commit is contained in:
Arno Kaimbacher 2018-10-19 12:54:40 +02:00
parent f906b7eb77
commit 14878a20c8
7 changed files with 76 additions and 26 deletions

View File

@ -28,7 +28,8 @@ class IndexController extends Controller
{
$builder = Dataset::query();
$datasets = $builder
->where('server_state', 'inprogress')
//->where('server_state', 'inprogress')
->whereIn('server_state', ['inprogress', 'unpublished'])
->get();
return view('publish.index', compact('datasets'));
}
@ -278,14 +279,22 @@ class IndexController extends Controller
$licenses = $request->input('licenses');
$dataset->licenses()->sync($licenses);
//store authors
$data_to_sync = [];
//store authors
$data_to_sync = [];
foreach ($request->get('authors') as $key => $person_id) {
$pivot_data = ['role' => 'author', 'sort_order' => $key + 1];
// if ($galery_id == $request->get('mainPicture')) $pivot_data = ['main' => 1];
$data_to_sync[$person_id] = $pivot_data;
}
$dataset->persons()->sync($data_to_sync);
//store contributors
$data_to_sync = [];
foreach ($request->get('contributors') as $key => $contributor_id) {
$pivot_data = ['role' => 'contributor', 'sort_order' => $key + 1];
$data_to_sync[$contributor_id] = $pivot_data;
}
$dataset->persons()->sync($data_to_sync);
//save main title:
if (isset($data['title_main'])) {

View File

@ -9,6 +9,7 @@ class Person extends Model
protected $fillable = [
'academic_title',
'date_of_birth',
'last_name',
'first_name',
'email',

File diff suppressed because one or more lines are too long

View File

@ -52,11 +52,12 @@ const app = new Vue({
uploadFieldName: 'photos',
fileCount: 0,
persons: [],
contributors: [],
step: 1,
dataset: {
type: '',
state: 'inprogress',
state: '',
rights: null,
project_id: '',
@ -74,7 +75,8 @@ const app = new Vue({
},
checkedAuthors: [],
checkedLicenses: [],// [],
files: []
files: [],
checkedContributors: [],
}
}
},
@ -164,6 +166,9 @@ const app = new Vue({
for (var i = 0; i < this.dataset.checkedAuthors.length; i++) {
formData.append('authors[' + i + ']', this.dataset.checkedAuthors[i]);
}
for (var i = 0; i < this.dataset.checkedContributors.length; i++) {
formData.append('contributors[' + i + ']', this.dataset.checkedContributors[i]);
}
/*
Make the request to the POST /multiple-files URL
@ -250,6 +255,14 @@ const app = new Vue({
this.dataset.checkedAuthors.push(person.id);
}
},
onAddContributor(person) {
//if person is not in person array
//if (this.persons.includes(person) == false) {
if (this.contributors.filter(e => e.id === person.id).length == 0) {
this.contributors.push(person);
this.dataset.checkedContributors.push(person.id);
}
},
/*
Removes a select file the user has uploaded
*/

View File

@ -95,8 +95,12 @@
<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']) }}
{{-- {{ 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">
{!! Form::select( 'State', ['unpublished', 'inprogress'], null, ['id' => 'state',
'placeholder' => '-- select server state --', 'v-model' => 'dataset.state', "v-validate" => "'required'", 'data-vv-scope' => 'step-2'] ) !!}
</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'] ) !!}
@ -212,6 +216,7 @@
<div v-if="step === 3" data-vv-scope="step-3">
<h1>Select authors, contributors</h1>
<fieldset id="fieldset-general">
<legend>Authors</legend>
<div class="pure-g">
@ -220,25 +225,40 @@
{{--
<my-autocomplete :items="[ 'Apple', 'Banana', 'Orange', 'Mango', 'Pear', 'Peach', 'Grape', 'Tangerine', 'Pineapple']"></my-autocomplete> --}}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<label v-for="(person, index) in 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-3">
@{{ person.full_name }}
</label>
<br />
<span>Checked Authors: @{{ dataset.checkedAuthors }}</span>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<label v-for="(person, index) in 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-3">
@{{ person.full_name }}
</label>
<br />
<span>Checked Authors: @{{ dataset.checkedAuthors }}</span>
</div>
</div>
{{-- <span v-for="(person, index) in persons">
<strong>@{{ person.full_name }}</strong>
</span> --}}
</div>
</div>
</fieldset>
<fieldset id="fieldset-general">
<legend>Contributors</legend>
<small id="contributorHelp" class="pure-form-message-inline">will come soon...</small>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<my-autocomplete title="searching active person table" @person="onAddContributor"></my-autocomplete>
{{--
<my-autocomplete :items="[ 'Apple', 'Banana', 'Orange', 'Mango', 'Pear', 'Peach', 'Grape', 'Tangerine', 'Pineapple']"></my-autocomplete> --}}
</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 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>
</div>
</fieldset>
<fieldset id="fieldset-general">
<legend>Submitters</legend>
<small id="submitterHelp" class="pure-form-message-inline">will come soon...</small>

View File

@ -37,11 +37,12 @@
</td>
<td>
{{-- <a class="edit" href="{{ route('settings.document.edit', $dataset->id) }}">
<span>publish</span>
</a> --}}
<a href="" class="pure-button button-small">Publish</a>
<a href="" class="pure-button button-small">Restrict</a>
@if ($dataset->server_state == "unpublished")
<a href="" class="pure-button button-small is-success">Publish</a>
<a href="" class="pure-button button-small is-success">Restrict</a>
@else
<a href="" class="pure-button button-small is-warning">Finish</a>
@endif
</td>
</tr>
@endforeach

View File

@ -25,6 +25,12 @@
<small id="emailHelp" class="pure-form-message-inline">email is optional.</small>
</div>
<div class="pure-control-group">
{!! Form::label('date_of_birth', 'Date Of Birth..') !!}
{!! Form::date('date_of_birth', null, ['placeholder' => date('y-m-d'), 'class' => 'form-control']) !!}
<small id="emailHelp" class="pure-form-message-inline">date of birth is optional.</small>
</div>
<div class="pure-control-group">
{!! Form::label('identifier_orcid', 'ORCID..') !!}
{!! Form::text('identifier_orcid', null, ['class' => 'form-control']) !!}