- // this = the container being edited
- if (DescriptorModelFactory.isContainer(this)) {
- utils.assignPathValue(this.model, name, value);
- CatalogItemsActions.catalogItemDescriptorChanged(this.getRoot());
- }
- }
-
- // change handler used for onChange event
- const changeHandler = (handleValueChange, event) => {
- event.preventDefault();
- console.debug(event.target.value);
- handleValueChange(event.target.value);
- };
- // create an onChange event handler for a text field for the specified field path (debounced to accumulate chars)
- const onTextChange = changeHandler.bind(null, _debounce(
- processFieldValueChange.bind(container, pathToProperty), 2000, {maxWait: 5000})); // max wait for short-name
- // create an onChange event handler for a select field for the specified field path
- const onSelectChange = changeHandler.bind(null, processFieldValueChange.bind(container, pathToProperty));
-
- if (isEnumeration) {
- const enumeration = Property.getEnumeration(property, value);
- const options = enumeration.map((d, i) => {
- // note yangforge generates values for enums but the system does not use them
- // so we categorically ignore them
- // https://trello.com/c/uzEwVx6W/230-bug-enum-should-not-use-index-only-name
- //return <option key={fieldKey + ':' + i} value={d.value}>{d.name}</option>;
- return <option key={':' + i} value={d.name}>{d.name}</option>;
- });
- const isValueSet = enumeration.filter(d => d.isSelected).length > 0;
- if (!isValueSet || property.cardinality === '0..1') {
- const noValueDisplayText = changeCase.title(property.name);
- options.unshift(<option key={'(value-not-in-enum)'} value="" placeholder={placeholder}>{noValueDisplayText}</option>);
- }
- return (
- <select
- key={fieldKey}
- id={fieldKey}
- className={ClassNames({'-value-not-set': !isValueSet})}
- defaultValue={value}
- title={pathToProperty}
- onChange={onSelectChange}
- onFocus={onFocus}
- onBlur={endEditing}
- onMouseDown={startEditing}
- onMouseOver={startEditing}
- readOnly={!isEditable}>
- {options}
- </select>
- );
- }
-
- if (isLeafRef) {
- let fullPathString = container.key + ':' + path.join(':');
- let containerRef = container;
- while (containerRef.parent) {
- fullPathString = containerRef.parent.key + ':' + fullPathString;
- containerRef = containerRef.parent;
- }
- const leafRefPathValues = Property.getLeafRef(property, path, value, fullPathString, catalogs, container);
-
- const options = leafRefPathValues && leafRefPathValues.map((d, i) => {
- return <option key={':' + i} value={d.value}>{d.value}</option>;
- });
- const isValueSet = leafRefPathValues.filter(d => d.isSelected).length > 0;
- if (!isValueSet || property.cardinality === '0..1') {
- const noValueDisplayText = changeCase.title(property.name);
- options.unshift(<option key={'(value-not-in-leafref)'} value="" placeholder={placeholder}>{noValueDisplayText}</option>);
- }
- return (
- <select
- key={fieldKey}
- id={fieldKey}
- className={ClassNames({'-value-not-set': !isValueSet})}
- defaultValue={value}
- title={pathToProperty}
- onChange={onSelectChange}
- onFocus={onFocus}
- onBlur={endEditing}
- onMouseDown={startEditing}
- onMouseOver={startEditing}
- readOnly={!isEditable}>
- {options}
- </select>
- );
- }
-
- if (isBoolean) {
- const options = [
- <option key={'true'} value="TRUE">TRUE</option>,
- <option key={'false'} value="FALSE">FALSE</option>
- ]
-
- // if (!isValueSet) {
- const noValueDisplayText = changeCase.title(property.name);
- options.unshift(<option key={'(value-not-in-leafref)'} value="" placeholder={placeholder}></option>);
- // }
- let val = value;
- if(typeof(val) == 'number') {
- val = value ? "TRUE" : "FALSE"