Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[add data] Suppress processor error messages until user dirties the form #7340

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ app.directive('outputPreview', function () {
restrict: 'E',
template: outputPreviewTemplate,
scope: {
oldObject: '=',
newObject: '=',
error: '='
processor: '='
},
link: function ($scope, $el) {
const div = $el.find('.visual')[0];
const processor = $scope.processor;

$scope.diffpatch = jsondiffpatch.create({
arrays: {
Expand All @@ -28,12 +27,10 @@ app.directive('outputPreview', function () {
});

$scope.updateUi = function () {
let left = $scope.oldObject;
let right = $scope.newObject;
let delta = $scope.diffpatch.diff(left, right);
if (!delta || $scope.error) delta = {};
let delta = $scope.diffpatch.diff(processor.inputObject, processor.outputObject);
if (!delta || processor.error || processor.new) delta = {};

div.innerHTML = htmlFormat(delta, left);
div.innerHTML = htmlFormat(delta, processor.inputObject);
};
},
controller: function ($scope, debounce) {
Expand All @@ -43,8 +40,8 @@ app.directive('outputPreview', function () {
$scope.updateUi();
}, 200);

$scope.$watch('oldObject', updateOutput);
$scope.$watch('newObject', updateOutput);
$scope.$watch('processor.outputObject', updateOutput);
$scope.$watch('processor.inputObject', updateOutput);
}
};
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import uiModules from 'ui/modules';
import angular from 'angular';
import _ from 'lodash';
import '../styles/_processor_ui_container.less';
import './output_preview';
Expand Down Expand Up @@ -26,9 +27,16 @@ app.directive('processorUiContainer', function ($compile) {
newScope.processor = processor;

const template = `<processor-ui-${typeId}></processor-ui-${typeId}>`;
const $innerEl = $compile(template)(newScope);
const $innerEl = angular.element(template);
const postLink = $compile($innerEl);
$container.append($innerEl);
postLink(newScope);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand what this change is doing?


$innerEl.appendTo($container);
$scope.$watch('processorForm.$pristine', (pristine) => {
if (!pristine) {
processor.new = false;
}
});
}
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ function updateProcessorOutputs(pipeline, simulateResults) {
simulateResults.forEach((result) => {
const processor = pipeline.getProcessorById(result.processorId);

processor.outputObject = _.get(result, 'output');
processor.error = _.get(result, 'error');
if (!processor.new) {
processor.outputObject = _.get(result, 'output');
processor.error = _.get(result, 'error');
}
});
}

Expand Down Expand Up @@ -155,7 +157,7 @@ export default class Pipeline {
}

updateOutput() {
const processors = this.processors;
const processors = _.reject(this.processors, { new: true });

const errorIndex = _.findIndex(processors, 'error');
const goodProcessor = errorIndex === -1 ? _.last(processors) : processors[errorIndex - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class Processor {
this.inputObject = undefined;
this.outputObject = undefined;
this.error = undefined;
this.new = true;
}

setParent(newParent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ processor-ui-container {
label {
font-weight: normal;
}

.alert {
margin-top: 10px;
margin-bottom: 0px;
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<processor-ui-container-header
processor="processor"
field="sourceField"
pipeline="pipeline">
</processor-ui-container-header>
<div
class="processor-ui-container-body"
ng-class="{locked: processor.locked}">
<form name="processorForm">
<processor-ui-container-header
processor="processor"
field="sourceField"
pipeline="pipeline">
</processor-ui-container-header>
<div
class="processor-ui-container-body-content"
ng-hide="processor.collapsed">
class="processor-ui-container-body"
ng-class="{locked: processor.locked}">
<div
ng-show="processor.error"
class="alert alert-danger">
{{processor.error.message}}
class="processor-ui-container-body-content"
ng-hide="processor.collapsed">
<div class="processor-ui-content"></div>
<div
ng-show="processor.error"
class="alert alert-danger">
{{processor.error.message}}
</div>
<output-preview
ng-hide="processor.error"
processor="processor">
</output-preview>
</div>
<div class="processor-ui-content"></div>
<output-preview
new-object="processor.outputObject"
old-object="processor.inputObject"
error="processor.error">
</output-preview>
<div class="overlay"></div>
</div>
<div class="overlay"></div>
</div>
</form>