Newer
Older
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<h1><%= title %></h1>
<div id="files"></div>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="app" >
PTSEFTON
committed
{{context}} {{changed}}
<h1><a v-bind:href="'?path=' + files.up">.. </a>(Get me outa here!)</h1>
PTSEFTON
committed
<template v-for="(item, id) in context">
PTSEFTON
committed
<tr><th>ID</th><th>{{ id }}</tr>
<tr v-for="(values, name) in item">
PTSEFTON
committed
PTSEFTON
committed
PTSEFTON
committed
<tr v-for="(val, i_index) in values">
<td>
<template v-if="val.id">
<b>{{ context[val.id].name[0].value }} ({{ val.id }})</b>
</template>
<template v-else>
<input v-model="val.value" type="text" size="45" v-on:keyup="trigger_change_on_enter"/>
PTSEFTON
committed
</template>
</td>
<td>
<template v-if="schema.properties[name] && schema.properties[name].input === 'link' " >
PTSEFTON
committed
<form v-on:submit.prevent="linkProp(val)">
<select v-model="link_to_id" >
<template v-for="(link_item, link_id) in context">
<template v-for="other_name in link_item.name">
<option v-if="link_id != val.id && schema.properties[name] && link_item.type && schema.properties[name].type.includes(link_item.type[0].value)" v-bind:value="link_id">{{ other_name.value }}</select>
PTSEFTON
committed
</template>
</template>
</select>
<button type="submit">Link</button>
</form>
</template>
</td>
</tr>
PTSEFTON
committed
</td>
</tr>
</table>
<form v-on:submit.prevent="addContextProp(item)">
<select v-model="prop_name" >
<option value="url">URL</option>
<option value="affiliation">Affiliation</option>
<option value="identifier">Identifier</option>
<option value="creator">Creator</option>
</select>
<button type="submit">Add prop</button>
</form>
<br><br>
</template>
<form v-on:submit.prevent="addContext(context)">
<select v-model="type" >
<option v-for="(type, type_name) in schema.types" v-bind:value="type_name"> {{ type_name }} </option>
</select>
<button type="submit">Add contextual item</button>
</form>
<table>
<tr>
<th>Name:</th>
<td><input v-model="file.name" type="text" size="45"/></td>
</tr>
<tr>
<th>Description:</th>
<td><input v-model="file.description" type="text" size="45"/></td>
<td> <button v-on:click="save()">Save</button>
</td>
</div>
</div>
<div id="filelist" border="1">
<ul v-for="dir in files.dirs">
<li><a v-bind:href="'?path=' + dir.absolute">{{ dir.name }}</a></li>
</ul>
</div>
var save = function save() {
console.log(data);
}
var context = {};
var schema = {};
document.addEventListener("DOMContentLoaded", function(event) {
const urlParams = new URLSearchParams(window.location.search);
const path = urlParams.get('path');
axios.get('/files?path=' + path)
files = response.data;
axios.get("/context_entities").then(function(response){
context = response.data;
axios.get("/schema").then(function(response){
schema = response.data;
schema: schema,
prop: {"name":"nom", "value": "val"},
type: "Person",
prop_name: "",
PTSEFTON
committed
link_to_id: "",
changed: 0
},
methods: {
"save": function save() {
axios.post('/files?path=' + path, this.$data.files.files).then(
)
},
"save_context": function save_context() {
axios.post('/context_entities?path=.', this.context).then(
function () {
}
)
},
"addContextProp": function addContextProp(item){
var prop_name = this.prop_name;
if (item[prop_name]) {
PTSEFTON
committed
item[prop_name].push({"value": "", "id": ""});
PTSEFTON
committed
item[prop_name] = [{"value": "", "id": ""}];
PTSEFTON
committed
this.changed += 1;
},
trigger_change_on_enter: function(e) {
if (e.keyCode === 13) {
this.changed += 1;
this.save_context();
}
PTSEFTON
committed
},
"linkProp": function linkProp(val) {
console.log("ID", this.link_to_id)
console.log("VAL", val.value)
val.value = context[this.link_to_id].name[0].value
val.id = this.link_to_id
this.changed += 1;
this.save_context();
PTSEFTON
committed
},
"addContext": function addContext(context){
var uuid4 = function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var id = "_b" + uuid4()
context[id] = schema.types[this.type].template;
context[id].name=[{"value": id}]
this.changed += 1;
this.save_context();
});
//document.getElementById("files").innerHTML = response['data'].model;
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
})})});