How to "lock" a field value based on default value in a react Json Schema form? - jsonschema

We have a json schema that includes a field, for which we want to control the value via the schema (rather than having the user specify the value).
We can set a default value - but this is simply overwritten by the formData that the user parses.
Is there a way to "lock" the field value to the default value provided in the schema, ensuring that the formData is updated with the schema-specified value?
{
"meta": {
"title": "SCHEMA REVISION",
"type": "object",
"properties": {
"rev": {
"title": "We want to lock the below default value via the schema",
"type": "string",
"default": "10.00"
}
}
}
}

Sorry, you cannot do this using the schema alone. It's not designed to be used for forms, so it doesn't have that functionality.
It sounds like you want a read-only field. The documentation for react JSON Schema form supports this: https://github.com/mozilla-services/react-jsonschema-form#read-only-fields
The ui:readonly uiSchema directive will mark all child widgets from a
given field as read-only.
Note: the uiSchema is in addition to your JSON Schema.

Related

How to update the pop-up note via API

I'm trying to update the pop-up note via the API. I can easily update the top box (aka the Note) but I don't see how I go about updating the pop-up section. What's odd to me is that the Note doesn't even appear in the WSE, abut when I send the update it does work.
When I retrieve the record, it also doesn't appear to send the data that I have in the pop-up section, and I'm not even clear how I can add it to the WSE.
I've tried just adding it to the JSON update with a couple different names like this (tried popupnote, notepopup), and that still goes through, but only updates the top box:
"note": {
"value": "Travis Update Test!"
},
"notepopup": {
"value": "Travis Pop update Test!"
},
Anyone know if this is possible?
The answer from Acumatica Support is below. In short you need to add a custom field in the items sectionm for the 2 notes and it works perfectly. When loading the items, if you plan to serialize into this class, add this ?$custom=Item.NoteText,Item.NotePopupText to the end of your url:
{
"id": "2a113b2c-d87f-e411-beca-00b56d0561c2",
"custom": {
"Item": {
"NoteText": {
"type": "CustomStringField",
"value": "Regular note 2"
},
"NotePopupText": {
"type": "CustomStringField",
"value": "Popup note 2"
}
}
}
}

Specifying color mapping in react components

Using the new "Colors" section of the analytical designer, I can specify custom colors to use for my insight:
When I get my visualization object, this comes through with properties that look like this:
"colorMapping": [
{
"id": "fdda26a33ca048f28bc702f047c04d73",
"color": {
"type": "guid",
"value": "guid3"
}
},
{
"id": "893b13af5d064ec5ba57f82ea3241bbe",
"color": {
"type": "guid",
"value": "guid4"
}
}
]
Passing that into the config section of the react component props results in some console errors (item.predicate is not a function in color.js:219). It seems to me that the color map values aren't coming through correctly when I get the visualization object.
Is there any way to get the custom color values and set them in the react component props?
If you use Visualization component consuming URI of existing visualization, it will automatically use this color mapping from visualization object so no extra config is needed.
If you use explicit components like BarChart or so, you need to transform colorMapping into form of so called predicates. For more info please read Gooddata.UI documentation and provide also colorPallete config. Hope this helps

How can I use REST url as data in Vega-lite

I have this REST API that returns tabular data in the following way:
{"data": [{"el1": 8, "el2": 9}, {"el1": 3, "el2": 4}]}
I would like to use el1 and el2 in a Vega-lite chart. How should I refer to the elements in the array?
From the documentation here:
(JSON only) The JSON property containing the desired data. This parameter can be used when the loaded JSON file may have surrounding structure or meta-data. For example
"property": "values.features"
is equivalent to retrieving json.values.features from the loaded JSON object.
It seems that you can try to specify the "property" property (punny, eh) on the format. Something like this:
"data": {
"url": <your url here>,
"format": {
"type": "json",
"property": "data"
},
}
Disclaimer: I haven't actually tested this but it looks to be supported (:

JqWidgets treegrid issues wiring up dataAdapter object

I'm in the AngularJS environment, and trying to get a jqWidgets TreeGrid working.
I have the dataAdapter all wired up with the Json formatted data, however the grid renders only one row.
I also have a test treeGrid on the same page, and with sample data, which is working fine.
I'm putting the final Json data setting side-by-side to try and determine where I'm going wrong.
I've used this page as a guide to wire up the treegrid settings, etc. http://www.jqwidgets.com/jquery-widgets-documentation/documentation/angularjs/angularjs.htm
Here is the html showing the jqx treegrid directive for the "bad" grid:
<jqx-tree-grid jqx-instance="jqGridHierObj" jqx-settings="vm.jqGridHierSettings"></jqx-tree-grid>
And the "bad" Json data tree settings binded vm.jqGridHierSettings (too large to post inline):
http://www.bobmazzo.com/grid/TreeGrid_Data_Bad.txt
and here is the "good" grid with Employee test data :
HTML:
<jqx-tree-grid jqx-instance="jqGridEmpObj" jqx-settings="vm.jqGridEmpSettings"></jqx-grid>
vm.jqGridEmpSettings Json data :
http://www.bobmazzo.com/grid/TreeGrid_Data_Good.txt
and from my Angular controller code, a snippet of the javascript with Json data bindings :
I need help to figure out why the "bad" grid is not working ! And why it only renders one row, where is should be showing a hierarchy of data.
thanks.
Bob
I found the solution. You must define the “children” as an array type in the 'source' object; that is, prior to passing that object into the dataAdapter. See the dataFields property below :
var source = {
dataType: "json",
dataFields: [
{
"name": "id",
"type": "number"
},
{
"name": "field0",
"type": "string"
},
{
"name": "field1",
"type": "number"
},
{
"name": "field2",
"type": "number"
},
{
name: 'children', // MUST DEFINE CHILDREN AS ARRAY TYPE
type: 'array'
},
],
hierarchy: {
root: 'children'
},
id: 'id',
localData: myData
};
var dataAdapter = new $.jqx.dataAdapter(source);

Nested JSON and duplicate entries in Sencha Touch

We have a JSON string of articles, where each article has comments. Also, both the article and the comments contain the author/commenter information.
Because Sencha is using "id" as a model key, after Sencha loads the JSON (as shown below) the first article contains article.user but its comment objects do not contain it, e.g. comment.user does not exist. The question is how can we avoid that issue?
One approach we tried is to remove the id field from the user model and the JSON. Then, Sencha will create its own id values and in that case all the data is loaded. However, it seems that if we made a change to the article.user object we wouldn't see that change in the other user objects that (we know) correspond to the same user.
Another approach which would save bandwidth and solve the previous problem is to avoid having (potentially) multiple copies of the same user object by having a pointer to the object for those cases. In this case, the user object of the article would be loaded but the other instances would only contain a pointer to that object. The problem here is that we cannot remove the initial object.
What would be the standard way to approach this problem in Sencha Touch (2)?
{"articles": [
{
"id": "14338138",
"user_id": "1",
"title": "test",
"user": {
"id":"1545"
"first_name": "Joe",
"last_name": "Kae",
"status":"1"
},
"comments": [
{
"id": "1545",
"article_id": "14338138",
"says":"This is my first comment to my own article.",
"user": {
"id":"42",
"first_name": "Joe",
"last_name": "Kae",
"status": "1"
}
},
{
"id": "1546",
"article_id": "14338138",
"says":"This is my second comment to my own article.",
"user": {
"id":"42",
"first_name": "Joe",
"last_name": "Kae",
"status": "1"
}
}
]
}
]
});
Take a look at Sencha Docs Data.Association