Commands and such
Former-commit-id: e2a84ea45e19a6c34c2a89fa2804ce63c35cbf53 [formerly d995af7874f5ee0ee22442357ebd4e160bed2786] [formerly ee876a568e127817caae55506ab128246237b5a8 [formerly 729064ffc8fb140d667ff39a04ddd122529a19cb]] Former-commit-id: 64554cfd503eab2e5daf0b33971fea1924ac8249 [formerly 8b6fa3f88083530ceeab62d52fbc381b1ac6c335] Former-commit-id: 3df08dbb64f46dee8c4ceebfcac273038960eec1
This commit is contained in:
@@ -46,7 +46,7 @@ export default {
|
||||
this.content = CodeMirror(document.getElementById('editor'), {
|
||||
value: this.req.content,
|
||||
lineNumbers: (this.req.language !== 'markdown'),
|
||||
viewportMargin: Infinity,
|
||||
viewportMargin: 500,
|
||||
autofocus: true,
|
||||
mode: this.req.language,
|
||||
theme: (this.req.language === 'markdown') ? 'markdown' : 'ttcn',
|
||||
|
||||
@@ -81,9 +81,9 @@ export default {
|
||||
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
if (i === 0) {
|
||||
breadcrumbs.push({ name: parts[i], url: '/' + parts[i] + '/' })
|
||||
breadcrumbs.push({ name: decodeURIComponent(parts[i]), url: '/' + parts[i] + '/' })
|
||||
} else {
|
||||
breadcrumbs.push({ name: parts[i], url: breadcrumbs[i - 1].url + parts[i] + '/' })
|
||||
breadcrumbs.push({ name: decodeURIComponent(parts[i]), url: breadcrumbs[i - 1].url + parts[i] + '/' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
per line. If the event is related to files, such as before and after saving, the environment variable
|
||||
<code>file</code> will be available with the path of the file.</p>
|
||||
|
||||
<h3>Before Save</h3>
|
||||
<textarea v-model.trim="beforeSave"></textarea>
|
||||
|
||||
<h3>After Save</h3>
|
||||
<textarea v-model.trim="afterSave"></textarea>
|
||||
<template v-for="command in commands">
|
||||
<h3>{{ capitalize(command.name) }}</h3>
|
||||
<textarea v-model.trim="command.value"></textarea>
|
||||
</template>
|
||||
|
||||
<p><input type="submit" value="Save"></p>
|
||||
</form>
|
||||
@@ -34,6 +33,7 @@ export default {
|
||||
name: 'settings',
|
||||
data: function () {
|
||||
return {
|
||||
commands: [],
|
||||
beforeSave: '',
|
||||
afterSave: ''
|
||||
}
|
||||
@@ -44,23 +44,46 @@ export default {
|
||||
created () {
|
||||
api.getCommands()
|
||||
.then(commands => {
|
||||
this.beforeSave = commands['before_save'].join('\n')
|
||||
this.afterSave = commands['after_save'].join('\n')
|
||||
for (let key in commands) {
|
||||
this.commands.push({
|
||||
name: key,
|
||||
value: commands[key].join('\n')
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(error => { this.showError(error) })
|
||||
|
||||
api.getPlugins()
|
||||
.then(plugins => {
|
||||
console.log(plugins)
|
||||
})
|
||||
.catch(error => { this.showError(error) })
|
||||
},
|
||||
methods: {
|
||||
...mapMutations([ 'showSuccess', 'showError' ]),
|
||||
capitalize (name) {
|
||||
let splitted = name.split('_')
|
||||
name = ''
|
||||
|
||||
for (let i = 0; i < splitted.length; i++) {
|
||||
name += splitted[i].charAt(0).toUpperCase() + splitted[i].slice(1) + ' '
|
||||
}
|
||||
|
||||
return name.slice(0, -1)
|
||||
},
|
||||
saveCommands (event) {
|
||||
event.preventDefault()
|
||||
|
||||
let commands = {
|
||||
'before_save': this.beforeSave.split('\n'),
|
||||
'after_save': this.afterSave.split('\n')
|
||||
}
|
||||
let commands = {}
|
||||
|
||||
if (commands['before_save'].length === 1 && commands['before_save'][0] === '') commands['before_save'] = []
|
||||
if (commands['after_save'].length === 1 && commands['after_save'][0] === '') commands['after_save'] = []
|
||||
for (let command of this.commands) {
|
||||
let value = command.value.split('\n')
|
||||
if (value.length === 1 && value[0] === '') {
|
||||
value = []
|
||||
}
|
||||
|
||||
commands[command.name] = value
|
||||
}
|
||||
|
||||
api.updateCommands(commands)
|
||||
.then(() => { this.showSuccess('Commands updated!') })
|
||||
|
||||
Reference in New Issue
Block a user