Update the BackButton text within a dialog view controller - xamarin.ios

I have a monotouch dialog view controller. I have a number of nested root elements
public RootElement LoginSection()
{
//var rootSection = new Section("");
var root = new RootElement ("I'm already a member");
EntryElement emailEnt = new EntryElement ("Login","Username or Email","");
EntryElement passwdEnt = new EntryElement ("Password","Password","",true);
StyledStringElement loginBtn = new StyledStringElement ("Login"){
Accessory = UITableViewCellAccessory.DetailDisclosureButton
};
Section loginDetails = new Section("Your Details"){emailEnt,passwdEnt,loginBtn};
loginBtn.Tapped += () => {
var result = ApiOperations.ApiValidateLoginCredentials (emailEnt.Value, passwdEnt.Value);
if (result) {
var login = DataOperations.DbGetLogin ();
//first time user so we need to save their details into the db
if (login == null) {
} else {
BTProgressHUD.Show ("Logging In", -1, BTProgressHUD.MaskType.Black);
BTProgressHUD.InvokeInBackground (delegate {
ApiOperations.QrCode (login.ConsumerId);
ApiOperations.ApiConsumer (login.ConsumerId);
AuthenicatedActionCompleted.Invoke (this, new EventArgs ());
BTProgressHUD.Dismiss ();
});
}
} else {
//didnt work
using (var alert = new UIAlertView ("Unable to login", "Please try again.", null, "OK", null))
alert.Show ();
}
};
root.Add (loginDetails);
return root;
}
My problem is the the length of each of the element titles. My top level root title is also long e.g. Welcome to my application
If I tap on an rootelement above the back button shows "welcome to...." ideally I would like the button to show "back" vs the long string.
Is it possible to update this?

Ok solved it. If anyone else has the same problem this worked for me.
The last line is the trick.
public override void LoadView ()
{
base.LoadView ();
View.BackgroundColor =UIColor.Clear;
TableView.BackgroundView = null;
var background = UIImage.FromBundle(Resources.BackgroundImagePath);
ParentViewController.View.BackgroundColor = UIColor.FromPatternImage (background);
this.NavigationItem.BackBarButtonItem = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null);
}

Related

Closing Case in Acumatica through API

I want to close the case in Partners Portal remotely using Web API, whenever I close the case in my (client) side. I was able to implement the code but ran into below issue.
It is changing the status and resolution of the case in Partners Portal but Close Case button is enabled and it is visible in My Open Case bucket. Please let me know if I can close the case remotely using Web API or if I am missing anything.
protected virtual void CRCase_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
var caseRow = (CRCase)e.Row;
if (caseRow != null)
{
if (caseRow.Status == "C") // Closed
{
string cloud9CaseCD = null;
cloud9CaseCD = CRCaseForCreate.Current.CaseCD;
string acumaticaCaseCD = string.Empty;
CSAnswers aCCaseNoAttribute = PXSelect<CSAnswers,
Where<CSAnswers.refNoteID, Equal<Required<CSAnswers.refNoteID>>,
And<CSAnswers.attributeID, Equal<Required<CSAnswers.attributeID>>>>>.Select(new PXGraph(), CRCaseForCreate.Current.NoteID, "ACCASENO");
if (aCCaseNoAttribute != null)
{
acumaticaCaseCD = aCCaseNoAttribute.Value;
if(!string.IsNullOrEmpty(acumaticaCaseCD))
{
SP203000WS.Screen context = new SP203000WS.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "https://sso.acumatica.com/Soap/SP203000.asmx";
PartnerPortalCreds loginCreds = GetCreds();
string username = loginCreds.PARTPRTUSE;
string password = loginCreds.PARTPRTPAS;
SP203000WS.LoginResult result = context.Login(username, password);
SP203000WS.Content CR306000 = context.GetSchema();
context.Clear();
SP203000WS.Content[] CR306000Content = context.Submit
(
new SP203000WS.Command[]
{
new SP203000WS.Value
{
Value = acumaticaCaseCD,
LinkedCommand = CR306000.Case.CaseID
},
new SP203000WS.Value
{
Value = "C",
LinkedCommand = new SP203000WS.Field { FieldName="Status", ObjectName="Case"}
},
new SP203000WS.Value
{
Value = "RD",
LinkedCommand = new SP203000WS.Field { FieldName="Resolution", ObjectName="Case"}
},
CR306000.Actions.Submit,
CR306000.Case.CaseID
}
);
context.Logout();
}
}
}
}
}
Tried below code using CloseCase Action: -
protected virtual void CRCase_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
var caseRow = (CRCase)e.Row;
if (caseRow != null)
{
if (caseRow.Status == "C") // Closed
{
string cloud9CaseCD = null;
cloud9CaseCD = CRCaseForCreate.Current.CaseCD;
string acumaticaCaseCD = string.Empty;
CSAnswers aCCaseNoAttribute = PXSelect<CSAnswers,
Where<CSAnswers.refNoteID, Equal<Required<CSAnswers.refNoteID>>,
And<CSAnswers.attributeID, Equal<Required<CSAnswers.attributeID>>>>>.Select(new PXGraph(), CRCaseForCreate.Current.NoteID, "ACCASENO");
if (aCCaseNoAttribute != null)
{
acumaticaCaseCD = aCCaseNoAttribute.Value;
if (!string.IsNullOrEmpty(acumaticaCaseCD))
{
SP203010WS.Screen context = new SP203010WS.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "https://sso.acumatica.com/Soap/SP203010.asmx";
PartnerPortalCreds loginCreds = GetCreds();
string username = loginCreds.PARTPRTUSE;
string password = loginCreds.PARTPRTPAS;
SP203010WS.LoginResult result = context.Login(username, password);
SP203010WS.Content CR306000 = context.GetSchema();
context.Clear();
var commands1 = new SP203010WS.Command[]
{
new SP203010WS.Value
{
Value = acumaticaCaseCD,
LinkedCommand = CR306000.Case.CaseID
},
new SP203010WS.Value
{
Value = "Yes",
LinkedCommand = CR306000.Case.ServiceCommands.DialogAnswer, Commit = true
},
CR306000.Actions.CloseCase
};
var data = context.Submit(commands1);
context.Logout();
}
}
}
}
}
In the below image you can see that the case is already closed but Close Case menu button is still visible.
Close Case Confirmation Dialogbox on Partners Portal. How should I answer this dialogbox programatically while closing the case using Web API.
Have you tried to invoke Close action via Web API instead of changing values of the Status and Resolution fields? As far as I know, Close button on the Partner Portal updates support case Status to Open and Reason to Pending Closure. Then it's up to support personnel to manually close the case.
Finally found the solution. Updated the code for CloseCase (second code snippet). This will mark the case as Pending Closure in Partners Portal.

Black window when navigating from App delegate in xamarin Ios

I'm getting a black window after navigating to a view controller. My app is calling a page from app delegate from the OpenUrl method.
public override bool OpenUrl(UIApplication app, NSUrl url, string sourceApp, NSObject annotation)
{
var rurl = new Rivets.AppLinkUrl(url.ToString());
// navController = new UINavigationController();
var id = string.Empty;
if (rurl.InputQueryParameters.ContainsKey("id"))
id = rurl.InputQueryParameters["id"];
if (rurl.InputUrl.Host.Equals("products") && !string.IsNullOrEmpty(id))
{
// var mainController = new UIViewController();
// NSUserDefaults.StandardUserDefaults.SetBool(true, "ForgotPwdLinkClicked");
return true;
}
else
{
//var c = new ProductViewController();
// UIApplication.SharedApplication.KeyWindow.RootViewController = c;
var c = new UpdatePasswordViewController();
navigationController.ModalPresentationStyle = UIModalPresentationStyle.OverFullScreen;
navigationController.PushViewController
(c, true);
//// return true ;
///*this.Window.RootViewController =
// c;*/
// NSUserDefaults.StandardUserDefaults.SetBool(true, "ForgotPwdLinkClicked");
return true;
}
}
These are my ViewController settings in XCode:
This Code resolve my issue
UIStoryboard Storyboard = UIStoryboard.FromName("MainStoryboard", null);// this will bee our storyboard name
var c = Storyboard.InstantiateViewController("UpdatePasswordViewController") as UpdatePasswordViewController;

MvvmCross - MvxTabBarViewController does not show the "More" button when using a Storyboard

