NativeScript Angular routing error after changing context of application - nativescript

I apologize at the start for the lengthy explanation that follows. I believe it is necessary to fully explain what is going on.
I setup my NS app to used tabbed navigation with a login screen by following the writeup here.
The overall structure of the app is identical to the structure of the app in the git repo here.
Instead of the players and teams in the git repo I have 3 tabs: Dashboard, Advisor, and Tasks. The tasks component uses a tasks service to get the tasks for the user via an API call and then displays a list of tasks. The user can tap on the task to view the task details. I use a class called Global that is imported by all of the components to store context info such as the username and the API token that was acquired after authenticating.
I replaced the welcome component with a profile component, the idea being that a profile button is displayed in the ActionBar, and from anywhere in the tab view the user can tap the profile button to view the profile page. I achieved this by including the following code in each of the tab components:
toProfile() {
this.re.navigateByUrl("/profile");
}
I am sure that is not the most efficient way to do it but it was what I came up with and it works. The profile page shows a bit of info and allows the user to log out. If the user is designated as an admin it provides a form to allow the admin user to impersonate any other user and see the app exactly as that user would.
The following code displays the impersonate form:
<GridLayout *ngIf="isAdmin" columns="auto, auto" rows="auto, auto">
<TextField hint="username" [(ngModel)]="impersonateUser" row="1" col="0"></TextField>
<button text="Impersonate" (tap)="impersonate()" row="1" col="1"></button>
</GridLayout>
The profile component imports the user service, task service, and the Global class. When an admin user enters a username (for example we will use "user2") and taps "impersonate" the following function in the profile component is called:
impersonate() {
Global.username = this.impersonateUser;
Global.isAdmin = "0";
this.taskService.reset();
this.userService.getUserInfo(Global.username)
.subscribe(
(resp) => {
this.userService.saveSession(Global.username, Global.token, Global.expires);
this.re.navigateByUrl("/tabs/default", {clearHistory: true});
},
(exception) => {
alert("Something went wrong.");
}
);
}
The task service reset function just clears any data the task service had in memory. I am navigating to /tabs/default at the end to trigger the onInit functions of the components so that new tasks will get pulled for the user being impersonated. The tasks page loads and displays the correct tasks that correspond to user2 via the following code:
<ng-template ngFor let-task [ngForOf]="tasks">
<GridLayout class="data-container" columns="*, auto" rows="auto, auto" [nsRouterLink]="['../task', task.ID]">
<Label [text]="task.TITLE" class="task-title" row="0" col="0"></Label>
<FlexboxLayout class="task-date" row="1" col="0">
<Label [text]="task.START_DATE | slice:0:10 | date:'MMM d, yyyy'"></Label>
<Label text=" - "></Label>
<Label [text]="task.END_DATE | slice:0:10 | date:'MMM d, yyyy'"></Label>
</FlexboxLayout>
<Label text="" class="fas task-status" [ngClass]="{'completed' : task.COMPLETED}" rowSpan="2" col="1"></Label>
</GridLayout>
</ng-template>
Everythign works up to this point. When the admin user taps on one of the tasks to view the task details I get the following error:
Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'this.currentOutlet.peekState')
When I inspect the elements with Chrome dev tools I can see that the GridLayout element has the proper ID that matches the task it should link to
<GridLayout ng-reflect-params="../task,5e46c219add54" iosOverflowSafeArea="true" classNAme="data-container">
Any help or insight would be greatly appreciated. I am relatively new to both Angular and NativeScript.
EDIT:
Here is a link to a NS playground where you can see the issue in action. I have removed just about everything that is not needed to replicate the issues.
To replicate:
Sign in with the username "u1".
Go to the tasks tab and tap one of the tasks. You will be taken to the task details.
Tap the Profile button on the Activity bar.
On the profile page enter u2 in the username field under Admin and tap the impersonate button. You will be returned to the dashboard as user2.
Go to the tasks tab and tap one of the tasks.
Tapping on the task should take you to the task details but instead, it produces the error described above.
NOTE: Tapping on any of the tasks on the dashboard at any time will not work. That is another issue I am trying to figure out. If you can help me figure out what I am doing wrong there as well it would be much appreciated.

Related

Cypress does not show the final page after running cy.origin

The test's domain is "exams.com/courses/XXXX"(xxxx is the course's #). After clicking the "buy course" button, the domain will be "payment.com".We filled in the payment information, and click the "pay" button, the webpage should be "exams.com/purchased_courses/XXXX".
Now I used cy.origin:
it("buy courses",()=>{
.........//click the "buy course" button
cy.origin("payment.com",()=>{
.........//fill in the payment information
cy.get('.submitButton-IconContainer').click()
//click the "pay" button
})
}
)
Issue is: when running the testing, the webpage "exams.com/purchased_courses/XXXX" slashed a second, and finally, the webpage stays in "exams.com/courses/XXXX".
Question:How can I let the testing shows "exams.com/purchased_courses/XXXX"? Thank you!
env: cypress 10.X.X
typescripe
node.js 18.8.0

How to hide TimePicker and DatePicker on lifecycle events in Xamarin Forms

