Dropdown created by EasyAdmin Bundle not closing on select - symfony

I am creating a backend to my Symfony4.2 site using the easyadmin bundle. in the new/edit form created for my entities it creates a dropdown to select from. However, in chrome and firefox these dropdowns are not behaving as expected. When I click on them it shows the options but it does not close if I select an option or click away from the dropdown menu. It works okay on Safari and Edge.
Here is the easyadmin.yaml
easy_admin:
#Global Settings
site_name: 'Physics Quiz SIte'
design:
assets:
favicon: '/build/images/favicon.ba133a8b.ico'
# this is the default form theme used by backends
form_theme: '#EasyAdmin/form/bootstrap_4.html.twig'
# these custom templates are applied to all entities
brand_color: '#1ABC9C'
menu:
- { label: 'Public Homepage', route: 'homepage', icon: 'home' }
- { entity: 'User', icon: 'user' }
- { entity: 'QuestionType' }
- { entity: 'Question' }
- { entity: 'Quiz' }
show:
max_results: 10
list:
actions:
- { name: 'edit', icon: 'pencil'}
- { name: 'delete', icon: 'trash'}
# allow deleting multiple items at once ...
batch_actions: ['delete']
# List the entity class name you want to manage
entities:
Quiz:
class: App\Entity\Quiz
form:
fields:
- property: 'quizname'
label: 'Quiz Name'
- property: 'course'
type: 'entity'
type_options:
expanded: false
multiple: false
This is the relevant page source that is created:
<div class="col-12 ">
<div class="form-group field-entity">
<label class="form-control-label required" for="quiz_course">Course</label>
<div class="form-widget">
<select id="quiz_course" name="quiz[course]" data-widget="select2" class="form-control">
<option value="1">Year 10 Physics</option>
<option value="2">Year 11 Physics</option>
</select>
</div>
</div>
</div>
and here are the scripts that may be relevant.
<script src="/bundles/easyadmin/select2/i18n/en.js"></script>
<script type="text/javascript">
$(function() {
// Select2 widget is only enabled for the <select> elements which
// explicitly ask for it
function init() {
$('form select[data-widget="select2"]').select2({
theme: 'bootstrap',
language: 'en'
});
}
$(document).on('easyadmin.collection.item-added', init);
init();
});
</script>
Here is a picture of the rendered dropdown:

This was a bug introduced in version 2.1.2.
https://github.com/EasyCorp/EasyAdminBundle/issues/2715
There was a new release 2.1.3 that fixes the problem.

Related

ORO CRM datagrid refresh after inline edit failed by missing parameter

