Setting already fetched Account Name/Login Name to Pnp Js Peoplepicker - reactjs

I am creating an edit form in spfx(with react js as a framework) where I will fetch data for particular list item using pnp js. I already fetched data from person type field say 'Sender'.Now I want to show the fetched user in peoplepicker control.
The below control is used in my code. Value for 'defaultSelectedUsers' is set statically to check whether once this control is loaded, the loginName mentioned there will pre-populate the user or not. But this attribute is not working.
Can anyone suggest how can I pre-populate this peoplepicker control?
<PeoplePicker
context={this.props.context}
titleText="Sender"
personSelectionLimit={1}
groupName={"some group here"}
showtooltip={true}
isRequired={true}
disabled={false}
defaultSelectedUsers=
{['i:0#.f|membership|abcUser#xyz23.onmicrosoft.com']}
selectedItems={this._getItems}
showHiddenInUI={false}
principalTypes={[PrincipalType.User]}
resolveDelay={200}
ensureUser={true}
/>
Expected Behaviour: As soon as page is loaded I want the user with login Name i:0#.f|membership|abcUser#xyz23.onmicrosoft.com pre-populated in peoplepicker control.

I was doing R&D on this issue from 2-3 days almost.But couldn't find anything. Today I just tried a simple thing. I put email of user instead of loginName and this thing worked.
<PeoplePicker
context={this.props.context}
titleText="Sender"
personSelectionLimit={1}
groupName={"some group here"}
showtooltip={true}
isRequired={true}
disabled={false}
**defaultSelectedUsers=
{['abcUser#xyz23.onmicrosoft.com']}**
selectedItems={this._getItems}
showHiddenInUI={false}
principalTypes={[PrincipalType.User]}
resolveDelay={200}
ensureUser={true}
/>

In my case adding ensureUser= {true} resolved the issue as follows
<PeoplePicker
context={this.props.context}
titleText="Multi People Picker for user name"
personSelectionLimit={5}
groupName={""}
showtooltip={true}
required={false}
disabled={false}
ensureUser= {true}
onChange={this._getPeoplePickerItemsUsername}
showHiddenInUI={false}
principalTypes={[PrincipalType.User]}
resolveDelay={1000} />

Related

puppeteer get instagram profile checkbox value - HTML does not change

Learning puppeteer... thought Instagram would be a good starting point.
Trying to see if my account in Instagram is configured to be a "Private Account" under Privacy and Security. My confusion is that the HTML for checked and unchecked is just about the same:
Checked:
<div class="qlmO5"><div class="bGWmh" id="accountPrivacy"><label class="U17kh PLphk" for="f2ef028392b78b8"><input class="tlZCJ" id="f2ef028392b78b8" type="checkbox" value="" checked=""><div class="mwD2G"></div>Private Account</label></div></div>
Unchecked:
<div class="qlmO5"><div class="bGWmh" id="accountPrivacy"><label class="U17kh PLphk" for="f111b1f63405c24"><input class="tlZCJ" id="f111b1f63405c24" type="checkbox" value="" checked=""><div class="mwD2G"></div>Private Account</label></div></div>
I thought it might be the <input>'s id value but that does not change based on the value of the checkbox. I also tried diffing the entire html of checked vs unchecked and they were identical.
In this case, am I supposed to take a screenshot and see if I can match an image of "☑ Private Account"? I feel that this may be possible, but not necessary.
HTML is indeed identical in both cases, but the DOM tree isn't. When private account "checkbox" is checked, the .mwD2G div gets a :before element which does the styling, so you can check for it in page.evaluate:
window.getComputedStyle(document.querySelector(".mwD2G"), ":before").getPropertyValue("content")
So if the box is checked, the result of the query is " ", if unchecked, none.
const privateProfile = await page.evaluate(() =>
window.getComputedStyle(document.querySelector(".mwD2G"), ":before")
.getPropertyValue("content") === "none" ? false : true)

