|
|
|
@ -2,7 +2,8 @@ import { extend, isString } from 'underscore'; |
|
|
|
import { AddOptions, Collection, Model } from '../../common'; |
|
|
|
import EditorModel from '../../editor/model/Editor'; |
|
|
|
import Properties from './Properties'; |
|
|
|
import Property, { PropertyProps } from './Property'; |
|
|
|
import Property from './Property'; |
|
|
|
import { PropertyTypes } from '..'; |
|
|
|
|
|
|
|
/** @private */ |
|
|
|
export interface SectorProperties { |
|
|
|
@ -12,7 +13,7 @@ export interface SectorProperties { |
|
|
|
visible?: boolean; |
|
|
|
buildProps?: string[]; |
|
|
|
extendBuilded?: boolean; |
|
|
|
properties?: PropertyProps[]; |
|
|
|
properties?: PropertyTypes[]; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -128,7 +129,7 @@ export default class Sector extends Model<SectorProperties> { |
|
|
|
* @returns {Array<[Property]>} |
|
|
|
*/ |
|
|
|
getProperties(opts: { withValue?: boolean; withParentValue?: boolean } = {}) { |
|
|
|
const props = this.get('properties') as any; |
|
|
|
const props = this.properties; |
|
|
|
const res = (props.models ? [...props.models] : props) as Property[]; |
|
|
|
return res.filter(prop => { |
|
|
|
let result = true; |
|
|
|
@ -150,9 +151,8 @@ export default class Sector extends Model<SectorProperties> { |
|
|
|
return this.getProperties().filter(prop => prop.get('id') === id)[0] || undefined; |
|
|
|
} |
|
|
|
|
|
|
|
addProperty(property: PropertyProps, opts: AddOptions) { |
|
|
|
// @ts-ignore
|
|
|
|
return this.get('properties')!.add(this.checkExtend(property), opts); |
|
|
|
addProperty(property: PropertyTypes, opts: AddOptions) { |
|
|
|
return this.properties.add(this.checkExtend(property), opts); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -163,7 +163,7 @@ export default class Sector extends Model<SectorProperties> { |
|
|
|
* @return {Array<Object>} Final props |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
extendProperties(props: PropertyProps[], moProps?: PropertyProps[], ex = false) { |
|
|
|
extendProperties(props: PropertyTypes[], moProps?: PropertyTypes[], ex = false) { |
|
|
|
var pLen = props.length; |
|
|
|
var mProps = moProps || this.get('properties')!; |
|
|
|
var ext = this.get('extendBuilded'); |
|
|
|
@ -198,7 +198,7 @@ export default class Sector extends Model<SectorProperties> { |
|
|
|
return ex ? isolated.filter(i => i) : props; |
|
|
|
} |
|
|
|
|
|
|
|
checkExtend(prop: any): PropertyProps { |
|
|
|
checkExtend(prop: any): PropertyTypes { |
|
|
|
const { extend, ...rest } = (isString(prop) ? { extend: prop } : prop) || {}; |
|
|
|
if (extend) { |
|
|
|
return { |
|
|
|
@ -216,12 +216,12 @@ export default class Sector extends Model<SectorProperties> { |
|
|
|
* @return {Array<Object>} |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
buildProperties(props: string | string[]): PropertyProps[] { |
|
|
|
buildProperties(props: string | string[]): PropertyTypes[] { |
|
|
|
const buildP = props || []; |
|
|
|
|
|
|
|
if (!buildP.length) return []; |
|
|
|
|
|
|
|
const builtIn = this.em?.get('StyleManager').builtIn; |
|
|
|
const builtIn = this.em?.Styles.builtIn; |
|
|
|
|
|
|
|
return builtIn?.build(buildP); |
|
|
|
} |
|
|
|
|