diff --git a/src/public/js/angularjs/controllers/singleTicket.js b/src/public/js/angularjs/controllers/singleTicket.js index 4acc8f74e..952aca7da 100644 --- a/src/public/js/angularjs/controllers/singleTicket.js +++ b/src/public/js/angularjs/controllers/singleTicket.js @@ -390,10 +390,24 @@ define(['angular', 'underscore', 'jquery', 'uikit', 'modules/socket', 'modules/n var id = form.find('input[name="ticketId"]'); var commentField = form.find('#commentReply'); if (commentField.length < 1 || id.length < 1) return; + + var $mdeError = null; if (commentField.val().length < 5) { - commentField.validate(); + // commentField.validate(); + commentField.parent().css({border: '1px solid #E74C3C'}); + var mdeError = $('
Please enter a valid comment. Comments must contain at least 5 characters.
'); + + $mdeError = commentField.siblings('.editor-statusbar').find('.mde-error'); + if ($mdeError.length < 1) + commentField.siblings('.editor-statusbar').prepend(mdeError); + return; + } else { + commentField.parent().css('border', 'none'); + $mdeError = commentField.parent().find('.mde-error'); + if ($mdeError.length > 0) $mdeError.remove(); } + if (form.isValid(null, null, false)) { $http.post('/api/v1/tickets/addcomment', { "comment": commentMDE.value(), @@ -418,6 +432,23 @@ define(['angular', 'underscore', 'jquery', 'uikit', 'modules/socket', 'modules/n if (form.length < 1) return; var noteField = form.find('#ticket-note'); if (noteField.length < 1 || id.length < 1) return; + + var $mdeError = null; + if (noteField.val().length < 5) { + noteField.parent().css({border: '1px solid #E74C3C'}); + var mdeError = $('
Please enter a valid note. Notes must contain at least 5 characters.
'); + + $mdeError = noteField.siblings('.editor-statusbar').find('.mde-error'); + if ($mdeError.length < 1) + noteField.siblings('.editor-statusbar').prepend(mdeError); + + return; + } else { + noteField.parent().css('border', 'none'); + $mdeError = noteField.parent().find('.mde-error'); + if ($mdeError.length > 0) $mdeError.remove(); + } + if (form.isValid(null, null, false)) { $http.post('/api/v1/tickets/addnote', { "note": noteField.val(), @@ -425,6 +456,8 @@ define(['angular', 'underscore', 'jquery', 'uikit', 'modules/socket', 'modules/n "owner": $scope.loggedInAccount._id }).success(function() { noteField.val(''); + if (noteMDE) + noteMDE.value(''); }).error(function(e) { $log.error('[trudesk:singleTicket:submitInternalNote]'); $log.error(e); diff --git a/src/sass/partials/common.sass b/src/sass/partials/common.sass index 123e221e5..e41137fb1 100644 --- a/src/sass/partials/common.sass +++ b/src/sass/partials/common.sass @@ -689,4 +689,8 @@ div.hoverAction .datepicker td span.active, .datepicker td.active.day, .datepicker td.active.year - background: lighten($accent_color, 5%) \ No newline at end of file + background: lighten($accent_color, 5%) + +.mde-error + font-weight: 600 + color: $accent_danger \ No newline at end of file diff --git a/src/views/subviews/singleticket.hbs b/src/views/subviews/singleticket.hbs index 3404e7a87..f0749a3a4 100644 --- a/src/views/subviews/singleticket.hbs +++ b/src/views/subviews/singleticket.hbs @@ -665,11 +665,13 @@ data-validation-error-msg="Please enter a valid comment. Comments must contain at least 5 characters." style="background: inherit; border-width: 0; border-bottom-width: 1px;"> -
- +
+
+ +