How do I get value from the custom component Floating Label? - nativescript

There is a custom component called Floating Label, which I found from the list of NativeScript examples,
I tried getting the values from component by giving them id, and I tried to use var c = page.getViewById("cisc").text; and put the value inside a variable, but that did not work, if I console.log the var that contains the getViewbyId("cisc"), it would output this in console.log(c);
StackLayout#file:///app/components/float-label/FloatLabel.xml:1:1;
Floating Label

That's absolutely expected, the id will be assigned to the root element of your custom component, in your case it's a StackLayout. In order to get the text you have to do page.getViewById("cisc").getChildAt(1).text.

Related

Kendo UI ComboBox for Angular: how to prevent Expected value of type Object error?

I am trying to make a Kendo ComboBox for Angular not crash with error "Prevent Expected value of type Object":
<kendo-combobox
formControlName="gender"
[data]="genders"
[textField]="'text'"
[valueField]="'value'"
[valuePrimitive]="false"
[filterable]="true"
[allowCustom]="true"
required
>
</kendo-combobox>
StackBlitz
The error can be obtained if the value is deleted and Tab is pressed (combo blur). In fact, by leaving an invalid value in the box, this error will occur.
I will explain below why I am using some settings:
textField and valueField - in my application I request complex objects and the selected value will provide some information to other form fields
[valuePrimitive]="false" - the selected value is a complex object
[allowCustom]="false" - I used this to allow the control to receive an initial value that is not among the list. In my application I am using server-side filtering with an empty initial list
When using in the application (server-side filtering) I also receive this error when pushing the arrow button, but I can get rid of this by either ensuring that initial value is within the list of values (ugly) or simply by removing the button.
Any idea about how to make this work?
According to Kendo UI for Angular you have to use a valueNormalizer function to convert what the user actually types into a valid object.
public valueNormalizer = (text: Observable<string>) => text.pipe(map((text: string) => {
return {
value: this.genders[this.genders.length - 1].value + 1, //whatever value
text: text
};
}));
Please check the updated Stackblitz and let me know if it is helpful.
valueNormalizer didn't work for me at all.
I went for a different solution (I can't post the code here because of security limitations in my company).
We want to allow an initial value and have to allow [allowCustomer]="true" because that initial value is not initially a part of the [data] array since we fetch it from the server.
I simply pushed the initial value to the [data] array and that fixes it. no need for [allowCustome]="true"

Set option selection on mat-select to return placeholder after selection

I have the following Angular 6 code:
https://stackblitz.com/edit/angular-pl9wkw
I'm tryin g to make the select dropdown reset to the place holder once a selection has been made. I am using these two lines to try and reference the process:
#ViewChild('selectDropdown') selectDropdown: MatSelect;
and
this.selectDropdown.AppComponent.reset();
Alas, it does not work to set the dropdown back to the placeholder. I know that it can be set back to the placeholder, because I have the blank <mat-option></mat-option> selectable, and once you do select it, it sets it back to the placeholder.
Any thoughts ... anyone.
In your onChange method make the following change.
this.selectDropdown.value = [];
// this.selectDropdown.AppComponent.reset();
In your Onchange make following change
this.selectDropdown.value.reset();

how to find visibility of element / image in calabash

I am working on calabash android with the platform ruby.
And I have to find the visibility of an element / image and it has id and as well only one property ie., enabled , that too always true.
and i tried the options isVisible , isDislayed but am not sure these properties exists
First try this command
query("*")
If it shows element, then proceed with getting element using ID.
query("* css:'#id_name'")
The above line will display all the element with ID=id_name.
Note: It will show only visible element.
If you need to get all element(visible/hidden), you need use this code:
query("* all css:'#id_name'")

Calculation from Value-List in Archer GRC based on date (with non-empty validation)

I've been trying to implement what's been asked in this Stack Overflow question, here:
Calculation for status in Archer GRC based on date
Trying to create a status field based on a number of Value Lists that
users select from, but a request has been made that we check a date
field for a value to ensure an estimated date has been set so that the
calculation can determine if the status of the record is "In
Progress", "Late" or "Not Started".
...and now, I have a requirement for an actual popup warning message of some sort to prompt the user to make sure the date field is not blank.
How would I add this functionality?
In order to deliver the functionality you are looking for you have to use a "Custom Object". It is an object you put on the layout of the application in Archer that contains JavaScript code. This code will be executed as soon as the form of the application is loaded. There is a special type of the field "Custom Object" available in the Layout editor for each application in the Application Builder in Archer.
Note - I don't recommend to use custom objects in general and neither RSA Support. Every time you modify the layout in the given application, you have retest and sometimes correct IDs for your custom object. You can write an ID independent custom object and use field names, but in this case custom object will have more code. I prefer to make custom objects as short as possible.
Your custom object should do the following:
Override the behavior of the "Save" and "Apply" button in the top tool bar available for every application form in Archer.
Once "Save" and "Apply" buttons are "overwritten", every time they are clicked on your function will be called. So you need to create a click handler function.
Your click handler function will check values user is required to populate and will either return warning, or will call the original handler for "Save/Apply" buttons.
This is a code template you can start with:
<script type="text/javascript">
// ids are used to locate buttons
var buttons_ids = [
"master_btnSave", // "Save" button ID
"master_btnApply" // "Apply" button ID
];
// parameters are used in the "onclick" default handlers to call original handlers
var buttons_parameters = [
"master$btnSave", // "Save" parameter
"master$btnApply" // "Apply" parameter
];
document.getElementById(buttons_ids[0]).onclick = function(){ Validator_of_required_fields(buttons_parameters[0])};
document.getElementById(buttons_ids[1]).onclick = function(){ Validator_of_required_fields(buttons_parameters[1])};
// end of the script body
//==== Validator function attached to Save and Apply buttons
function Validator_of_required_fields(parameter){
// ids of the input fields to validate
var inputs_to_validate_ip_address = [ "master_DefaultContent_rts_XXX_YYY_t" ];
// jQuery selector is used here. Archer v5.x has jQuery library loaded by default
// you will need to modify this selector
var field_value = $('#'+inputs_to_validate_ip_address[0]+':first').val();
if(field_value.length = 0) {
// Here you are calling Archer Warning function
var msg = "[Text to display to user]";
var title = 'Required Field';
WarningAlert(msg,title);
return false;
};
// default onclick processor
ShowAnimationAndPostback(parameter);
return false;
};
Some comments on this code:
You will need to modify the validation function to work with values stored in the fields you need.
I used a rather 'unusual' way to override the behavior of the "Save" and "Apply" buttons using the following code:
document.getElementById(buttons_ids[0]).onclick = function(){ bla, bla, bla }There are simpler way to do the same, but this way custom object works fine in IE8-11, FF, Chrome and Opera. Let me know if you find a simpler way to override buttons that is browser agnostic.
Function WarningAlert(msg,title); is a build-in Archer warning message function. It worked fine in Archer v5.4. You might need to use simple JavaScript Alert function if WarningAlert doesn't work in your version of Archer.
Note that behavior of the "Save" and "Apply" buttons might be overwritten back to default in case if user opens up any pop-up dialog windows to populate a value list or cross-reference field. If that is the case, you will have to wrap the code provided into another function and attach it to the OnLoadWindow event (or similar).
I try to avoid using any JavaScript libraries in my custom objects. This way it is simpler to support them and you have less dependencies. I used jQuery in the provided example only because Archer already uses this library once the page is loaded.
Flak, make sure to test your custom object very well and good luck!

How do you get Length of Text in a Mojo TextField?

How do you get the length of the text inside a Mojo TextField?
I'm trying to set a multiLine TextField with a limit of 150 chars, I tried doing it with a counter, but ran into a issue of not being able to decrement the counter when the text was erased, or adding the right number when pasting text, so my new approach was to get the length of the text each time you press a letter.
I've already tried this: (gets called in the charsAllow attribute of the textField)
if (this.controller.get("mensaje").mojo.getValue().length <= 150) {
return true;
}
this.controller.get("mensaje").mojo.blur();
return false;
but it doesn't work.... I debugged and the function exits just after the line in bold... it doesn't even returns true or false.
I also tried assigning the length value to a variable or assigning the text to a variable and then get the length, but nothing.
It's the same issue. It returns just after the getValue().
Also, maybe because of this issue, the text scrolls instead of wrapping, but when the textField loses focus it wraps the text.
If 'mensaje' is the HTML id of your text field, try getting it and using .innerHTML().length. In other words, work with the DOM element using Javascript/Prototype functions instead of the Mojo object.
My first guess would be that "this" isn't being passed into charsAllow properly. Did you .bind(this) the function you're passing as an argument?
I found this a little odd... the function mojo.getValue() actually works... but not from inside the function called by "charsAllow"..., and also, the function called by charsAllow can't call any other function, it just breaks out of the function doing nothing... does someone have a way to limit the chars in a MultiLine TextField??? (mojo textfield, to preserve the look :D). Thanks!!
this blog explains a bit about text fields might be useful:
http://kmdarshan.com/wordpress/?p=3305

Resources