Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Component with contentQuestion doesn't work correctly. fixed #112
- Loading branch information
1 parent
861a70c
commit bc01565
Showing
4 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { IQuestion, QuestionCustomModel } from 'survey-core'; | ||
import { SurveyPDF } from '../survey'; | ||
import { IPoint, DocController } from '../doc_controller'; | ||
import { FlatQuestion } from './flat_question'; | ||
import { FlatRepository } from './flat_repository'; | ||
import { IPdfBrick } from '../pdf_render/pdf_brick'; | ||
|
||
export class FlatCustomModel extends FlatQuestion { | ||
constructor(protected survey: SurveyPDF, | ||
question: IQuestion, protected controller: DocController) { | ||
super(survey, question, controller); | ||
} | ||
public async generateFlatsContent(point: IPoint): Promise<IPdfBrick[]> { | ||
const flat = FlatRepository.getInstance().create(this.survey, this.question, this.controller, this.question.getType()); | ||
return flat.generateFlatsContent(point); | ||
} | ||
} | ||
|
||
FlatRepository.getInstance().register('custom_model', FlatCustomModel); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(<any>window)['HTMLCanvasElement'].prototype.getContext = async () => { | ||
return {}; | ||
}; | ||
|
||
import { ComponentCollection } from 'survey-core'; | ||
import { SurveyPDF } from '../src/survey'; | ||
import { IRect, IPoint, DocController } from '../src/doc_controller'; | ||
import { FlatSurvey } from '../src/flat_layout/flat_survey'; | ||
import { FlatRanking } from '../src/flat_layout/flat_ranking'; | ||
import { IPdfBrick } from '../src/pdf_render/pdf_brick'; | ||
import { TextBrick } from '../src/pdf_render/pdf_text'; | ||
import { SurveyHelper } from '../src/helper_survey'; | ||
import { TestHelper } from '../src/helper_test'; | ||
const __dummy_rn: FlatRanking = new FlatRanking(null, null, null); | ||
|
||
test('Check ranking in custom component', async () => { | ||
ComponentCollection.Instance.add({ name: 'comp', questionJSON: { type: 'rating', choices: ['A', 'B'] } }); | ||
const json: any = { | ||
questions: [ | ||
{ | ||
titleLocation: 'hidden', | ||
name: 'comp', | ||
type: 'comp' | ||
} | ||
] | ||
}; | ||
const survey: SurveyPDF = new SurveyPDF(json, TestHelper.defaultOptions); | ||
const controller: DocController = new DocController(TestHelper.defaultOptions); | ||
const flats: IPdfBrick[][] = await FlatSurvey.generateFlats(survey, controller); | ||
expect(flats.length).toBe(1); | ||
ComponentCollection.Instance.clear(); | ||
}); |