set heights on syntax highlight inputs

This commit is contained in:
Keith Grant
2019-06-06 15:30:09 -07:00
committed by Jim Ladd
parent 7b828d73be
commit 0f19d98d84
5 changed files with 33 additions and 24 deletions

View File

@@ -485,6 +485,8 @@
} }
.CodeMirror { .CodeMirror {
min-height: initial !important;
max-height: initial !important;
border-radius: 5px; border-radius: 5px;
font-style: normal; font-style: normal;
color: @field-input-text; color: @field-input-text;

View File

@@ -2,7 +2,7 @@ const templateUrl = require('~components/syntax-highlight/syntax-highlight.parti
function atSyntaxHighlightController ($scope, AngularCodeMirror) { function atSyntaxHighlightController ($scope, AngularCodeMirror) {
const vm = this; const vm = this;
const variablesName = `${$scope.name}_codemirror`; const varName = `${$scope.name}_codemirror`;
function init () { function init () {
if ($scope.disabled === 'true') { if ($scope.disabled === 'true') {
@@ -10,16 +10,14 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) {
} else if ($scope.disabled === 'false') { } else if ($scope.disabled === 'false') {
$scope.disabled = false; $scope.disabled = false;
} }
// TODO: get default value
$scope.value = $scope.value || $scope.default; $scope.value = $scope.value || $scope.default;
$scope.parseType = 'jinja2';
$scope.variablesName = variablesName; $scope.varName = varName;
$scope[variablesName] = $scope.value || ''; $scope[varName] = $scope.value;
const codeMirror = AngularCodeMirror($scope.disabled); const codeMirror = AngularCodeMirror($scope.disabled);
codeMirror.addModes({ codeMirror.addModes({
jinja2: { jinja2: {
mode: 'jinja2', mode: $scope.mode,
matchBrackets: true, matchBrackets: true,
autoCloseBrackets: true, autoCloseBrackets: true,
styleActiveLine: true, styleActiveLine: true,
@@ -31,20 +29,19 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) {
}); });
codeMirror.showTextArea({ codeMirror.showTextArea({
scope: $scope, scope: $scope,
model: variablesName, model: varName,
element: `${$scope.name}_codemirror`, element: `${$scope.name}_codemirror`,
lineNumbers: true, lineNumbers: true,
mode: 'jinja2', mode: $scope.mode,
}); });
$scope.$watch(variablesName, () => { $scope.$watch(varName, () => {
$scope.value = $scope[variablesName]; $scope.value = $scope[varName];
}); });
} }
vm.name = $scope.name; vm.name = $scope.name;
// vm.variablesName = variablesName; vm.rows = $scope.rows || 6;
vm.parseType = $scope.parseType;
if ($scope.init) { if ($scope.init) {
$scope.init = init; $scope.init = init;
} }
@@ -74,7 +71,10 @@ function atCodeMirrorTextarea () {
tooltipPlacement: '@', tooltipPlacement: '@',
value: '=', value: '=',
name: '@', name: '@',
init: '=' init: '=',
default: '@',
rows: '@',
mode: '@',
} }
}; };
} }

View File

@@ -23,7 +23,7 @@
</div> </div>
<textarea <textarea
ng-disabled="disabled" ng-disabled="disabled"
rows="2" rows="{{ vm.rows }}"
ng-model="codeMirrorValue" ng-model="codeMirrorValue"
name="{{ vm.name }}_codemirror" name="{{ vm.name }}_codemirror"
class="form-control Form-textArea" class="form-control Form-textArea"

View File

@@ -592,14 +592,16 @@ export default ['i18n', function(i18n) {
label: i18n._('Start Message'), label: i18n._('Start Message'),
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',
type: 'syntax_highlight', type: 'syntax_highlight',
mode: 'jinja2',
default: '', default: '',
ngShow: "customize_messages", ngShow: "customize_messages",
rows: 1, rows: 2,
}, },
start_body: { start_body: {
label: i18n._('Start Message Expanded'), label: i18n._('Start Body'),
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',
type: ' syntax_highlight', type: 'syntax_highlight',
mode: 'jinja2',
default: '', default: '',
ngShow: "customize_messages && notification_type.value == 'email'", ngShow: "customize_messages && notification_type.value == 'email'",
}, },
@@ -607,14 +609,16 @@ export default ['i18n', function(i18n) {
label: i18n._('Success Message'), label: i18n._('Success Message'),
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',
type: 'syntax_highlight', type: 'syntax_highlight',
mode: 'jinja2',
default: '', default: '',
ngShow: "customize_messages", ngShow: "customize_messages",
rows: 1, rows: 2,
}, },
success_body: { success_body: {
label: i18n._('Success Message Expanded'), label: i18n._('Success Body'),
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',
type: ' syntax_highlight', type: 'syntax_highlight',
mode: 'jinja2',
default: '', default: '',
ngShow: "customize_messages && notification_type.value == 'email'", ngShow: "customize_messages && notification_type.value == 'email'",
}, },
@@ -622,14 +626,16 @@ export default ['i18n', function(i18n) {
label: i18n._('Error Message'), label: i18n._('Error Message'),
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',
type: 'syntax_highlight', type: 'syntax_highlight',
mode: 'jinja2',
default: '', default: '',
ngShow: "customize_messages", ngShow: "customize_messages",
rows: 1, rows: 2,
}, },
error_body: { error_body: {
label: i18n._('Error Message Expanded'), label: i18n._('Error Body'),
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',
type: ' syntax_highlight', type: 'syntax_highlight',
mode: 'jinja2',
default: '', default: '',
ngShow: "customize_messages && notification_type.value == 'email'", ngShow: "customize_messages && notification_type.value == 'email'",
}, },

View File

@@ -1364,11 +1364,12 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += `id="${form.name}_${fld}" `; html += `id="${form.name}_${fld}" `;
html += `class="${field.class}" `; html += `class="${field.class}" `;
html += `label="${field.label}" `; html += `label="${field.label}" `;
html += `tooltip="${field.awPopOver}" `; html += `tooltip="${field.awPopOver || ''}" `;
html += `name="${fld}" `; html += `name="${fld}" `;
html += `value="${fld}" `; html += `value="${fld}" `;
html += `default="${field.default || ''}" `; html += `default="${field.default || ''}" `;
html += `rows="${field.rows || 6}" `; html += `rows="${field.rows || 6}" `;
html += `mode="${field.mode}" `;
html += `ng-disabled="${field.ngDisabled}" `; html += `ng-disabled="${field.ngDisabled}" `;
html += '></at-syntax-highlight>'; html += '></at-syntax-highlight>';
} }