diff --git a/src/helpers/viewdata/index.js b/src/helpers/viewdata/index.js index 9b5c8e83d..2f197f0dd 100644 --- a/src/helpers/viewdata/index.js +++ b/src/helpers/viewdata/index.js @@ -26,6 +26,33 @@ viewdata.users = {}; viewController.getData = function(request, cb) { async.parallel([ + function(callback) { + viewdata.ticketSettings = {}; + async.parallel([ + function(done) { + settingSchema.getSetting('ticket:minlength:subject', function(err, setting) { + if (!err && setting && setting.value) + viewdata.ticketSettings.minSubject = setting.value; + else + viewdata.ticketSettings.minSubject = 10; + + + return done(); + }); + }, + function(done) { + settingSchema.getSetting('ticket:minlength:issue', function(err, setting) { + if (!err && setting && setting.value) + viewdata.ticketSettings.minIssue = setting.value; + else + viewdata.ticketSettings.minIssue = 10; + + + return done(); + }); + } + ], callback); + }, function(callback) { if (global.env === 'development') require('../../sass/buildsass').build(callback); diff --git a/src/public/js/angularjs/controllers/settings.js b/src/public/js/angularjs/controllers/settings.js index 436729a05..4f0f1a44e 100644 --- a/src/public/js/angularjs/controllers/settings.js +++ b/src/public/js/angularjs/controllers/settings.js @@ -896,6 +896,29 @@ define([ }); }; + function saveMinLength(settingName, length) { + $http.put('/api/v1/settings', { + name: settingName, + value: length + }, { + headers: { + 'Content-Type': 'application/json' + } + }).then(function successCallback() { + helpers.UI.showSnackbar('Setting Saved.', false); + }, function errorCallback(err) { + helpers.UI.showSnackbar(err, true); + }); + } + + $scope.saveMinSubjectLengthClick = function() { + saveMinLength('ticket:minlength:subject', $scope.minSubjectLength); + }; + + $scope.saveMinIssueLengthClick = function() { + saveMinLength('ticket:minlength:issue', $scope.minIssueLength); + }; + $scope.allowUserRegistrationChanged = function() { var vm = this; $scope.allowUserRegistration = vm.allowUserRegistration; diff --git a/src/settings/defaults.js b/src/settings/defaults.js index 4fa439a0a..64d5e7fcd 100644 --- a/src/settings/defaults.js +++ b/src/settings/defaults.js @@ -84,6 +84,50 @@ function showTourSettingDefault(callback) { }); } +function ticketLengthSettingDefault(callback) { + async.parallel([ + function(done) { + SettingsSchema.getSettingByName('ticket:minlength:subject', function(err, setting) { + if (err) { + winston.warn(err); + return done(err); + } + + if (!setting) { + var s = new SettingsSchema({ + name: 'ticket:minlength:subject', + value: 10 + }); + + s.save(done); + } else + return done(); + }); + }, + function(done) { + SettingsSchema.getSettingByName('ticket:minlength:issue', function(err, setting) { + if (err) { + winston.warn(err); + return done(err); + } + + if (!setting) { + var s = new SettingsSchema({ + name: 'ticket:minlength:issue', + value: 10 + }); + + s.save(done); + } else + return done(); + }); + } + ], function(err) { + if (_.isFunction(callback)) + return callback(err); + }); +} + function ticketTypeSettingDefault(callback) { SettingsSchema.getSettingByName('ticket:type:default', function(err, setting) { if (err) { @@ -322,6 +366,9 @@ settingsDefaults.init = function(callback) { function(done) { return ticketTypeSettingDefault(done); }, + function(done) { + return ticketLengthSettingDefault(done); + }, function(done) { return ticketPriorityDefaults(done); }, diff --git a/src/settings/settingsUtil.js b/src/settings/settingsUtil.js index 631f6e7b9..8aab5c8a7 100644 --- a/src/settings/settingsUtil.js +++ b/src/settings/settingsUtil.js @@ -63,6 +63,8 @@ util.getSettings = function(callback) { s.colorQuaternary = parseSetting(settings, 'color:quaternary', '#E6E7E8'); s.defaultTicketType = parseSetting(settings, 'ticket:type:default', ''); + s.minSubjectLength = parseSetting(settings, 'ticket:minlength:subject', 10); + s.minIssueLength = parseSetting(settings, 'ticket:minlength:issue', 10); s.mailerEnabled = parseSetting(settings, 'mailer:enable', false); s.mailerHost = parseSetting(settings, 'mailer:host', ''); diff --git a/src/views/partials/createTicketWindow.hbs b/src/views/partials/createTicketWindow.hbs index a7b529a0d..01648e539 100644 --- a/src/views/partials/createTicketWindow.hbs +++ b/src/views/partials/createTicketWindow.hbs @@ -6,16 +6,16 @@