I want to make password property of User model to be visible in Loopback explorer, in such case it should not be hidden. Is it possible to revert visibility of the property hidden in the base model?
You need to delete password from hidden properties of the User.
You can create a boot script and put below code there :
var filtered = app.models.User.settings.hidden.filter(function(item)
{
return item !== 'password';
}
);
app.models.User.settings.hidden = filtered;
Related
I'm using Acumatica customization Acumatica-LotSerialNbrAttribute
This customization adds a new screen for look for InventoryID and LotSerialNbr and visualize its attributes.
I'm trying to add this window to the acumatica mobile app.
Here my code:
add screen IN202501 {
add container "InventoryLotSerialContainers" {
add field "InventoryID"
add field "LotSerialNbr"
add group "Attributes" {
displayName = "Attributes"
collapsable = True
add attributes "AttributesAttributes"
}
add recordAction "Save" {
behavior = Save
}
add recordAction "Cancel" {
behavior = Cancel
}
attachments {
}
}
}
And the screen is visible on the mobile app with the 2 selectors
Then I select Inventory and when I select Lot Serial Nbr, the first selector is in blank, causing that I can't review the attributtes neither save the information.
Here the InventoryID selector in blank.
Hope you can help me to successfully publish this screen on acumatica mobile app.
Thanks.
Attributes are a grid style representation in Acumatica. That means you need a container that will show multiple records. I'm getting rusty on mobile pretty quickly, but I believe your definition is set to display a single value value only.
Try adding a separate container for attributes:
add container "AttributesAttributes" {
add field "Attribute"
add field "Value"
}
This should open into a view of multiple records, showing all of your attributes. By specifying the Attribute and Value fields, you should see both data elements in the container.
I have a scenario where I have 2 profiles (user and admin) and I have a selection page once a person logs in. On the selection page, there are 2 radio buttons for (User and Admin profiles), what I am trying to achieve is, the person can choose only 1 profile (this is achieved by the radio button), now assuming I have saved the selected value, I want to set the rootPage to AdminPage or UserPage, but I don't want to immediately navigate, I just want to update/set the path so that when the person goes back (by pressing the back key or previous button) it will take the person to the desired page. Please let me know your thoughts.
Maby this will put you in the right direction:
https://ionicframework.com/docs/api/navigation/NavController/#insert
do not set adminPage or userPage as rootPage but insert the page on the stack
The trick here is that you want to set the root to a new page after the user tries to go back, the easiest way to achieve this is using the NavController navguards to execute a code before leaving the page, this way it'll check wich page the user has selected and then set the root.
Since the select can be easy impemented following the docs i'll leave that aside. Let's just say you have a property userType that is a string and can be 'user' or 'admin', in your select page you'll do the following:
public canLeave: boolean = false; //this'll controll if the user can leave the page or not
public userType: string = 'user'; // just setting a default value to your select
// this is a navguard
ionViewCanLeave() {
if(!this.canLeave){
if(this.userType == 'user'){
this.canLeave = true; // you'll need to set canLeave to true so when setting the rootpage it doesn't enters the if statemente again
this.navCtrl.setRoot('UserPage');
} else {
this.canLeave = true;
this.navCtrl.setRoot('AdminPage');
}
}
return true;
}
Hope this helps.
I got the solution to the error,
ionViewCanLeave() {
if(!this.canLeave){
if(this.userType == 'user'){
this.canLeave = true; // you'll need to set canLeave to true so when setting the rootpage it doesn't enters the if statemente again
this.navCtrl.setRoot('UserPage'); // <-- this should be UserPage instead of 'UserPage'
} else {
this.canLeave = true;
this.navCtrl.setRoot('AdminPage'); // <-- this should be AdminPage instead of 'AdminPage'
}
}
return true;
}
I am using GetDataSourceItem Method from glass mapper to return my datasource item to the view, I debug the code when the datasource is empty the calloutModel in controller will be null, but from the view, model will not be null, it will have the current item model i am using the following code :
my controller action :
public ActionResult Callout()
{
// I didn't fill the datasource in the component
// calloutModel value is coming null.
var calloutModel= GetDataSourceItem<CalloutModel>();
return View(calloutModel);
}
my view:
#inherits Glass.Mapper.Sc.Web.Mvc.GlassView<CalloutModel>
// Model is coming the current item in the view (it should be null)
It looks like this is due to the GlassView base class. That class overrides the InitHelpers method and calls its GetModel method if the model is null. The GetModel method will fall back to the context item if there is no data source item.
To prevent this, you could change your #inherits directive to an #model CalloutModel and then use the #Html.Glass() helper to get access to the Editable methods and such.
I need image field source of a product item to change depending on the folder path I am creating a product item under when creating the item in content or page editor.
If I am creating a product under /home/bicycles, I need the product item image field to auto change to /sitecore/media library/Images/bicycles
If I am creating a product under /home/cars, I need the product item image field to auto change to /sitecore/media library/Images/cars
If I am creating a product under /home/scooters, I need the product item image field to auto change to /sitecore/media library/Images/scooters
The default setting for that image field source in the datatemplate is /sitecore/media library/Images/bicycles
How can I go about doing this?
One option is to create a custom Content Editor field that extends the default image field type.
Start by creating a class that inherits from Sitecore.Shell.Applications.ContentEditor.Image. Then override the OnPreRender method to determine and set the Source property of the image field based on your location criteria/requirements.
See comments in the code below for more information.
public class ContextAwareImageField : Sitecore.Shell.Applications.ContentEditor.Image
{
/// <summary>
/// The ItemID proprety is set by the Content Editor via reflection
/// </summary>
public string ItemID { get; set; }
/// <summary>
/// Override the OnPreRender method.
/// The base OnPreRender method assigns a value to the Source viewstate property and we need to overwrite it.
/// </summary>
/// <param name="e"></param>
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
Source = GetSource();
}
protected virtual string GetSource()
{
//retrieve and return the computed source value if it has already been set
var contextSource = GetViewStateString("ContextSource");
if (!string.IsNullOrWhiteSpace(contextSource))
return contextSource;
//retrieve the context item (the item containing the image field)
var contextItem = Sitecore.Context.ContentDatabase.GetItem(ItemID);
if (contextItem == null)
return string.Empty;
//determine the source to be used by the media browser
//in this case we're just checking based on parent path, but any logic could be inserted
contextSource = "/sitecore/media library/Images";
switch (contextItem.Parent.Paths.FullPath.ToLowerInvariant())
{
case "/sitecore/content/home/bicycles":
contextSource = "/sitecore/media library/Images/Bicycles";
break;
case "/sitecore/content/home/cars":
contextSource = "/sitecore/media library/Images/Cars";
break;
case "/sitecore/content/home/scooters":
contextSource = "/sitecore/media library/Images/Scooters";
break;
}
//store the computed source value in view bag for later retrieval
SetViewStateString("ContextSource", contextSource);
//return the computed source value
return contextSource;
}
}
Next, perform the following steps:
Login to the Sitecore desktop with administrator rights and use the database icon in the lower right to switch to the Core database.
In the Core database, open the Content Editor then navigate to /sitecore/system/Field Types/Simple Types. There you will find an item representing the Image field type.
Duplicate the Image field type item and rename the duplicated item to something relevant (e.g. Context Aware Image).
Edit the duplicated item
In the Assembly field, provide the name of the assembly file containing your custom image field class (e.g. MyClient.MySite.dll)
In the Class field, provide the name of the custom image field class, including the namespace (e.g. MyClient.MySite.CustomFields.ContextAwareImageField)
Delete the value in the Control field
Save your changes
Switch back to the Master database.
Open the Content Editor, then navigate to a template that should contain your new image field.
Either create a new field in the template and choose your new custom field type in the Type dropdown. Or, change the Type for an existing image field.
Save your template changes.
In the content tree, navigate to an item based on the template above and click the Browse button for the contained image field. The media browser dialog should default to the source location specified by the logic in your custom field.
Note: if you are using a version of Sitecore that contains a SPEAK-based media browser dialog, you will have to switch to Tree View in the dialog (icon in the upper right) in order to see the source location specified by your custom field.
I have a m2m relation where in my AdminForm I would use raw_id_fields instead of the filter_horizontal option. For explanation I prefer the raw_id_fields instead of the filter_horizontal option, because the records are already categorized. So in the popup-window the user has the ability to search and filter via category.
But there are two points that I can't figure out:
possibility to selecting more than one record in the popup window
showing the real names instead of the pk in the input_field
It's possible. In order to select more than one record, you need to override default dismissRelatedLookupPopup() in django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js by including your script in the Media class of your ModelAdmin or widget:
var dismissRelatedLookupPopup = (function(prev, $) {
return function(win, chosenId) {
var name = windowname_to_id(win.name);
var elem = document.getElementById(name);
// 1. you could add extra condition checking here, for example
if ($(elem).hasClass('my_raw_id_ext_cls')) { // add this class to the field
// ...logic of inserting picked items from the popup page
}
else { // default logic
prev(win, chosenId);
}
// 2. or you could copy the following part from RelatedObjectLookups.js ...
if (elem.className.indexOf('vManyToManyRawIdAdminField') != -1 && elem.value) {
elem.value += ',' + chosenId;
// 2. and add a return. Remember this acts globally.
return;
} else {
document.getElementById(name).value = chosenId;
}
// 3. the following line cause the popup to be closed while one item is picked.
// You could comment it out, but this would also affect the behavior of picking FK items.
win.close();
}
})(dismissRelatedLookupPopup, django.jQuery);
Django does not support this by default. There are some snippets at djangosnippets.org, you may want to take a look at them.
Finally I'm using a modified https://django-salmonella.readthedocs.org/en/latest/. I don't show the input field and show the selected records in a table.