Search
Preparing search index...
The search index is not available
catreact-html
Options
All
Public
Public/Protected
All
Inherited
Externals
Only exported
Menu
Globals
"ext/CvCellValueDef"
External module "ext/CvCellValueDef"
Index
Enumerations
Image
Existence
State
Classes
Cv
Image
Package
Cv
Image
Package
Delete
Cv
Image
Package
Pick
Cv
Image
Package
Redo
Cv
Image
Package
Undo
Cv
Image
Package
Url
Interfaces
Cv
Attribute
Cell
Value
Def
Props
Cv
Attribute
Cell
Value
Def
State
Cv
Cell
Value
Def
Props
Cv
Cell
Value
Def
State
Cv
Image
Producer
Variables
Cv
Attribute
Cell
Value
Def
Cv
Cell
Value
Def
cv_
no_
selection_
value
Object literals
Cv
Cell
Value
Def
Mixin
Variables
Cv
Attribute
Cell
Value
Def
Cv
Attribute
Cell
Value
Def
:
ClassicComponentClass
<
CvAttributeCellValueDefProps
>
= React.createClass<CvAttributeCellValueDefProps, CvCellValueDefState>({mixins: [CvBaseMixin, CvCellValueDefMixin],componentWillMount: function () {this.refresh();},componentWillReceiveProps: function (nextProps) {this.refresh(nextProps);},getDefaultProps: function () {return {cellValueDef: null, detailsContext: null, detailsCallback: null, overrideText: null,overrideDefaultValue: null, valueChangeListener:null, classSelector:null, hasFocus:false }},getInitialState: function () {return {availableValues: null, imageExistenceState: null}},render: function () {const csf = this.props.classSelector ? this.props.classSelector : (propDef:PropDef, defaultClass?:string):string => { return defaultClass }const inlineStyle = this.props.inlineStyle;if (this.props.renderer) {return this.props.renderer(this.getChildContext().cvContext);} else {const detailsContext = this.detailsContext();const cellValueDef:AttributeCellValueDef = this.cellValueDef();const overrideDefaultValue = this.props.overrideDefaultValue;const focusFn = (ref)=>{ if(ref) ref.focus(); }let component = null;if (cellValueDef && cellValueDef.propertyName) {if (!detailsContext.isReadModeFor(cellValueDef.propertyName) && !this.props.overrideText) {const prop:Prop = detailsContext.buffer.propAtName(cellValueDef.propertyName);const propDef:PropDef = detailsContext.entityRecDef.propDefAtName(cellValueDef.propertyName);if (prop) {/*** Combobox ***/if (cellValueDef.isComboBoxEntryMethod) {if (this.state.availableValues && this.state.availableValues.length > 0) {//this is not applied atmconst cn = csf(propDef,"form-control cv-cell-def-select-box");const defaultValue = overrideDefaultValue ? overrideDefaultValue :this._findPropValueInList(prop.value, propDef, this.state.availableValues);//do we need to allow the user to set null values in a select dropdown?//if so, set data to this: (however, side-effect lists do not like this...)//data={[cv_no_selection_value, ...this.state.availableValues]}component = <DropdownListdefaultValue={defaultValue}data={this.state.availableValues}textField={((item)=>this._getOptionDisplayValue(item, propDef)) as any}onChange={this._propChange.bind(this, prop.name, propDef)}ref={focusFn}/>}/*** Dropdown ***/} else if (cellValueDef.isDropDownEntryMethod) {if (this.state.availableValues && this.state.availableValues.length > 0) {if(propDef.isListType) {component = <Multiselect defaultValue={overrideDefaultValue ? overrideDefaultValue : this._createDisplayValueList(prop.value, propDef)}data={this._createDisplayValueList(this.state.availableValues, propDef)}textField='display' placeholder="No Items Selected"onChange={this._listChange.bind(this, prop.name, propDef)} ref={focusFn}/>} else {//this is not applied atmconst cn = csf(propDef,"form-control cv-cell-def-select-box");const defaultValue = overrideDefaultValue ? overrideDefaultValue :this._findPropValueInList(prop.value, propDef, this.state.availableValues);//do we need to allow the user to set null values in a select dropdown?//if so, set data to this: (however, side-effects lists do not like this...)//data={[cv_no_selection_value, ...this.state.availableValues]}component = <DropdownListdefaultValue={defaultValue}data={this.state.availableValues}textField={((item)=>this._getOptionDisplayValue(item, propDef)) as any}onChange={this._propChange.bind(this, prop.name, propDef)}ref={focusFn}/>}}/*** Icon chooser ***/} else if (cellValueDef.isIconEntryMethod) {if (this.state.availableValues && this.state.availableValues.length > 0) {component = <DropdownList defaultValue={this._findPropValueInList(prop.value, propDef, this.state.availableValues)}data={this.state.availableValues}placeholder="No Items Selected"valueComponent={this._newIconRenderer("cv-icon-chooser-value")}itemComponent={this._newIconRenderer("cv-icon-chooser-item")}onChange={this._propChangeIcon.bind(this, prop.name, propDef)}ref={focusFn}/>}} else {/*** Binary ***/if (detailsContext.isBinary(cellValueDef)) {const imageActions:Array<CvImageAction> = this.props.imageProducers == null ? null :this.props.imageProducers.filter(ip=> {return (this.state.imageExistenceState == ImageExistenceState.Present && ip.includeWhenImageExists)|| (this.state.imageExistenceState == ImageExistenceState.Missing && ip.includeWhenImageDoesNotExist)|| (this.state.imageExistenceState == ImageExistenceState.Deleted && ip.includeWhenImageIsDeleted);}).map(w=>{let ip:CvImageProducer = w as CvImageProducer;let launchPick = ()=> {let input:HTMLInputElement = this.refs["inputFileRef"] as HTMLInputElement;input.click();};let a:CvValueAdapter<CvImagePackage> = new CvValueAdapter<CvImagePackage>();let f = this.setImageFromDataUrl.bind(this, prop.name, propDef, launchPick);a.subscribe((v:Object)=>{ f(v) });return { callback:()=>{ ip.prodImageCB(a.createValueListener())},buttonClassName:ip.buttonClassName};});const style = this.props.inlineStyle ? this.props.inlineStyle : (this.props.imageStyle ? this.props.imageStyle : this.props.style);const readOnly = (this.props.imageReadOnly === undefined) || (this.props.imageReadOnly === null) ? false : this.props.imageReadOnly;component = <div><input type="file" onChange={this._fileChange.bind(this, prop.name, propDef)} ref="inputFileRef" style={{display:"none"}}/>{(this.state.selectedImageSrc || this.state.imageExistenceState == ImageExistenceState.Deleted) ?<CvImage style={style} actions={imageActions} src={this.state.selectedImageSrc} readOnly={readOnly}/> :<CvHtmlProp style={style} propName={cellValueDef.propertyName} entityRec={detailsContext.entityRec}imageActions={imageActions} imageReadOnly={readOnly}/>}</div>} else {/*** Boolean ***/if (propDef.isBooleanType) {component =<input type="checkbox" defaultChecked={overrideDefaultValue != null ? overrideDefaultValue : prop.value}onChange={this._checkboxChange.bind(this, prop.name, propDef)} autoFocus={this.props.hasFocus}/>/*** Datetime ***/} else if (propDef.isDateTimeType) {component =<DateTimePickerdefaultValue={overrideDefaultValue ? overrideDefaultValue : prop.value}onChange={this._dateChange.bind(this, prop.name, propDef)}calendar={true}time={true}format={{datetime:"medium"}}editFormat={{datetime:"short"}}timeFormat={{time:"medium"}}ref={focusFn}/>/*** Date ***/} else if (propDef.isDateType) {component =<DateTimePickerdefaultValue={overrideDefaultValue ? overrideDefaultValue : prop.value}onChange={this._dateChange.bind(this, prop.name, propDef)}calendar={true}time={false}format={{date:"long"}}editFormat={{date:"short"}}ref={focusFn}/>/*** Time ***/} else if (propDef.isTimeType) {component =<DateTimePickerdefaultValue={overrideDefaultValue ? overrideDefaultValue : (prop.value ? (prop.value as TimeValue).toDateValue() : null)}onChange={this._dateChange.bind(this, prop.name, propDef)}calendar={false}time={true}format={{time:"medium"}}timeFormat={{time:"medium"}}ref={focusFn}/>} else if(propDef.isFileAttachment) {component =<input style={inlineStyle} type="file"onChange={this._fileChange.bind(this, prop.name, propDef)} autoFocus={this.props.hasFocus}/>/*** Text ***/} else if(propDef.isTextBlock) {const cn = csf(propDef, "form-control");component = <textarea id={cellValueDef.propertyName}className={cn}style={inlineStyle}onBlur={(e:any)=>this._propChange(prop.name, propDef, e.currentTarget.value)}defaultValue={prop ? prop.value : ""} autoFocus={this.props.hasFocus}/>} else {const cn = csf(propDef, "form-control");component = <input type="text"className={cn}style={inlineStyle}onBlur={(e:any)=>this._propChange(prop.name, propDef, e.currentTarget.value)}id={cellValueDef.propertyName}defaultValue={overrideDefaultValue ? overrideDefaultValue : PropFormatter.formatForWrite(prop, propDef)}autoFocus={this.props.hasFocus}/>}}}}} else {const propDef:PropDef = detailsContext.entityRecDef.propDefAtName(cellValueDef.propertyName);let optionalClassName = propDef.isTextBlock ? {className:"cv-text-area"} : {};component = <CvHtmlProp {...optionalClassName} propName={cellValueDef.propertyName} entityRec={detailsContext.entityRec}overrideValue={this.props.overrideText} style={inlineStyle} imageReadOnly={true}/>}}return component;}},refresh: function (nextProps) {const cellValueDef = this.cellValueDef(nextProps);const detailsContext = this.detailsContext(nextProps);const prop:Prop = detailsContext.buffer.propAtName(cellValueDef.propertyName);const propDef:PropDef = detailsContext.entityRecDef.propDefAtName(cellValueDef.propertyName);if (!detailsContext.isReadModeFor(cellValueDef.propertyName)) {if (cellValueDef.propertyName && (cellValueDef.isComboBoxEntryMethod || cellValueDef.isDropDownEntryMethod || cellValueDef.isIconEntryMethod)) {detailsContext.getAvailableValues(cellValueDef.propertyName).onComplete((valueTry:Try<Array<any>>) => {if (valueTry.isSuccess) {this.setState({availableValues: valueTry.success});} else {const event:CvEvent<CvMessage> = {type: CvEventType.MESSAGE,eventObj: {message: 'Could not get available values for property: ' + cellValueDef.propertyName,messageObj: valueTry.failure,type: CvMessageType.ERROR}}this.eventRegistry().publish(event, false);}});// If not already done, set the image-existence-state.} else if (propDef.isBinaryType && (!this.state.imageExistenceState) && detailsContext.isFirstReadComplete) {if (prop && prop.value) {this.setState({imageExistenceState: ImageExistenceState.Present});} else {this.setState({imageExistenceState: ImageExistenceState.Missing});}}}},setImageFromDataUrl:function (propName:string, propDef:PropDef, launchPick:()=>void, imagePackage:CvImagePackage) {const imagePresent = this.state.imageExistenceState === ImageExistenceState.Present;const futureUndoUrl = (imagePresent && this.state.selectedImageSrc) ? this.state.selectedImageSrc : null;let dataUrl:string = null;let needToSetImage = false;// If this is an undo request, and there is no imageUndoData in state, then we should undo with the original// value which requires an async read.if (imagePackage.isPick()) {launchPick();} else if (imagePackage.isUndo()) {if (this.state.imageUndoData) {// Set the new value in the model and state.dataUrl = this.state.imageUndoData;needToSetImage = true;} else {// If there is no undo data, read the binary value from the SDK.const detailsContext = this.detailsContext();const cellValueDef: AttributeCellValueDef = this.cellValueDef();const prop: Prop = detailsContext.buffer.propAtName(cellValueDef.propertyName);detailsContext.binaryAt(cellValueDef.propertyName, detailsContext.buffer.before).onComplete((binaryTry: Try<Binary>) => {if (binaryTry.isSuccess) {if (this.isMounted()) {this.setState({imageUndoData: binaryTry.success.toUrl()});this.setImageFromDataUrl(propName, propDef, launchPick, new CvImagePackageUrl(binaryTry.success.toUrl()));}}});}} else if (imagePackage.isUrl()) {// If the value is being set, take the current value and add to the undo state for a future undo.dataUrl = (imagePackage as CvImagePackageUrl).url;this.setState({imageUndoData: futureUndoUrl});needToSetImage = true;} else if (imagePackage.isDelete()) {dataUrl = null;this.setState({imageUndoData: futureUndoUrl});needToSetImage = true;}if (needToSetImage) {if (this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, dataUrl);this.detailsCallback().setBinaryPropWithDataUrl(propName, dataUrl);this.setState({selectedImageSrc: dataUrl,imageExistenceState: (dataUrl ? ImageExistenceState.Present : ImageExistenceState.Deleted)});}},_createDisplayValueList: function(values:Array<any>, propDef):Array<any> {if(values && values.length > 0) {return values.map((value)=>{ return this._createDisplayValueObject(value, propDef);});} else {return null;}},_createDisplayValueObject: function(optionValue:any, propDef:PropDef) {return {display: this._getOptionDisplayValue(optionValue, propDef), value:optionValue};},_getOptionDisplayValue: function (optionValue:any, propDef:PropDef):string {if(optionValue === cv_no_selection_value) {return 'No Selection';} else if (optionValue instanceof CodeRef) {return (optionValue as CodeRef).description;} else if (optionValue instanceof ObjectRef) {return (optionValue as ObjectRef).description;} else {return PropFormatter.toString(optionValue, propDef);}},_findPropValueInList: function(optionValue:any, propDef:PropDef, optionValues:Array<any>) {const result = ArrayUtil.find(optionValues,item=>Prop.identity(optionValue, propDef) == Prop.identity(item, propDef));return result ? result : cv_no_selection_value;},_listChange: function(propName:string, propDef:PropDef, list:Array<any>) {const value = list.map((v)=>{ return v.value; });if(this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, value);this.detailsCallback().setPropValue(propName, value);},_propChange: function (propName:string, propDef:PropDef, selectedValue:any) {let value = selectedValue === cv_no_selection_value ? null : selectedValue;if (value == '' || value === undefined) {value = null;}if(this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, value);this.detailsCallback().setPropValue(propName, value);},_propChangeIcon: function (propName:string, propDef:PropDef, cr:CodeRef) {if(this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, cr);this.detailsCallback().setPropValue(propName, cr);},_dateChange: function (propName:string, propDef:PropDef, dateValue:Date, stringValue:string) {if(this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, dateValue);if (dateValue) {if (propDef.isDateTimeType || propDef.isDateType) {this.detailsCallback().setPropValue(propName, dateValue);} else if (propDef.isTimeType) {this.detailsCallback().setPropValue(propName, TimeValue.fromDateValue(dateValue));}} else {this.detailsCallback().setPropValue(propName, null);}},_checkboxChange: function (propName:string, propDef:PropDef, e:any) {if (e.currentTarget.checked) {if(this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, true);this.detailsCallback().setPropValue(propName, true);} else {if(this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, false);this.detailsCallback().setPropValue(propName, false);}},_fileChange:function (propName:string, propDef:PropDef, e:any) {if(e.currentTarget.files) {const files:FileList = e.currentTarget.files;if(files.length > 0) {if(this.props.valueChangeListener) this.props.valueChangeListener(propName, propDef, files[0]);//Attachmentif(propDef.isFileAttachment) {this.detailsCallback().setPropValue(propName, new Attachment(files[0].name, files[0]));} else {//Binaryvar fr = new FileReader();fr.onload = (e:any)=>{const dataUrl = e.target.result;this.detailsCallback().setBinaryPropWithDataUrl(propName, dataUrl);this.setState({selectedImageSrc: dataUrl, imageExistenceState: ImageExistenceState.Present});}fr.readAsDataURL( files[0] );}}}},_newIconRenderer:function(className:string) {return React.createClass({render() {const cr:CodeRef = this.props.item as CodeRef;return <div className={className}><img src={this._findPath(cr.description)} /><span>{cr.code}</span></div>},_findPath: function (desc:string) {if (desc) {const i = desc.indexOf(":");if (i > -1 && (i < desc.length-1)) {var answer = desc.substr(i+1);}}return answer;}});}})
Cv
Cell
Value
Def
Cv
Cell
Value
Def
:
ClassicComponentClass
<
CvCellValueDefProps
>
= React.createClass<CvCellValueDefProps, CvCellValueDefState>({mixins: [CvBaseMixin, CvCellValueDefMixin],render: function () {if (this.props.renderer) {return this.props.renderer(this.getChildContext().cvContext);} else {const detailsContext:DetailsContext = this.detailsContext();const cellValueDef:CellValueDef = this.cellValueDef();let component = null;if (cellValueDef) {if (cellValueDef instanceof AttributeCellValueDef) {const prop = detailsContext.entityRec.propAtName((cellValueDef as AttributeCellValueDef).propertyName);const hasFocus = detailsContext.detailsDef.focusPropName ?(cellValueDef as AttributeCellValueDef).propertyName == detailsContext.detailsDef.focusPropName : false;const styleInfo:CvDataAnnoStyle = (CvDataAnno as any).generateStyleInfo(prop);component = <CvDataAnno dataAnnoStyle={styleInfo} paneContext={detailsContext}wrapperElem={this.props.wrapperElem}wrapperElemProps={this.props.wrapperElemProps}><CvAttributeCellValueDef detailsContext={detailsContext}detailsCallback={this.detailsCallback()}cellValueDef={this.cellValueDef()}imageProducers={this.props.imageProducers}imageReadOnly={this.props.imageReadOnly}overrideDefaultValue={this.props.overrideDefaultValue}overrideText={styleInfo.overrideText}valueChangeListener={this.props.valueChangeListener}hasFocus={hasFocus}/></CvDataAnno>return component;} else if (cellValueDef instanceof LabelCellValueDef) {component = <span className="cv-label-cell-def">{(cellValueDef as LabelCellValueDef).value}</span>} else if (cellValueDef instanceof ForcedLineCellValueDef) {component = <span className="cv-forced-line-cell-def"/>} else if (cellValueDef instanceof TabCellValueDef) {component = <span className="cv-tab-cell-def">{' '}</span>} else if (cellValueDef instanceof SubstitutionCellValueDef) {component =<span className="cv-sub-cell-def">{(cellValueDef as SubstitutionCellValueDef).value}</span>} else {component = <span/>}}const props = ObjUtil.addAllProps(this.props.wrapperElemProps, {});return React.createElement(this.props.wrapperElem, props, component);}}})
cv_
no_
selection_
value
cv_
no_
selection_
value
:
string
= "cv_no_selection_value"
Object literals
Cv
Cell
Value
Def
Mixin
Cv
Cell
Value
Def
Mixin
:
object
cell
Value
Def
cell
Value
Def
(
nextProps
:
any
)
:
any
Parameters
nextProps:
any
Returns
any
details
Callback
details
Callback
(
nextProps
:
any
)
:
any
Parameters
nextProps:
any
Returns
any
details
Context
details
Context
(
nextProps
:
any
)
:
any
Parameters
nextProps:
any
Returns
any
get
Child
Context
get
Child
Context
(
)
:
any
Returns
any
Globals
"ext/
CvCell
Value
Def"
Image
Existence
State
Cv
Image
Package
Cv
Image
Package
Delete
Cv
Image
Package
Pick
Cv
Image
Package
Redo
Cv
Image
Package
Undo
Cv
Image
Package
Url
Cv
Attribute
Cell
Value
Def
Props
Cv
Attribute
Cell
Value
Def
State
Cv
Cell
Value
Def
Props
Cv
Cell
Value
Def
State
Cv
Image
Producer
Cv
Attribute
Cell
Value
Def
Cv
Cell
Value
Def
cv_
no_
selection_
value
Cv
Cell
Value
Def
Mixin
Generated using
TypeDoc