How to use the plywood.AttributeInfo function in plywood

To help you get started, we’ve selected a few plywood examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github implydata / plyql / src / variables.ts View on Github external
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]);
}
github geo-opensource / pivot / src / client / views / settings-view / data-table / data-table.tsx View on Github external
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
      });
    };
github geo-opensource / pivot / src / client / modals / attribute-modal / attribute-modal.tsx View on Github external
initFromProps(props: AttributeModalProps) {
    if (props.attributeInfo) {
      this.setState({
        newInstance: new AttributeInfo(props.attributeInfo.valueOf()),
        canSave: props.mode === 'create',
        errors: {}
      });
    }
  }