feat: add zone attribute to getControlValue api
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { ControlComponent, ControlType } from '../../../dataset/enum/Control'
|
import { ControlComponent, ControlType } from '../../../dataset/enum/Control'
|
||||||
|
import { EditorZone } from '../../../dataset/enum/Editor'
|
||||||
import { ElementType } from '../../../dataset/enum/Element'
|
import { ElementType } from '../../../dataset/enum/Element'
|
||||||
import {
|
import {
|
||||||
IControl,
|
IControl,
|
||||||
@@ -432,7 +433,7 @@ export class Control {
|
|||||||
): IGetControlValueResult {
|
): IGetControlValueResult {
|
||||||
const { conceptId } = payload
|
const { conceptId } = payload
|
||||||
const result: IGetControlValueResult = []
|
const result: IGetControlValueResult = []
|
||||||
const getValue = (elementList: IElement[]) => {
|
const getValue = (elementList: IElement[], zone: EditorZone) => {
|
||||||
let i = 0
|
let i = 0
|
||||||
while (i < elementList.length) {
|
while (i < elementList.length) {
|
||||||
const element = elementList[i]
|
const element = elementList[i]
|
||||||
@@ -444,7 +445,7 @@ export class Control {
|
|||||||
const tr = trList[r]
|
const tr = trList[r]
|
||||||
for (let d = 0; d < tr.tdList.length; d++) {
|
for (let d = 0; d < tr.tdList.length; d++) {
|
||||||
const td = tr.tdList[d]
|
const td = tr.tdList[d]
|
||||||
getValue(td.value)
|
getValue(td.value, zone)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -466,6 +467,7 @@ export class Control {
|
|||||||
if (type === ControlType.TEXT) {
|
if (type === ControlType.TEXT) {
|
||||||
result.push({
|
result.push({
|
||||||
...element.control,
|
...element.control,
|
||||||
|
zone,
|
||||||
value: textControlValue || null,
|
value: textControlValue || null,
|
||||||
innerText: textControlValue || null
|
innerText: textControlValue || null
|
||||||
})
|
})
|
||||||
@@ -483,6 +485,7 @@ export class Control {
|
|||||||
.join('')
|
.join('')
|
||||||
result.push({
|
result.push({
|
||||||
...element.control,
|
...element.control,
|
||||||
|
zone,
|
||||||
value: code || null,
|
value: code || null,
|
||||||
innerText: innerText || null
|
innerText: innerText || null
|
||||||
})
|
})
|
||||||
@@ -490,12 +493,23 @@ export class Control {
|
|||||||
i = j
|
i = j
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const elementList = [
|
const data = [
|
||||||
...this.draw.getHeaderElementList(),
|
{
|
||||||
...this.draw.getOriginalMainElementList(),
|
zone: EditorZone.HEADER,
|
||||||
...this.draw.getFooterElementList()
|
elementList: this.draw.getHeaderElementList()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
zone: EditorZone.MAIN,
|
||||||
|
elementList: this.draw.getOriginalMainElementList()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
zone: EditorZone.FOOTER,
|
||||||
|
elementList: this.draw.getFooterElementList()
|
||||||
|
}
|
||||||
]
|
]
|
||||||
getValue(elementList)
|
for (const { zone, elementList } of data) {
|
||||||
|
getValue(elementList, zone)
|
||||||
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ControlType, ControlIndentation } from '../dataset/enum/Control'
|
import { ControlType, ControlIndentation } from '../dataset/enum/Control'
|
||||||
|
import { EditorZone } from '../dataset/enum/Editor'
|
||||||
import { ICheckbox } from './Checkbox'
|
import { ICheckbox } from './Checkbox'
|
||||||
import { IElement } from './Element'
|
import { IElement } from './Element'
|
||||||
import { IRange } from './Range'
|
import { IRange } from './Range'
|
||||||
@@ -95,6 +96,7 @@ export interface IGetControlValueOption {
|
|||||||
export type IGetControlValueResult = (Omit<IControl, 'value'> & {
|
export type IGetControlValueResult = (Omit<IControl, 'value'> & {
|
||||||
value: string | null
|
value: string | null
|
||||||
innerText: string | null
|
innerText: string | null
|
||||||
|
zone: EditorZone
|
||||||
})[]
|
})[]
|
||||||
|
|
||||||
export interface ISetControlValueOption {
|
export interface ISetControlValueOption {
|
||||||
|
|||||||
Reference in New Issue
Block a user