37 lines
920 B
TypeScript
37 lines
920 B
TypeScript
import 'reflect-metadata';
|
|
import { Property, PropertyDefinition } from '../types/property';
|
|
|
|
export function EditorProperty(
|
|
editorPropertyDefinition?: PropertyDefinition
|
|
): PropertyDecorator {
|
|
return (target, propertyKey): void => {
|
|
let properties: Array<Property> = Reflect.getOwnMetadata(
|
|
'properties',
|
|
target
|
|
);
|
|
|
|
if (!properties) {
|
|
Reflect.defineMetadata('properties', (properties = []), target);
|
|
}
|
|
|
|
properties.push(
|
|
new Property({ ...editorPropertyDefinition, name: String(propertyKey) })
|
|
);
|
|
};
|
|
}
|
|
|
|
export function EditorPropertyExclude(): PropertyDecorator {
|
|
return (target, propertyKey): void => {
|
|
let excluded: Array<string> = Reflect.getOwnMetadata(
|
|
'excludedProperties',
|
|
target
|
|
);
|
|
|
|
if (!excluded) {
|
|
Reflect.defineMetadata('excludedProperties', (excluded = []), target);
|
|
}
|
|
|
|
excluded.push(String(propertyKey));
|
|
};
|
|
}
|