Fuse-box client scripts integration + deps update
This commit is contained in:
@@ -1,51 +1,56 @@
|
||||
/* global $, Vue, alerts */
|
||||
'use strict'
|
||||
|
||||
import $ from 'jquery'
|
||||
import Vue from 'vue'
|
||||
|
||||
// Vue Create User instance
|
||||
|
||||
let vueCreateUser = new Vue({
|
||||
el: '#modal-admin-users-create',
|
||||
data: {
|
||||
email: '',
|
||||
provider: 'local',
|
||||
password: '',
|
||||
name: '',
|
||||
loading: false
|
||||
},
|
||||
methods: {
|
||||
open: (ev) => {
|
||||
$('#modal-admin-users-create').addClass('is-active')
|
||||
$('#modal-admin-users-create input').first().focus()
|
||||
module.exports = (alerts) => {
|
||||
let vueCreateUser = new Vue({
|
||||
el: '#modal-admin-users-create',
|
||||
data: {
|
||||
email: '',
|
||||
provider: 'local',
|
||||
password: '',
|
||||
name: '',
|
||||
loading: false
|
||||
},
|
||||
cancel: (ev) => {
|
||||
$('#modal-admin-users-create').removeClass('is-active')
|
||||
vueCreateUser.email = ''
|
||||
vueCreateUser.provider = 'local'
|
||||
},
|
||||
create: (ev) => {
|
||||
vueCreateUser.loading = true
|
||||
$.ajax('/admin/users/create', {
|
||||
data: {
|
||||
email: vueCreateUser.email,
|
||||
provider: vueCreateUser.provider,
|
||||
password: vueCreateUser.password,
|
||||
name: vueCreateUser.name
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'POST'
|
||||
}).then((rData, rStatus, rXHR) => {
|
||||
vueCreateUser.loading = false
|
||||
if (rData.ok) {
|
||||
vueCreateUser.cancel()
|
||||
window.location.reload(true)
|
||||
} else {
|
||||
alerts.pushError('Something went wrong', rData.msg)
|
||||
}
|
||||
}, (rXHR, rStatus, err) => {
|
||||
vueCreateUser.loading = false
|
||||
alerts.pushError('Error', rXHR.responseJSON.msg)
|
||||
})
|
||||
methods: {
|
||||
open: (ev) => {
|
||||
$('#modal-admin-users-create').addClass('is-active')
|
||||
$('#modal-admin-users-create input').first().focus()
|
||||
},
|
||||
cancel: (ev) => {
|
||||
$('#modal-admin-users-create').removeClass('is-active')
|
||||
vueCreateUser.email = ''
|
||||
vueCreateUser.provider = 'local'
|
||||
},
|
||||
create: (ev) => {
|
||||
vueCreateUser.loading = true
|
||||
$.ajax('/admin/users/create', {
|
||||
data: {
|
||||
email: vueCreateUser.email,
|
||||
provider: vueCreateUser.provider,
|
||||
password: vueCreateUser.password,
|
||||
name: vueCreateUser.name
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'POST'
|
||||
}).then((rData, rStatus, rXHR) => {
|
||||
vueCreateUser.loading = false
|
||||
if (rData.ok) {
|
||||
vueCreateUser.cancel()
|
||||
window.location.reload(true)
|
||||
} else {
|
||||
alerts.pushError('Something went wrong', rData.msg)
|
||||
}
|
||||
}, (rXHR, rStatus, err) => {
|
||||
vueCreateUser.loading = false
|
||||
alerts.pushError('Error', rXHR.responseJSON.msg)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$('.btn-create-prompt').on('click', vueCreateUser.open)
|
||||
$('.btn-create-prompt').on('click', vueCreateUser.open)
|
||||
}
|
||||
|
@@ -1,34 +1,43 @@
|
||||
/* global $, Vue, usrData, alerts */
|
||||
'use strict'
|
||||
|
||||
/* global usrData */
|
||||
|
||||
'use strict'
|
||||
|
||||
import $ from 'jquery'
|
||||
import Vue from 'vue'
|
||||
|
||||
// Vue Delete User instance
|
||||
|
||||
let vueDeleteUser = new Vue({
|
||||
el: '#modal-admin-users-delete',
|
||||
data: {
|
||||
loading: false
|
||||
},
|
||||
methods: {
|
||||
open: (ev) => {
|
||||
$('#modal-admin-users-delete').addClass('is-active')
|
||||
module.exports = (alerts) => {
|
||||
let vueDeleteUser = new Vue({
|
||||
el: '#modal-admin-users-delete',
|
||||
data: {
|
||||
loading: false
|
||||
},
|
||||
cancel: (ev) => {
|
||||
$('#modal-admin-users-delete').removeClass('is-active')
|
||||
},
|
||||
deleteUser: (ev) => {
|
||||
vueDeleteUser.loading = true
|
||||
$.ajax('/admin/users/' + usrData._id, {
|
||||
dataType: 'json',
|
||||
method: 'DELETE'
|
||||
}).then((rData, rStatus, rXHR) => {
|
||||
vueDeleteUser.loading = false
|
||||
vueDeleteUser.cancel()
|
||||
window.location.assign('/admin/users')
|
||||
}, (rXHR, rStatus, err) => {
|
||||
vueDeleteUser.loading = false
|
||||
alerts.pushError('Error', rXHR.responseJSON.msg)
|
||||
})
|
||||
methods: {
|
||||
open: (ev) => {
|
||||
$('#modal-admin-users-delete').addClass('is-active')
|
||||
},
|
||||
cancel: (ev) => {
|
||||
$('#modal-admin-users-delete').removeClass('is-active')
|
||||
},
|
||||
deleteUser: (ev) => {
|
||||
vueDeleteUser.loading = true
|
||||
$.ajax('/admin/users/' + usrData._id, {
|
||||
dataType: 'json',
|
||||
method: 'DELETE'
|
||||
}).then((rData, rStatus, rXHR) => {
|
||||
vueDeleteUser.loading = false
|
||||
vueDeleteUser.cancel()
|
||||
window.location.assign('/admin/users')
|
||||
}, (rXHR, rStatus, err) => {
|
||||
vueDeleteUser.loading = false
|
||||
alerts.pushError('Error', rXHR.responseJSON.msg)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$('.btn-deluser-prompt').on('click', vueDeleteUser.open)
|
||||
$('.btn-deluser-prompt').on('click', vueDeleteUser.open)
|
||||
}
|
||||
|
@@ -1,28 +1,35 @@
|
||||
/* global $, _, currentBasePath */
|
||||
'use strict'
|
||||
|
||||
import $ from 'jquery'
|
||||
import _ from 'lodash'
|
||||
import { setInputSelection } from '../helpers/form'
|
||||
import { makeSafePath } from '../helpers/pages'
|
||||
|
||||
// -> Create New Document
|
||||
|
||||
let suggestedCreatePath = currentBasePath + '/new-page'
|
||||
module.exports = (currentBasePath) => {
|
||||
let suggestedCreatePath = currentBasePath + '/new-page'
|
||||
|
||||
$('.btn-create-prompt').on('click', (ev) => {
|
||||
$('#txt-create-prompt').val(suggestedCreatePath)
|
||||
$('#modal-create-prompt').toggleClass('is-active')
|
||||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length) // eslint-disable-line no-undef
|
||||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden')
|
||||
})
|
||||
$('.btn-create-prompt').on('click', (ev) => {
|
||||
$('#txt-create-prompt').val(suggestedCreatePath)
|
||||
$('#modal-create-prompt').toggleClass('is-active')
|
||||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length)
|
||||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden')
|
||||
})
|
||||
|
||||
$('#txt-create-prompt').on('keypress', (ev) => {
|
||||
if (ev.which === 13) {
|
||||
$('.btn-create-go').trigger('click')
|
||||
}
|
||||
})
|
||||
$('#txt-create-prompt').on('keypress', (ev) => {
|
||||
if (ev.which === 13) {
|
||||
$('.btn-create-go').trigger('click')
|
||||
}
|
||||
})
|
||||
|
||||
$('.btn-create-go').on('click', (ev) => {
|
||||
let newDocPath = makeSafePath($('#txt-create-prompt').val()) // eslint-disable-line no-undef
|
||||
if (_.isEmpty(newDocPath)) {
|
||||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden')
|
||||
} else {
|
||||
$('#txt-create-prompt').parent().addClass('is-loading')
|
||||
window.location.assign('/create/' + newDocPath)
|
||||
}
|
||||
})
|
||||
$('.btn-create-go').on('click', (ev) => {
|
||||
let newDocPath = makeSafePath($('#txt-create-prompt').val())
|
||||
if (_.isEmpty(newDocPath)) {
|
||||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden')
|
||||
} else {
|
||||
$('#txt-create-prompt').parent().addClass('is-loading')
|
||||
window.location.assign('/create/' + newDocPath)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@@ -1,47 +1,54 @@
|
||||
/* global $, _, alerts, currentBasePath */
|
||||
'use strict'
|
||||
|
||||
import $ from 'jquery'
|
||||
import _ from 'lodash'
|
||||
import { makeSafePath } from '../helpers/form'
|
||||
import { setInputSelection } from '../helpers/pages'
|
||||
|
||||
// -> Move Existing Document
|
||||
|
||||
if (currentBasePath !== '') {
|
||||
$('.btn-move-prompt').removeClass('is-hidden')
|
||||
module.exports = (currentBasePath, alerts) => {
|
||||
if (currentBasePath !== '') {
|
||||
$('.btn-move-prompt').removeClass('is-hidden')
|
||||
}
|
||||
|
||||
let moveInitialDocument = _.lastIndexOf(currentBasePath, '/') + 1
|
||||
|
||||
$('.btn-move-prompt').on('click', (ev) => {
|
||||
$('#txt-move-prompt').val(currentBasePath)
|
||||
$('#modal-move-prompt').toggleClass('is-active')
|
||||
setInputSelection($('#txt-move-prompt').get(0), moveInitialDocument, currentBasePath.length)
|
||||
$('#txt-move-prompt').removeClass('is-danger').next().addClass('is-hidden')
|
||||
})
|
||||
|
||||
$('#txt-move-prompt').on('keypress', (ev) => {
|
||||
if (ev.which === 13) {
|
||||
$('.btn-move-go').trigger('click')
|
||||
}
|
||||
})
|
||||
|
||||
$('.btn-move-go').on('click', (ev) => {
|
||||
let newDocPath = makeSafePath($('#txt-move-prompt').val())
|
||||
if (_.isEmpty(newDocPath) || newDocPath === currentBasePath || newDocPath === 'home') {
|
||||
$('#txt-move-prompt').addClass('is-danger').next().removeClass('is-hidden')
|
||||
} else {
|
||||
$('#txt-move-prompt').parent().addClass('is-loading')
|
||||
|
||||
$.ajax(window.location.href, {
|
||||
data: {
|
||||
move: newDocPath
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'PUT'
|
||||
}).then((rData, rStatus, rXHR) => {
|
||||
if (rData.ok) {
|
||||
window.location.assign('/' + newDocPath)
|
||||
} else {
|
||||
alerts.pushError('Something went wrong', rData.error)
|
||||
}
|
||||
}, (rXHR, rStatus, err) => {
|
||||
alerts.pushError('Something went wrong', 'Save operation failed.')
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let moveInitialDocument = _.lastIndexOf(currentBasePath, '/') + 1
|
||||
|
||||
$('.btn-move-prompt').on('click', (ev) => {
|
||||
$('#txt-move-prompt').val(currentBasePath)
|
||||
$('#modal-move-prompt').toggleClass('is-active')
|
||||
setInputSelection($('#txt-move-prompt').get(0), moveInitialDocument, currentBasePath.length) // eslint-disable-line no-undef
|
||||
$('#txt-move-prompt').removeClass('is-danger').next().addClass('is-hidden')
|
||||
})
|
||||
|
||||
$('#txt-move-prompt').on('keypress', (ev) => {
|
||||
if (ev.which === 13) {
|
||||
$('.btn-move-go').trigger('click')
|
||||
}
|
||||
})
|
||||
|
||||
$('.btn-move-go').on('click', (ev) => {
|
||||
let newDocPath = makeSafePath($('#txt-move-prompt').val()) // eslint-disable-line no-undef
|
||||
if (_.isEmpty(newDocPath) || newDocPath === currentBasePath || newDocPath === 'home') {
|
||||
$('#txt-move-prompt').addClass('is-danger').next().removeClass('is-hidden')
|
||||
} else {
|
||||
$('#txt-move-prompt').parent().addClass('is-loading')
|
||||
|
||||
$.ajax(window.location.href, {
|
||||
data: {
|
||||
move: newDocPath
|
||||
},
|
||||
dataType: 'json',
|
||||
method: 'PUT'
|
||||
}).then((rData, rStatus, rXHR) => {
|
||||
if (rData.ok) {
|
||||
window.location.assign('/' + newDocPath)
|
||||
} else {
|
||||
alerts.pushError('Something went wrong', rData.error)
|
||||
}
|
||||
}, (rXHR, rStatus, err) => {
|
||||
alerts.pushError('Something went wrong', 'Save operation failed.')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user