Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getVariablesFlatDataset() {
let attributes: Attributes = [];
let flatDatum: Record = {};
for (let variablesDatum of variablesData) {
let name = variablesDatum['VARIABLE_NAME'];
let value: any = variablesDatum['VARIABLE_VALUE'];
let type: PlyType = 'STRING';
// Do this crazy MySQL conversion (I am not making this up)
if (value === 'ON' || value === 'OFF') {
value = value === 'ON';
type = 'BOOLEAN';
}
flatDatum[name] = value;
attributes.push(new AttributeInfo({ name, type }));
}
return Dataset.fromJS([flatDatum]);
}
renderAttributeAdd() {
const { onChange, dataCube } = this.props;
const { showAddAttributeModal } = this.state;
if (!showAddAttributeModal) return null;
const attributes = dataCube.attributes;
const attribute = new AttributeInfo({
name: generateUniqueName('a', (name) => attributes.filter(a => a.name === name).length === 0 ),
type: 'STRING'
});
const onSave = (attribute: AttributeInfo) => {
onChange(dataCube.changeAttributes(dataCube.attributes.concat([attribute]).sort()));
this.closeAttributeSuggestions();
};
const onAlternateClick = () => {
this.setState({
showSuggestionsModal: true,
showAddAttributeModal: false
});
};
initFromProps(props: AttributeModalProps) {
if (props.attributeInfo) {
this.setState({
newInstance: new AttributeInfo(props.attributeInfo.valueOf()),
canSave: props.mode === 'create',
errors: {}
});
}
}