I have a datagrid:
datagrids:
gates-under-location-grid:
inline_editing:
enable: true
extended_entity_name: Entity\Gate
source:
type: orm
query:
select:
- g
- l
- ancestor.id as ancestorId
- ancestor.name as ancestorName
from:
- { table: Entity\Gate, alias: g }
join:
left:
- { join: g.locations, alias: l }
inner:
- { join: Entity\LocationClosure, alias: lc, conditionType: WITH, condition: 'l.id=lc.descendant' }
- { join: Entity\Location, alias: ancestor, conditionType: WITH, condition: 'ancestor=:rootLocation'}
where:
and:
- lc.ancestor=:rootLocation
bind_parameters:
rootLocation: ~
hints:
- HINT_TRANSLATABLE
columns:
name:
label: 'gate.datagrid.field.name'
align: left
locations:
label: 'gate.datagrid.field.locations'
align: left
data_name: locations
data: locations
type: twig
template: Partials/Datagrid/Gate:locations_cell_in_gate_under_location_grid.html.twig
frontend_type: html
inline_editing:
behaviour: enable_selected
editor:
view: oroform/js/app/views/editor/related-id-select-editor-view
view_options:
value_field_name: locations.name
placeholder: 'placeholder'
autocomplete_api_accessor:
class: oroentity/js/tools/entity-select-search-api-accessor
entity_name: Entity\Location
search_handler_name: locations
value_field_name: id
field_name: name
label_field_name: name
properties:
id: ~
view_link:
type: url
route: gate_view
params: [ id ]
update_link:
type: url
route: gate_update
params: [ id ]
sorters:
columns:
name: { data_name: g.name }
default:
name: ASC
filters:
columns:
name:
type: string
data_name: g.name
actions:
view:
type: navigate
label: 'common.grid.details'
link: view_link
icon: eye
update:
type: navigate
label: 'common.grid.edit'
icon: edit
link: update_link
options:
entityHint: 'gate.datagrid.entityhint'
export: true
entity_pagination: true
routerEnabled: false
The location cell editor template is in the locations_cell_in_gate_under_location_grid.html file:
{% import 'OroUIBundle::macros.html.twig' as UI %}
<span class="inline-actions-element">
{% for location in value %}
<span class="tags-container">
<a href="#" title="{{ location.name }}" class="tags-container__tag-entry">
<span>
{{ location.name }}
</span>
</a>
</span>
{% endfor %}
<span class="inline-actions-element_actions inline-actions-element_wrapper" data-role="container">
{{ UI.clientButton({
'dataUrl': path('gate_locations_update',
{
'gateId': record.rootEntity.id,
'locationId': record.getValue('ancestorId')
}),
'aCss': 'inline-actions-btn inline-actions-btn--size-s',
'iCss': 'fa-pencil',
'dataId': record.rootEntity.id,
'title' : 'Edit'|trans,
'label' : 'Edit'|trans,
'widget' : {
'type' : 'dialog',
'multiple' : false,
'reload-grid-name' : 'gates-under-location-grid',
'options' : {
'alias': 'gate_locations_update_dialog',
'stateEnabled': false,
'dialogOptions' : {
'title' : 'gate.datagrid.under_location.locations_edit_widget.title'|trans,
'allowMaximize': false,
'allowMinimize': false,
'width': 600,
'modal': true,
},
},
},
}) }}
</span>
Controller action is the following:
/**
* Shows editForm, or updates Gate with given ID
*
* #Route("/locations-edit/gate/{gateId}/location/{locationId}", name="gate_locations_update", requirements={"gateId"="\d+","locationId"="\d+"})
* #Template("Gate:locations_update.html.twig")
* #ParamConverter("gate", class="Entity\Gate", options={"id" = "gateId"})
* #ParamConverter("location", class="Entity\Location", options={"id" = "locationId"})
*
* #param Request $request
* #param Gate $gate
* #param Location $location
*
* #return array|RedirectResponse
*/
public function updateLocationsAction(Request $request, Gate $gate, Location $location)
{
$form = $this->get('form.factory')
->create(GateLocationsType::class, $gate, ['attr' => ['rootLocation' => $location]]);
return $this->get('oro_form.update_handler')
->update(
$gate,
$form,
$this->get('translator')->trans('common.processes.successful_saved'),
$request
);
}
I wanted to refresh the cell after inline edit, but since i didn't find any chance, it would be good to refresh whole datagrid.
The problem is with this solution, after cell data stored, i got the Data loading failed, try reloading the page. If the issue appears again please contact your administrator. message, and it's logged in the log file:
request.CRITICAL: Uncaught PHP Exception Oro\Bundle\DataGridBundle\Exception\InvalidArgumentException: "Cannot bind datasource parameter "rootLocation", there is no datagrid parameter with path "rootLocation"." at vendor/oro/platform/src/Oro/Bundle/DataGridBundle/Datasource/Orm/ParameterBinder.php line 164 {"exception":"[object] (Oro\\Bundle\\DataGridBundle\\Exception\\InvalidArgumentException(code: 0): Cannot bind datasource parameter \"rootLocation\", there is no datagrid parameter with path \"rootLocation\". at app/vendor/oro/platform/src/Oro/Bundle/DataGridBundle/Datasource/Orm/ParameterBinder.php:164, Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException(code: 0): The key \"rootLocation\" does exist in an array. at app/vendor/oro/platform/src/Oro/Component/PropertyAccess/PropertyAccessor.php:435)"} []
I tried to add the parameters, but these efforts didn't affected on the error.
Could somebody help, how to pass the rootLocation parameter for the refresh?
Thanks in advance!
A custom controller is not a recommended way to handle the inline editing in the datagrid.
Please follow the official documentation on Creating editable data grid cells in OroPlatform applications.
Also, there is a general reference on inline editing in the OroPlatform datagrids, where you can find the documentation about all the existing inline editor options. You can use one of them, instead of implementing the custom one, or you can use it as a base for creating your own editor.

How to remove active class of previously selected list item on selecting new one in angular

I want to remove the active class of list item which I had set intentionally active so when the page load I want this list item to remain active using routerLinkActive="active". I want to disable this active class when I select the other items of list in angular
I tried using ngClass but didn't worked as expected. How can this be done without using jquery?
<ul class="nav">
<li routerLinkActive="active" *ngFor="let menuItem of menuItems" [ngClass]="{'active': selectedItem == menuItem}" (click)="listClick($event, menuItem)">
<a class="nav-link" [routerLink]="[menuItem.path]">
<p>{{ menuItem.title }}</p>
</a>
</li>
</ul>
declare interface RouteInfo {
path: String,
title: String,
class: String
}
export const ROUTES: RouteInfo[] = [
{ path: '', title: 'Dashboard', class: '' },
{ path: '/vessel', title: 'Vessel Details', class: '' },
{ path: '/arrival', title: 'Arrival Details', class: ''},
{ path: '/stock', title: 'StockYard', class: ''},
{ path: '/cargo', title: 'Cargo Details', class: '' },
{ path: '/other', title: 'Others', class: ''}
];
menuItems: any[];
selectedItem= false;
listClick(event, newValue) {
console.log(newValue);
this.selectedItem = !this.selectedItem;
}
The intentionally setted active class should be disabled when other list items are clicked.
I see what your trying to do now. You shouldn't need to use ngClass or the click event. Angular will check to see if the active route matches the routerLink path. If it does, the class specified in ActiveRouterLink is added.
It's hard to solve your issue without knowing what you are seeing but try adding [routerLinkActiveOptions]="{exact: true} to the li element.

