mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Block empty server titles
This commit is contained in:
parent
b7d0aaa6bf
commit
da7a71ed7f
@ -37,7 +37,18 @@ module.exports = Marionette.ItemView.extend({
|
|||||||
submit: function (modal) {
|
submit: function (modal) {
|
||||||
modal.preventClose()
|
modal.preventClose()
|
||||||
|
|
||||||
this.model.set(this.serialize())
|
var data = this.serialize()
|
||||||
|
|
||||||
|
if (!data.title) {
|
||||||
|
sweetAlert({
|
||||||
|
title: 'Error',
|
||||||
|
text: 'Server title cannot be empty',
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.model.set(data)
|
||||||
|
|
||||||
var self = this
|
var self = this
|
||||||
|
|
||||||
|
@ -57,12 +57,24 @@ module.exports = Marionette.LayoutView.extend({
|
|||||||
|
|
||||||
save: function (e) {
|
save: function (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
var self = this
|
var self = this
|
||||||
var oldId = this.model.get('id')
|
var oldId = this.model.get('id')
|
||||||
var data = this.settingsView.currentView.serialize()
|
var data = this.settingsView.currentView.serialize()
|
||||||
|
|
||||||
|
if (!data.title) {
|
||||||
|
sweetAlert({
|
||||||
|
title: 'Error',
|
||||||
|
text: 'Server title cannot be empty',
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_.extend(data, this.missionsView.currentView.serialize())
|
_.extend(data, this.missionsView.currentView.serialize())
|
||||||
_.extend(data, this.modsView.currentView.serialize())
|
_.extend(data, this.modsView.currentView.serialize())
|
||||||
_.extend(data, this.parametersView.currentView.serialize())
|
_.extend(data, this.parametersView.currentView.serialize())
|
||||||
|
|
||||||
this.model.save(data, {
|
this.model.save(data, {
|
||||||
success: function () {
|
success: function () {
|
||||||
var newId = self.model.get('id')
|
var newId = self.model.get('id')
|
||||||
|
@ -8,6 +8,11 @@ module.exports = function (manager, mods) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
router.post('/', function (req, res) {
|
router.post('/', function (req, res) {
|
||||||
|
if (!req.body.title) {
|
||||||
|
res.status(400).send('Server title cannot be empty')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var server = manager.addServer(req.body)
|
var server = manager.addServer(req.body)
|
||||||
res.json(server)
|
res.json(server)
|
||||||
})
|
})
|
||||||
@ -18,6 +23,11 @@ module.exports = function (manager, mods) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
router.put('/:server', function (req, res) {
|
router.put('/:server', function (req, res) {
|
||||||
|
if (!req.body.title) {
|
||||||
|
res.status(400).send('Server title cannot be empty')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var server = manager.getServer(req.params.server)
|
var server = manager.getServer(req.params.server)
|
||||||
server.update(req.body)
|
server.update(req.body)
|
||||||
manager.save()
|
manager.save()
|
||||||
|
Loading…
Reference in New Issue
Block a user