How to add data- attributes to a field in alpacajs? - alpacajs

I am using alpacaJs 1.5.23.
I need to add data-(like data-target) attributes to my fields. Is there a way?

Yes you can do this by using data property in options object of your alpaca configuration like this:
"data": {
"target": "test value"
}
here's a working fiddle for this.

Related

Prettier formatting a Vue component when I don't want it to

I've got Prettier configured to format on save.
I'm using a Vue component I got from npm to display data from an API.
<ExampleComponent
:aDynamicProp="foo"
dataset="bar"
/>
The prop dataset is required by the component.
The issue is Prettier wants to change dataset to data-set every time I save. I imagine because it thinks i'm trying to create a HTML data attribute.
As per Prettier docs i've tried adding <!-- prettier-ignore-attribute --> above the component but this doesn't seem to work (perhaps because I'm triggering formatting on save, or because it's a Vue template and not HTML?).
Can anyone shed light as to how I can force Prettier to ignore the prop?
Many thanks!
Add colon : to :dataset and that should do the trick, if it's just static string that's doing inside dataset then do :dataset="`my string`" with backtick (`). If you are getting data from data(){}, computed or from methods as mentioned below then just do :dataset="yourData":
export default {
data() {
return {
yourData: 'Your String'
}
},
// or
computed: {
yourData() {
return 'Your String'
},
},
// or
methods: {
yourData() {
return 'Your String'
},
},
};

How do I use a variable for an options (DropDown) parameter?

I have an Azure-DevOps build with a task that uses an options (DropDown) parameter. I would like to dynamically set the parameter using a variable such as $(DatabaseEnvironment). How can I use this variable when the UI does not allow text to be entered?
You need to make the field editable. Add this to your definition for the field:
"properties": {
"EditableOptions": "True"
}

WFFM form tag has role attribute which is redundant

The tag produced by WFFM contains the attribute role="form".
This is considered a redundant attribute and is causing issues for our site accessibility scan.
Here are the specifics from the accessibility scan...
A WAI-ARIA attribute that has the exact same features as the HTML element it has been applied to has been used. The WAI-ARIA attribute is redundant since is doesn't provide the user with any additional information.
Looking at the MVC form rendering that is installed with WFF, I see it points to the following class and method - Sitecore.Forms.Mvc.Controllers.FormController, Sitecore.Forms.Mvc.
Decompiling that class I can see their is a Sitecore.Forms.Mvc.Constants class which contains several attributes of the rendered form element, but not the role="form" attribute.
Would anyone know where Sitecore might be adding the attribute role to the form element?
Check the Views\Form\EditorTemplates\FormViewModel.cshtml file.
You will see there:
var attributes = new RouteValueDictionary()
{
{ "enctype", "multipart/form-data" },
{ "class", #Model.CssClass },
{ "id", Model.ClientId },
{ "role", "form" },
{ Constants.Wffm, Model.Item.ID }
};
and a bit lower those attributes (containing form role) are used in BeginRouteForm method:
using (Html.BeginRouteForm(routeName, queryString, FormMethod.Post, attributes))

Loopback Filter Based On Related Model Properties

I want to be able to filter based on the properties of related models. For example, I have a Class object with a Building object. I want to get a list of classes that take place in a certain building.
This filter
{
"include":"building",
"scope":{
"where":{
"name":"warehouse"
}
}
}
returns all classes, but only includes building if its name is "warehouse". What I want is for the where clause on building name to apply to the whole filter so that I only get the class if it's building has that name.
Is there any way to do what I want?
Thanks!
You can do this in code, see include with filters in the docs.
I'm not sure about the JSON but I think it should look more like this:
"include": {
"relation": "building",
"scope": {
"where": {"name": "warehouse"}
}
}
At the moment this is not possible. The issue has been described in this topic; https://github.com/strongloop/loopback/issues/517
It looks like Strongloop is not going to implement this feature in the near future.
Whenever you want to use it on API CALL , you can follow a model like this one
and adapt it to your context.
//Here (as filter) , we get just the most recent message of a chat
{
"include" : {
"relation" : "messages" ,
"scope" :
{
"order" : "createdAt DESC" ,
"limit":1,
"skip":0
}
}
}
At the moment this is not possible in loopback, but you can use this component for resolve this ploblem. It is an easy to use and works perfectly.
https://www.npmjs.com/package/loopback-component-relation-filter
after you configure the component in the component-config.json file as the component documentation says. You can resolve your problem with.
assuming that the main model is called classes and that it has the relationship called building.
var filter = {
where: {
building:{ name:"warehouse" }
}
}
app.models.classes.find(filter, console.log);
That code only returns the classes when building name is warehouse.

django-autocomplete-light add parameter to query url

I'm trying to pass some data along to the autocomplete_light.AutocompleteModelBase so I can exclude some models from the search. I'm trying to use the Dependencies info in the docs here
but I can seem to get it.
The id of the input is id_alternate_version-autocomplete, so I'm trying:
$("#id_alternate_version-autocomplete").yourlabsWidget().autocomplete.data = {'id': 'foo'};
But the url called looks like http://127.0.0.1:8000/autocomplete/FooAutocomplete/?q=bar
I want: http://127.0.0.1:8000/autocomplete/FooAutocomplete/?q=bar&id=foo
How can I do something like that?
DAL provides a way to do this with "forwarding" of another rendered form field's value.
See http://django-autocomplete-light.readthedocs.io/en/master/tutorial.html#filtering-results-based-on-the-value-of-other-fields-in-the-form
This is how I did it:
$(document).ready(function() {
$('form#recipe').on('change propertychange keyup input paste', function() {
var ingredient_item_type = $("form#recipe input[type='radio']:checked").val();
var widget = $("form#recipe input#id_ingredients_text").parents('.autocomplete-light-widget');
if(ingredient_item_type) {
widget.yourlabsWidget().autocomplete.data['hello'] = 'world';
}
});
});
Javascript acrobatics aside, the key observation is thus:
anything you put in the .data object of the autocomplete widget will
automatically be made part of the GET request. HTH.