- contributorType in edit form of Editor

- contributorType in OAI
This commit is contained in:
Arno Kaimbacher 2020-05-05 22:13:10 +02:00
parent 3a2336adad
commit cf996de390
14 changed files with 45 additions and 19 deletions

View File

@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\View;
use \Exception;
use Illuminate\Support\Facades\Config;
class EditorController extends Controller
{
@ -125,6 +126,8 @@ class EditorController extends Controller
$languages = DB::table('languages')
->where('active', true)
->pluck('part1', 'part1');
$contributorTypes = Config::get('enums.contributor_types');
// $options = License::all('id', 'name_long');
$licenses = License::select('id', 'name_long', 'link_licence')
@ -148,6 +151,7 @@ class EditorController extends Controller
'dataset',
'titleTypes',
'descriptionTypes',
'contributorTypes',
'languages',
'messages',
'projects',
@ -263,6 +267,7 @@ class EditorController extends Controller
$index = 0;
foreach ($request->get('contributors') as $key => $person) {
$pivot_data = ['role' => 'contributor', 'sort_order' => $index + 1, 'allow_email_contact' => false];
$pivot_data = array_merge($pivot_data, $person['pivot']);
// if ($galery_id == $request->get('mainPicture')) $pivot_data = ['main' => 1];
if (isset($person['id'])) {
// $data_to_sync[$person['id']] = $pivot_data;

View File

@ -400,9 +400,9 @@ class IndexController extends Controller
foreach ($request->get('contributors') as $key => $contributor) {
$pivot_data = [
'role' => 'contributor',
'sort_order' => $key + 1,
'contributor_type' => $contributor['contributor_type']
'sort_order' => $key + 1
];
$pivot_data = array_merge($pivot_data, $contributor['pivot']);
if (isset($contributor['id'])) {
//$data_to_sync[$person['id']] = $pivot_data;
$dataset->persons()->attach($contributor['id'], $pivot_data);

View File

@ -233,6 +233,7 @@ class SubmitController extends Controller
$index = 0;
foreach ($request->get('contributors') as $key => $person) {
$pivot_data = ['role' => 'contributor', 'sort_order' => $index + 1, 'allow_email_contact' => false];
$pivot_data = array_merge($pivot_data, $person['pivot']);
// if ($galery_id == $request->get('mainPicture')) $pivot_data = ['main' => 1];
if (isset($person['id'])) {
// $data_to_sync[$person['id']] = $pivot_data;

View File

@ -59,7 +59,7 @@ trait DatasetExtension
'PersonContributor' => array(
'model' => Person::class,
'through' => 'link_documents_persons',
'pivot' => array('role' => 'contributor'),
'pivot' => array('role' => 'contributor', 'contributor_type' => 'contributor_type'),
// 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
//'sort_field' => 'SortOrder',
'relation' => 'persons',
@ -290,6 +290,7 @@ trait DatasetExtension
$pivotValue = $pivArray['role'];
//$through = $this->externalFields[$fieldname]['through'];
$rows = $this->{$relation}()->wherePivot('role', $pivotValue)->get();
//$rows = $this->{$relation}()->get();
//$rows = $this->belongsToMany($modelclass, $through, 'document_id')->wherePivot('role', $pivotValue)->get();
}
} else {
@ -303,11 +304,23 @@ trait DatasetExtension
// $result[] = $row;//->value;
$attributes = array_keys($row->getAttributes());
if (isset($this->externalFields[$fieldname]['pivot'])) {
$pivotArray = $this->externalFields[$fieldname]['pivot'];
$arrayKeys = array_keys($pivotArray);
$extendedArrayKeys = array_map(function ($pivotAttribute) {
return "pivot_" . $pivotAttribute;
}, $arrayKeys);
$attributes = array_merge($attributes, $extendedArrayKeys);
}
$objArray = [];
foreach ($attributes as $property_name) {
$fieldName = self::convertColumnToFieldname($property_name);
$fieldval = "";
if ($fieldName == "Type") {
if (substr($property_name, 0, 6) === "pivot_") {
$str = ltrim($property_name, 'pivot_');
$fieldName = self::convertColumnToFieldname($str);
$fieldval = $row->pivot->{$str};
} elseif ($fieldName == "Type") {
$fieldval = ucfirst($row->{$property_name});
} else {
// $field =new Field($fieldName);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -122,7 +122,7 @@
<xsl:text>persistent</xsl:text>
</deletedRecord>
<granularity>
<xsl:text>YYYY-MM-DD</xsl:text>
<xsl:text>YYYY-MM-DDThh:mm:ssZ</xsl:text>
</granularity>
<description>
<oai-identifier xmlns="http://www.openarchives.org/OAI/2.0/oai-identifier" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai-identifier http://www.openarchives.org/OAI/2.0/oai-identifier.xsd">

View File

@ -253,13 +253,18 @@
<xsl:template match="PersonContributor" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<contributor>
<xsl:if test="@ContributorType != ''">
<xsl:attribute name="contributorType">
<xsl:value-of select="@ContributorType" />
</xsl:attribute>
</xsl:if>
<contributorName>
<xsl:if test="@NameType != ''">
<!-- <xsl:if test="@NameType != ''">
<xsl:attribute name="nameType">
<xsl:value-of select="@NameType" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@LastName" />
</xsl:if> -->
<xsl:value-of select="concat(@FirstName, ' ',@LastName)" />
</contributorName>
</contributor>
</xsl:template>

View File

@ -119,7 +119,8 @@ export default class EditDataset extends Vue {
this.licenses = window.Laravel.licenses;
this.checkeds = window.Laravel.checkeds;
this.referenceTypes = window.Laravel.referenceTypes;
this.relationTypes = window.Laravel.relationTypes;
this.relationTypes = window.Laravel.relationTypes;
console.log(this.form);
}
created() {

View File

@ -53,8 +53,8 @@
data-vv-scope="step-1" />
</td>
<td v-if="Object.keys(contributortypes).length">
<select type="text" v-bind:name="heading+'['+index+'][contributor_type]'" v-validate="{required: true}"
data-vv-scope="step-1" v-model="item.contributor_type">
<select type="text" v-bind:name="heading+'['+index+'][pivot][contributor_type]'" v-validate="{required: true}"
data-vv-scope="step-1" v-model="item.pivot.contributor_type">
<option v-for="(option, i) in contributortypes" :value="option" :key="i">
{{ option }}
</option>

View File

@ -155,8 +155,7 @@ const app = new Vue({
},
beforeMount() {
this.messages = window.Laravel.messages;
this.contributorTypes = window.Laravel.contributorTypes;
console.log(this.contributorTypes);
this.contributorTypes = window.Laravel.contributorTypes;
},
computed: {
keywords_length() {
@ -334,7 +333,7 @@ const app = new Vue({
formData.append('contributors[' + i + '][email]', contributor.email);
formData.append('contributors[' + i + '][identifier_orcid]', contributor.identifier_orcid);
formData.append('contributors[' + i + '][status]', contributor.status);
formData.append('contributors[' + i + '][contributor_type]', contributor.contributor_type);
formData.append('contributors[' + i + '][pivot][contributor_type]', contributor.pivot.contributor_type);
if (contributor.id !== undefined) {
formData.append('contributors[' + i + '][id]', contributor.id);
}
@ -539,7 +538,7 @@ const app = new Vue({
}
},
addNewContributor() {
let newContributor = { status: 0, first_name: '', last_name: '', email: '', academic_title: '', identifier_orcid: '' };
let newContributor = { status: 0, first_name: '', last_name: '', email: '', academic_title: '', identifier_orcid: '', pivot: { contributor_type: ''} };
this.dataset.contributors.push(newContributor);
},
onAddContributor(person) {
@ -550,6 +549,7 @@ const app = new Vue({
} else if (this.dataset.persons.filter(e => e.id === person.id).length > 0) {
this.$toast.error("person is already defined as author");
} else {
person.pivot = { contributor_type: '' };
this.dataset.contributors.push(person);
this.dataset.checkedContributors.push(person.id);
this.$toast.success("person has been successfully added as contributor");

View File

@ -78,7 +78,7 @@
<input name="authors" v-model="form.authors" type="hidden" class="form-check-input" v-validate="'required'"
data-vv-as="Author">
<person-table name="authors" v-bind:messages="messages" v-bind:heading="'authors'" v-bind:personlist="form.authors"></person-table>
<person-table name="contributors" v-bind:messages="messages" v-bind:heading="'contributors'" v-bind:personlist="form.contributors">
<person-table name="contributors" v-bind:messages="messages" v-bind:contributortypes="contributorTypes" v-bind:heading="'contributors'" v-bind:personlist="form.contributors">
</person-table>
</fieldset>

View File

@ -54,6 +54,7 @@
'form' => $dataset,
'titleTypes' => $titleTypes,
'descriptionTypes' => $descriptionTypes,
'contributorTypes'=> $contributorTypes,
'languages' => $languages,
'messages' => $messages,
'projects' => $projects,

View File

@ -76,7 +76,7 @@
</div>
<input name="authors" v-model="form.authors" type="hidden" class="form-check-input" v-validate="'required'" data-vv-as="Author">
<person-table name="authors" v-bind:messages="messages" v-bind:show-heading="false" v-bind:heading="'authors'" v-bind:personlist="form.authors"></person-table>
<person-table name="contributors" v-bind:messages="messages" v-bind:heading="'contributors'" v-bind:personlist="form.contributors">
<person-table name="contributors" v-bind:messages="messages" v-bind:contributortypes="contributorTypes" v-bind:heading="'contributors'" v-bind:personlist="form.contributors">
</person-table>
</fieldset>