2020-05-04 11:50:23 +00:00
|
|
|
<template>
|
2019-11-25 13:41:25 +00:00
|
|
|
<div>
|
2020-04-09 15:48:55 +00:00
|
|
|
<h3 v-if="heading && personlist.length && showHeading == true">{{ heading }}</h3>
|
2019-11-25 13:41:25 +00:00
|
|
|
<table class="pure-table pure-table-horizontal" v-if="personlist.length">
|
|
|
|
<thead class="thead-dark">
|
|
|
|
<tr>
|
|
|
|
<th scope="col">#</th>
|
2020-01-09 17:42:09 +00:00
|
|
|
<th scope="col">ID</th>
|
2019-11-25 13:41:25 +00:00
|
|
|
<th scope="col">First Name</th>
|
|
|
|
<th scope="col">Last Name</th>
|
|
|
|
<th scope="col">Email</th>
|
2020-01-28 11:13:01 +00:00
|
|
|
<th scope="col">
|
|
|
|
<label for="language">
|
|
|
|
<span>
|
2020-05-04 11:50:23 +00:00
|
|
|
ORCID <i v-tooltip="{ content: messages.orcid, class: 'tooltip-custom tooltip-other-custom' }"
|
|
|
|
class="far fa-lg fa-question-circle"></i>
|
2020-01-28 11:13:01 +00:00
|
|
|
</span>
|
|
|
|
</label>
|
|
|
|
</th>
|
2020-05-04 11:50:23 +00:00
|
|
|
<th scope="col" v-if="Object.keys(contributortypes).length">
|
|
|
|
<span>Type</span>
|
|
|
|
</th>
|
2019-11-25 13:41:25 +00:00
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2020-05-04 11:50:23 +00:00
|
|
|
<draggable v-bind:list="personlist" tag="tbody" v-on:start="isDragging=true" v-on:end="isDragging=false">
|
|
|
|
<tr v-for="(item, index) in personlist" v-bind:key="item.id"
|
|
|
|
v-bind:class="[item.status==true ? 'activeClass' : 'inactiveClass']">
|
2019-11-25 13:41:25 +00:00
|
|
|
<td scope="row">{{ index + 1 }}</td>
|
2020-01-28 11:13:01 +00:00
|
|
|
<td>
|
2020-05-04 11:50:23 +00:00
|
|
|
<input style="width:30px;" v-bind:name="heading+'['+index+'][id]'" class="form-control" v-model="item.id"
|
|
|
|
readonly data-vv-scope="step-1" />
|
2020-01-28 11:13:01 +00:00
|
|
|
</td>
|
2019-11-25 13:41:25 +00:00
|
|
|
<td>
|
2020-05-04 11:50:23 +00:00
|
|
|
<input v-bind:name="heading+'['+index+'][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" />
|
2019-11-25 13:41:25 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-05-04 11:50:23 +00:00
|
|
|
<input v-bind:name="heading+'['+index+'][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" />
|
2019-11-25 13:41:25 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-01-28 11:13:01 +00:00
|
|
|
<!-- v-validate="'required|email'" -->
|
2020-05-04 11:50:23 +00:00
|
|
|
<input v-bind:name="heading+'['+index+'][email]'" class="form-control" placeholder="[EMAIL]"
|
|
|
|
v-model="item.email" v-validate="{required: true, email: true, unique: [personlist, index, 'email']}"
|
|
|
|
v-bind:readonly="item.status==1" data-vv-scope="step-1" />
|
2019-11-25 13:41:25 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-05-04 11:50:23 +00:00
|
|
|
<input style="width:70px;" v-bind:name="heading+'['+index+'][identifier_orcid]'" class="form-control"
|
|
|
|
placeholder="[ORCID]" v-model="item.identifier_orcid" v-bind:readonly="item.status==1"
|
|
|
|
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">
|
|
|
|
<option v-for="(option, i) in contributortypes" :value="option" :key="i">
|
|
|
|
{{ option }}
|
|
|
|
</option>
|
|
|
|
</select>
|
2019-11-25 13:41:25 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-05-04 11:50:23 +00:00
|
|
|
<button class="pure-button button-small is-warning" @click.prevent="removeAuthor(index)">
|
2019-11-25 13:41:25 +00:00
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</draggable>
|
|
|
|
</table>
|
2019-07-24 07:28:04 +00:00
|
|
|
</div>
|
2019-07-19 15:41:57 +00:00
|
|
|
</template>
|
|
|
|
|
2019-11-25 13:41:25 +00:00
|
|
|
<script lang="ts">
|
2020-05-04 11:50:23 +00:00
|
|
|
import draggable from "vuedraggable";
|
|
|
|
import { Component, Inject, Vue, Prop, Watch } from "vue-property-decorator";
|
|
|
|
import Tooltip from 'vue-directive-tooltip';
|
|
|
|
import 'vue-directive-tooltip/dist/vueDirectiveTooltip.css';
|
|
|
|
Vue.use(Tooltip);
|
2019-11-25 13:41:25 +00:00
|
|
|
|
2020-05-04 11:50:23 +00:00
|
|
|
@Component({
|
|
|
|
components: { draggable }
|
|
|
|
})
|
|
|
|
export default class PersonTable extends Vue {
|
|
|
|
@Inject("$validator") readonly $validator;
|
|
|
|
// inject: {
|
|
|
|
// $validator: "$validator"
|
|
|
|
// },
|
|
|
|
name: "person-table";
|
|
|
|
// components: {
|
|
|
|
// draggable
|
|
|
|
// },
|
2019-11-25 13:41:25 +00:00
|
|
|
|
2020-05-04 11:50:23 +00:00
|
|
|
editable = true;
|
|
|
|
isDragging = false;
|
|
|
|
delayedDragging = false;
|
2019-11-25 13:41:25 +00:00
|
|
|
|
2020-05-04 11:50:23 +00:00
|
|
|
@Prop({ required: true, type: Array })
|
|
|
|
personlist;
|
|
|
|
@Prop({ default: {}, type: Object })
|
|
|
|
contributortypes;
|
|
|
|
@Prop(Number)
|
|
|
|
rowIndex;
|
|
|
|
@Prop(String)
|
|
|
|
heading;
|
|
|
|
@Prop({ required: true, type: Array })
|
|
|
|
messages;
|
|
|
|
@Prop({ default: true, type: Boolean })
|
|
|
|
showHeading;
|
2019-11-25 13:41:25 +00:00
|
|
|
|
2020-05-04 11:50:23 +00:00
|
|
|
// props: {
|
|
|
|
// personlist: {
|
|
|
|
// type: Array,
|
|
|
|
// required: true
|
|
|
|
// },
|
|
|
|
// rowIndex: {
|
|
|
|
// type: Number
|
|
|
|
// },
|
|
|
|
// heading: String
|
|
|
|
// },
|
2019-11-25 13:41:25 +00:00
|
|
|
|
2020-05-04 11:50:23 +00:00
|
|
|
itemAction(action, data, index) {
|
|
|
|
console.log("custom-actions: " + action, data.full_name, index);
|
|
|
|
}
|
2019-11-25 13:41:25 +00:00
|
|
|
|
2020-05-04 11:50:23 +00:00
|
|
|
removeAuthor(key) {
|
|
|
|
this.personlist.splice(key, 1);
|
|
|
|
}
|
2019-11-25 13:41:25 +00:00
|
|
|
|
2020-05-04 11:50:23 +00:00
|
|
|
onMove({ relatedContext, draggedContext }) {
|
|
|
|
const relatedElement = relatedContext.element;
|
|
|
|
const draggedElement = draggedContext.element;
|
|
|
|
return (!relatedElement || !relatedElement.fixed) && !draggedElement.fixed;
|
|
|
|
}
|
2019-11-25 13:41:25 +00:00
|
|
|
}
|
2019-07-19 15:41:57 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2020-05-04 11:50:23 +00:00
|
|
|
.custom-actions button.ui.button {
|
|
|
|
padding: 8px 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.custom-actions button.ui.button>i.icon {
|
|
|
|
margin: auto !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.activeClass {
|
|
|
|
background-color: aquamarine;
|
|
|
|
}
|
|
|
|
|
|
|
|
.inactiveClass {
|
|
|
|
background-color: orange;
|
|
|
|
}
|
2019-07-19 15:41:57 +00:00
|
|
|
</style>
|