Merged in feature/multichecks (pull request #153)
Multiple Checks in a Cell * multi
This commit is contained in:
@@ -104,6 +104,25 @@ func TestGetDocumentText(t *testing.T) {
|
||||
|
||||
assertReaders(t, txtFile, text)
|
||||
})
|
||||
t.Run("table_select", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := DocTextConfig{}
|
||||
svc := Service{
|
||||
cfg: &cfg,
|
||||
}
|
||||
mockTextract := textractmock.NewMockTextractClient(t)
|
||||
cfg.TextractClient = mockTextract
|
||||
|
||||
textractBaseOut, pdf, txtFile, close := getFiles(t, "table_select")
|
||||
defer close()
|
||||
|
||||
textExpectations(t, ctx, mockTextract, pdf, textractBaseOut)
|
||||
|
||||
text, err := svc.getDocumentText(ctx, pdf)
|
||||
require.NoError(t, err)
|
||||
|
||||
assertReaders(t, txtFile, text)
|
||||
})
|
||||
t.Run("multi_column", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := DocTextConfig{}
|
||||
|
||||
@@ -30,7 +30,7 @@ func (s *Service) addTable(ctx context.Context, id uuid.UUID, blockMap map[uuid.
|
||||
|
||||
invalidRows := make([]bool, params.maxRow+1)
|
||||
for _, cell := range params.table {
|
||||
if !cell.isSelected && cell.column == 0 {
|
||||
if !cell.isSelected {
|
||||
invalidRows[cell.row] = true
|
||||
}
|
||||
}
|
||||
@@ -117,19 +117,34 @@ func (s *Service) addComponentTable(ctx context.Context, id uuid.UUID, blockMap
|
||||
|
||||
func (s *Service) getCellContent(id uuid.UUID, blockMap map[uuid.UUID]types.Block) (string, bool) {
|
||||
var str strings.Builder
|
||||
isSelected := true
|
||||
var isSelected *bool
|
||||
for _, uid := range s.getRelationshipIds(blockMap[id]) {
|
||||
if blockMap[uid].BlockType == types.BlockTypeWord {
|
||||
if str.String() != "" {
|
||||
str.WriteRune(' ')
|
||||
}
|
||||
str.WriteString(*blockMap[uid].Text)
|
||||
} else if blockMap[uid].BlockType == types.BlockTypeSelectionElement && blockMap[uid].SelectionStatus == types.SelectionStatusNotSelected {
|
||||
isSelected = false
|
||||
}
|
||||
|
||||
if blockMap[uid].BlockType != types.BlockTypeSelectionElement {
|
||||
continue
|
||||
}
|
||||
|
||||
if isSelected == nil || !*isSelected {
|
||||
selected := true
|
||||
if blockMap[uid].SelectionStatus == types.SelectionStatusNotSelected {
|
||||
selected = false
|
||||
}
|
||||
isSelected = &selected
|
||||
}
|
||||
}
|
||||
|
||||
return str.String(), isSelected
|
||||
selected := true
|
||||
if isSelected != nil {
|
||||
selected = *isSelected
|
||||
}
|
||||
|
||||
return str.String(), selected
|
||||
}
|
||||
|
||||
func (s *Service) addCellToTable(rowIndex int, columnIndex int, content string, isSelected bool, params *tableParams) {
|
||||
|
||||
Reference in New Issue
Block a user