Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ReadOnly property for form fields #165

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions apps/field.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package apps

type FieldType string
type TextFieldSubtype string

const (
// Text field. "subtype":"textarea" for multi-line text input (Modal only?).
Expand All @@ -22,6 +23,14 @@ const (

// A mattermost channel reference (~name).
FieldTypeChannel FieldType = "channel"

TextFieldSubtypeInput TextFieldSubtype = "input"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://developers.mattermost.com/integrate/apps/interactivity/ the field is named text. Are the docs wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, but it's documented as text there not input. Fixed in 3cda372 (#805)

TextFieldSubtypeTextarea TextFieldSubtype = "textarea"
TextFieldSubtypeNumber TextFieldSubtype = "number"
TextFieldSubtypeEmail TextFieldSubtype = "email"
TextFieldSubtypeTelephone TextFieldSubtype = "tel"
TextFieldSubtypeURL TextFieldSubtype = "url"
TextFieldSubtypePassword TextFieldSubtype = "password"
)

type SelectOption struct {
Expand All @@ -38,6 +47,7 @@ type Field struct {

Type FieldType `json:"type"`
IsRequired bool `json:"is_required,omitempty"`
ReadOnly bool `json:"readonly,omitempty"`

// Present (default) value of the field
Value interface{} `json:"value,omitempty"`
Expand Down Expand Up @@ -72,7 +82,7 @@ type Field struct {
SelectStaticOptions []SelectOption `json:"options,omitempty"`

// Text props
TextSubtype string `json:"subtype,omitempty"`
TextMinLength int `json:"min_length,omitempty"`
TextMaxLength int `json:"max_length,omitempty"`
TextSubtype TextFieldSubtype `json:"subtype,omitempty"`
TextMinLength int `json:"min_length,omitempty"`
TextMaxLength int `json:"max_length,omitempty"`
}