DropdownSingleSelect user input type in Azure AD B2C

I have claim 'country' with type 'DropdownSingleSelect' which has list of countries to be shown and 'SelectByDefault=true' enabled for 'US' country in list.
This control is shown to user in the 1st step of user journey and user changed the value in dropdown. Example, user selected 'UK'.
Now in the 3rd step of user journey(self asserted), i have to show the same dropdown with the value he selected and get confirmation from user.
If i put that claim in outputclaim, dropdown is shown to user but default value 'US' selected. It should have shown the selected value as 'UK'.
If i remove 'SelectByDefault=true' attribute from list of values, it is showing as expected.
Is it expected behaviour or can it be fixed in user journey itself?
I could address this by adding default value for the claim in the "sign up" technical profile (or any profile which shows the claim to user for the first time). This causes a default value to be selected in the dropdown. I have a countryCode claim with possible values as all countries. I haven't set SelectByDefault=true in ClaimType. I added following to sign up technical profile
<InputClaims>
<InputClaim ClaimTypeReferenceId="countryCode" DefaultValue="IN"/>
</InputClaims>
Short version of the profile is
<ClaimsProvider>
<DisplayName>Local Account</DisplayName>
<TechnicalProfiles>
<TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
<InputClaims>
<InputClaim ClaimTypeReferenceId="countryCode" DefaultValue="IN"/>
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="countryCode"/>
</OutputClaims>
</TechnicalProfile>
</TechnicalProfiles>
</ClaimsProvider>
At other places where the claim is used (and value is set), it automatically shows selected value.

Need to get dynamic count of the selected check-boxes

I'm having the two types of check-boxes one is for selectAll check-box in the data table header, and another type selecting the check-box for each row.
I'm doing a operation, So I need to show the confirmation message, How do I get the count of the selected check-boxes from the Managed Bean.
My code was written in JSF 1.2.
I can able to do select all records, select records, ManagedBean is working fine, But I need to get how many of them got selected for deletion.
Here is the JSF code,
<i:commandLink id="delete"
onclick="if (!confirm('#{managedBean.deleteSelectedCount}')) return false;"
action="#{managedBean.deleteRecords}"
title="Delete records"
immediate="true">
<i:graphicImage url="images/icons/delete.gif" alt="Delete records" />
</i:commandLink>
;
;//Some coding
;
//Data table code starts
<i:dataTable id="caseDataTable"
<h:column>
<f:facet name="header">
<i:selectBooleanCheckbox id="selectAllRecords" title="select All records"
value="#{managedBean.selectAll}">
<a4j:support event="onclick" reRender="caseDataTable,globalMessages" action="#{managedBean.actionSelectAllRecordss}" onsubmit="showBusyIndicator();" oncomplete="hideBusyIndicator();" />
</i:selectBooleanCheckbox>
</f:facet>
<h:outputLabel for="selectCheckbox" value="selectCheckbox"/>
<i:selectBooleanCheckbox id="selectCheckbox"
title="select a record" value="#{managedBean.selected}" >
<a4j:support event="onclick" reRender="selectAllRecords, globalMessages" action="#{managedBean.actionSelectionChange}"
onsubmit="showBusyIndicator();" oncomplete="hideBusyIndicator();"/>
</i:selectBooleanCheckbox>
</h:column>
Possible solution is to use h:inputHidden component (I think it exists in JSF 1.2. If not, you can find some alternative).
For example
Add h:inputHidden to the page
<h:inputHidden id="selectedCountHidden" value="#{managedBean.deleteSelectedCount}"/>
Each time you click on header check box or any of row check boxes, calculate deleteSelectedCount value and re-render h:inputHidden. Something like
<i:selectBooleanCheckbox id="selectCheckbox" title="select a record" value="#{managedBean.selected}" >
<a4j:support event="onclick" reRender="...,selectedCountHidden,..."
And now, since h:inputHidden will always hold deleteSeletedCount value, you can read its value via java script so there is no need for re-loading the page when you click on commandLink
<i:commandLink id="delete"
onclick="if(!confirm(document.getElementById('form:selectedCountHidden').value))return false;"..../>
Note that if you have form with id defined, you will need to call
document.getElementById('form:selectedCountHidden').value
Otherwise just call
document.getElementById('selectedCountHidden').value
In any case, inspect page source and you will find the exact id of p:inputHidden.

