- edit Dataset before release to editor

- robots.txt avoid search bots
- adapt Dataset.ts and LocationsMap.ts for edit form
- edit createForm for new dataset attributes
- vue-countdown.vue 1800 seconds
This commit is contained in:
Arno Kaimbacher 2019-12-20 11:44:40 +01:00
parent 37a77d019b
commit 43d98a1f82
27 changed files with 1139 additions and 353 deletions

144
resources/js/EditDataset.js Normal file
View file

@ -0,0 +1,144 @@
import { Component, Vue, Watch } from 'vue-property-decorator';
import axios from 'axios';
import VeeValidate from 'vee-validate';
Vue.use(VeeValidate);
import LocationsMap from './components/locations-map.vue';
import Dataset from './components/Dataset';
@Component({
components: {
LocationsMap
}
})
export default class EditDataset extends Vue {
// form: {},
projects = [];
checkeds = '';
form = new Dataset();
// form = {
// // reject_reviewer_note: '',
// language: '',
// type: '',
// project_id: '',
// creating_corporation: 'TETHYS Repository',
// embargo_date: '',
// coverage: {
// xmin: "",
// ymin: "",
// xmax: "",
// ymax: "",
// elevation_min: "",
// elevation_max: "",
// elevation_absolut: "",
// depth_min: "",
// depth_max: "",
// depth_absolut: "",
// time_min: "",
// time_max: "",
// time_absolut: ""
// },
// // checkedAuthors: [],
// // checkedLicenses: [],
// // files: [],
// // keywords: [],
// // references: [],
// titles: [],
// abstratcs: [],
// clicenses : []
// // checkedContributors: []
// };
allErros = [];
success = false;
beforeMount() {
// this.form = window.Laravel.form;
this.realMerge(this.form, window.Laravel.form);
this.projects = window.Laravel.projects;
this.licenses = window.Laravel.licenses;
this.checkeds = window.Laravel.checkeds;
}
/*
* Recursively merge properties of two objects
*/
realMerge(from, dbObject) {
for (var prop in dbObject) {
try {
if (typeof dbObject[prop] !== 'object') {
from[prop] = dbObject[prop];
} else if (this.isObject(dbObject[prop])) {
from[prop] = this.realMerge(from[prop], dbObject[prop]);
}
else if (this.isObject(dbObject[prop]) || this.isObject(from[prop])) {
// coverage relation if null from dbObject
from[prop] = from[prop];
}
else if (Array.isArray(dbObject[prop])) {
from[prop] = dbObject[prop];
}
else {
from[prop] = null;
}
} catch (e) {
// Property in destination object not set; create it and set its value.
from[prop] = dbObject[prop];
}
}
if (from.embargo_date) {
from.embargo_date = this.formatDateFormat(new Date(from.embargo_date), 'yyyy-MM-dd');
}
return from;
}
formatDateFormat(x, y) {
var z = {
M: x.getMonth() + 1,
d: x.getDate(),
h: x.getHours(),
m: x.getMinutes(),
s: x.getSeconds()
};
y = y.replace(/(M+|d+|h+|m+|s+)/g, function (v) {
return ((v.length > 1 ? "0" : "") + eval('z.' + v.slice(-1))).slice(-2)
});
return y.replace(/(y+)/g, function (v) {
return x.getFullYear().toString().slice(-v.length)
});
}
isObject(item) {
return (typeof item === "object" && !Array.isArray(item) && item !== null);
}
onSubmit() {
// var dataform = new FormData();
// dataform.append('name', this.form.name);
// // dataform.append('comments', this.form.comments);
// console.log(this.form.name);
// axios.post('/vuevalidation/form', dataform).then(response => {
// console.log(response);
// this.allerros = [];
// this.form.name = '';
// this.form.comments = [];
// this.success = true;
// }).catch((error) => {
// this.allerros = error.response.data.errors;
// this.success = false;
// });
this.submitted = true;
this.$validator.validate().then(result => {
if (result) {
// console.log('From Submitted!');
document.getElementById("submitEditForm").submit();
return;
}
});
}
}

View file

