anyojs: how to embed controls in list items? - enyo

I'm completely new to enyo and trying to learn. So, i've decided to create a simple configuration app for my server-side project.
I am trying to crate something like this:
group1 [on]/ off | option1 <select_box_selected_opt1>
group2 on /[off] | option2 <select_box_selected_opt2>
group3 [on]/ off > option3 <select_box_selected_opt3>
| option4 <select_box_selected_opt4>
| option5 <select_box_selected_opt5>
| option6 <select_box_selected_opt6>
So these are two lists with items like
{name:"option_name"}, {name:"switch", kind:"onyx.ToggleButton"}
or a picker in right one.
Problem is togglers, checkboxes and pickers are not working. They behave strange: togglers do not change their visual state after first click and pickers do not display options and their buttons freze in "pressed" state. The oncnahge events happen, but in strange order.
No errors or warnings in console.
Maybe, i'm doing it wrong?

Check out the documentation here: https://github.com/enyojs/enyo/wiki/Lists
List uses a flyweight pattern so the controls aren't 'live' without a little help. You probably want a Repeater instead.

Related

How to pass a JSON value to a function?

I would like to create a simple label in the app that would show whether the gate is open or not. That is, for this I can use a boolean type that returns true/false, but I would like it to display yes/no on the page instead of true/false and add a translation in Dutch, that is, depending on how the user initially sets the language of the app, the yes/no message will be displayed in that language. In the app, I already have the other . translatedor false.
That is, half th success is. The function works. However, instead of this true/false, I would like to put yes/no in 2 language versions.
I was thinking of adding something like translations in the JSON file, for example: "true": "yes" and "false": "no" and the same in the Dutch version, because currently the value of true/false is returned automatically, however, I don't know how I could pass something like that to the code line shown above. Does anyone have an idea how I could implement this?
I recommend you to use build-in angular translator or install ngx-translate. If you use 2nd option your code will look like this:
<dd class="col-sm-6">{{gate.open ? ('gate_open' | translate) : ( 'gate_closed' | translate) }} </dd>
Ofc you have to add translation to json or ts files

LabVIEW: view every time a button is pressed

I’m trying to make a simple project to practice with LabVIEW:
I’m creating a VI with a standard Button and a stop button.
When the VI is running, I’ clicking the button many times and then, when I click on STOP, I would visualize on Front Panel a “List” (I’m using an array for this) which contain a timestamp for every button pression.
Is it possible? How can I do this?
I’m trying to create an array with the “insert into array” element, but it doesn’t seem to work..
Thank you all guys!
This does what you request. Two frames of the event structure and an autoindexing array collecting only the timestamps from the OK button press frames.

setting default option tag Selected rails

I am generating a list of objects in a option tag using ruby rails .eg
%optgroup
-for #people in c do
%option(value: cac,)
how do i specify a default for the option tag? like a place holder which says please select person, and also how do set it from a cookie or previous selected country.
thanks
Something like this should work(not sure what objects you are working with so the attribute names may need to be changed):
%optgroup
-for #people in c do
-if c.id == default.id
%option{value: c.value, selected: true}
-else
%option{value: c.value}
But the helper that #Iceman linked you allows you to do this in a much simpler way. (http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/grouped_options_for_select)

2 Mutually exclusive RadioButton "Lists"

