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

[Feature][3.3] Add a toggle other field depending of the selected value of the based on the select2 value. #1257

Closed
wants to merge 3 commits into from

Conversation

mamarmite
Copy link
Contributor

@mamarmite mamarmite commented Mar 1, 2018

Based on PR #165 by @OwenMelbz and the original select2_from_array.

Actually, I adapted the logic to a WhiteList pattern instead of blacklist patterns. Because Select field can be huge. This would be more of a proof of concept.

todo : Improve it by made that a behaviour as a property for fields.
That can be added as a plugin loaded if the field have the feature or not.
Like :

$this->crud->addField([
    'name' => 'notes',
    'label' => 'Notes',
    'toggle' => true,
     'toggle_fields' => $whitelistArray (compose as thisFieldValue => [$fields]),
]);

This kind of behaviour is good to limit the confusion for the user.

Anyhow, I pushed it here, to share, feel free to do anything with it. Love the product :)

@welcome
Copy link

welcome bot commented Mar 1, 2018

BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly.

Please keep in mind that:

  • if this constitutes a breaking change, it might take quite a while for this to get merged; we try to emulate the Laravel release cycle as much as possible, so developers can upgrade both software once; this means a new big release every ~6 months;
  • even if it's a non-breaking change, it might take a few days/weeks for the PR to get merged; unless it's a no-brainer, we like to have some community feedback on new features, before we merge them; this leads to higher-quality code, in the end; we learnt this the hard way :-)
  • not all PRs get merged; sometimes we just have to hold out new features, to keep the packages lean; sometimes we don't include features that only apply to niche use cases;
  • we're not perfect; if you think we're wrong, call us out on it; but in a kind way :-) we all make mistakes, best we learn from them and build better software together;

Thank you!

--
Justin Case
The Backpack Robot

@tabacitu
Copy link
Member

tabacitu commented Mar 9, 2018

Hi @mamarmite ,

Thanks a lot for the contribution (and the praise). I'll test & review this shortly and decide whether to merge this or @OwenMelbz 's #165 PR. I think it's high time we provide a solution for this problem.

Cheers!

@tabacitu tabacitu changed the title Add a toggle other field depending of the selected value of the based on the select2 value. [Feature][3.4] Add a toggle other field depending of the selected value of the based on the select2 value. Mar 9, 2018
@tabacitu tabacitu changed the title [Feature][3.4] Add a toggle other field depending of the selected value of the based on the select2 value. [Feature][3.3] Add a toggle other field depending of the selected value of the based on the select2 value. Mar 9, 2018
…om file.

Added crud-field-trait-toggable.js to be able to use it as a trait (kinda).
@todo
Copy link

todo bot commented Mar 14, 2018

make global vars more viewable with g_ ? or find an ES6 convention ready.

//setup based properties. @todo : make global vars more viewable with g_ ? or find an ES6 convention ready.
var $self = $(this),
toggles = $self.data(settings.dataName),
value = $self.val(),
fieldSet = $self.attr('name');


This comment was generated by todo based on a @todo comment in 9247f58 in #1257. cc @mamarmite.

@mamarmite
Copy link
Contributor Author

I change the code to use the code as a jquery plugin (version 0.5)
I must repeat, This is more a Gist than a PR. Where would you like to get this kind of contribution : PR, GIST, etc. ?

@mamarmite
Copy link
Contributor Author

I test it with a checklist field too. I created a GIST to show how I made it. Feel free to reimplement everything.
https://gist.github.com/mamarmite/822a258f715a804e79485d6aeaad3a4a

The jquery plugin is V 0.5, first implementation that work for my case. Need confronting more problems to solve.
I needed to change the label on toggle, so I added this issue, but it make the pluggin clunky. I have a case were two value toggle the same field, so I add each values to toggle the field.

Anyhow, I keep it here. Thanks again. Great community and reactivity :)

…checkfield is checked. #Need-refactoring : to make it easier to read.
@mamarmite
Copy link
Contributor Author

mamarmite commented Sep 17, 2018

This was more a gist than a PR. Closing this.

@tabacitu
Copy link
Member

tabacitu commented Feb 5, 2022

@mamarmite this is it. It's time we actually provide a solution for this, in the Backpack core. What do you think of the idea in #4158 ? Can't tell if it's incredibly good or incredibly stupid. Thank you 🙏

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.

2 participants