2017-03-07 21:59:15 +01:00
|
|
|
import React from 'react';
|
|
|
|
import Transformation from './Transformation.jsx';
|
|
|
|
import ParseResult from '../ParseResult.jsx';
|
2017-03-27 07:34:58 +02:00
|
|
|
import LineItemBlock from '../LineItemBlock.jsx';
|
|
|
|
import LineItemBlockPageView from '../../components/debug/LineItemBlockPageView.jsx';
|
2017-03-07 21:59:15 +01:00
|
|
|
import { REMOVED_ANNOTATION } from '../Annotation.jsx';
|
|
|
|
|
2017-03-27 07:34:58 +02:00
|
|
|
// Abstract class for transformations producing LineItemBlock(s) to be shown in the LineItemBlockPageView
|
|
|
|
export default class ToLineItemBlockTransformation extends Transformation {
|
2017-03-07 21:59:15 +01:00
|
|
|
|
|
|
|
constructor(name) {
|
2017-03-27 07:34:58 +02:00
|
|
|
super(name, LineItemBlock.name);
|
|
|
|
if (this.constructor === ToLineItemBlockTransformation) {
|
2017-03-07 21:59:15 +01:00
|
|
|
throw new TypeError("Can not construct abstract class.");
|
|
|
|
}
|
|
|
|
this.showWhitespaces = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
showModificationCheckbox() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
createPageView(page, modificationsOnly) {
|
2017-03-27 07:34:58 +02:00
|
|
|
return <LineItemBlockPageView
|
2017-03-07 21:59:15 +01:00
|
|
|
key={ page.index }
|
|
|
|
page={ page }
|
|
|
|
modificationsOnly={ modificationsOnly }
|
|
|
|
showWhitespaces={ this.showWhitespaces } />;
|
|
|
|
}
|
|
|
|
|
|
|
|
completeTransform(parseResult:ParseResult) {
|
|
|
|
// The usual cleanup
|
|
|
|
parseResult.messages = [];
|
|
|
|
parseResult.pages.forEach(page => {
|
|
|
|
page.items = page.items.filter(item => !item.annotation || item.annotation !== REMOVED_ANNOTATION);
|
|
|
|
page.items.forEach(item => item.annotation = null);
|
|
|
|
});
|
|
|
|
return parseResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|