NG-Admin: Is there a way to create an "add new" button on a referenced_list?

I have a referenced_list in my ng-admin app:
nga.field('profiles', 'referenced_list') // display list of related profiles
.targetEntity(profiles)
.targetReferenceField('user_id')
.targetFields([
nga.field('id').isDetailLink(true),
nga.field('username'),
]),
nga.field('', 'template').label('')
.template('<span class="pull-right"><ma-filtered-list-button entity-name="profiles" filter="{ user_id: entry.values.id }" size="sm"></ma-filtered-list-button></span>')
The template field creates a "view all related profiles" link.
What I would like to do is create a "add new profile" button that links to the profile creation page, and pre-selects the current user_id.
Is there a hack to do this or a custom template / directive that can do this?
The <ma-create-button>directive has been added a few days ago (https://github.com/marmelab/ng-admin/pull/696). It allows exactly what you want:
<ma-create-button entity-name="comments" default-values="{ post_id: entry.values.id }" size="xs"></ma-create-button>
It's available in ng-admin 0.9-dev and higher.

Adding a teaser image to Composite.News

Is it possible to add a teaser image to the default Composite.News package? Out of the box the news ext. brings all I need but a teaser image for the list view is missing in my case.
Yes, but this require modifications with package.
Edit News data type: go to Data -> Page Datafolders -> locate Composite.News.NewsItem -> right click -> Edit -> on the Fields tab add new field for example named "TeaserImage", Field Type = Data Reference, Reference Type = C1 Image File, Optional = Yes -> Save data type.
Modify the News Form Markup:
The News data item contains custom Form Markup, so the new added field will be not automatically appear there, so you should manually add the markup for the new field: go to Data -> Page Datafolders -> locate Composite.News.NewsItem -> right click -> Edit Form Markup -> add markup for the new TeaserImage field:
<cms:binding name="TeaserImage" type="System.String" optional="true" />
</cms:bindings>
<cms:layout>
<cms:layout.label>
<cms:read source="Title" />
</cms:layout.label>
<TabPanels>
<PlaceHolder Label="Settings">
<FieldGroup>
...
<TextArea Label="Teaser" Help="The short description of the news item">
<TextArea.Text>
<cms:bind source="Teaser" />
</TextArea.Text>
</TextArea>
<DataReferenceTreeSelector Label="TeaserImage" Help="" Handle="Composite.Management.ImageSelectorDialog" SearchToken="Composite.Plugins.Elements.ElementProviders.MediaFileProviderElementProvider.MediaFileSearchToken,Composite|MimeTypes=',\ \'image/gif\',\ \'image/jpeg\',\ \'image/png\',\ \'image/bmp\'', Extensions=null, Folder=null, HideSubfolders='False', Keyword=null" DataType="Composite.Data.Types.IImageFile,Composite" NullValueAllowed="true">
<DataReferenceTreeSelector.Selected>
<cms:bind source="TeaserImage" />
</DataReferenceTreeSelector.Selected>
</DataReferenceTreeSelector>
</FieldGroup>
</PlaceHolder>
<XhtmlEditor Label="News Story" Help="News Story" ClassConfigurationName="common">
...
</XhtmlEditor>
</TabPanels>
</cms:layout>
Modify the XSLT function Composite.News.NewsList -> edit the function call "GetNewsItemXml" -> modify Selected fields (select the new TeaserImage field), -> edit function Template and add the code where you want to render the Tease Image.

Resources