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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -52,11 +52,12 @@ const app = new Vue({
uploadFieldName: 'photos', uploadFieldName: 'photos',
fileCount: 0, fileCount: 0,
persons: [], persons: [],
contributors: [],
step: 1, step: 1,
dataset: { dataset: {
type: '', type: '',
state: 'inprogress', state: '',
rights: null, rights: null,
project_id: '', project_id: '',
@ -74,7 +75,8 @@ const app = new Vue({
}, },
checkedAuthors: [], checkedAuthors: [],
checkedLicenses: [],// [], checkedLicenses: [],// [],
files: [] files: [],
checkedContributors: [],
} }
} }
}, },
@ -164,6 +166,9 @@ const app = new Vue({
for (var i = 0; i < this.dataset.checkedAuthors.length; i++) { for (var i = 0; i < this.dataset.checkedAuthors.length; i++) {
formData.append('authors[' + i + ']', this.dataset.checkedAuthors[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 Make the request to the POST /multiple-files URL
@ -250,6 +255,14 @@ const app = new Vue({
this.dataset.checkedAuthors.push(person.id); 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 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"> <div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('State', 'State..') !!} {!! Form::label('State', 'State..') !!}
{{ Form::text('State', null, ['class' => 'pure-u-23-24', 'placeholder' => trans('validation.attributes.backend.pages.title'), {{-- {{ 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']) }} '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"> {{-- <div class="select pure-u-23-24">
{!! Form::select( 'State', array_except(Config::get('enums.server_states'),['published', 'deleted', 'temporary']), '', {!! 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'] ) !!} ['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"> <div v-if="step === 3" data-vv-scope="step-3">
<h1>Select authors, contributors</h1> <h1>Select authors, contributors</h1>
<fieldset id="fieldset-general"> <fieldset id="fieldset-general">
<legend>Authors</legend> <legend>Authors</legend>
<div class="pure-g"> <div class="pure-g">
@ -220,25 +225,40 @@
{{-- {{--
<my-autocomplete :items="[ 'Apple', 'Banana', 'Orange', 'Mango', 'Pear', 'Peach', 'Grape', 'Tangerine', 'Pineapple']"></my-autocomplete> --}} <my-autocomplete :items="[ 'Apple', 'Banana', 'Orange', 'Mango', 'Pear', 'Peach', 'Grape', 'Tangerine', 'Pineapple']"></my-autocomplete> --}}
</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">
<label v-for="(person, index) in persons" :for="person.id" class="pure-checkbox"> <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"> <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 }} @{{ person.full_name }}
</label> </label>
<br /> <br />
<span>Checked Authors: @{{ dataset.checkedAuthors }}</span> <span>Checked Authors: @{{ dataset.checkedAuthors }}</span>
</div>
</div> </div>
{{-- <span v-for="(person, index) in persons">
<strong>@{{ person.full_name }}</strong>
</span> --}}
</div>
</div> </div>
</fieldset> </fieldset>
<fieldset id="fieldset-general"> <fieldset id="fieldset-general">
<legend>Contributors</legend> <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>
<fieldset id="fieldset-general"> <fieldset id="fieldset-general">
<legend>Submitters</legend> <legend>Submitters</legend>
<small id="submitterHelp" class="pure-form-message-inline">will come soon...</small> <small id="submitterHelp" class="pure-form-message-inline">will come soon...</small>

View File

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

View File

@ -25,6 +25,12 @@
<small id="emailHelp" class="pure-form-message-inline">email is optional.</small> <small id="emailHelp" class="pure-form-message-inline">email is optional.</small>
</div> </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"> <div class="pure-control-group">
{!! Form::label('identifier_orcid', 'ORCID..') !!} {!! Form::label('identifier_orcid', 'ORCID..') !!}
{!! Form::text('identifier_orcid', null, ['class' => 'form-control']) !!} {!! Form::text('identifier_orcid', null, ['class' => 'form-control']) !!}