mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
add options for code mirror to be read only
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
angular.module('AngularCodeMirrorModule', [])
|
angular.module('AngularCodeMirrorModule', [])
|
||||||
|
|
||||||
.factory('AngularCodeMirror', [ function() {
|
.factory('AngularCodeMirror', [ function() {
|
||||||
return function() {
|
return function(readOnly) {
|
||||||
var fn = function() {
|
var fn = function() {
|
||||||
|
|
||||||
this.myCodeMirror = null;
|
this.myCodeMirror = null;
|
||||||
@@ -63,12 +63,19 @@ angular.module('AngularCodeMirrorModule', [])
|
|||||||
height += parseInt(self.element.css('padding-top').replace(/px|%/,''),10) +
|
height += parseInt(self.element.css('padding-top').replace(/px|%/,''),10) +
|
||||||
parseInt(self.element.css('padding-bottom').replace(/px|%/,''),10);
|
parseInt(self.element.css('padding-bottom').replace(/px|%/,''),10);
|
||||||
height += 2; //for the border
|
height += 2; //for the border
|
||||||
|
|
||||||
// hide
|
// hide
|
||||||
self.element.hide();
|
self.element.hide();
|
||||||
|
|
||||||
// Initialize CodeMirror
|
// Initialize CodeMirror
|
||||||
self.modes[mode].value = scope[model];
|
self.modes[mode].value = scope[model];
|
||||||
|
|
||||||
|
// if readOnly is passed to AngularCodeMirror, set the
|
||||||
|
// options for all modes to be readOnly
|
||||||
|
if (readOnly) {
|
||||||
|
Object.keys(self.modes).forEach(function(val) {
|
||||||
|
self.modes[val].readOnly = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
self.myCodeMirror = CodeMirror(document.getElementById('cm-' + model + '-container'), self.modes[mode]);
|
self.myCodeMirror = CodeMirror(document.getElementById('cm-' + model + '-container'), self.modes[mode]);
|
||||||
|
|
||||||
// Adjust the height
|
// Adjust the height
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ export default
|
|||||||
fld = (params.variable) ? params.variable : 'variables',
|
fld = (params.variable) ? params.variable : 'variables',
|
||||||
pfld = (params.parse_variable) ? params.parse_variable : 'parseType',
|
pfld = (params.parse_variable) ? params.parse_variable : 'parseType',
|
||||||
onReady = params.onReady,
|
onReady = params.onReady,
|
||||||
onChange = params.onChange;
|
onChange = params.onChange,
|
||||||
|
readOnly = params.readOnly;
|
||||||
|
|
||||||
function removeField(fld) {
|
function removeField(fld) {
|
||||||
//set our model to the last change in CodeMirror and then destroy CodeMirror
|
//set our model to the last change in CodeMirror and then destroy CodeMirror
|
||||||
@@ -35,8 +36,7 @@ export default
|
|||||||
|
|
||||||
function createField(onChange, onReady, fld) {
|
function createField(onChange, onReady, fld) {
|
||||||
//hide the textarea and show a fresh CodeMirror with the current mode (json or yaml)
|
//hide the textarea and show a fresh CodeMirror with the current mode (json or yaml)
|
||||||
|
scope[fld + 'codeMirror'] = AngularCodeMirror(readOnly);
|
||||||
scope[fld + 'codeMirror'] = AngularCodeMirror();
|
|
||||||
scope[fld + 'codeMirror'].addModes($AnsibleConfig.variable_edit_modes);
|
scope[fld + 'codeMirror'].addModes($AnsibleConfig.variable_edit_modes);
|
||||||
scope[fld + 'codeMirror'].showTextArea({
|
scope[fld + 'codeMirror'].showTextArea({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ export default
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
//scope.setSearchAll('host');
|
//scope.setSearchAll('host');
|
||||||
ParseTypeChange({ scope: scope, field_id: 'pre-formatted-variables' });
|
ParseTypeChange({ scope: scope, field_id: 'pre-formatted-variables', readOnly: true });
|
||||||
scope.$emit('LoadPlays', data.related.job_events);
|
scope.$emit('LoadPlays', data.related.job_events);
|
||||||
})
|
})
|
||||||
.error(function(data, status) {
|
.error(function(data, status) {
|
||||||
|
|||||||
Reference in New Issue
Block a user