@ -4,7 +4,7 @@ import { Component, Vue, Watch } from 'vue-property-decorator';
function initialState() {
return {
type: "",
state: "",
server_state: "",
rights: null,
project_id: "",
@ -28,27 +28,27 @@ function initialState() {
// ymax: ""
// },
coverage: {
xmin: "",
ymin: "",
xmax: "",
ymax: "",
elevation_min: "",
elevation_max: "",
elevation_absolut: "",
depth_min: "",
depth_max: "",
depth_absolut: "",
time_min: "",
time_max: "",
time_absolut: ""
x_min: null,
y_min:null,
x_max: null,
y_max: null,
elevation_min: null,
elevation_max: null,
elevation_absolut: null,
depth_min: null,
depth_max: null,
depth_absolut: null,
time_min: null,
time_max: null,
time_absolut: null
},
checkedAuthors: [],
checkedLicenses: [], // [],
files: [],
keywords: [],
subjects: [],
references: [],
titles: [],
descriptions: [],
abstratcs: [],
checkedContributors: [],
// checkedSubmitters: [],
@ -66,7 +66,7 @@ export default class Dataset extends Vue {
// }
initialState = {};
type = "";
state = "";
server_state = "";
rights = null;
project_id = "";
@ -90,10 +90,10 @@ export default class Dataset extends Vue {
// ymax: ""
// },
coverage = {
xmin: "",
ymin: "",
xmax: "",
ymax: "",
x_min: "",
y_min: "",
x_max: "",
y_max: "",
elevation_min: "",
elevation_max: "",
elevation_absolut: "",
@ -107,10 +107,10 @@ export default class Dataset extends Vue {
checkedAuthors = [];
checkedLicenses = [];
files = [];
keywords = [];
subjects = [];
references = [];
titles = [];
descriptions = [];
abstracts = [];
checkedContributors = [];
// checkedSubmitters: [],

View file

@ -7,7 +7,6 @@ export default class DeleteButton extends L.Control {
faIcon: 'fa-trash',
id: "",
text: ""
// faIcon: 'fa-check-circle'
};
geolocation = null;
@ -16,16 +15,6 @@ export default class DeleteButton extends L.Control {
_map = null;
_container = null;
//constructor:
// initialize(options) {
// //util.mixin(this.options, options);
// L.Util.setOptions(this, options);
// // properties
// this.geolocation = options.geolocation;
// this.drawnItems = options.drawnItems;
// this.bounds = options.bounds;
// }
constructor(options) {
super();
//util.mixin(this.options, options);
@ -47,11 +36,6 @@ export default class DeleteButton extends L.Control {
this._container.style.width = "30px";
this._container.style.height = "30px";
this._buildButton();
// container.onclick = function() {
// console.log("buttonClicked");
// };
return this._container;
}
@ -68,10 +52,10 @@ export default class DeleteButton extends L.Control {
}
L.DomEvent.on(_link, 'click', function (ev) {
this.drawnItems.clearLayers();
this.options.geolocation.xmin = "";
this.options.geolocation.ymin = "";
this.options.geolocation.xmax = "";
this.options.geolocation.ymax = "";
this.options.geolocation.x_min = "";
this.options.geolocation.y_min = "";
this.options.geolocation.x_max = "";
this.options.geolocation.y_max = "";
this._map.fitBounds(this.bounds);
},
this);

View file

@ -136,11 +136,11 @@ export default class LocationsMap extends Vue {
// if (type === "rectancle") {
// layer.bindPopup("A popup!" + layer.getBounds().toBBoxString());
var bounds = layer.getBounds();
this.geolocation.xmin = bounds.getSouthWest().lng;
this.geolocation.ymin = bounds.getSouthWest().lat;
this.geolocation.x_min = bounds.getSouthWest().lng;
this.geolocation.y_min = bounds.getSouthWest().lat;
// console.log(this.geolocation.xmin);
this.geolocation.xmax = bounds.getNorthEast().lng;
this.geolocation.ymax = bounds.getNorthEast().lat;
this.geolocation.x_max = bounds.getNorthEast().lng;
this.geolocation.y_max = bounds.getNorthEast().lat;
// }
drawnItems.addLayer(layer);
@ -166,7 +166,7 @@ export default class LocationsMap extends Vue {
}
get validBoundingBox(): boolean {
if (this.geolocation.xmin != "" && this.geolocation.ymin != "" && this.geolocation.xmax != "" && this.geolocation.ymax != "" ) {
if (this.geolocation.x_min != "" && this.geolocation.y_min != "" && this.geolocation.x_max != "" && this.geolocation.y_max != "" ) {
return true;
}
return false;

View file

@ -90,7 +90,7 @@ import { Component, Inject, Vue, Prop, Watch } from "vue-property-decorator";
components: { draggable }
})
export default class PersonTable extends Vue {
@Inject("$validator") readonly $validator!: string;
@Inject("$validator") readonly $validator;
// inject: {
// $validator: "$validator"
// },

View file

@ -8,10 +8,10 @@
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<label for="xmin">xmin:</label>
<input
name="xmin"
name="coverage[x_min]"
type="text"
class="pure-u-23-24"
v-model="geolocation.xmin"
v-model="geolocation.x_min"
data-vv-scope="step-2"
id="xmin"
v-validate="'decimal'"
@ -21,10 +21,10 @@
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<label for="ymin">ymin:</label>
<input
name="ymin"
name="coverage[y_min]"
type="text"
class="pure-u-23-24"
v-model="geolocation.ymin"
v-model="geolocation.y_min"
data-vv-scope="step-2"
id="ymin"
v-validate="'decimal'"
@ -34,10 +34,10 @@
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<label for="xmax">xmax:</label>
<input
name="xmax"
name="coverage[x_max]"
type="text"
class="pure-u-23-24"
v-model="geolocation.xmax"
v-model="geolocation.x_max"
data-vv-scope="step-2"
id="xmax"
v-validate="'decimal'"
@ -47,10 +47,10 @@
<div class="pure-u-1 pure-u-md-1-2 pure-div">
<label for="ymax">ymax:</label>
<input
name="ymax"
name="coverage[y_max]"
type="text"
class="pure-u-23-24"
v-model="geolocation.ymax"
v-model="geolocation.y_max"
data-vv-scope="step-2"
id="ymax"
v-validate="'decimal'"

View file

@ -1,5 +1,5 @@
<template>
<div v-show="warningSeconds <= 600" class="vue-countdown">
<div v-show="warningSeconds <= 1800" class="vue-countdown">
<div class="vue-countdown--time">
remaining time: {{ time }}
</div>

View file

@ -150,7 +150,7 @@ const app = new Vue({
},
computed: {
keywords_length() {
return this.dataset.keywords.length;
return this.dataset.subjects.length;
},
isInitial() {
return this.currentStatus === STATUS_INITIAL;
@ -249,7 +249,7 @@ const app = new Vue({
formData.append('server_state', status);
formData.append('type', this.dataset.type);
formData.append('language', this.dataset.language);
// formData.append('server_state', this.dataset.state);
// formData.append('server_state', this.dataset.server_state);
formData.append('rights', Number(this.dataset.rights));
formData.append('creating_corporation', this.dataset.creating_corporation);
formData.append('project_id', this.dataset.project_id);
@ -262,10 +262,10 @@ const app = new Vue({
if (this.dataset.coverage.xmin !== "" && this.dataset.coverage.ymin != '' &&
this.dataset.coverage.xmax !== '' && this.dataset.coverage.ymax !== '') {
formData.append('coverage[x_min]', this.dataset.coverage.xmin);
formData.append('coverage[y_min]', this.dataset.coverage.ymin);
formData.append('coverage[x_max]', this.dataset.coverage.xmax);
formData.append('coverage[y_max]', this.dataset.coverage.ymax);
formData.append('coverage[x_min]', this.dataset.coverage.x_min);
formData.append('coverage[y_min]', this.dataset.coverage.y_min);
formData.append('coverage[x_max]', this.dataset.coverage.x_max);
formData.append('coverage[y_max]', this.dataset.coverage.y_max);
}
if (this.isElevationAbsolut) {
@ -337,8 +337,8 @@ const app = new Vue({
formData.append('references[' + i + '][relation]', reference.relation);
}
for (var i = 0; i < this.dataset.keywords.length; i++) {
let keyword = this.dataset.keywords[i];
for (var i = 0; i < this.dataset.subjects.length; i++) {
let keyword = this.dataset.subjects[i];
formData.append('keywords[' + i + '][value]', keyword.value);
formData.append('keywords[' + i + '][type]', keyword.type);
formData.append('keywords[' + i + '][language]', keyword.language);
@ -351,8 +351,8 @@ const app = new Vue({
formData.append('titles[' + i + '][type]', title.type);
}
for (var i = 0; i < this.dataset.descriptions.length; i++) {
let description = this.dataset.descriptions[i];
for (var i = 0; i < this.dataset.abstracts.length; i++) {
let description = this.dataset.abstracts[i];
formData.append('descriptions[' + i + '][value]', description.value);
formData.append('descriptions[' + i + '][language]', description.language);
formData.append('descriptions[' + i + '][type]', description.type);
@ -453,13 +453,13 @@ const app = new Vue({
addKeyword() {
let newKeyword = { value: '', type: 'uncontrolled', language: this.dataset.language };
//this.dataset.files.push(uploadedFiles[i]);
this.dataset.keywords.push(newKeyword);
this.dataset.subjects.push(newKeyword);
},
/*
Removes a selected keyword
*/
removeKeyword(key) {
this.dataset.keywords.splice(key, 1);
this.dataset.subjects.splice(key, 1);
},
addTitle() {
let newTitle = { value: '', language: '', type: '' };
@ -475,13 +475,13 @@ const app = new Vue({
addDescription() {
let newTitle = { value: '', language: '', type: '' };
//this.dataset.files.push(uploadedFiles[i]);
this.dataset.descriptions.push(newTitle);
this.dataset.abstracts.push(newTitle);
},
/*
Removes a selected description
*/
removeDescription(key) {
this.dataset.descriptions.splice(key, 1);
this.dataset.abstracts.splice(key, 1);
},
filesChange(fieldName, fileList) {
this.fileCount = fileList.length

View file

@ -0,0 +1,5 @@
import EditDataset from './EditDataset';
const app = new EditDataset({
el: '#app1'
})