- add author during publishing

- defining geolocation is bidirectional
This commit is contained in:
Arno Kaimbacher 2019-06-26 19:01:22 +02:00
parent 0dc6ca034e
commit 4f8ef4fc30
6 changed files with 243 additions and 125 deletions

View file

@ -51,12 +51,12 @@
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<label for="xmax">xmax: </label>
<input name="xmax" type="text" class="pure-u-23-24" v-model="geolocation.xmax" data-vv-scope="step-2" id="xmax" v-validate="'decimal'">
<input name="xmax" type="text" class="pure-u-23-24" v-model="geolocation.xmax" data-vv-scope="step-2" id="xmax" v-validate="'decimal'">
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<label for="ymax">ymax: </label>
<input name="ymax" type="text" class="pure-u-23-24" v-model="geolocation.ymax" data-vv-scope="step-2" id="ymax" v-validate="'decimal'">
<input name="ymax" type="text" class="pure-u-23-24" v-model="geolocation.ymax" data-vv-scope="step-2" id="ymax" v-validate="'decimal'">
</div>
<input type="button" v-on:click="zoomTo" value="validate coordinates">
</div>
@ -71,6 +71,9 @@ import "leaflet-draw";
//const L = window.L;
export default {
inject: {
$validator: '$validator'
},
props: {
geolocation: {
type: Object

View file

@ -43,7 +43,7 @@ Vue.use(VueToast);
Vue.use(VeeValidate, {
// validity: true
useConstraintAttrs: true
});
});
const STATUS_INITIAL = 0, STATUS_SAVING = 1, STATUS_SUCCESS = 2, STATUS_FAILED = 3;
const app = new Vue({
@ -115,18 +115,18 @@ const app = new Vue({
// add the required rule
VeeValidate.Validator.extend('translatedLanguage', {
getMessage: field => 'The translated title must be in a language other than than the dataset language.',
validate: (value, [mainLanguage, type]) => {
validate: (value, [mainLanguage, type]) => {
if (type == "translated") {
return value !== mainLanguage;
}
return true;
}
return true;
}
});
},
mounted() {
//this.step = 2;
this.reset();
this.reset();
},
computed: {
isInitial() {
@ -164,10 +164,10 @@ const app = new Vue({
showModal() {
this.isModalVisible = true;
},
closeModal() {
},
closeModal() {
this.isModalVisible = false;
},
},
reset() {
// reset form to initial state
this.currentStatus = STATUS_INITIAL;
@ -232,11 +232,11 @@ const app = new Vue({
formData.append('abstract_main[language]', this.dataset.abstract_main.language);
if (this.dataset.coverage.xmin !== "" && this.dataset.coverage.ymin != '' &&
this.dataset.coverage.xmax !== '' && this.dataset.coverage.ymax !== '') {
formData.append('coverage[xmin]', this.dataset.coverage.xmin);
formData.append('coverage[ymin]', this.dataset.coverage.ymin);
formData.append('coverage[xmax]', this.dataset.coverage.xmax);
formData.append('coverage[ymax]', this.dataset.coverage.ymax);
this.dataset.coverage.xmax !== '' && this.dataset.coverage.ymax !== '') {
formData.append('coverage[xmin]', this.dataset.coverage.xmin);
formData.append('coverage[ymin]', this.dataset.coverage.ymin);
formData.append('coverage[xmax]', this.dataset.coverage.xmax);
formData.append('coverage[ymax]', this.dataset.coverage.ymax);
}
if (this.isElevationAbsolut) {
@ -244,31 +244,43 @@ const app = new Vue({
}
else if (this.isElevationRange) {
formData.append('coverage[elevation_min]', this.dataset.coverage.elevation_min);
formData.append('coverage[elevation_max]', this.dataset.coverage.elevation_max);
}
formData.append('coverage[elevation_max]', this.dataset.coverage.elevation_max);
}
if (this.isDepthAbsolut) {
formData.append('coverage[depth_absolut]', this.dataset.coverage.depth_absolut);
}
else if (this.isDepthRange) {
formData.append('coverage[depth_min]', this.dataset.coverage.depth_min);
formData.append('coverage[depth_max]', this.dataset.coverage.depth_max);
}
formData.append('coverage[depth_max]', this.dataset.coverage.depth_max);
}
if (this.isTimeAbsolut) {
formData.append('coverage[time_absolut]', this.dataset.coverage.time_absolut);
}
else if (this.isTimeRange) {
formData.append('coverage[time_min]', this.dataset.coverage.time_min);
formData.append('coverage[time_max]', this.dataset.coverage.time_max);
}
formData.append('coverage[time_max]', this.dataset.coverage.time_max);
}
for (var i = 0; i < this.dataset.checkedLicenses.length; 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++) {
let person = this.dataset.persons[i];
formData.append('authors[' + i + '][first_name]', person.first_name);
formData.append('authors[' + i + '][last_name]', person.last_name);
formData.append('authors[' + i + '][email]', person.email);
formData.append('authors[' + i + '][identifier_orcid]', person.identifier_orcid);
formData.append('authors[' + i + '][status]', person.status);
if (person.id !== undefined) {
formData.append('authors[' + i + '][id]', person.id)
}
}
// 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]);
}
@ -286,7 +298,7 @@ const app = new Vue({
for (var i = 0; i < this.dataset.keywords.length; i++) {
let keyword = this.dataset.keywords[i];
formData.append('keywords[' + i + '][value]', keyword.value);
formData.append('keywords[' + i + '][value]', keyword.value);
formData.append('keywords[' + i + '][type]', keyword.type);
}
@ -294,14 +306,14 @@ const app = new Vue({
let title = this.dataset.titles[i];
formData.append('titles[' + i + '][value]', title.value);
formData.append('titles[' + i + '][language]', title.language);
formData.append('titles[' + i + '][type]', title.type);
formData.append('titles[' + i + '][type]', title.type);
}
for (var i = 0; i < this.dataset.descriptions.length; i++) {
let description = this.dataset.descriptions[i];
formData.append('descriptions[' + i + '][value]', description.value);
formData.append('descriptions[' + i + '][language]', description.language);
formData.append('descriptions[' + i + '][type]', description.type);
formData.append('descriptions[' + i + '][type]', description.type);
}
/*
@ -374,20 +386,20 @@ const app = new Vue({
removeReference(key) {
this.dataset.references.splice(key, 1);
},
/*
adds a new Keyword
*/
addKeyword() {
let newKeyword = { value: '', type: '', language: this.dataset.language };
//this.dataset.files.push(uploadedFiles[i]);
this.dataset.keywords.push(newKeyword);
},
/*
adds a new Keyword
*/
addKeyword() {
let newKeyword = { value: '', type: '', language: this.dataset.language };
//this.dataset.files.push(uploadedFiles[i]);
this.dataset.keywords.push(newKeyword);
},
/*
Removes a selected keyword
*/
removeKeyword(key) {
this.dataset.keywords.splice(key, 1);
},
removeKeyword(key) {
this.dataset.keywords.splice(key, 1);
},
addTitle() {
let newTitle = { value: '', language: '', type: '' };
//this.dataset.files.push(uploadedFiles[i]);
@ -416,8 +428,8 @@ const app = new Vue({
let uploadedFiles = fileList;
/*
Adds the uploaded file to the files array
*/
Adds the uploaded file to the files array
*/
for (var i = 0; i < uploadedFiles.length; i++) {
let fileName = uploadedFiles[i].name.replace(/\.[^/.]+$/, '');
let uploadeFile = { file: uploadedFiles[i], label: fileName, sorting: 0 };
@ -430,10 +442,18 @@ const app = new Vue({
// }
},
addNewAuthor() {
let newAuthor = { status: 0, first_name: '', last_name: '', email: '', academic_title: '', identifier_orcid: '' };
this.dataset.persons.push(newAuthor);
},
removeAuthor(key) {
this.dataset.persons.splice(key, 1);
},
onAddAuthor(person) {
//if person is not in person array
//if (this.persons.includes(person) == false) {
if (this.dataset.persons.filter(e => e.id === person.id).length == 0) {
//person.sort_order = this.dataset.persons.length;
this.dataset.persons.push(person);
this.dataset.checkedAuthors.push(person.id);
}

View file

@ -187,18 +187,54 @@
{{--
<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-u-1 pure-u-md-1-2 pure-div">
<div class="pure-control-group checkboxlist">
<input name="persons" v-model="dataset.checkedAuthors" type="hidden" class="form-check-input" v-validate="'required'" data-vv-as="Creator" data-vv-scope="step-1">
<label v-for="(person, index) in dataset.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-1">
@{{ person.full_name }}
</label>
<br />
{{-- <span>Checked Authors: @{{ dataset.checkedAuthors }}</span> --}}
<br />
</div>
</div>
</div> --}}
</div>
<div class="pure-u-1 pure-u-md-1-2 pure-div">
{!! Form::label('additionalCreators', 'Add additional creator(s) if creator is not in database') !!}
<button class="pure-button button-small" @click.prevent="addNewAuthor()">+</button>
</div>
<table class="pure-table pure-table-horizontal" v-if="dataset.persons.length">
<thead>
<tr>
<th>Index</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Orcid</th>
<th style="width: 130px;"></th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in dataset.persons" v-bind:key="item.sort_order" v-bind:class="[item.status==1 ? 'activeClass' : 'inactiveClass']" >
<td>@{{ index }}</td>
<td>
<input name="first_name" class="form-control" placeholder="[FIRST NAME]" v-model="item.first_name" v-bind:readonly="item.status==1" v-validate="'required'" data-vv-scope="step-1" />
</td>
<td>
<input name="last_name" class="form-control" placeholder="[LAST NAME]" v-model="item.last_name" v-bind:readonly="item.status==1" v-validate="'required'" data-vv-scope="step-1" />
</td>
<td>
<input name="email" class="form-control" placeholder="[EMAIL]" v-model="item.email" v-validate="'required|email'" v-bind:readonly="item.status==1" v-validate="'required'" data-vv-scope="step-1" />
</td>
<td>
<input name="identifier_orcid" class="form-control" placeholder="[ORCID]" v-model="item.identifier_orcid" v-bind:readonly="item.status==1" data-vv-scope="step-1" />
<small id="orcidHelp" class="pure-form-message-inline">ORCID is optional</small>
</td>
<td>
<button class="pure-button button-small is-warning" @click.prevent="removeAuthor(index)">-</button>
</td>
</tr>
</tbody>
</table>
</fieldset>
<fieldset id="fieldset-contributors">
@ -419,11 +455,11 @@
<div class="pure-u-1 pure-u-md-1">
<label for="time-option-one" class="pure-radio">
<input id="time-option-one" type="radio" v-model="time" value="absolut">
absolut time
absolut time (dd.MM.yyyy HH:mm:ss)
</label>
<label for="time-option-two" class="pure-radio">
<input id="time-option-two" type="radio" v-model="time" value="range">
time range
time range (dd.MM.yyyy HH:mm:ss)
</label>
<label for="time-option-three" class="pure-radio">
<input id="time-option-three" type="radio" v-model="time" value="no_time">
@ -551,8 +587,6 @@
<div v-if="step === 3 && isInitial" data-vv-scope="step-3">
<h1>Step 3: Other Elements</h1>
<fieldset id="fieldset-licenses">
<legend>Rights List</legend>
@ -679,7 +713,8 @@
<a href="javascript:void(0)" @click="reset()" class="pure-button button-small">Upload new Dataset</a>
</p>
<p>
<a href="javascript:void(0)" @click="editNewDataset()" class="pure-button button-small">@{{ redirectLink }}</a>
{{-- <a href="javascript:void(0)" @click="editNewDataset()" class="pure-button button-small">@{{ redirectLink }}</a> --}}
<a href="javascript:void(0)" @click="editNewDataset()" class="pure-button button-small">Release your submitted dataset</a>
</p>
<ul class="list-unstyled">
{{-- <li v-for="item in uploadedFiles">
@ -726,6 +761,13 @@
.has-error .help-block {
display: block;
}
.activeClass {
background-color: aquamarine;
}
.inactiveClass {
background-color: orange;
}
</style>