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

[ResourceBundle] Generic autocomplete form type for resources #3951

Merged
merged 4 commits into from
Jun 10, 2016

Conversation

tuka217
Copy link
Contributor

@tuka217 tuka217 commented Jan 22, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets #3831
License MIT
Doc PR -

@tuka217 tuka217 changed the title [WIP]Resource autocomplete [WIP] Generic autocomplete form type for resources Jan 22, 2016
@tuka217 tuka217 force-pushed the resource-autocomplete branch 13 times, most recently from bd40f72 to 482eec3 Compare January 29, 2016 10:01
@tuka217 tuka217 force-pushed the resource-autocomplete branch 4 times, most recently from d8b63a2 to 83f3518 Compare February 16, 2016 08:23
@tuka217 tuka217 force-pushed the resource-autocomplete branch 6 times, most recently from 47cdc95 to f3b6c83 Compare February 18, 2016 23:03
@tuka217 tuka217 changed the title [WIP] Generic autocomplete form type for resources [ResourceBundle] Generic autocomplete form type for resources Feb 19, 2016
public function transform($value)
{
if (null === $value) {
return array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All arrays should be changed to [...] ;)

$this->getParent()->shouldReturn('entity');
}

function it_has_a_name($metadata)
Copy link
Contributor

@michalmarcinkowski michalmarcinkowski Jun 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@tuka217 tuka217 force-pushed the resource-autocomplete branch 2 times, most recently from f3f41dd to 6b0a9a8 Compare June 8, 2016 13:40
* @Transform /^taxon with "([^"]+)" name/
* @Transform /^taxon (?:|to |should be )"([^"]+)"$/
* @Transform /^"([^"]+)" (?:|as a parent |parent )taxon$/
* @Transform /^(?:a|an) "([^"]+)"$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this transformer. I bet it could cause a weird bugs or blow up a whole app if another similar transformer would be placed somewhere else...

[ResourceBundle] Rename EntityHiddenType to ResourceToHiddenIdentifierType, refactor this class
[ResourceBundle] Remove ObjectToIdentifierServicePass
[ResourceBundle] Add MetadataInterface to ReosuceToHiddentIdentifier and ResourceToIdentifier types
[SettingBundle] Rename ObjectToIdentifierTransformer to ReosurceToIdentifierTransformer and ObjectSelectionToIdentifierCollectionTransformer to ResourceSelectionToIdentifierCollectionTransformer
[CoreBundle] Change entity_to_identifier to sylius_resourceName_from_identifier
[UserBundle] Add configuration for from_identifier type for group
[VariationBundle] Add configuration for from_identifier type for variant
[AddressingBundle] Add configuration for from_identifier type for country
[ResourceBundle] Add IdentifierToResourceType and IdentifierToResourceTransformer
[ResourceBundle] remove ObjectCollectionToIdentifiersTransformer
[ResourceBundle] rebulid ResourceChoiceType

[ResourceBundle] Rename EntityHiddenType to ResourceToHiddenIdentifierType, refactor this class
[ResourceBundle] Remove ObjectToIdentifierServicePass
[ResourceBundle] Add MetadataInterface to ResouceToHiddentIdentifier and ResourceToIdentifier types
[CoreBundle] Change entity_to_identifier to sylius_resourceName_from_identifier
[UserBundle] Add configuration for from_identifier type for group
[VariationBundle] Add configuration for from_identifier type for variant
[AddressingBundle] Add configuration for from_identifier type for country
[ResourceBundle] Add IdentifierToResourceType and IdentifierToResourceTransformer
[ResourceBundle] remove ObjectCollectionToIdentifiersTransformer
[ResourceBundle] rebulid ResourceChoiceType

[ResourceBundle] Add ResourceAutocompleteType, ResourceAutocompleteToIdentifierTransformer
[WebBundle] Add scripts for select2 and custom function about change src attribute in html element
[TaxonomyBundle] Add method in TaxonRepository for get all taxons (only id and name)
[Grid]Fix StringFilter
@tuka217 tuka217 force-pushed the resource-autocomplete branch 3 times, most recently from 50fae96 to 9b1bce5 Compare June 9, 2016 11:54
Remove old implementation of autocomplete select
@pjedrzejewski
Copy link
Member

Great work Ania! Thank you! 🎆 👍

@bendavies
Copy link
Contributor

so when are ResourceToIdentifierTransformer and ResourceFromIdentifierTransformer used?

@pjedrzejewski
Copy link
Member

ResourceToIdentifier is used when we need to select a resource from list, but the end data should be identifier: for example on promotions, where we need to select a taxon, but in db we want to serialize only its code, not whole object.

ResourceFromIdentifier is used when we want to use a hidden field with taxon code in the frontend (for autocomplete), but need real object to be the end data. (mainTaxon select field on Product)

@bendavies
Copy link
Contributor

thanks @pjedrzejewski

@koemeet
Copy link
Contributor

koemeet commented Jun 10, 2016

@pjedrzejewski Isn't it a better idea to use the doctrine types for this and add it on pre_submit, so you have the "hidden" effect, but still keep a proper choice list to work with your data. I think it is quite limiting to use those types for handling auto complete etc. Also the EntityType will use the provided query builder with an appended AND WHERE id = :submitted_id, so your DB queries are fine there. If we would not use that approach, how could we for example use it for "hidden" multiple choice fields?

// would something like this be acceptable? It is easy to understand and hides it from rendering in the front-end, so no 100.000 variant lookups.
$builder->addEventListener(FormEvents::PRE_SUBMIT, function(FormEvent $event) {
    $event->getForm()->add('variant', 'sylius_product_variant_choice');
});

pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
[ResourceBundle] Generic autocomplete form type for resources
pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
[ResourceBundle] Generic autocomplete form type for resources
pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
[ResourceBundle] Generic autocomplete form type for resources
pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
[ResourceBundle] Generic autocomplete form type for resources
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