I'm running into an issue on android where our TimePicker and DatePicker stay visible when we navigate OnPause(). We need to redirect our users back to the login screen when they background the application, but if the TimePicker or DatePicker is active when they do this it stays on the screen. It appears above the login screen and pressing cancel or ok crashes the app.
We are hooking into the native android lifecycle events (not just using Xamarins built in hooks) and we redirect OnResume(). I've tested this in a barebones app though and it still happens OnPause().
Here is our TimePicker causing us the issue:
<TimePicker x:Name="VitalTimePicker" HorizontalOptions="Fill" VerticalOptions="Fill" IsVisible="false" PropertyChanged="OnTimePickerPropertyChanged"/>
And here is an example of changing screens on a lifecycle event:
protected override void OnSleep()
{
App.Current.MainPage = new NavigationPage(new NotesPage());
}
Any ideas? I was thinking of clearing the Pickers but I can't seem to find how to do that
Edit
Just to add a little more context
The Application class (app.xaml.cs) has lifecycle hooks that we use to catch when our users background the app. In here we call MainPage = new NavigationPage(new LoginPage()); which takes the app back to the login page.
I've added
protected override void OnDisappearing()
{
VitalTimePicker.Unfocus();
VitalDatePicker.Unfocus();
}
to the view i'm working from and it seems to be called when we background the application, but for some reason the TimePicker is staying on the screen when our login page pops up again.
You can programmatically close DatePickers and TimePickers using the method Unfocus(). I'd recommend closing them before you call the next page, as I don't know if they will be able to be referenced and closed after the other screen has been initialized.
Create a method that calls VitalTimePicker.Unfocus() and the same for any other picker you have, and call this method before changing to login screen and you should be good to go.

Automation using Watir button elements

So I have been experimenting with Watir automation scripts using Ruby. I have tried to experiment with different websites, like Twitter, Gmail, and Yahoo. Here is the catch: I am able to open a browser, login, and get to the home page. On all of these whether it is compose a new email or tweet every time I select it with the appropriate ID or Class, it throws an error in the terminal like this...
.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:533:in assert_element_found': unable to locate element, using {:title=>"compose", :tag_name=>"button"} (Watir::Exception::UnknownObjectException)
from /Users/xxx/.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:505:inassert_exists'
from /Users/xxx/.rvm/gems/ruby-2.2.1/gems/watir-webdriver-0.8.0/lib/watir-webdriver/elements/element.rb:114:in click'
from yahoo_mail.rb:18:incompose_email'
from yahoo_mail.rb:27:in `'
My question is, are there elements that you simply cannot click or select using Watir automation?
EDIT: How would I be able to hit this to be more specific? I seem to be getting the same results on Yahoo, Gmail, and Twitter when it comes to composing anything after getting logged in. So I how would I hit this button?
button id="global-new-tweet-button" type="button" class="js-global-new-tweet js-tooltip btn primary-btn tweet-btn js-dynamic-tooltip" data-placement="bottom" data-component-term="new_tweet_button">
The HTML for the Compose button is basically the following (NOTE: id attribute removed):
<button tabindex="0" data-action="compose" title="Compose" class="btn btn-compose">
Your stacktrace indicates that you're using this locator:
{:title=>"compose", :tag_name=>"button"}
If you change :title=>"compose" to :title=>"Compose", you should be in business.
Have you tried the following code?
button(id:'global-new-tweet-button').when_present.click
Maybe you were clicking the button without checking if it is already present on the page.

Start workflow popup menu is empty in OpenKM web interface

I've created a simple workflow in jBoss studio and deployed it on OpenKM, every things is OK and my workflow will be shown in administration panel but in desktop panel there is no files in /okm:root/ and when I want to start my workflow the workflow lists in 'workflow start' dialog is empty, Did not have any entry.
Can any one please help me with how can I start my workflow?
As a note, I uses Firefox 30 and Java plug-in is disable on it
You must enable available workflow list from profiles ( administration -> profiles -> first tab). Also to start any workflow you need to doing it selecting a document.
In addition if your problem is that you're not showing th form just when you start workflow then take in consideration, there's an special task name in forms.xml if you want to be shown the form at the moment you're registering. You can see example in this form with task called task="run_config":
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.1//EN"
"http://www.openkm.com/dtd/workflow-forms-2.1.dtd">
<workflow-forms>
<workflow-form task="run_config">
<input label="number" name="number" />
<button name="submit" label="Submit" />
</workflow-form>
<workflow-form task="task">
<input label="number" name="number" data="modified" />
<button name="submit" label="Submit" />
</workflow-form>
</workflow-forms>
Here you can find some examples http://wiki.openkm.com/index.php/File:Course_workflows.zip, also I suggest take a look on it. Hope this could be useful for you

how to make a Location Service Permission MessageBox

I have submited a App but is not certified because this:
"This application uses the Location Service API to determine a user's location and show them events taking place nearby
however, it does not appear to contain a privacy policy that is accessible to users explaining how the application uses the
Location Service API."
And what i want to do is something like this
When user clicks in Policty Statement open a new window with settings page with my app location policies.
Can anyone help me? How can i add a link like in image?
Cumps
You can navigate to a page using the Hyperlink control
<Textblock>
<Hyperlink NavigateUri="/PrivacyPage.xaml"
TargetName="_blank">Privacy Statement</Hyperlink>
</Textblock>
See MSDN for more info
I don't think you can put a hyperlink in a call to MessageBox.Show() though so you have to create your own Messagebox-like page.
The first time the app is launched you direct the user to your message page. E.g. using this in MainPage.xaml
OnNavigatedTo(...)
{
if(!AppSettings.HasMessageBeenShown)
{
AppSettings.HasMessageBeenShown=true;
NavigationContext.Navigate(new Uri("/MessagePage.xaml", UriKind.Relative));
}
}

Resources