Hover rule for keywords in XText - dsl

I was wondering if XText supports hover information for keywords (rules). So far I have only seen examples for instances of those, never for the keyword as such.
To outline here is a small sample of what I have in mind.
/**
* use: login (username, password)
*/
Login: 'login' ('('username=STRING ',' password=STRING ')' )?;
In the Editor I would then expect to see "use: login (username, password)" when I hover over "login", the highlighted keyword. Ideally one could use a Javadoc style of comment, but any other solution is welcome.

Related

Material Design - one search field, two available actions

Need a tip for design. Now we have a one search field, with 2 actions - where you can search for a role or a user
If you search for a user you can copy his (role) assignments OR
If you search for a role you can add the selected role.
Generally, UI looks now like this:
Copy user's assignments
Add role
How can this UI be simplified for the user?
I think you should add a menu to the Appbar, similar to the Menus section of the Material Design standard for Layout Structure:
The images above are pulled from the standard, but could be used in your case.
Ditch the radio buttons and present the current search context with its default placeholder text in the search field. Offer a button in the Appbar that presents a modal Menu.
When the menu is presented, offer the available search contexts to the user, allowing them to switch. Upon selection, re-render the search field with new placeholder text. It should probably clear anything that was previously entered.
If for some reason the set of contexts is limited to one (permissions, security, or another reason), present that option in the placeholder text and hide the menu button.

Extend buttons to show long messages

Preface
I am currently coding Microsoft's Botbuilder SDK in Node.js.
The Problem
In the case of prompting the user to choose from a set of options that are clickable buttons, the text of the buttons get cut off with appended ellipses. Here is an example using Microsoft's Bot Framework Emulator:
Here is the code:
bot.dialog('mainMenu', [
(session, args, next) => {
// buttonOptions is an array of size 4 all with the
// string 'VERY LONG TEXT THAT GETS CUT OFF'
builder.Prompts.choice(session, 'What would you like to do?'
, buttonOptions, { listStyle: builder.ListStyle.button });
}
]);
The Desired Result
I would like to show the entire text of the buttons. I am aware that the listStyle: list exists that shows the entire text, but I am looking for a solution that allows button-use.
The Question
Is there a way to expand the buttons to show the entire length of long text in these types of prompts? Alternative perspectives not confined to this listStyle are welcome.
The way the choices are displayed is implemented by each channel, so you may concentrate on your target channel.
Some channels implementations (typically emulator and webchat) are open-source and you can create your own fork to build the behavior you need.
Emulator
Bot Framework's emulator sources are located on GitHub.
Webchat
I already replied to a similar question about customizing the webchat to display all the text of the buttons. To avoid duplicates, please have a look directly here: Using botbuilder SDK's Prompt.choice(), is it possible to have a custom tooltip which displays long choice-text?
It allow rendering buttons multiline like that:
You can add to the text "\n". So the button look it similar like this
Example
For a better result, I determined a maximum value and divided the string length. With this number I made a split. After I searched the last white space to put "\n".

Watir fails to interact with elements and reports that they are disabled

Whilst automating a collection of integration tests for various OAUTH providers, I found that watir does not seem to work with the Fitbit auth page, and always reports that the text_fields are disabled, no matter what I do.
This may be a bug in watir, or it may be something peculiar to the the Fitbit page (broken HTML or deliberate anti-scripting code).
The fitbit page is located at https://www.fitbit.com/oauth2/authorize/
watir can detect the email text_field exists:
browser.wait_until{ browser.text_field( name: 'email' ).exists? }
but any attempt to interact with it reports an error that it is disabled:
browser.text_field( name: 'email' ).wait_until_present
I've tried tabbing through all the fields on the page to see if this enables it, and I've tried using browser.driver.action.move_to to click on the element, but nothing seems to work.
Any thoughts?
The problem is that there are 3 text fields with the name "email". If you get a collection of the text fields, you can see that only some of them are visible:
browser.text_fields(name: 'email').map(&:visible?)
#=> [false, true, false]
Watir interacts with the first match, which in this case is one of the hidden fields. You actually want the second field - ie the visible one.
You can use the :visible flag to tell Watir to find the first visible one:
browser.text_field(name: 'email', visible: true).set('value')

Form does not postback when submit is clicked, jade, node.js

I have a form created with jade, it does not postback when submit button is clicked.
I have looked at many similar problems, I tried the solutions, which include ensuring that the input fields all have a 'name', I have made sure all the input field have a name but the form still does not post back, here it is
//views/users/new.jade
h1 New User
form(action="/users", method="POST")
p
label(for="username") Username
input#username(name="username")
p
label(for="name") Name
input#name(name="name")
p
label(for="bio") Bio
textarea#bio(name="bio")
p
input(type="submit",value="Create")
The post handler is this
//routes/users
module.exports=function(app){
app.post('/users',function(req,res){
if(users[req.body.username]){ //Check if user exists
res.send('Confllict, 409')
}else
{
//add to users list
users[req.body.username]=req.body;
res.redirect('/users');
}
});
};
Jade uses indention to show what content goes between the tags
p
this is inside the p tags
also there is shorthand
p this is also in the tag
in your original code you are telling Jade that there is a p tag then the next line is outside the p tags.
This is an easy problem to run into if you aren't careful with indentation using Pug (previously Jade). I realize this is an old question, and it has several hits so perhaps this answer will shed some light for new Pug users.
The problem with the OP's code is the Form does not know how to post without a button, and the Submit button doesn't know where to post to without being associated with the Form. Why? Indentation.
Jade and Pug tips for success:
They produce html, so it helps to think in html layouts when developing the template (would you put text outside of your p element? Of course not).
Pug uses indentation to form layout and element hierarchy.
Html Forms must enclose the elements that are to be associated or bound to it.
A Submit Button does nothing unless you define an event handler.
Forms define a destination in their definition, which a button type element can leverage.
In the code listed by the OP, every Pug element is left-aligned. This puts all elements at the same level, so there is no hierarchy or nesting. Since there is no other event handler explicitly defined for the Submit button, nothing happens when it is clicked, despite the form having an action and a valid method.
To fix this, the Input (submit button) can be nested inside the Form.
Reworking the code to include indented hierarchy will enable the POST to function as expected (removed all the other elements for readability):
h1 New User
form(action="/users", method="POST")
label(for="username") Username
input#username(name="username")
label(for="name") Name
input#name(name="name")
label(for="bio") Bio
textarea#bio(name="bio")
input(type="submit",value="Create")
The resulting form won't be a pretty, but it will function:
The Form has an action and method.
All dependent elements are indented.
The input has a type of Submit and is child to the form.
Of course, a server must have a binding at the address to receive the data in order to do anything with it.

Drupal: re-selecting taxonomy terms in advanced search

I'm sure I'm not the first one to try to address this, but Google isn't doing me any good.
If you use the Advanced Search in Drupal to filter on taxonomy terms, the search form comes back with the term IDs in the keyword textbox like so:
search phrase category:32,33
The chosen values are NOT selected again in the taxonomy select box.
Instead of showing them in the keyword textbox, I would like them to be selected in the taxonomy select box - the way that any user would expect a form like this to act. I have been looking for a module that will add this functionality, to no avail. I have tried implementing hook_form_alter() to set the #default_value on that form element based on the previous form submission (available in the $form_state arg), but a) this seems kludgy and b) it seems that this function is called once to validate the form and again to re-display it, and the submitted value isn't available the second time (which is when it's needed).
Any suggestions?
It took much longer than it should have, but I finally figured out how to do this. I may release a module on the Drupal site later on, but in case anyone else has this same problem, this was the solution I came to.
Create a module and use hook_form_alter() to modify the form. I already had a module I was using to customize the advanced search, so I put it in there. I won't get into the detail of building your own module - you can find a simple tutorial for that, and you only need to define this one function.
/**
* Implementation of hook_form_alter().
* Remove 'category:x,y,z' from the keyword textbox and select them in the taxonomy terms list
*/
function modulename_form_alter(&$form, $form_state, $form_id) {
// Advanced node search form
if ($form_id == 'search_form' && $form['module']['#value'] == 'node' && user_access('use advanced search')) {
// Remove category:x,y,z from the keyword box
$searchPhrase = $form['basic']['inline']['keys']['#default_value'];
if(!empty($searchPhrase) && strpos($searchPhrase, 'category:') !== false) {
$searchWords = explode(' ', $form['basic']['inline']['keys']['#default_value']);
foreach($searchWords as $index=>$word) {
if(strpos($word, 'category:') === 0) {
// Use the value to set the default on the taxonomy search
$word = substr($word, strlen('category:'));
$form['advanced']['category']['#default_value'] = explode(',', $word);
// Remove it from the keyword textbox
unset($searchWords[$index]);
}
}
// Re-set the default value for the text box without the category: part
$form['basic']['inline']['keys']['#default_value'] = implode(' ', $searchWords);
}
}
}
Thanks for sharing this. After several drupal installations I am facing this problem now, too. However, this time I had to use some search extensions like search_config and search_files to meet the clients requirements. Furthermore, I'm using better_select which turns select lists into lists of checkboxes (easier to select mulitple values on long lists). Thus, the checkboxes always returned some value (either the id if selected or 0 (zero) if not selected) and I ended up with something like "search phrase category:0,0,0,0,...,0".
Your solution above indeed removes the "category:0,0,0,0,0,0,...,0" string from keyword search field and checks all taxonomy terms correctly. The same can be done for content types, you'll just have to replace "category:" by "type:" throughout the whole script.
Paul

Resources