Improves UX for readonly codemirrors so that users can copy/paste

This commit is contained in:
Jared Tabor 2018-06-21 12:30:53 -07:00
parent 7cd203d610
commit aac939d9e4
No known key found for this signature in database
GPG Key ID: 1B343EC4C3CF7E5C
6 changed files with 31 additions and 22 deletions

View File

@ -37,15 +37,6 @@
// Disabled
textarea[disabled="disabled"] + div[id*="-container"]{
.CodeMirror {
cursor: not-allowed;
}
.CodeMirror.cm-s-default,
.CodeMirror-line {
background-color: @ebgrey;
}
.CodeMirror-gutters {
border-color: @b7grey;
}
@ -55,12 +46,4 @@ textarea[disabled="disabled"] + div[id*="-container"]{
background-color: @default-bg;
color: @default-interface-txt;
}
.CodeMirror-lines {
cursor: default;
}
.CodeMirror-cursors {
display: none;
}
}

View File

@ -18,6 +18,11 @@
flex: 1 0 auto;
}
.atCodeMirror-labelRightSide{
display: flex;
align-items: center;
}
.atCodeMirror-labelText{
text-transform: uppercase;
color: #707070;
@ -74,3 +79,8 @@
margin-left: 10px;
}
}
.atCodeMirror-badge{
display: initial;
margin-right: 20px;
}

View File

@ -13,8 +13,12 @@ function atCodeMirrorController (
ParseVariableString
) {
const vm = this;
function init (vars) {
if ($scope.disabled === 'true') {
$scope.disabled = true;
} else if ($scope.disabled === 'false') {
$scope.disabled = false;
}
$scope.variables = ParseVariableString(_.cloneDeep(vars));
$scope.parseType = ParseType;
const options = {

View File

@ -9,8 +9,8 @@ function CodeMirrorStrings (BaseString) {
VARIABLES: t.s('VARIABLES'),
EXPAND: t.s('EXPAND'),
YAML: t.s('YAML'),
JSON: t.s('JSON')
JSON: t.s('JSON'),
READONLY: t.s('READ ONLY')
};
ns.tooltip = {

View File

@ -16,8 +16,12 @@ function atCodeMirrorModalController (
ParseVariableString
) {
const vm = this;
function resize () {
if ($scope.disabled === 'true') {
$scope.disabled = true;
} else if ($scope.disabled === 'false') {
$scope.disabled = false;
}
const editor = $(`${CodeMirrorModalID} .CodeMirror`)[0].CodeMirror;
const height = $(ModalHeight).height() - $(ModalHeader).height() -
$(ModalFooter).height() - 100;
@ -30,6 +34,11 @@ function atCodeMirrorModalController (
}
function init () {
if ($scope.disabled === 'true') {
$scope.disabled = true;
} else if ($scope.disabled === 'false') {
$scope.disabled = false;
}
$(CodeMirrorModalID).modal('show');
$scope.extra_variables = ParseVariableString(_.cloneDeep($scope.variables));
$scope.parseType = ParseType;

View File

@ -42,7 +42,10 @@
</div>
</div>
</div>
<div>
<div class="atCodeMirror-labelRightSide">
<div class="at-RowItem-tag at-RowItem-tag--header atCodeMirror-badge" ng-show="disabled === 'true' || disabled === true">
{{ vm.strings.get('label.READONLY')}}
</div>
<button type="button" class="close" ng-click="closeFn()">
<i class="fa fa-times-circle"></i>
</button>