In my application, I'm using the MvxTabBarViewController to display some tabs (the MvxTabBarViewController is loaded using a Storyboard):
public partial class RootView : MvxTabBarViewController
{
private int _tabIndex = 0;
private Dictionary<int, SectionBase> _sectionBaseForConfig;
public new RootViewModel ViewModel
{
get { return (RootViewModel)base.ViewModel; }
set { base.ViewModel = value; }
}
public RootView(IntPtr handle)
: base(handle)
{
}
UIViewController tab1, tab2, tab3, tab4, tab5, tab6, tab7;
public override async void ViewDidLoad()
{
base.ViewDidLoad();
if (ViewModel == null)
return;
tab1 = new UIViewController();
tab1.Title = "1";
tab1.View.BackgroundColor = UIColor.Green;
tab2 = new UIViewController();
tab2.Title = "2";
tab2.View.BackgroundColor = UIColor.Orange;
tab3 = new UIViewController();
tab3.Title = "3";
tab3.View.BackgroundColor = UIColor.Red;
tab4 = new UIViewController();
tab4.Title = "4";
tab4.View.BackgroundColor = UIColor.Blue;
tab5 = new UIViewController();
tab5.Title = "5";
tab5.View.BackgroundColor = UIColor.Brown;
tab6 = new UIViewController();
tab6.Title = "6";
tab6.View.BackgroundColor = UIColor.Brown;
tab7 = new UIViewController();
tab7.Title = "7";
tab7.View.BackgroundColor = UIColor.Brown;
var tabs = new UIViewController[] {
tab1, tab2, tab3, tab4, tab5, tab6, tab7
};
ViewControllers = tabs;
CustomizableViewControllers = null;
SelectedViewController = ViewControllers[0];
}
}
Unfortunately, even if there are 7 tabs, only 5 are displayed and the "More" button does not show. Anyone got an idea ? I stuck on this problem since 2 hrs now, without any clues :(
Thanks!

Monotouch Dialog: Getting SimpleMultilineEntryElement to respect its 'size'

I am using a SimpleMultilineEntryElement in MonotouchDialog, from the Elements Pack (here).
Regardless of the height setting, this element continued to appear at the 'default' table cell height. The actual editable part varied, but the background cell outline did not. Much browsing indicated a SizingSource needed to be implemented, and I've done that. So, using a pretty brittle workaround I can now resize cells selectively. Using the UnevenRows property on the Root element did not help. Trying to get the cell at that index killed the app, even though indexes were definitely being returned.
Is there a way to just make it use the height properties I defined for the Multiline entryelement?
using System;
using System.Drawing;
using MonoTouch.Dialog;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using ElementPack;
using System.Collections.Generic;
namespace MyNameSpace
{
// Edit existing project or add one if none exists
public partial class ProjectEdit : DialogViewController
{
Project _p;
UINavigationController _nc;
public ProjectEdit (Project p, UINavigationController nc) : base(null, true)
{
_p = p;
_nc = nc;
if (_p == null)
{
_p = new Project();
_p.InitialiseProjectDefaults();
}
}
public override Source CreateSizingSource (bool unevenRows)
{
//if (unevenRows)
{
return new unevenSizingSource(this);
}
}
public class unevenSizingSource : DialogViewController.SizingSource
{
public unevenSizingSource(DialogViewController vc) : base (vc)
{
}
public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
{
// workaround to resize selectively
// location
if (indexPath.Section == 1 && indexPath.Row == 0)
{
return 200;
}
// description
if (indexPath.Section == 2 && indexPath.Row == 0)
{
return 200;
}
return 200;
}
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
}
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
// Client selection
ClientListViewController cl = new ClientListViewController(_nc, _p);
var basicDetailsSection = new Section("Client") {
new StringElement(_p.ClientDisplayName, delegate { _nc.PushViewController(cl, true); })
//new UIViewElement ("", new GapElement (), true)
};
var locationSection = new Section("Location") {
new SimpleMultilineEntryElement ("", "This is the\n location.") { Editable = true, Height = 200, }
};
var descSection = new Section ("Job Description"){
new SimpleMultilineEntryElement ("", "This is the\n description") { Editable = true, Height = 200 }
};
Root = new RootElement ("Project Details") {
basicDetailsSection, locationSection, descSection
};
}
}
}
you must set Root.UnevenRows before view appeared. Controller example -
using System;
using MonoTouch.Dialog;
using ElementPack;
namespace Test1
{
public class Test2ViewController : DialogViewController
{
public Test2ViewController (): base(new RootElement("test"))
{
Root.UnevenRows = false;
Root.Add (new Section ()
{
new SimpleMultilineEntryElement(string.Empty, "value")
{
Height = 150, Editable = true
},
new SimpleMultilineEntryElement(string.Empty, "value2")
{
Height = 250, Editable = true
}});
}
}
}

SharePoint 2010 - enable custom ribbon button only if user has permission to edit selected item

I have a custom action in a ribbon, and I need to enable the button only if current user has permission to edit the item (Contribute role). I have a PageComponent to tell the UI if command can be handled, but I can figure out how to check user permissions for an item in javascript.
This is in my PageComponent:
canHandleCommand: function (commandId) {
switch (commandId) {
case 'Command1':
var ids = getSelectedIds(); // gets an array of selected ids
var selectionChanged = false;
if (ids.length != this.previousIds.length) {
selectionChanged = true;
} else {
for (var index in ids) {
if (ids[index] != this.previousIds[index]) {
selectionChanged = true;
}
}
}
if (selectionChanged) {
this.enabledStatusChecked = false;
}
this.previousIds = ids;
if (!this.enabledStatusChecked) {
this.checkIsEnabled(ids);
}
return this.isEnabled;
}
return false;
},
checkIsEnabled: function (ids) {
this.enabledStatusChecked = true;
this.isEnabled = false;
if (ids.length != 1) {
return;
}
var id = ids[0];
var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getById(SP.ListOperation.Selection.getSelectedList());
var item = list.getItemById(id);
context.load(item);
context.executeQueryAsync(Function.createDelegate(this, function () {
var contentTypeId = item.get_item('ContentTypeId').toString();
if (!contentTypeId.lastIndexOf(Constants.InternalNormContentTypeId, 0)) {
this.isEnabled = true;
// !! need to check permissions here !!
}
RefreshCommandUI();
}), Function.createDelegate(this, function () {
RefreshCommandUI();
}));
},
This code enables the button only if 1 item is selected and if it is of specified content type. Does anybody have any idea about how to check permission through javascript?
from my point of view. You have two ways, the first adding tag in html/master page:
http://buyevich.blogspot.com/2010/08/hide-ribbon-from-visitorsanonimus-users_31.html
or created asp control and also take it to page:
http://dicemastersharespoint.blogspot.com/2011/02/hiding-buttonscontrols-on-sharepoint.html
Write back whether possible for your solution or not.
Best Regards
Martin

Resources