DisplayValue returns a single-line, human-readable rendering of the field value suitable for a table cell. Multi-value fields (labels, assignees, etc.) are joined with commas, and embedded line breaks are collapsed so a value with newlines cannot corrupt table row alignment. It is used by item-list
()
| 479 | // newlines cannot corrupt table row alignment. It is used by item-list to show a |
| 480 | // named field's value without a separate field-ID preflight lookup. |
| 481 | func (v FieldValueNodes) DisplayValue() string { |
| 482 | var value string |
| 483 | switch data := projectFieldValueData(v).(type) { |
| 484 | case nil: |
| 485 | return "" |
| 486 | case string: |
| 487 | value = data |
| 488 | case float64: |
| 489 | value = strconv.FormatFloat(data, 'f', -1, 64) |
| 490 | case []string: |
| 491 | value = strings.Join(data, ", ") |
| 492 | case map[string]interface{}: |
| 493 | title, _ := data["title"].(string) |
| 494 | value = title |
| 495 | default: |
| 496 | value = fmt.Sprintf("%v", data) |
| 497 | } |
| 498 | return singleLineFieldValue(value) |
| 499 | } |
| 500 | |
| 501 | // singleLineFieldValue collapses carriage returns and newlines so a multi-line |
| 502 | // field value stays within a single table cell. Following the convention used by |