-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add "default" initialize property to QCBX #6037
base: production
Are you sure you want to change the base?
Changes from 6 commits
09256f0
ffe34d9
5418395
698cf42
b480976
b1c2a52
41f21fe
007ce67
3036c93
d644da7
ed6c17b
9875ee5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ export type FieldTypes = { | |
readonly hasViewButton: boolean; | ||
readonly typeSearch: string | undefined; | ||
readonly searchView: string | undefined; | ||
readonly defaultRecordId: string | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (optional) If it's possible, can you include the respected default values (CURRENT_USER, CURRENT_AGENT, and BLANK) into this type? That way, the default values will be present when using Intellisense with this property. |
||
} | ||
>; | ||
readonly Text: State< | ||
|
@@ -246,6 +247,7 @@ const processFieldType: { | |
: getProperty('viewBtn')?.toLowerCase() === 'true', | ||
typeSearch: getProperty('name'), | ||
searchView: getProperty('searchView'), | ||
defaultRecordId: getProperty('defaultRecordId'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (just a note) If desired, you can do whatever additional parsing here that you need! For example, you can check if the value here is one of the defaults and if not, then try and parse it as an integer and otherwise return undefined. That way, when working with If you do change how the defaultRecordId is parsed, don't forget to modify the type definition accordingly and other places it's used (like the syncer). |
||
}; | ||
} else { | ||
console.error('QueryComboBox can only be used to display a relationship'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also a note, building on the above comment)
Whatever parsing behavior you implement in the form parsing code should also be reflected here in the Syncer as well (the Syncer is in charge of converting xml to json and vice-versa; for ease of use for visual editor).
One benefit of working with the Syncer is that it's also in charge of emitting errors to the user while they are using the CodeMirror text editor.
For example the following error when trying to render a
to-many
relationship with a QueryComboBox:Screen.Recording.2025-01-07.at.3.20.14.AM.mov
Is caused because of the following console.error statement on the QueryComboBox syncer!:
specify7/specifyweb/frontend/js_src/lib/components/FormEditor/viewSpec.ts
Lines 820 to 836 in c55f4dd
Maybe you want to check the value: is one of the defaults, the default is being used correctly1, a valid number and a record exists with the ID, etc.
Footnotes
We know CURRENT_AGENT and CURRENT_USER should only be used for relationships to Agent and Specifyuser (respectively): currently a user can technically use the defaults in any QueryComboBox ↩