refactor: Source view Vue component

pull/112/head
NGPixel 8 years ago
parent bf6eae1428
commit 45d94e7e94

@ -29,6 +29,7 @@ import adminUsersCreateComponent from './modals/admin-users-create.vue'
import adminProfileComponent from './pages/admin-profile.component.js'
import adminSettingsComponent from './pages/admin-settings.component.js'
import sourceComponent from './pages/source.component.js'
// ====================================
// Initialize Vue Modules
@ -83,6 +84,7 @@ $(() => {
colorPicker: colorPickerComponent,
loadingSpinner: loadingSpinnerComponent,
search: searchComponent,
sourceView: sourceComponent,
tree: treeComponent
},
store,

@ -1,112 +0,0 @@
'use strict'
import Vue from 'vue'
import _ from 'lodash'
/**
* Alerts
*/
class Alerts {
/**
* Constructor
*
* @class
*/
constructor () {
let self = this
self.mdl = new Vue({
el: '#alerts',
data: {
children: []
},
methods: {
acknowledge: (uid) => {
self.close(uid)
}
}
})
self.uidNext = 1
}
/**
* Show a new Alert
*
* @param {Object} options Alert properties
* @return {null} Void
*/
push (options) {
let self = this
let nAlert = _.defaults(options, {
_uid: self.uidNext,
class: 'info',
message: '---',
sticky: false,
title: '---'
})
self.mdl.children.push(nAlert)
if (!nAlert.sticky) {
_.delay(() => {
self.close(nAlert._uid)
}, 5000)
}
self.uidNext++
}
/**
* Shorthand method for pushing errors
*
* @param {String} title The title
* @param {String} message The message
*/
pushError (title, message) {
this.push({
class: 'error',
message,
sticky: false,
title
})
}
/**
* Shorthand method for pushing success messages
*
* @param {String} title The title
* @param {String} message The message
*/
pushSuccess (title, message) {
this.push({
class: 'success',
message,
sticky: false,
title
})
}
/**
* Close an alert
*
* @param {Integer} uid The unique ID of the alert
*/
close (uid) {
let self = this
let nAlertIdx = _.findIndex(self.mdl.children, ['_uid', uid])
let nAlert = _.nth(self.mdl.children, nAlertIdx)
if (nAlertIdx >= 0 && nAlert) {
nAlert.class += ' exit'
Vue.set(self.mdl.children, nAlertIdx, nAlert)
_.delay(() => {
self.mdl.children.splice(nAlertIdx, 1)
}, 500)
}
}
}
export default Alerts

@ -1,14 +1,17 @@
'use strict'
import $ from 'jquery'
import * as ace from 'brace'
import 'brace/theme/tomorrow_night'
import 'brace/mode/markdown'
import pageLoader from '../components/page-loader'
module.exports = (alerts) => {
if ($('#page-type-source').length) {
var scEditor = ace.edit('source-display')
export default {
name: 'source-view',
data() {
return {}
},
mounted() {
let scEditor = ace.edit('source-display')
scEditor.setTheme('ace/theme/tomorrow_night')
scEditor.getSession().setMode('ace/mode/markdown')
scEditor.setOption('fontSize', '14px')
@ -16,12 +19,6 @@ module.exports = (alerts) => {
scEditor.setOption('wrap', true)
scEditor.setReadOnly(true)
scEditor.renderer.updateFull()
let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : ''
require('../modals/create.js')(currentBasePath)
require('../modals/move.js')(currentBasePath, alerts)
scEditor.renderer.on('afterRender', () => {
pageLoader.complete()
})

@ -347,7 +347,7 @@
height: 100%;
}*/
#page-type-source .ace-container {
main > .ace-container {
min-height: 95vh;
}

@ -4,7 +4,7 @@ block rootNavCenter
h2.nav-item= pageData.meta.title
block rootNavRight
i.nav-item#notifload
loading-spinner
span.nav-item
if rights.write
a.button.is-outlined.btn-move-prompt.is-hidden
@ -23,7 +23,7 @@ block rootNavRight
block content
#page-type-source(data-entrypath=pageData.meta.path)
source-view(inline-template, data-entrypath=pageData.meta.path)
.ace-container
#source-display= pageData.markdown

Loading…
Cancel
Save