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

View File

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

View File

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

View File

@ -59,7 +59,7 @@ trait DatasetExtension
'PersonContributor' => array( 'PersonContributor' => array(
'model' => Person::class, 'model' => Person::class,
'through' => 'link_documents_persons', '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_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
//'sort_field' => 'SortOrder', //'sort_field' => 'SortOrder',
'relation' => 'persons', 'relation' => 'persons',
@ -290,6 +290,7 @@ trait DatasetExtension
$pivotValue = $pivArray['role']; $pivotValue = $pivArray['role'];
//$through = $this->externalFields[$fieldname]['through']; //$through = $this->externalFields[$fieldname]['through'];
$rows = $this->{$relation}()->wherePivot('role', $pivotValue)->get(); $rows = $this->{$relation}()->wherePivot('role', $pivotValue)->get();
//$rows = $this->{$relation}()->get();
//$rows = $this->belongsToMany($modelclass, $through, 'document_id')->wherePivot('role', $pivotValue)->get(); //$rows = $this->belongsToMany($modelclass, $through, 'document_id')->wherePivot('role', $pivotValue)->get();
} }
} else { } else {
@ -303,11 +304,23 @@ trait DatasetExtension
// $result[] = $row;//->value; // $result[] = $row;//->value;
$attributes = array_keys($row->getAttributes()); $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 = []; $objArray = [];
foreach ($attributes as $property_name) { foreach ($attributes as $property_name) {
$fieldName = self::convertColumnToFieldname($property_name); $fieldName = self::convertColumnToFieldname($property_name);
$fieldval = ""; $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}); $fieldval = ucfirst($row->{$property_name});
} else { } else {
// $field =new Field($fieldName); // $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> <xsl:text>persistent</xsl:text>
</deletedRecord> </deletedRecord>
<granularity> <granularity>
<xsl:text>YYYY-MM-DD</xsl:text> <xsl:text>YYYY-MM-DDThh:mm:ssZ</xsl:text>
</granularity> </granularity>
<description> <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"> <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" <xsl:template match="PersonContributor" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<contributor> <contributor>
<xsl:if test="@ContributorType != ''">
<xsl:attribute name="contributorType">
<xsl:value-of select="@ContributorType" />
</xsl:attribute>
</xsl:if>
<contributorName> <contributorName>
<xsl:if test="@NameType != ''"> <!-- <xsl:if test="@NameType != ''">
<xsl:attribute name="nameType"> <xsl:attribute name="nameType">
<xsl:value-of select="@NameType" /> <xsl:value-of select="@NameType" />
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if> -->
<xsl:value-of select="@LastName" /> <xsl:value-of select="concat(@FirstName, ' ',@LastName)" />
</contributorName> </contributorName>
</contributor> </contributor>
</xsl:template> </xsl:template>

View File

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

View File

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

View File

@ -155,8 +155,7 @@ const app = new Vue({
}, },
beforeMount() { beforeMount() {
this.messages = window.Laravel.messages; this.messages = window.Laravel.messages;
this.contributorTypes = window.Laravel.contributorTypes; this.contributorTypes = window.Laravel.contributorTypes;
console.log(this.contributorTypes);
}, },
computed: { computed: {
keywords_length() { keywords_length() {
@ -334,7 +333,7 @@ const app = new Vue({
formData.append('contributors[' + i + '][email]', contributor.email); formData.append('contributors[' + i + '][email]', contributor.email);
formData.append('contributors[' + i + '][identifier_orcid]', contributor.identifier_orcid); formData.append('contributors[' + i + '][identifier_orcid]', contributor.identifier_orcid);
formData.append('contributors[' + i + '][status]', contributor.status); 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) { if (contributor.id !== undefined) {
formData.append('contributors[' + i + '][id]', contributor.id); formData.append('contributors[' + i + '][id]', contributor.id);
} }
@ -539,7 +538,7 @@ const app = new Vue({
} }
}, },
addNewContributor() { 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); this.dataset.contributors.push(newContributor);
}, },
onAddContributor(person) { onAddContributor(person) {
@ -550,6 +549,7 @@ const app = new Vue({
} else if (this.dataset.persons.filter(e => e.id === person.id).length > 0) { } else if (this.dataset.persons.filter(e => e.id === person.id).length > 0) {
this.$toast.error("person is already defined as author"); this.$toast.error("person is already defined as author");
} else { } else {
person.pivot = { contributor_type: '' };
this.dataset.contributors.push(person); this.dataset.contributors.push(person);
this.dataset.checkedContributors.push(person.id); this.dataset.checkedContributors.push(person.id);
this.$toast.success("person has been successfully added as contributor"); 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'" <input name="authors" v-model="form.authors" type="hidden" class="form-check-input" v-validate="'required'"
data-vv-as="Author"> 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="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> </person-table>
</fieldset> </fieldset>

View File

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

View File

@ -76,7 +76,7 @@
</div> </div>
<input name="authors" v-model="form.authors" type="hidden" class="form-check-input" v-validate="'required'" data-vv-as="Author"> <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="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> </person-table>
</fieldset> </fieldset>