Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #413 from Josh-Dunning/ace-text
Browse files Browse the repository at this point in the history
Added ace text editor to profiles page
  • Loading branch information
galthaus authored Jul 3, 2017
2 parents 4ca1561 + a287b61 commit c9b868d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/assets/views/dialogs/addprofiledialog.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ <h2>Profile</h2>
</div>
<div layout="row">
<div flex style="align-self: stretch;">
<textarea ng-model="value.value" style="width: 100%; height: 100%; font-family: monospace; flex-grow: 1;" ng-class="{'error': !parse(value.value, 1)||!locals.api.testSchema(parse(value.value, 0),locals.attribs[value.name].schema)}"></textarea>
<div ui-ace="{
useWrapMode: true,
showGutter: true,
mode: 'json',
onLoad: loadProfile(key)
}" style="height: 100%;"></div>
</div>
<div flex style="overflow-x: auto; padding-left: 16px;">
<pre>{{locals.attribs[value.name].schema | json}}</pre>
Expand Down
12 changes: 12 additions & 0 deletions app/js/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@
});
};

// Used with ace text editor to convert objects to JSON automatically
$scope.loadProfile = name => function(editor) {
editor.setValue(locals.profile.values[name].value,
-1
);
editor.getSession().on('change', function() {
try {
locals.profile.values[name].value = editor.getValue();
} catch (e) { /* eslint no-empty: off*/ }
});
};

$scope.providerMap = (function () {
let pm = {};
for (let i in locals._providers) {
Expand Down

0 comments on commit c9b868d

Please sign in to comment.