import { deepCopy, getElementId, randomCode } from "../../../../plugins/utils"; const MODEL = { type: "FILL_LINE", x: 0, y: 0, w: 500, h: 100, minHeight: 40, sign: "subjective", topicName: "", topicNo: null, startNumber: 1, questionsCount: 4, questionNumberPerLine: 2, lineNumberPerQuestion: 1, lineSpacing: 40, questionDirection: "vertical", questionLineType: "norm", questionLineNums: [], numberPre: "", isCovered: false, }; const getModel = (options = {}) => { let model = Object.assign({}, deepCopy(MODEL), options); model.key = randomCode(); if (!model.id) model.id = getElementId(); if (model.questionLineType === "norm") { let questionLineNums = []; for ( let j = model.startNumber; j < model.startNumber + model.questionsCount; j++ ) { questionLineNums.push({ no: j, count: model.lineNumberPerQuestion, }); } model.questionLineNums = questionLineNums; } else { const orgQuestionLineCounts = model.questionLineNums.map( (item) => item.count ); let questionLineNums = []; for (let j = 0; j < model.questionsCount; j++) { questionLineNums.push({ no: j + model.startNumber, count: orgQuestionLineCounts[j] || model.lineNumberPerQuestion, }); } model.questionLineNums = questionLineNums; } return model; }; export { MODEL, getModel };