show error for disallowed new lines in code mirror

This commit is contained in:
Keith Grant 2019-08-23 14:19:09 -07:00 committed by Jim Ladd
parent a10ad58c75
commit 901d41e261
4 changed files with 11 additions and 0 deletions

View File

@ -16,6 +16,11 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) {
$scope.$watch(varName, () => {
$scope.value = $scope[varName];
if ($scope.oneLine && $scope.value && $scope.value.includes('\n')) {
$scope.hasNewlineError = true;
} else {
$scope.hasNewlineError = false;
}
});
}
@ -84,6 +89,7 @@ function atCodeMirrorTextarea () {
init: '=',
default: '@',
rows: '@',
oneLine: '@',
mode: '@',
}
};

View File

@ -29,4 +29,5 @@
class="form-control Form-textArea"
id="{{ vm.name }}_codemirror">
</textarea>
<div class="error" ng-show="hasNewlineError">New lines are not supported in this field</div>
</div>

View File

@ -610,6 +610,7 @@ export default ['i18n', function(i18n) {
default: '',
ngShow: "customize_messages && notification_type.value != 'webhook'",
rows: 2,
oneLine: 'true',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
started_body: {
@ -632,6 +633,7 @@ export default ['i18n', function(i18n) {
default: '',
ngShow: "customize_messages && notification_type.value != 'webhook'",
rows: 2,
oneLine: 'true',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
success_body: {
@ -654,6 +656,7 @@ export default ['i18n', function(i18n) {
default: '',
ngShow: "customize_messages && notification_type.value != 'webhook'",
rows: 2,
oneLine: 'true',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
},
error_body: {

View File

@ -1369,6 +1369,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += `value="${fld}" `;
html += `default="${field.default || ''}" `;
html += `rows="${field.rows || 6}" `;
html += `one-line="${field.oneLine || ''}"`;
html += `mode="${field.mode}" `;
html += `ng-disabled="${field.ngDisabled}" `;
html += '></at-syntax-highlight>';