Example #1
0
File: Pc.js Project: barbalex/ae
function buildFieldForProperty(
  propertyCollection,
  object,
  value,
  key,
  pcType,
  collectionIsEditing
) {
  const pcName = propertyCollection.Name.replace(/"/g, "'")
  // bad hack because jsx shows ' not as ' but as '
  if (typeof value === 'string') {
    value = value.replace(''', '\'')
  }
  // lr.Taxonomie is lr.Einheit of to level lr > never change lr.Taxonomie
  if (key === 'Taxonomie' && object.Gruppe === 'Lebensräume') {
    collectionIsEditing = false
  }
  // don't show 'GUID' - id is used instead
  // this field was removed and should not exist any more
  if (key === 'GUID') {
    return null
  }
  const buildAsSingleLink = (
    (
      object.Gruppe === 'Flora' &&
      (key === 'Offizielle Art' || key === 'Eingeschlossen in' || key === 'Synonym von')
    ) ||
    (
      object.Gruppe === 'Moose' &&
      key === 'Akzeptierte Referenz'
    )
  )
  if (buildAsSingleLink) {
    // build as single link
    // console.log('value', value)
    // get name from guid
    app.objectStore.getObject(value)
      .then((linkedObject) => {
        if (linkedObject) {
          const linkedObjectId = linkedObject.id
          const standardtaxonomie = linkedObject.Taxonomien.find((taxonomy) =>
            taxonomy.Standardtaxonomie
          )
          const linkedObjectName = standardtaxonomie.Eigenschaften['Artname vollständig']
          return (
            <LinkToSameGroup
              key={key}
              fieldName={key}
              guid={linkedObjectId}
              objectName={linkedObjectName}
              collectionIsEditing={collectionIsEditing}
            />
          )
        }
      })
      .catch((error) =>
        addError({
          title: 'pc.js: error getting item from objectStore:',
          msg: error
        })
      )
  }
  if (
    (key === 'Gültige Namen' || key === 'Eingeschlossene Arten') &&
    object.Gruppe === 'Flora'
  ) {
    // build array of links
    return (
      <LinksToSameGroup
        key={key}
        fieldName={key}
        objects={value}
        collectionIsEditing={collectionIsEditing}
      />
    )
  }
  const dontShowThisField = (
    (object.Gruppe === 'Flora' && ['Artname', 'Synonyme'].includes(key)) ||
    (key === 'Parent' && object.Gruppe === 'Lebensräume') ||
    (key === 'Hierarchie' && isArray(value))
  )
  if (dontShowThisField) {
    return null
  }
  if (isArray(value)) {
    // this field contains an array of values
    return (
      <FieldInput
        key={key}
        fieldName={key}
        fieldValue={value.toString()}
        inputType="textarea"
        pcType={pcType}
        pcName={pcName}
        collectionIsEditing={collectionIsEditing}
      />
    )
  }
  return (
    <Field
      key={key}
      fieldName={key}
      fieldValue={value}
      pcType={pcType}
      pcName={pcName}
      collectionIsEditing={collectionIsEditing}
    />
  )
}
Example #2
0
 Promise.all(rPartnerIds.map((id) =>
   app.objectStore.getObject(id)