Angular ui-select : Adding custom ids - ui-select

I am using angular ui-select.
<ui-select ng-model="selected" theme="select2">
<ui-select-match placeholder="Select">{{$select.selected.name}}
</ui-select-match>
<ui-select-choices
repeat="student in studentList | filter: $select.search"
ng-class="{{student.name}} == 'ABC' ? 'found' : 'not_Found' ">
{{student.name}}
</ui-select-choices>
</ui-select>
Can we add custom ids to each of the new li formed from the ui-select-choices?
If yes then how?

Yes, using the ugly but standard Angular repeat syntax:
repeat="student.id as student in studentList | ..."

Related

How to display a controller variable in view(blade)

I have a variable generated by the controller in laravel 5.8, I want to display this variable on the view
I have tried using the conventional {!! $variable !!} but it returns
#section('page_heading',"System Dashboard | {!! $region !!}")
I expect to get Kalipso Dashboard |Northern Region but instead am getting Kalipso Dashboard |
It will be set as below
Suppose value of $region = 'Your custom string message here.';
#section('page_heading',"System Dashboard | {{ $region }}")
Found the solution.
Used #section('page_heading',"System Dashboard | $region ")

Show News Item creator or owner full name in Plone

I'm trying to show the full name for each news item in a list. For the moment I have only the user id (nickname).
Is there a simple way (in existing .pt file) to show the full name of creator or owner instead of a nickname?
The page must work for anonymous users, too. I mean - the page must be public.
Some details:
<div class="container-fluid news-list-container"
tal:define="news_items python:context.getFolderContents(contentFilter={'portal_type':['News Item'], 'sort_on': 'Date', 'sort_order': 'descending',});
Batch python:modules['Products.CMFPlone'].Batch;
b_size python:4;
b_start python:0;
b_start request/b_start | b_start;
batch python:Batch(news_items, b_size, int(b_start), orphan=0);"
tal:condition="news_items">
<div class="news-list-items">
<tal:items tal:repeat="news_item batch">
<!-- News item -->
<div class="row news-item"
tal:define="news_object python:news_item.getObject();
news_date python:news_object.getField('modification_date').getAccessor(news_object)();
news_title python:news_object.getField('title').getAccessor(news_object)();
news_description python:news_object.getField('description').getAccessor(news_object)();
news_image python:news_object.getField('image').getAccessor(news_object)();
news_url python:news_object.absolute_url();
news_creators python:news_object.getField('creators').getAccessor(news_object)(); .... ...
<tal:fullname define="membership context/portal_membership;
info python:membership.getMemberInfo(user.getId());
fullname info/fullname">
You are are <span class="name" tal:content="fullname" />
</tal:fullname>
This example is taken from the plone documentation
You can get inspired a lot by this code:
https://github.com/collective/Products.Scrawl/blob/1021047c4ef6c2655d104e8b345a24140da9e4aa/Products/Scrawl/browser/blogentry_view.pt#L32
<tal:name tal:condition="item_creator"
tal:define="author python:context.portal_membership.getMemberInfo(item_creator)">
<span i18n:translate="label_by_author">Posted by
<a href="#"
title="Read more posts by this author"
tal:attributes="href string:${context/portal_url}/author/${item_creator}"
tal:content="python:author and author['fullname'] or item_creator"
tal:omit-tag="not:author"
i18n:domain="scrawl"
i18n:name="author"
i18n:attributes="title author_title">
Bob Dobalina
</a>
</span>
</tal:name>
Mind the possible performance issues.
A cached view method may work a lot better, e.g.:
#memoize
def userid2fullname(self, userid):
pm = api.portal.get_tool('portal_membership')
memberinfo = pm.getMemberInfo(userid)
return memberinfo and memberinfo['fullname'] or userid

allow new methods in sandbox policy in twig (drupal 8)

