Multiselect in Impresspages Plugin Options - plugins

How may I use a multiselect field in the Impresspages Plugin options. Something like this:
{
"label": "Social Nets",
"name": "socialNets",
"type": "select",
"multiple": "multiple",
"default": "",
"values": ["", "facebook", "twitter", "pintrest"]
}
Of course, the field above "multiple" doesn't work in this code snip. So, how to implement it in the plugin options json file?

You can use "Checkboxes" field type
"options": [
{
"label": "XXX",
"name": "xxx",
"type": "Checkboxes",
"values": ["option1", "option2", "options3", "option4"]
}
]

There is no such option implemented in the core of the system. Meaning, there's no such field type as 'multiselect'. You can check how other fields are implemented and extend the core, create pull-request and we'll add it in next release.

Related

How to create checklist in Configuration from VSCode extension

How do I create a checklist in configuration panel via extension.
I dont see an option to do this in documentation. Something like this:
Tried placing it hierarchically but UI seems to be different :
"apexPMD.rulefix.1": {
"type": "boolean",
"default": true,
"description": "If Else Statements Must use Braces"
},
"apexPMD.rulefix.2": {
"type": "boolean",
"default": true,
"description": "For Statements Must use Braces"
},
"apexPMD.rulefix.3": {
"type": "boolean",
"default": true,
"description": "While Statements Must use Braces"
},

Define defaultSnippets for JSONSchema additionalProperties

As the title suggests, I would like to define a vscode defaultSnippet for the additionalProperites of a JSONObject. The JSONSchema looks like the following
"$schema ": "http://json-schema.org/draft-07/schema#",
"type":"object",
"additionalProperties":{
"type": "object",
"properties":{
"name":{"type":"string"}
}
}
So just adding defaultSnippet property does not seem to work:
"$schema ": "http://json-schema.org/draft-07/schema#",
"type":"object",
"additionalProperties":{
"defaultSnippets": [{
"label": "test",
"description": "Additional property template",
"body": {
"$1": {
"name": "$2"
}
}
}],
"type": "object",
"properties":{
"name":{"type":"string"}
}
}
Is there a workaround to obtain the same behavior?
Your code is correct, but vscode at this moment is only checking properties for snippets. I had the same problem, so I've created Pull Request with fix for this issue.
https://github.com/microsoft/vscode-json-languageservice/pull/62
You can replace default extension if you in rush or just wait for merge and update.

Azure DevOps API - how to discover link between field and picklist

