Blockly restrict input_value to another block - javascript

In my Blockly project, I have two 3 blocks rcm_a, rcm_b and rcm_c.
Blockly.defineBlocksWithJsonArray([{
"type": "rcm_c",
"message0": "Requirement block- rcm_a: %1 rcm_b: %2",
"args0": [
{
"type": "input_value",
"name": "rcm_a"
},
{
"type": "input_value",
"name": "rcm_b",
"check": ["rcm_b"]
}
],
"output": "Text",
"colour": "%{BKY_LOOPS_HUE}"
}]);
As you can see the above code of rcm_c, I am trying to restrict the second input to be of block rcm_b, and that apparently doesn't seem to be working. The same input will not accept any input type. Here's rcm_b's code:
Blockly.defineBlocksWithJsonArray([{
"type": "rcm_b",
"message0": "rcm_b %1",
"args0": [
{
"type": "input_value",
"name": "VALUE1",
"check": "String"
}
],
"output": "Text",
"colour": "%{BKY_LOOPS_HUE}"
}]);
I tried following this guide's Statement Stacks section (I am aware that I am trying to type check inputs and not statements) to achieve type-checking. What am I doing wrong?
Help is much appreciated!

Ah, seems like the 'output' of rcm_b needed to be rcm_b!

Related

VS code extension : Add new keybindings in package.json based on a boolean value in extension configuration

I have created a vs code extension with these contributes in package.json
Here I have a configuration called addKeyBoardShortcuts which is a boolean and when user checks this I want the keybindings array to be updated only when the boolean is true
Right now the editor.emmet.action.incrementNumberByOne command keybinding is always there when this extension is enabled, but I want this keybinding to only be present when addKeyBoardShortcuts is checked by the user.
Any help is much appreciated !
"contributes": {
"keybindings": [
{
"command": "editor.emmet.action.incrementNumberByOne",
"key": "ctrl+shift+i",
"mac": "cmd+shift+i"
}
],
"configuration": {
"type": "object",
"title": "Rem to Px comment configuration",
"properties": {
"remToPxComment.commentColor": {
"type": "string",
"default": "#36C210",
"description": "Decoration color for the comment value"
},
"remToPxComment.remConversionValue": {
"type": "number",
"default": "16",
"description": "value to convert px to rem, default is 16px"
},
"remToPxComment.convertToRemOrPx": {
"type": "string",
"default": "px",
"enum": [
"px",
"rem"
],
"description": "tell if conversion is from rem to px to the other way around"
},
"remToPxComment.addKeyBoardShortcuts": {
"type": "boolean",
"default": false
}
}
}
},
As I mentioned in the comment, if you are trying to avoid showing the contributed keybinding in the Keyboard Shortcuts editor I don't think that is possible. You can disable/enable it based on your contributed setting pretty easily though.
In your package.json:
"configuration": [
{
"title": "Folder Operations",
"properties": {
"folder-operations.enableKeybinding": { // your setting name
"type": "boolean",
"scope": "machine",
"default": true,
"markdownDescription": "your description here"
}
}
}
],
"keybindings": [
{
"command": "editor.emmet.action.incrementNumberByOne",
"key": "ctrl+shift+i",
"mac": "cmd+shift+i",
"when": "config.folder-operations.enableKeybinding" // your extension
}
]
]
The context key config.folder-operations.enableKeybinding will be true or false depending on the value of your setting - whether it remains at the default or is changed by the user. Start the context key with the config. and vscode will automatically retrieve the setting's value each time the keybinding is triggered.

Zapier API Code assistance - extract data from JSON

I am trying to use a JSON response in a Zapier response. The data looks like this:
I'm trying to use the Induction and Site Suitability href value in a Zap, however, when I try to use this in Zapier, Zapier gives me this:
I was going to use a find of some sorts to find Induction and Site Suitability and then return the href after that, but because of the formatting, I can't do that. Does anyone know how I can do this with Formatter or Code (Python/Javascript) or something else in Zapier?
Thank you
Luke
Here is the API result in code:
{
"competencies": [
{
"competency": {
"name": "Forklift Operator Permit",
"href": "https://link/22059"
},
"status": {
"value": "Active",
"type": "active"
},
"expiryWarning": "2021-04-15T13:59:00Z",
"expiry": "2021-04-30T13:59:00Z",
"disabled": false,
"href": "https://link/1b1594d738"
},
{
"competency": {
"name": "Induction and Site Suitability",
"href": "https://link/24033"
},
"status": {
"value": "Active",
"type": "active"
},
"expiryWarning": "2021-04-15T13:59:00Z",
"expiry": "2021-04-30T13:59:00Z",
"disabled": false,
"href": "https://link/8e26b5ea4bbc800e"
}
]
}

I need recommendation for structure to use Cytoscape js

