+ add new contributor
+ change sort_order of contributors
This commit is contained in:
parent
9c210a0d96
commit
590c0812fe
|
@ -342,14 +342,27 @@ class IndexController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//store contributors
|
//store contributors
|
||||||
|
// if (isset($data['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()->attach($contributor_id, $pivot_data);
|
||||||
|
// }
|
||||||
|
// //$dataset->persons()->sync($data_to_sync);
|
||||||
|
// }
|
||||||
if (isset($data['contributors'])) {
|
if (isset($data['contributors'])) {
|
||||||
//$data_to_sync = [];
|
//$data_to_sync = [];
|
||||||
foreach ($request->get('contributors') as $key => $contributor_id) {
|
foreach ($request->get('contributors') as $key => $contributor) {
|
||||||
$pivot_data = ['role' => 'contributor', 'sort_order' => $key + 1];
|
$pivot_data = ['role' => 'contributor', 'sort_order' => $key + 1];
|
||||||
//$data_to_sync[$contributor_id] = $pivot_data;
|
if (isset($contributor['id'])) {
|
||||||
$dataset->persons()->attach($contributor_id, $pivot_data);
|
//$data_to_sync[$person['id']] = $pivot_data;
|
||||||
|
$dataset->persons()->attach($contributor['id'], $pivot_data);
|
||||||
|
} else {
|
||||||
|
$dataContributor = new Person($contributor);
|
||||||
|
$dataset->persons()->save($dataContributor, $pivot_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//$dataset->persons()->sync($data_to_sync);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//store submitters
|
//store submitters
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
|
<h3 v-if="heading && personlist.length">{{ heading }}</h3>
|
||||||
<table class="pure-table pure-table-horizontal" v-if="personlist.length">
|
<table class="pure-table pure-table-horizontal" v-if="personlist.length">
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -66,6 +68,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</draggable>
|
</draggable>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -98,7 +101,8 @@ export default {
|
||||||
},
|
},
|
||||||
rowIndex: {
|
rowIndex: {
|
||||||
type: Number
|
type: Number
|
||||||
}
|
},
|
||||||
|
heading: String
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
itemAction(action, data, index) {
|
itemAction(action, data, index) {
|
||||||
|
|
|
@ -290,6 +290,10 @@ const app = new Vue({
|
||||||
formData.append('licenses[' + i + ']', this.dataset.checkedLicenses[i]);
|
formData.append('licenses[' + i + ']', this.dataset.checkedLicenses[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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.persons.length; i++) {
|
for (var i = 0; i < this.dataset.persons.length; i++) {
|
||||||
let person = this.dataset.persons[i];
|
let person = this.dataset.persons[i];
|
||||||
formData.append('authors[' + i + '][first_name]', person.first_name);
|
formData.append('authors[' + i + '][first_name]', person.first_name);
|
||||||
|
@ -302,11 +306,19 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (var i = 0; i < this.dataset.checkedAuthors.length; i++) {
|
// for (var i = 0; i < this.dataset.checkedContributors.length; i++) {
|
||||||
// formData.append('authors[' + i + ']', this.dataset.checkedAuthors[i]);
|
// formData.append('contributors[' + i + ']', this.dataset.checkedContributors[i]);
|
||||||
// }
|
// }
|
||||||
for (var i = 0; i < this.dataset.checkedContributors.length; i++) {
|
for (var i = 0; i < this.dataset.contributors.length; i++) {
|
||||||
formData.append('contributors[' + i + ']', this.dataset.checkedContributors[i]);
|
let contributor = this.dataset.contributors[i];
|
||||||
|
formData.append('contributors[' + i + '][first_name]', contributor.first_name);
|
||||||
|
formData.append('contributors[' + i + '][last_name]', contributor.last_name);
|
||||||
|
formData.append('contributors[' + i + '][email]', contributor.email);
|
||||||
|
formData.append('contributors[' + i + '][identifier_orcid]', contributor.identifier_orcid);
|
||||||
|
formData.append('contributors[' + i + '][status]', contributor.status);
|
||||||
|
if (contributor.id !== undefined) {
|
||||||
|
formData.append('contributors[' + i + '][id]', contributor.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// for (var i = 0; i < this.dataset.checkedSubmitters.length; i++) {
|
// for (var i = 0; i < this.dataset.checkedSubmitters.length; i++) {
|
||||||
// formData.append('submitters[' + i + ']', this.dataset.checkedSubmitters[i]);
|
// formData.append('submitters[' + i + ']', this.dataset.checkedSubmitters[i]);
|
||||||
|
@ -489,6 +501,10 @@ const app = new Vue({
|
||||||
this.dataset.checkedAuthors.push(person.id);
|
this.dataset.checkedAuthors.push(person.id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
addNewContributor() {
|
||||||
|
let newContributor = { status: 0, first_name: '', last_name: '', email: '', academic_title: '', identifier_orcid: '' };
|
||||||
|
this.dataset.contributors.push(newContributor);
|
||||||
|
},
|
||||||
onAddContributor(person) {
|
onAddContributor(person) {
|
||||||
//if person is not in contributors array
|
//if person is not in contributors array
|
||||||
//if (this.contributors.includes(person) == false) {
|
//if (this.contributors.includes(person) == false) {
|
||||||
|
|
|
@ -207,27 +207,32 @@
|
||||||
<button class="pure-button button-small" @click.prevent="addNewAuthor()">+</button>
|
<button class="pure-button button-small" @click.prevent="addNewAuthor()">+</button>
|
||||||
</div>
|
</div>
|
||||||
<input name="persons" v-model="dataset.persons" type="hidden" class="form-check-input" v-validate="'required'" data-vv-as="Creator" data-vv-scope="step-1">
|
<input name="persons" v-model="dataset.persons" type="hidden" class="form-check-input" v-validate="'required'" data-vv-as="Creator" data-vv-scope="step-1">
|
||||||
<h3>Draggable table</h3>
|
<person-table name="persons" v-bind:heading="'creator table'" v-bind:personlist="dataset.persons"></person-table>
|
||||||
<person-table name="persons" v-bind:personlist="dataset.persons"></person-table>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset id="fieldset-contributors">
|
<fieldset id="fieldset-contributors">
|
||||||
<legend>Contributors</legend>
|
<legend>Contributor(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">
|
||||||
<my-autocomplete title="searching active person table" @person="onAddContributor"></my-autocomplete>
|
<my-autocomplete title="searching active person table" @person="onAddContributor"></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="(contributor, index) in dataset.contributors" :for="contributor.id" class="pure-checkbox">
|
<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-1">
|
<input type="checkbox" name="contributors" v-bind:value="contributor.id" v-model="dataset.checkedContributors" class="form-check-input" data-vv-scope="step-1">
|
||||||
@{{ contributor.full_name }}
|
@{{ contributor.full_name }}
|
||||||
</label>
|
</label>
|
||||||
<br />
|
<br />
|
||||||
{{-- <span>Checked Contributors: @{{ dataset.checkedContributors }}</span> --}}
|
<span>Checked Contributors: @{{ dataset.checkedContributors }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div> --}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pure-u-1 pure-u-md-1-2 pure-div">
|
||||||
|
{!! Form::label('additionalContributors', 'Add additional contributor(s) if contributor is not in database') !!}
|
||||||
|
<button class="pure-button button-small" @click.prevent="addNewContributor()">+</button>
|
||||||
</div>
|
</div>
|
||||||
|
{{-- <h3>contributor table</h3> --}}
|
||||||
|
<person-table name="contributors" v-bind:heading="'contributor table'" v-bind:personlist="dataset.contributors"></person-table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset id="fieldset-publisher">
|
<fieldset id="fieldset-publisher">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user