I'm trying to replicate an Azure DevOps process from one organization to another via the AZDO REST Api. I'm working on replicating the layout and am stuck because I can't discover the relationship between a custom field and a picklist when querying the source AZDO instance.
In my scenario I have a test work item type which I've called Issue. On the Issue interface I've created a custom field which is a picklist. While I can retrieve a list of lists via the Rest API and examine the field as well, I can't figure out how the two are related.
Here is a partial payload from the field:
{
"count": 39,
"value": [
...
{
"referenceName": "Custom.IssueSource",
"name": "Issue Source",
"type": "string",
"description": "Who is this attributed to",
"required": true,
"url": "https://dev.azure.com/MYORG/_apis/work/processes/f390103e-7097-4f19-b5b5-f9dbcf92bb6f/behaviors",
"customization": "custom"
},
... ]
}
and here is a partial payload from the lists get query which I used trial and error to determine was the picklist I've assigned:
{
"count": 10,
"value": [
...
{
"id": "2998d4e4-2bec-4935-98a1-b67a0b0b6d5d",
"name": "picklist_e854661e-8620-4ad9-be28-b974c5cb3a5d",
"type": "String",
"isSuggested": false,
"url": "https://dev.azure.com/MYORG/_apis/work/processes/lists/2998d4e4-2bec-4935-98a1-b67a0b0b6d5d"
},
...
]
}
Here is a partial layout response for the WIT:
{
"pages": [
{
"id": "d0171d51-ff84-4038-afc1-8800ab613160.System.WorkItemType.Details",
"inherited": true,
"label": "Details",
"pageType": "custom",
"visible": true,
"isContribution": false,
"sections": [
{
"id": "Section1",
"groups": [
...
{
"id": "bf03e049-5062-4d82-b91d-4396541fbed2",
"label": "Custom",
"isContribution": false,
"visible": true,
"controls": [
{
"id": "Custom.IssueSource",
"label": "Issue Source",
"controlType": "FieldControl",
"readOnly": false,
"visible": true,
"isContribution": false
}
]
}
]
},
... ]
}
Using fiddler against the AZDO web interface, the only time I see a reference to the picklist is from another non-AZDO API to https://dev.azure.com/MYORG/_apis/Contribution/dataProviders/query
Is there a way to discover the link via the AZDO Rest API? I saw this question which was similar but was about creating the link
Figured it out. Turns out you need to query from a different scope - work item tracking rather than work item tracking process:
https://dev.azure.com/MYORG/_apis/wit/fields/Custom.IssueSource?api-version=5.0-preview.2
returns
{
"name": "Issue Source",
"referenceName": "Custom.IssueSource",
"description": "Who is this attributed to",
"type": "string",
"usage": "workItem",
"readOnly": false,
"canSortBy": true,
"isQueryable": true,
...
"isIdentity": false,
--> "isPicklist": true,
"isPicklistSuggested": false,
--> "picklistId": "2998d4e4-2bec-4935-98a1-b67a0b0b6d5d",
"url": "https://dev.azure.com/MYORG/_apis/wit/fields/Custom.IssueSource"
}

Task.Json triggers validation on invisible only fields

I am trying to create a Azure DevOps Pipelines Custom extension. I have a task.json where fields are visible on certain conditions.
For example:
{
"name": "actions",
"type": "picklist",
"label": "Actions",
"defaultValue": "Select",
"required": true,
"helpMarkDown": "Select an Action from the dropdown as per your requirement.",
"options": {
"New": "Add",
"Delete": "Delete"
}
},
{
"name": "backEndIPAddress",
"type": "string",
"label": "IP Address",
"required": true,
"defaultValue": "",
"helpMarkDown": "",
"visibleRule": "actions = New",
"validation": {
"expression": "isMatch(value,'^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?){0,15}$','IgnoreCase')",
"message": "Invalid IP Address. Please try again!"
}
}
The issue when the IPAddress field is hidden, the validation is still tried and it fails. How to ensure that the fields are validated only if they are visible?
A few options:
Set a default value for the input
Update the regex to include ^$| at the start to allow empty values ('require':true will take care of the requiredness)
Remember that there should be a default isIpV4Address(value: string) function so you don't have to specify the regex.
From the docs it looks like there is an upcoming when clause which will dictate when the set of rules should trigger, I suppose this may be causing the currently unwanted behavior.
See also:
https://github.com/Microsoft/vsts-tasks/blob/1d75fa8f66aa1cf7a9cb62946939f30f087b2969/docs/taskinputvalidation.md

Getting expected object definitions from Magento 2 REST API

When calling the Magento 2 REST API to get the schema for working with products using:
..rest/all/schema?services=catalogProductRepositoryV1
The response back includes:
...
"paths": {
"/V1/products": {
"post": {
"tags": [
"catalogProductRepositoryV1"
],
"description": "Create product",
"operationId": "catalogProductRepositoryV1SavePost",
"parameters": [
{
"name": "$body",
"in": "body",
"schema": {
"required": [
"product"
],
"properties": {
"product": {
"$ref": "#/definitions/catalog-data-product-interface"
},
"saveOptions": {
"type": "boolean"
}
},
"type": "object"
}
}
],...
How do you go about getting the definition/schema for the "product" object that it expects during a POST call? i.e. the following definition:
"properties": {
"product": {
"$ref": "#/definitions/catalog-data-product-interface"
},
Looks like its only possible using the swagger GUI. Essentially replicate these steps and change your search term for whatever you're searching for:
Go to: http://devdocs.magento.com/swagger/index.html
Ctrl + f >> search for whatever you're after. In the case of the above: catalogProductRepositoryV1
Expand the API interface by clicking it
Choose your REST Method
Under "Parameters" there will be a Model/Model Schema showing you what payload it expects.
Welcome to Swagger! It's great when you know how to use it!