We are using Cytoscape + neo4j + spring boot + REST. We've tried to use some formats pass to frontend, however didn't work that well. So looking for best structure to use Cytoscape js.
========
Added later.
For example response from neo4j apoc export json query would be like this:
{
"application": {
"type": "node",
"id": "hhj354",
"labels": [
"Application"
],
"properties": {
"appid": "A90378",
"name": "hkjgj",
"status": "In Production"
}
},
"changes": [
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": sfd
},
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": sfd
},
{
"node": {
"type": "node",
"id": "fdsf324",
"labels": [
"Change"
],
"properties": {
"type": "gjhk",
"startdate": "2019-11-21 02:11:32"
}
},
"group": "2019-11",
"relation": 453
}
]
}
I need some detailed parsing codes. Parsing in backend or front end both ok as long as short enough.
Thanks in advance.
As far as I'm concerned, the front-end should do the less calculations as possible.
Therefore, try to send a JSON as close as possible to the format specified in the specs of cytoscape.js
The basic idea of graph is that it's composed of nodes and edges, those elements (as cytoscape calls them) have ids that can help you select them in a easier way.
No Calculation in Back-End
If you want to use built-in format .json from CALL apoc.export.json.all("all.json",{useTypes:true})then you will have for example to do some transformation in the front-end:
responseJson => {
responseJson.map(element => {
return {
group: element.type,
data : {
id: `${element.type}${element.id}`,
myFavouriteProperty: element.property
}
}
}

JSON faker for all combination

Currently I have a requirement of generating test data for a JSON schema. I have found this following github very useful for this:
https://www.npmjs.com/package/json-schema-faker#overview
Now, if we want to extend it to generate all the required fields + all combinations of optional field, how can we generate this. For example:
The following JSON schema should output two JSON's:
{
"title": "Example Schema",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["name"]
}
{
"name" : <random_string>
}
AND
{
"name" : <random_string>,
"age" : <random_int>
}
You can try json-faker which is available in npm, it is easy to use

TypeError: Object [object Array] has no method 'getProperty'

I'm kind of new to this whole posting a question thing, so please be gentle!
I am using Breeze as part of the "Hot Towel" SPA stack and retrieving data from a custom WebApi endpoint written in PHP. It's not a full implementation, I've just written enough to give me what I need.
The metadata my endpoint is generating is as follows:
{
"shortName": "Project",
"namespace": "WebApi.ORM.Cartesius",
"autoGeneratedKeyType": "Identity",
"defaultResourceName": "Project",
"dataProperties": [
{
"name": "id",
"isPartOfKey": true,
"isNullable": false,
"dataType": "Int32"
},
{
"name": "title",
"isNullable": false,
"maxLength": 256,
"dataType": "String"
},
{
"name": "date",
"isNullable": false,
"dataType": "DateTime"
},
{
"name": "review_date",
"isNullable": true,
"dataType": "DateTime"
},
{
"name": "summary",
"isNullable": true,
"dataType": "String"
}
],
"navigationProperties": [
{
"name": "Team",
"entityTypeName": "Team:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "team_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
{
"name": "ProjectAuthor",
"entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "project_author_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
{
"name": "Itinerary",
"entityTypeName": "Itinerary:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "itinerary_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
Everything is working fine until I try and do an expand on my query:
var query = new breeze.EntityQuery()
.from("Project")
.where("id","eq",project.id)
.expand("ProjectAuthor");
This query returns the following from my endpoint:
[
{
"$id": 1,
"$type": "WebApi.ORM.Cartesius.Project",
"id": 2,
"title": "teat",
"date": "2013-11-04 14:00:00+07",
"review_date": null,
"summary": null,
"ProjectAuthor": [
{
"$id": 2,
"$type": "WebApi.ORM.Cartesius.ProjectAuthor",
"id": 1,
"account_id": 1,
"project_id": 2,
"Project": [
{
"$ref": 1
}
]
},
{
"$id": 3,
"$type": "WebApi.ORM.Cartesius.ProjectAuthor",
"id": 3,
"account_id": 2,
"project_id": 2,
"Project": [
{
"$ref": 1
}
]
}
]
}
]
Then Breeze chokes on it throwing:
TypeError: Object [object Array] has no method 'getProperty'
Debugging points to line 5059 in Breeze where it tries to getProperty on an array of entities rather than a single entity I assumed this had something to do with whether the navigation property was set to scalar or not but switching them around made no difference.
I'm sure I'm doing something massively wrong, but I can't figure out what it is and I've kind of hit a brick wall. I've read the docs from top to bottom and am implementing this as best as I can understand but it's possible I'm a little confused.
Thanks in advance for any help and apologies if I have not made myself clear or provided enough info
I think your problem is in the metadata
"name": "ProjectAuthor",
"entityTypeName": "ProjectAuthor:#WebApi.ORM.Cartesius",
"isScalar": true,
"associationName": "project_author_project_id_fkey",
"invForeignKeyNames": [
"project_id"
]
},
On that nav property Project->ProjectAuthor your telling it that its a scalar but its not in the data set..
"ProjectAuthor": [
{
..........
I've had this problem aswell .. 99% time its a metadata problem, if not there then start cutting metadata apart until you isolate the error .. though I'm sure thats the problem.. you need a hasMany there and an isScalar on the inverse navigation

Categories

Resources