-
Notifications
You must be signed in to change notification settings - Fork 592
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
Pro 6799 design default values invisible fields #4816
base: main
Are you sure you want to change the base?
Conversation
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.
I like where you're going with this.
@@ -632,6 +632,15 @@ module.exports = { | |||
} | |||
); | |||
} catch (error) { | |||
const isVisible = isParentVisible === false |
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.
Thank you, I did wonder if there was a cleaner way.
@@ -263,15 +266,15 @@ export default { | |||
// updating. This is only really a concern in editors that can swap | |||
// the active doc/object without unmounting AposSchema. | |||
this.$nextTick(() => { | |||
this.schemaReady = true; | |||
/* this.schemaReady = true; */ |
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.
We generally do not use this comment syntax, but maybe you're relying on it to remind you to go back.
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.
This is a draft PR, so not ready for review, it's just for me to have a global vision on my work.
6de153c
to
9bbcd21
Compare
const errorsList = []; | ||
const isCurrentVisible = isParentVisible === false | ||
? false | ||
: await self.isVisible(req, schema, data, field.name); |
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.
Notable difference here (previous versions might be buggy). We pass data instead of destination because destination is not fully built at this point.
I think isVisible
should compare data as they have been set by the user and not the potential default values.
Tests are green with it but you might have some reasons to not allow this.
Let me know.
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.
Data can be unvalidated stuff of unexpected types etc., it could be anything. Trusting it is problematic. You might get away with that in isVisible
because you're not saving the values, but then isVisible
must be written carefully to not assume the values are at all well-formed, for instance it must not assume string fields are actually strings yet, etc. because nothing has been validated.
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.
data
might contains obsolete values.
You can also have preventFieldsOnly
set to true
meaning destination
will only contains partial fields.
We should think about these and if it has any impact on your implementation.
handler() { | ||
this.updateNextAndEmit(); | ||
} | ||
}, |
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.
We don't need a deep watch here, we can simply call the method when v-model
updates fieldState
, see above change.
@@ -52,6 +52,7 @@ | |||
:server-error="fields[field.name].serverError" | |||
:doc-id="docId" | |||
:generation="generation" | |||
@update:model-value="updateNextAndEmit" |
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.
With this, no more need for a deep watcher.
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.
Why not on the compare meta version?
} else { | ||
this.next.data[field.name] = this.modelValue.data[field.name]; | ||
} | ||
}); |
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.
Only indentation in this block
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.
It is possible that changes are not necessary but see my note here about trusting data
, isVisible
must be written very defensively if it is going to see unvalidated user input.
const errorsList = []; | ||
const isCurrentVisible = isParentVisible === false | ||
? false | ||
: await self.isVisible(req, schema, data, field.name); |
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.
Data can be unvalidated stuff of unexpected types etc., it could be anything. Trusting it is problematic. You might get away with that in isVisible
because you're not saving the values, but then isVisible
must be written carefully to not assume the values are at all well-formed, for instance it must not assume string fields are actually strings yet, etc. because nothing has been validated.
@@ -52,6 +52,7 @@ | |||
:server-error="fields[field.name].serverError" | |||
:doc-id="docId" | |||
:generation="generation" | |||
@update:model-value="updateNextAndEmit" |
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.
Why not on the compare meta version?
const errorsList = []; | ||
const isCurrentVisible = isParentVisible === false | ||
? false | ||
: await self.isVisible(req, schema, data, field.name); |
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.
data
might contains obsolete values.
You can also have preventFieldsOnly
set to true
meaning destination
will only contains partial fields.
We should think about these and if it has any impact on your implementation.
f0a8ef6
to
3fe5a9c
Compare
…of deep watching it
52e6290
to
2341d53
Compare
destination, | ||
destinationPath = '', | ||
hiddenAncestors = false | ||
}) { |
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.
This method might be moved somewhere else
} | ||
|
||
if (typeof error !== 'string') { | ||
self.apos.util.error(error.path + '\n' + error.stack); |
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.
Makes sense to me to show what field failed, error path being the name.
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.
I think it is better to log this detail later when logging the overall error. But I wouldn't die on that hill.
Will the error type ever be a string? I believe that went away in A3/A4...
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.
I guess it's smart to check.
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.
I like the general strategy. Still think it makes more sense to set aposPath
on each field
just once in schema.validate
and its related functions.
@@ -7,6 +7,8 @@ | |||
* Focus properly Widget Editor modals when opened. Keep the previous active focus on the modal when closing the widget editor. | |||
* a11y improvements for context menus. | |||
* Fixes broken widget preview URL when the image is overridden (module improve) and external build module is registered. | |||
* In th schema convert method, we wait all sub convert to run, to have access to the final destination object in order to check if |
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.
typo
} = {} | ||
) { | ||
const options = { | ||
fetchRelationships, | ||
ancestors, | ||
isParentVisible | ||
ancestorSchemas, | ||
ancestorPath |
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.
I think it is better to compute the aposPath
of a field once, in the validate
method of schema
and its related functions, rather than pushing this boulder up the hill on each convert call 🪨
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.
Yes good point. We agree that we are talking about the schema path and not the actual destination one.
} | ||
|
||
if (typeof error !== 'string') { | ||
self.apos.util.error(error.path + '\n' + error.stack); |
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.
I think it is better to log this detail later when logging the overall error. But I wouldn't die on that hill.
Will the error type ever be a string? I believe that went away in A3/A4...
} | ||
|
||
if (typeof error !== 'string') { | ||
self.apos.util.error(error.path + '\n' + error.stack); |
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.
I guess it's smart to check.
PRO-6528
Summary
fieldReady
property for each field.Must work with async fields like dynamic choices, being able to set a field not ready during fetching and ready when operation is finished.
What are the specific steps to test this change?
Cypress tests 🟢
What kind of change does this PR introduce?
Make sure the PR fulfills these requirements:
If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.
Other information: