Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "core/CvProp"

Index

Interfaces

Variables

Variables

CvProp

CvProp: ClassicComponentClass<CvPropProps> = React.createClass<CvPropProps, CvPropState>({mixins: [CvBaseMixin],componentWillUpdate: function(nextProps, nextState, nextContext) {//Log.debug("updating CvProps")},componentDidMount: function () {//Log.debug("mounting CvProps");this.refresh();},componentWillReceiveProps: function (nextProps, nextContext) {//reset the loaded state if this is a 'new' propif(this.props.propName !== nextProps.propName ||this.entityRec() !== this.entityRec(nextProps, nextContext)) {this.loaded = false;}this.refresh(nextProps, nextContext);},entityRec: function (nextProps, nextContext) {if(nextProps && nextProps.entityRec) {return nextProps.entityRec;} else if(nextContext) {return this.findEntityRec(nextContext.cvContext.scopeCtx);} else {return this.findEntityRec();}},entityRecDef: function (nextProps, nextContext) {return this.paneContext(nextProps, nextContext).entityRecDef;},getChildContext: function () {const ctx = this.getDefaultChildContext();ctx.cvContext.scopeCtx.scopeObj = this.prop();return ctx;},getDefaultProps: function () {return {propName: null,defaultValue: null,booleanRenderer: null,binaryRenderer: null,handler: null,isVisible: null,entityRec: null,wrapperElemName: 'span',wrapperElemProps: null,overrideValue: null,currencySymbol: '$',percentageSymbol: '%',style: null,className: null,renderer: null,dataPropNames: []}},getInitialState: function () {return {binary: null};},paneContext: function (nextProps, nextContext) {if(nextProps && nextProps.paneContext) {return nextProps.paneContext;}else if(nextContext) {return this.findPaneContext(nextContext.cvContext.scopeCtx);} else {return this.findPaneContext();}},prop: function (nextProps, nextContext) {const propName = nextProps ? nextProps.propName : this.props.propName;return this.entityRec(nextProps, nextContext).propAtName(propName)},propDef: function (nextProps, nextContext) {const propName = nextProps ? nextProps.propName : this.props.propName;return this.entityRecDef(nextProps, nextContext).propDefAtName(propName);},render: function () {const prop = this.prop();if (!prop || (this.props.isVisible && !this.props.isVisible(prop))) {return null;}if (this.props.renderer) {return this.props.renderer(this.getChildContext().cvContext);} else if (this.props.handler) {return this.props.handler(prop);} else {if (React.Children.count(this.props.children) > 0) {return this.props.children} else {/* setup props for the wrapper element */const propDef = this.propDef();const nullRenderer = propDef && propDef.isBinaryType;let props = {style: this.props.style, className: this.props.className};if(this.props.wrapperElemProps) {props = ObjUtil.addAllProps(this.props.wrapperElemProps, props);}/* overridden value */if (this.props.overrideValue != null) {return React.createElement(this.props.wrapperElemName, props, this.props.overrideValue);/* missing value */} else if (!nullRenderer && (prop.value === null || prop.value === undefined)) {return this.props.defaultValue !== null ?React.createElement(this.props.wrapperElemName, props, this.props.defaultValue) : null;} else {const propDef = this.propDef();/* binary property */if (propDef && propDef.isBinaryType) {if(this.state.binary) {var dataUrl = this.state.binary.toUrl();}return this.props.binaryRenderer ? this.props.binaryRenderer(dataUrl) :React.createElement(this.props.wrapperElemName, props, '[binary]');/* boolean property */} else if (propDef && propDef.isBooleanType) {return this.props.booleanRenderer ? this.props.booleanRenderer(prop.value) :React.createElement(this.props.wrapperElemName, props, String(prop.value));} else {/* text property */const value = DefaultLocale.getAssociatedSymbol((CvProp as any).formatDataType(prop, propDef), propDef);/* copy the props rendered value to any attributes that were specified */if(this.props.dataPropNames && this.props.dataPropNames.length > 0) {this.props.dataPropNames.forEach(name=>props[name] = value);}return React.createElement(this.props.wrapperElemName, props, value);}}}}},refresh: function (nextProps, nextContext) {const prop = this.prop(nextProps, nextContext);if(prop) {const propDef = this.propDef(nextProps, nextContext);if (propDef && propDef.isBinaryType) {//if this is an update and the propName hasn't changed, don't reload the binaryif(this.loaded && nextProps && nextProps.propName === this.props.propName) {return;}const paneContext = this.paneContext(nextProps, nextContext);paneContext.binaryAt(this.props.propName, this.entityRec(nextProps, nextContext)).onComplete((binaryTry:Try<Binary>) => {if (binaryTry.isSuccess) {if (this.isMounted()) {this.setState({binary: binaryTry.success});}} else {const event:CvEvent<CvMessage> = {type:CvEventType.MESSAGE,eventObj:{message:'Could not load binary property: ' + prop.name, messageObj: binaryTry.failure, type: CvMessageType.ERROR}}this.eventRegistry().publish(event, false);}this.loaded = true;});}}},statics : {formatDataType: function (prop:Prop, propDef:PropDef):string {return PropFormatter.formatForRead(prop, propDef);}}})

Generated using TypeDoc