fix(designer/node.ts): fix hasLoop logic

This commit is contained in:
林熠 2020-08-18 11:24:17 +08:00
parent 5d643124c4
commit 99a7288696

View File

@ -6,7 +6,6 @@ import {
PropsMap, PropsMap,
PropsList, PropsList,
NodeData, NodeData,
TitleContent,
I18nData, I18nData,
SlotSchema, SlotSchema,
PageSchema, PageSchema,
@ -396,9 +395,23 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
return v != null && v !== '' && v !== true; return v != null && v !== '' && v !== true;
} }
/**
* has loop when 1. loop is validArray with length > 1 ; OR 2. loop is variable object
* @return boolean, has loop config or not
*/
@computed hasLoop() { @computed hasLoop() {
const v = this.getExtraProp('loop', false)?.getValue(); const value = this.getExtraProp('loop', false)?.getValue();
return v != null && v !== ''; if (value === undefined || value === null) {
return false;
}
if (Array.isArray(value) && value.length > 0) {
return true;
}
if (isJSExpression(value)) {
return true;
}
return false;
} }
wrapWith(schema: Schema) { wrapWith(schema: Schema) {