EasyAdmin Bundle - Symfony

I work with EasyAdmin and I don't know how to add an image in list view.
I would like to add next to the prices two pictures (simply 2 logos) with a link to the website in question. The admin can click on logo A or B who redirect to the website.
I can insert my links with entiy's priority (Interface with links).
.
Here is my code:
app/config/config.yml
list:
fields:
- { property: 'low_amz', label: 'Amazon' }
- { property: 'url_amz', label: 'Amz', type: 'url' }
- { property: 'low_pm', label: 'PriceMinister' }
- { property: 'url_pm', label: 'Pm', type: 'url' }
But how I replace these link's value with my images. The images are stocked in local.
With my thumbnails, it works:
- { property: 'urlPdtImg', type: 'image', label: ' ' }
But in my case, I want just to change the value "string" in img. Of course, this does not work:
- { property: 'url_pm', label: 'Pm', type: 'url', base_path: '/img/Amazon.svg' }}
EasyAdmin Bundle 1.17.12
Symfony 3.4
Have a nice day.
Here are my files:
File config.yml:
- { property: 'url_amz', label: ' ', type: 'url', template: 'easy_admin/fields/_url1.html.twig' }
File _url.html.twig
<a href="{{ value }}">
<img src="{{ asset('Img/PM.svg') }}" alt="Amazon logo" style="height: 30px;"/>
Result

How do I add a <select> input to the product variantForm in Reaction Commerce?

How do I get a <select> drop-down menu in the product varientForm?
Something like what we see here:
To accomplish adding a <select> to variantForm as seen above we need to edit or extend three files, variantForm.html, variantForm.js and the products.js schema:
reaction/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/variantForm.html
reaction/imports/plugins/included/product-variant/client/templates/products/productDetail/variants/variantForm/variantForm.js
reaction/lib/collections/schemas/products.js
In the AutoForm live example of <select> we see a schema that looks like this:
{
typeTest: {
type: String,
optional: true,
autoform: {
type: "select",
options: function () {
return [
{label: "2013", value: 2013},
{label: "2014", value: 2014},
{label: "2015", value: 2015}
];
}
}
}
}
and a Blaze template HTML that looks like this:
{{#autoForm id="types2" schema=typesSchema2}}
{{> afFormGroup name="typeTest" type="select" options=optionsHelper}}
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
{{/autoForm}}
Step 1
Edit/extend products.js schema file adding your select except we only need to add these parts:
typeTest: {
type: String,
optional: true,
autoform: {
type: "select"
}
},
Reaction Commerce ignores the optionHelper function from AutoForm as we see in the above example. I keep the autoform: { type: "select" } just to express intension. For a real-world example of a product.js schema modified this way see here.
Step 2
Add your helper function to variantForm.js that returns your selection's options object. Inside Template.variantForm.helpers({}) add:
variantTypeOptions: function (){
return [
{label: "Default", value: 2013},
{label: "Height & Weight", value: "Height & Weight"}
];
},
Nice and simple (and similar to the AutoForm example), these become the selection options we see in the screenshot above. Real-world example here.
Step 3
Final step. Let's lastly add the Blaze template HTML to variantForm.html:
<div class="form-group{{#if afFieldIsInvalid name='variantType'}} has-error{{/if}}">
<label class="control-label">{{afFieldLabelText name='variantType'}}</label>
{{>afFieldInput name='variantType' type="select" options=variantTypeOptions}}
{{#if afFieldIsInvalid name='variantType'}}
<span class="help-block">{{afFieldMessage name='variantType'}}</span>
{{/if}}
</div>
With our focus on:
{{>afFieldInput name='variantType' type="select" options=variantTypeOptions}}
Real-world example here.
Closing Remarks
You may need to do a rc reset for the changes to the schema to take effect, but WARNING, this will wipe your local development database. See the note in the RC Docs about having to do frequent resets in the "Creating a Plugin" article.

Add event on top of mizzao:autocomplete package in meteor

I am using mizzao:autocomplete package in one of my search field in my application. Autocomplete is working fine and auto-suggestion is coming from my DB. As per given in the usage documentation this package using separate template for showing the suggestion list. Usually when someone select from given suggestion, the list will disappear and selected value appears in the textbox.
Now what i want is manually trigger some event in title template & do some extra stuff in autoComplete template when someone select some suggestion..
autoComplete.html
<template name="autoComplete">
<div class="col-md-4">
<h4>Auto Complete</h4>
{{> inputAutocomplete settings=settings id="jobTitle" class="form-control" name="title" placeholder="Job Title" autocomplete="off"}}
</div>
</template>
<template name="titles">
{{title}}
</template>
autoComplete.js
Template.autoComplete.helpers({
settings : function() {
return {
position: 'bottom',
limit: 10,
rules: [
{
collection: JobTitleCollection,
field: 'title',
matchAll: true,
template: Template.titles
}
]
};
}
});
You want to use the autocompleteselect event, as described in the docs.
Template.foo.events({
"autocompleteselect input": function(event, template, doc) {
console.log("selected ", doc);
}
});
(Disclaimer: I am mizzao.)

Resources