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

Fix: .editable(false) on "reference" type field in EditView #342

Merged
merged 3 commits into from
Mar 18, 2015

Conversation

vasiakorobkin
Copy link

When applying .editable(false) field method on field of "reference" type for EditView - we get no visible representation of this field - we get a link with empty inner text. This is because of getReadWidget() which passes an empty value to corresponding directive.
So I've slightly changed this function to fix this issue.

@fzaninotto
Copy link
Member

It's not normal that you get an empty value. Does the related entity have an empty title or name?

For instance, for a Reference from Comment to Post:

comment.listView().fields([
    ...,
    nga.field('post_id', 'reference')
        .label('Post')
        .targetEntity(post)
        .targetField(nga.field('title'))
])

The displayed value when editable is false is the post title. Your patch makes it fallback to post_id, but you shouldn't represent the related entity by a nullable field in the first place...

So either I don't understand your use case, or the patch is wrong.

vasiakorobkin pushed a commit to vasiakorobkin/ng-admin that referenced this pull request Mar 7, 2015
@vasiakorobkin
Copy link
Author

Related entity doesn't have empty title/name.
In your example you're talking about listView and it seems to be no problem there.

The problem takes place in editView. Let's say, that I'm in need to have a Reference from Comment to Post defined only once - on Comment creation. Therefore in Comment's editView this Reference shouldn't be editable. 1d7f47f illustrates my attempt to get such behavior. As a result we can see an empty string instead of post title, while editing any of the Comments.

But you were right about my patch. It was wrong. c8960a4 is my another attempt to fix this issue. Now it seems to work as expected.

@fzaninotto
Copy link
Member

You patch fixes the non-editable reference in edit view, but in return breaks the editable reference...

@vasiakorobkin
Copy link
Author

Fixed in b71d686
I'll try to be more attentive next time.

fzaninotto added a commit that referenced this pull request Mar 18, 2015
Fix: .editable(false) on "reference" type field in EditView
@fzaninotto fzaninotto merged commit 89f2999 into marmelab:master Mar 18, 2015
@fzaninotto
Copy link
Member

Thanks!

@vasiakorobkin vasiakorobkin deleted the uneditable_reference branch March 19, 2015 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants