Skip to content

Commit

Permalink
SDC-9343 Disable switch to single-edit while errors are present
Browse files Browse the repository at this point in the history
Change-Id: I79e889aa6262b8f48c683f0f85c980092faddb9f
Reviewed-on: https://review.streamsets.net/15174
Reviewed-by: Madhukar Devaraju <madhu@streamsets.com>
Tested-by: StreamSets CI <streamsets-ci-spam@streamsets.com>
  • Loading branch information
chabb committed Jun 22, 2018
1 parent 82652bd commit f62964f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ angular

angular.extend($scope, {
fieldPaths: [],
codeMirrorErrors: {},
dFieldPaths: [],
fieldPathsType: [],
fieldSelectorPaths: [],
Expand Down Expand Up @@ -104,11 +105,25 @@ angular
lineWrapping: $rootScope.$storage.lineWrapping
};
}
if (!$scope.codeMirrorErrors[configDefinition.name]) {
$scope.codeMirrorErrors[configDefinition.name] = [];
}
// NOTE(chab) the mode is 'text/plain' for bulk edit, even if we are waiting for a json object
// should not we get an application/json mode instead ?
if (configDefinition.type === 'MODEL' || configDefinition.mode === "text/javascript") {
codeMirrorOptions.gutters = ['CodeMirror-lint-markers'];
codeMirrorOptions.lint = true;
codeMirrorOptions.lint = {
"getAnnotations": function(cm, updateLinting, options) {
// call the built in javascript linter, we cannot pass directly options, as JSHINT
var errors = CodeMirror.lint.javascript(cm,{ indent: options.indent});
$scope.codeMirrorErrors[configDefinition.name] = errors;
// use $timeout to trigger safely a digest loop in the next event loop, so changes can
// be applied, we need to do this as this code is not called by angular
$timeout(0, {});
updateLinting(errors);
},
"async": true
}
}

return angular.extend(codeMirrorOptions, pipelineService.getDefaultELEditorOptions(), options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@
</button>

<div class="pull-right field-selector-btn" ng-hide="isPipelineReadOnly || isPipelineRunning">
<i class="fa fa-exclamation-triangle icon-danger"
ng-show="codeMirrorErrors[configDefinition.name].length > 0" ></i>
<button type="button" class="btn btn-link"
ng-disabled="codeMirrorErrors[configDefinition.name].length > 0"
ng-click="bulkEdit = !bulkEdit">
{{bulkEdit ? ('home.detailPane.configurationTab.switchToSimpleMode' | translate) : ('home.detailPane.configurationTab.switchToBulkMode' | translate)}}
{{bulkEdit ?
('home.detailPane.configurationTab.switchToSimpleMode' | translate) : ('home.detailPane.configurationTab.switchToBulkMode' | translate)}}
</button>
</div>

Expand Down

0 comments on commit f62964f

Please sign in to comment.