I am getting this error when using the "field collection" module :
Twig_Sandbox_SecurityError: Calling "uri" method on a "Drupal\field_collection\Entity\FieldCollectionItem" object is not allowed in "themes/communitylife/templates/content/node.html.twig" at line 83. in Drupal\Core\Template\TwigSandboxPolicy->checkMethodAllowed() (line 99 of core/lib/Drupal/Core/Template/TwigSandboxPolicy.php).
the code that causes the problem is this one :
<div class=" title-col col-md-7">
<a href="{{file_url(node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_file.entity.uri.value)}}" target="_blank"> <strong> {{node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_description.value}}
<span class="file-type"> ({{node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_file.entity.uri.value | slice(-3) }} </span>, <span class="file-size"> {{node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_file.entity.size }}) </span>
</strong></a>
</div>
what is the best way to fix this ? is it by adding (uri) to the allowed methods in the sandbox policy ? if yes then how I can do that ?
I read in the twig documentation that I can do something like this :
$policy = new Twig_Sandbox_SecurityPolicy($tags, $filters, $methods, $properties, $functions);
but I didn't understand how or where to put this code.
Thanks in advance
Drupal's twig sandbox policy (defined in core/lib/Drupal/Core/Template/TwigSandboxPolicy.php) reads from the global $settings array so you can define your own in your settings.php i.e.
// Override default twig method whitelist.
$settings['twig_sandbox_whitelisted_methods'] = [
// Defaults:
'id',
'label',
'bundle',
'get',
'__toString',
'toString',
// Additions:
'url',
];

identifying image object using css for protractor automation

I am using protractor for angular js automation. I am trying to get the 'fa fa-something' text from the below element structure using css identifier-
<div class="Itemlistcontainer">
<ul class="itemlist sortlist ui-sortable">
<!-- ngRepeat: Item in Items | orderBy:CustomSort:false --><li ng-repeat=" Item in Items | orderBy:CustomSort:false" ng-show="!searchinput || ([Item.Name]|filter:searchinput).length" ng-class="{ 'itemdisabled' : !CanUseTask(Item) || deactivate }" class="ng-scope ui-draggable">
<div bo-attr="" bo-attr-id="Item.Id" bo-attr-title="Item.Details | html2string" class="label itemlabel" id="3d991564-a1a9-49ab-8659-a26e00fbfae6" title="Blah blah blah.">
<span>
<i ng-class="itemIconClass(Item)" style="margin-right: 5px;" class="fa fa-something"></i>
</span><span bo-text="item.Name | ellipse : 32">Item Name</span>
</div>
<!--ngRepeat: Item in Items....and the list goes on
I need to know under what Item in Items was this 'fa fa-something' found. I am using element(By.css('ul.itemlist i.itemIconClass(Item)').getAttribute('class').getText()
which is not working.
element(By.css('ul.itemlist i.itemIconClass(Item)').getAttribute('class').getText()
can't work as you're trying to interpolate an angular template expression in a protractor element selector
I think you need :
element(By.css('ul.itemlist i.fa.fa-something').getAttribute('class').getText()
And to determine what Item in Items was this 'fa fa-something' found maybe you need an ID (which will be easier to read, no need to parse class attribute by extracting fa fasomething etc...

Symfony2: set a class to the select generated by birthdate widget

In my form I generate the birthdate field with:
{{form_widget(form.birthdate) }}
The following html is generated:
<div id="fos_user_registration_form_birthdate">
<select id="fos_user_registration_form_birthdate_month" name="fos_user_registration_form[birthdate][month]">
<select id="fos_user_registration_form_birthdate_day" name="fos_user_registration_form[birthdate][day]">
,
<select id="fos_user_registration_form_birthdate_year" name="fos_user_registration_form[birthdate][year]">
</div>
I want to add a class to the select in order to customize their style.
How can I do that?
PS: If I add
'attr' => array('class' => 'select-style'),
the class is attributed to <div id="fos_user_registration_form_birthdate">, not to the select
{{ form_widget(account_form.birthday.day,{'attr':{'class':'some_class'}}) }}
{{ form_widget(account_form.birthday.month,{'attr':{'class':'some_class'}}) }}
{{ form_widget(account_form.birthday.year,{'attr':{'class':'some_class'}}) }}
That is the best you can do without overriding the twig template for the date widget yourself. If you look at the default template for the date widget here you'll see there are no attributes passed specifically to the select inputs. You can, however, apply a class to the containing div and then use a CSS selector like this to style them
.dateWrapper select { /* style here */ }

Resources