I think this has to be THE most frustrating thing I've ever done in web forms. Yet one would think it would be the easiest of all things in the world to do. That is this:
I need 2 separate lists of radiobuttons on my .aspx page. One set allows a customer to select an option. The other set does also but for a different purpose. But only one set can have a selected radiobutton.
Ok I've tried this using 2 asp.net Radiobuttonlists controls on the same page. Got around the nasty bug with GroupName (asp.net assigns the control's uniqueID which prevents the groupname from ever working because now, 2 radiobuttonlists can't have the same groupname for all their radiobuttons because each radiobuttonlist has a different uniqueID thus the bug assigns the unique ID as the name attribute when the buttons are rendered. since the name sets are different, they are not mutually exclusive). Anyway, so I created that custom RadioButtonListcontrol and fixed that groupname problem.
But when ended up happening is when I went to put 2 instances of my new custom radiobuttonlist control on my .aspx page, all was swell until I noticed that every time I checked for radiobuttonlist1.SelectedValue or radiobuttonlist2.SelectedValue (did not matter which I was checking) the value always spit back string.empty and i was not able to figure out why (see http://forums.asp.net/t/1401117.aspx).
Ok onto the third try tonight and into the break of dawn (no sleep). I tried to instead just scrap trying to use 2 custom radiobuttonlists altogether because of that string.empty issue and try to spit out 2 sets of radiobuttonlists via using 2 asp.net repeaters and a standard input HTML tag inside. Got that working. Ok but the 2 lists still are not mutually exclusive. I can select a value in the first set of radiobuttons from repeater1 and same goes for repeater2. I cannot for the life of me get the "sets" to be mutually exclusive sets of radiobuttons.
As you have two groups of radio buttons that you want to function as one group of radio buttons, the solution is simple: Make it one group of radio buttons.
The only problem you have then is that the value that you get has the same name from both lists, but that can be solved by adding a prefix to the values so that you easily identify from which list the option comes.
Update: based on the new info posted as an answer. The option I proposed on my original answer corresponds to the 3. You really must consider the following:
Html radio buttons have only 1
built-in mechanism to handle the
exclusivity, which is the name.
You are explicitly requesting a no js solution, so given the above you must manipulate the Ids to achieve it. If you weren't blocking this option I am sure someone would come up with some nice jquery or js library that already supports it.
The option 3 is clearly the less invasive, as you are not forced to affect the actual data, and are not affected by future updates to it.
It's not that much code, just something extra on the List indexes, and some simple thing as:
int? list1Value = null;
int? list2Value = null;
var value = Request.Form["somegroup"];
if (value.StartsWith("List1"))
list1Value = int.Parse(value.Substring(5));
else
list2Value = int.Parse(value.Substring(5));//Assuming List2 as prefix
Original:
I saw your other question, and you just need to use the same group name. Make sure you have different values for all items regardless of the list they come from. A way to achieve this is adding something to the values, like: <%# "List1-" + Eval("ID") %> and modifying the code that reads your Request.Form["yourgroupname"].
I think you should just use RadioButtons instead of RadioButtonLists.
Here's an article that presents a solution to resolve the radiobutton naming bug.
Though this post is dated 1 year ago already, I just read it because I face the same problem.
Currently I have 1 solution using jQuery:
Client side script (you must also include jQuery)
function SetRadio(rb) {
$('input:checked').attr('checked', false);
rb.checked = true;
}
For every radiobutton (which is a listitem in a radiobuttonlist) I add the following on the serverside:
li.Attributes.Add("onclick", "javascript:SetRadio(this)");
For me this works in both IE and Firefox, with 3 radiobuttonlists, without using groupnames.
You can check each radiobuttonlist for a selecteditem/value, or you can extend the SetRadio function so it stores the selected value in a hidden field.
Regards,
M

Cucumber/Webrat: follow link by CSS class?

is it possible to follow a link by it's class name instead of the id, text or title? Given I have (haha, cucumber insider he?) the following html code:
<div id="some_information_container">
Translation here
</div>
I do not want to match by text because I'd have to care about the translation values in my tests
I want to have my buttons look all the same style, so I will use the CSS class.
I don't want to assign a id to every single link, because some of them are perfectly identified through the container and the link class
Is there anything I missed in Cucumber/Webrat? Or do you have some advices to solve this in a better way?
Thanks for your help and best regards,
Joe
edit: I found an interesting discussion going on about this topic right here - seems to remain an open issue for now. Do you have any other solutions for this?
Here's how I did it with cucumber, hope it helps. The # in the step definition helps the CSS understand whats going on.
This only works with ID's not class names
Step Definition
Then /^(?:|I )should see ([^\"]*) within a div with id "([^\"]*)"$/ do |text, selector|
# checks for text within a specified div id
within "##{selector}" do |content|
if defined?(Spec::Rails::Matchers)
content.should contain(text)
else
hc = Webrat::Matchers::HasContent.new(text)
assert hc.matches?(content), hc.failure_message
end
end
end
Feature
Scenario Outline: Create Project
When I fill in name with <title>
And I select <data_type> from data_type
And I press "Create"
Then I should see <title> within a div with id "specifications"
Scenarios: Search Terms and Results
| data_type | title |
| Books | A Book Title |
Here is how to assert text within an element with the class name of "edit_botton"
Then I should see "Translation here" within "[#class='edit_button']"
How about find('a.some-class').click?
I'm not very familiar with the WebRat API, but what about using a DOM lookup to get the reference ID of the class that you are looking for then passing that to the click_link function?
Here's a link to some javascript to retrieve an item by class.
http://mykenta.blogspot.com/2007/10/getelementbyclass-revisited.html
Now that I think about it, what about using Javascript to just simply change it to some random ID then clicking that?
Either way, that should work until the frugal debate of a name to include the getbyclass function as is resolved.
Does have_tag work for you?
have_tag('a.edit_button')

Resources