Commit 305cd09f authored by Markus Opolka's avatar Markus Opolka
Browse files

Merge branch 'feature-refactor' into 'master'

Feature Refactor

See merge request !6
parents 39b9e081 6686bcdd
<template>
<ul style="list-style-type:none; padding:8px;">
<template v-for="(child, name) in root">
<li><v-chip label outline small color="blue darken-4">{{underscore(capitalize(name))}}</v-chip>
<li><v-chip label outline small color="blue darken-4">{{header(name)}}</v-chip>
<span v-if="isText(child)"> {{child._text}}</span>
<ul v-if="isFeature(child)" style="list-style-type:none; padding:5px;">
<li v-for="attr in child.feature">
<span v-if="attr._attributes">
<v-chip label small v-on:click.native="mark(attr.ref)">
<span v-if="attr._attributes.category">Category: {{(attr._attributes.category)}}</span>
<span v-if="attr._attributes.type">, Type: {{(attr._attributes.type)}}</span>
<span v-if="attr._attributes.subtype">, Subtype: {{(attr._attributes.subtype)}}</span>
</v-chip>
<v-tooltip right>
<v-chip label small v-on:click.native="mark(attr.ref)" slot="activator" :color="background">
<span v-if="attr._attributes.category">Category: {{(attr._attributes.category)}}</span>
<span v-if="attr._attributes.type">, Type: {{(attr._attributes.type)}}</span>
<span v-if="attr._attributes.subtype">, Subtype: {{(attr._attributes.subtype)}}</span>
</v-chip>
<span v-if="attr._attributes.ref">Lines: {{attr._attributes.ref}}</span>
</v-tooltip>
</span>
<span v-else-if="attr.category">
<v-chip label small v-on:click.native="mark(attr.ref)">
<span v-if="attr.category">Category: {{(attr.category)}}</span>
<span v-if="attr.type">, Type: {{(attr.type)}}</span>
<span v-if="attr.subtype">, Subtype: {{(attr.subtype)}}</span>
</v-chip>
<v-tooltip right>
<v-chip label small v-on:click.native="mark(attr.ref)" slot="activator" :color="background">
<span v-if="attr.category">Category: {{(attr.category)}}</span>
<span v-if="attr.type">, Type: {{(attr.type)}}</span>
<span v-if="attr.subtype">, Subtype: {{(attr.subtype)}}</span>
</v-chip>
<span>Lines: {{attr.ref}}</span>
</v-tooltip>
</span>
<span v-else>
<v-chip label small>
<v-chip label small :color="background">
{{cutoff(attr)}}
</v-chip>
</span>
......@@ -37,16 +43,15 @@ export default {
// Recursive Component for Features in a Letter
data () {
return {
data: null
data: null,
background: 'white'
}
},
methods: {
mark (ref) {
// console.log(ref)
},
capitalize (str) {
str = String(str)
return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() })
str = str.replace(/\b\w/g, l => l.toUpperCase())
return str
},
underscore (str) {
str = String(str)
......@@ -56,6 +61,20 @@ export default {
str = String(str)
return str.substr(0, 100)
},
umlaut (str) {
str = String(str)
str = str.replace(/ue/g, 'ü')
str = str.replace(/ae/g, 'ä')
str = str.replace(/Ae/g, 'Ä')
str = str.replace(/oe/g, 'ö')
return str
},
header (str) {
str = this.underscore(str)
str = this.capitalize(str)
str = this.umlaut(str)
return str
},
isAttribute (obj) {
return Object.keys(obj)[0] === '_attributes'
},
......
......@@ -41,6 +41,11 @@
<v-progress-linear indeterminate color="primary"></v-progress-linear>
</v-flex>
<!-- Caching Info -->
<v-snackbar :timeout="timeout" :top="true" :left="true" v-model="snackbar">
Reloaded Document Cache
</v-snackbar>
</v-layout>
</v-container>
......@@ -53,7 +58,9 @@ export default {
return {
header: 'Letters',
letters: null,
reloading: false
reloading: false,
timeout: 1000,
snackbar: false
}
},
methods: {
......@@ -61,19 +68,20 @@ export default {
// Trigger Backend to reload cache
this.reloading = true
this.$http.get('http://localhost:3000/api/metadata/reload').then(function (data) {
this.load()
this.load(true)
})
},
load () {
load (snack) {
// Initial load of metadata
this.$http.get('http://localhost:3000/api/metadata/table').then(function (data) {
this.letters = data.body
this.reloading = false
this.snackbar = snack
})
}
},
created () {
this.load()
this.load(false)
}
}
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment