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

In a condition, adding a rule to check if a filename on disk is null doesn't work #9740

Closed
3 tasks done
ruihildt opened this issue Nov 11, 2021 · 5 comments
Closed
3 tasks done
Labels

Comments

@ruihildt
Copy link

Preflight Checklist

Describe the Bug

I'm trying to conditionally display a notice based on whether an Input and an Image are correctly completed.

In order to do this, I added to the Notice the following rules:

{
	"_and": [
		{
			"_and": [
				{
					"input": {
						"_nnull": true
					}
				},
				{
					"image": {
						"filename_disk": {
							"_nnull": true
						}
					}
				}
			]
		}
	]
}

While the input rule works, checking if the image filename on the disk is null doesn't.

To Reproduce

  • Create a new collection with 1 Input, 1 Image, 1 Notice
  • Configure the notice's interface to show a Warning color and a warning text
  • Add a new condition called "Show as completed" with a rule "All of the following" with two rules: text field isn't null, Image => Filename(Disk) Isn't null
  • Now adding an image and some text in the input wrongly show the warning

Errors Shown

None

What version of Directus are you using?

9.0.0

What version of Node.js are you using?

14.15.4

What database are you using?

12.5

What browser are you using?

Firefox

What operating system are you using?

Linux

How are you deploying Directus?

Docker

@joselcvarela
Copy link
Member

Hello @ruihildt
I can verify this issue.

The source of this issue seems to be that the item passed into v-form has only the foreign keys like:

  image: "f4316821-ee91-4367-bad0-8732a72f5d6c"

Although each interface is capable of fetch its own related data.
For example, the image interface has

  id: "f4316821-ee91-4367-bad0-8732a72f5d6c",
  filename_download: "filename.jpeg"
  ...

So, instead of having multiple data split, maybe we could have a store with all data related to the item.
I believe this will implies to have some refactoring on how fetch is made across all fields

What are your thoughts @rijkvanzanten?

@ruihildt
Copy link
Author

Hello @joselcvarela , as my goal is to just check whether there's an image or not, would it be possible to check whether there's a foreign key?

Especially as the only data listed inside of an Image is an image ID (not sure if it's the same as the foreign key).

@joselcvarela
Copy link
Member

Hello @ruihildt
I believe you can use this as raw value, since it will not be possible through the interface:

{
  "_and": [
    {
      "input": {
        "_nnull": true
      }
    },
    {
      "image": {
        "_nnull": true
      }
    }
  ]
}

Tell if it worked 👍

@ruihildt
Copy link
Author

I can confirm it works, and pleasantly enough, it displays nicely in the visual rule editor.

For my usecase, in the visual rules selector, I suggest you make clicking on an Image to select the whole object, so users can set a rule against it.
And only when you click on the right angle icon on the right, you get to sub-object rules creation.

@azrikahar
Copy link
Contributor

I suggest you make clicking on an Image to select the whole object, so users can set a rule against it.
And only when you click on the right angle icon on the right, you get to sub-object rules creation.

This has been possible for a while, but was recently restricted from selecting nested or sub-object properties in #14818 to avoid confusions, while we await #8228 to be implemented.

That being said, closing this in favor of tracking relational conditions feature in #8228.

@azrikahar azrikahar closed this as not planned Won't fix, can't repro, duplicate, stale Aug 17, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants