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

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"
}

Related

Is it possible to add a a variable within a placeholder transform in Visual Studio Code?

I am looking to write an visual studio code user snippet like this:
"Surround With Div": {
"prefix": "sdiv",
"body": ["${1/(.*)/<div class=\"${1}\">${TM_SELECTED_TEXT}<\\/div>/}"],
"description": "Surround With Div"
}
But it does not seem to be working. Is there any way I can make something like this work? Using the variable inside the result of the regex transform?
To clarify for people:
What I was trying to achieve is this:
Select a portion of html document
Type sdiv over it to get the snippet
write something like -> header for the class name...
then when I would hit TAB I would get a div with the class header and the content I first selected inside it
But I realized you can't do something like that...could have done it with $CLIPBOARD but had to copy it first
So I decided to do something a bit different using a keybinding instead.
It is actually more straightforward than it seems. You do not need a transform at all - you can't put a variable like $TM_SELECTED_TEXT or $CLIPBOARD inside a transform anyway.
"Surround With Div": {
"prefix": "sdiv",
"body": [
"<div class=\"${1}\">${TM_SELECTED_TEXT}</div>"],
"description": "Surround With Div"
}

Apollo Link State Default Resolver Not Working (#client query parameter variables)

Example here: https://codesandbox.io/s/j4mo8qpmrw
Docs here: https://www.apollographql.com/docs/link/links/state.html#default
TLDR: This is a todo list, the #client query parameters don't filter out the list.
This is the query, taking in $id as a parameter
const GET_TODOS = gql`
query todos($id: Int!) {
todos(id: $id) #client {
id
text
}
}
`;
The query passes the variable in there
<Query query={GET_TODOS} variables={{ id: 1 }}>
/* Code */
</Query>
But the default resolver doesn't use the parameter, you can see it in the codesandbox.io example above.
The docs say it should work, but I can't seem to figure what I'm missing. Thanks in advance!
For simple use cases, you can often rely on the default resolver to fetch the data you need. However, to implement something like filtering the data in the cache or manipulating it (like you do with mutations), you'll need to write your own resolver. To accomplish what you're trying to do, you could do something like this:
export const resolvers = {
Query: {
todos: (obj, args, ctx) => {
const query = gql`
query GetTodos {
todos #client {
id
text
}
}
`
const { todos } = ctx.cache.readQuery({ query })
return todos.filter(todo => todo.id === args.id)
},
},
Mutation: {},
}
EDIT: Every Type we define has a set of fields. When we return a particular Type (or List of Types), each field on that type will utilize the default resolver to try to resolve its own value (assuming that field was requested). The way the default resolver works is simple -- it looks at the parent (or "root") object's value and if it finds a property matching the field name, it returns the value of that property. If the property isn't found (or can't be coerced into whatever Scalar or Type the field is expecting) it returns null.
That means we can, for example, return an object representing a single Todo and we don't have to define a resolver for its id or text fields, as long as the object has id and text properties on it. Looking at it another way, if we wanted to create an arbitrary field on Todo called textWithFoo, we could leave the cache defaults as is, and create a resolver like
(obj, args, ctx) => obj.text + ' and FOO!'
In this case, a default resolver would do us no good because the objects stored in the cache don't have a textWithFoo property, so we write our own resolver.
What's important to keep in mind is that a query like todos is just a field too (in this case, it's a field on the Query Type). It behaves pretty much the same way any other field does (including the default resolver behavior). With apollo-link-state, though, the data structure you define under defaults becomes the parent or "root" value for your queries.
In your sample code, your defaults include a single property (todos). Because that's a property on the root object, we can fetch it with a query called todos and still get back the data even without a resolver. The default resolver for the todos field will look in the root object (in this case your cache), see a property called todos and return that.
On the flip side, a query like todo (singular) doesn't have a matching property in the root (cache). You need to write a resolver for it to have it return data. Similarly, if you want to manipulate the data before returning it in the query (with or without arguments), you need to include a resolver.

How to add data- attributes to a field in 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.

Change feature name in gate document with JAPE or Groovy

I have a GATE document like that:
I need to change the name of a feature in the annotation. Here i need to change typeby category
Is it possible to do that with a JAPE rule or Groovy script ?
Yes, either. A JAPE rule is probably the simplest:
Phase: RenameFeature
Input: Mention
Options: control = all
Rule: Rename
({Mention}):mention
-->
:mention {
for(Annotation a : mentionAnnots) {
a.getFeatures().put("category", a.getFeatures().remove("type"));
// note Map.remove returns the value we just removed
}
}
Inside a RHS Java block labelled with :label the variable labelAnnots is an AnnotationSet containing the annotations that were matched by the label on the LHS. In this case there's only one of them but the for loop is still the most convenient way to access the individual Annotation from the set.

Add template items in TinyMCE

I'd like to add "template items" in tineMCE editor.
The template items act like a placeholder for dynamically inserted data.
An example:
Instead of writing: "Hi {firstname}, you are {years} years old."
I'd like to insert a object instead of the "{firstname}" that gets replaced to "{firstname}" when saving against the server. It should also translate back when loading it into the editor.
The object should be selected from a dropdown (but that should be easy once the other things are fixed).
In this case you eighter need to replace the placeholder when saving:
tinymce.activeEditor.onSaveContent.add(function(ed, o) {
console.debug(o.element.nodeName);
// do your replacement here using a regular expression and the saved value from the dropdown selection
});
or when selecting a name from the dropdown select box of your own plugin.
To return it back when loading you will need to store the replacement string in the satabase too and replace it on startup of tinymce using a regular expression.
// Andreas from db should be placed in a custom initialisation paramter like this:
db_firstname_save: '<?php echo $value_from_db; ?>', // $value_from_db = 'Andreas'
Replace the value from DB using a regular expression
tinymce.activeEditor.onInit.add(function(ed) {
console.debug('Editor is done: ' + ed.id);
// do your replacement here using a regular expression
ed.setcontent(ed.getContent.replace(ed.getParam('db_firstname_save'),'{firstname}'));
});
In order to select the Firstname to be saved to db from a dropdown you will need to create your own plugin. How to do that is to be found on the tinymce documentation wiki.