This allows a user to edit a dataset, view, and accept or reject the changes in a Git diff kind of manner. I'm sure some optimizations can be added to my example.
Note that some column must act like a primary key, this could be abstracted from the expression into a separate prop.
Example v.81 Perspective View
[
{
"type": "ia.container.flex",
"version": 0,
"props": {
"direction": "column"
},
"meta": {
"name": "root"
},
"position": {},
"custom": {},
"children": [
{
"type": "ia.container.flex",
"version": 0,
"props": {
"alignItems": "center"
},
"meta": {
"name": "HeaderFlex"
},
"position": {
"basis": "50px"
},
"custom": {},
"children": [
{
"type": "ia.display.label",
"version": 0,
"props": {
"text": "Data Diff (Edits are made in this table)",
"textStyle": {
"fontWeight": "bold"
}
},
"meta": {
"name": "Label"
},
"position": {
"grow": 1
},
"custom": {}
},
{
"type": "ia.input.button",
"version": 0,
"props": {
"text": "Submit Edits",
"primary": false,
"image": {
"icon": {
"path": "material/save_alt",
"color": "limegreen"
}
}
},
"meta": {
"name": "Button_0"
},
"position": {
"shrink": 0,
"basis": "125px"
},
"custom": {},
"propConfig": {
"props.enabled": {
"binding": {
"type": "expr",
"config": {
"expression": "len({view.custom.dataChanges}) > 0"
}
}
}
},
"events": {
"component": {
"onActionPerformed": {
"type": "script",
"scope": "G",
"config": {
"script": "\tself.view.custom.rawData = self.view.custom.editData"
}
}
}
}
},
{
"type": "ia.input.button",
"version": 0,
"props": {
"text": "Reject Edits",
"primary": false,
"image": {
"icon": {
"path": "material/restore_from_trash",
"color": "lightcoral"
}
}
},
"meta": {
"name": "Button"
},
"position": {
"shrink": 0,
"basis": "120px"
},
"custom": {},
"propConfig": {
"props.enabled": {
"binding": {
"type": "expr",
"config": {
"expression": "len({view.custom.dataChanges}) > 0"
}
}
}
},
"events": {
"component": {
"onActionPerformed": {
"type": "script",
"scope": "G",
"config": {
"script": "\tself.view.refreshBinding('custom.editData')"
}
}
}
}
}
]
},
{
"type": "ia.container.flex",
"version": 0,
"props": {
"alignItems": "center"
},
"meta": {
"name": "NewRowFlex"
},
"position": {
"basis": "50px"
},
"custom": {},
"children": [
{
"type": "ia.input.text-field",
"version": 0,
"props": {
"placeholder": "city..."
},
"meta": {
"name": "TextField_City"
},
"position": {
"grow": 1,
"basis": "25%"
},
"custom": {},
"propConfig": {
"props.text": {
"binding": {
"type": "property",
"config": {
"path": "view.custom.newRow_City",
"bidirectional": true
}
}
}
}
},
{
"type": "ia.input.text-field",
"version": 0,
"props": {
"placeholder": "country..."
},
"meta": {
"name": "TextField_County"
},
"position": {
"grow": 1,
"basis": "25%"
},
"custom": {},
"propConfig": {
"props.text": {
"binding": {
"type": "property",
"config": {
"path": "view.custom.newRow_Country",
"bidirectional": true
}
}
}
}
},
{
"type": "ia.input.numeric-entry-field",
"version": 0,
"props": {
"placeholder": "population..."
},
"meta": {
"name": "NumericEntryField_Population"
},
"position": {
"grow": 1,
"basis": "25%"
},
"custom": {},
"propConfig": {
"props.value": {
"binding": {
"type": "property",
"config": {
"path": "view.custom.newRow_Population",
"bidirectional": true
}
}
}
}
},
{
"type": "ia.input.button",
"version": 0,
"props": {
"text": "Add Row",
"primary": false,
"image": {
"icon": {
"path": "material/playlist_play",
"color": "limegreen"
}
}
},
"meta": {
"name": "Button_AddRow"
},
"position": {
"shrink": 0,
"basis": "125px"
},
"custom": {},
"propConfig": {
"props.enabled": {
"binding": {
"type": "expr",
"config": {
"expression": "{view.custom.newRow_City} != ''\r\n\t&& {view.custom.newRow_Country} != ''\r\n\t&& {view.custom.newRow_Population} != null"
}
}
}
},
"events": {
"component": {
"onActionPerformed": {
"type": "script",
"scope": "G",
"config": {
"script": "\tdataIn = self.view.custom.editData\n\tnewRow = [\n\t\tself.view.custom.newRow_City,\n\t\tself.view.custom.newRow_Country,\n\t\tself.view.custom.newRow_Population,\n\t]\n\t\n\tdataOut = system.dataset.addRow(dataIn, newRow)\n\tself.view.custom.editData = dataOut\n\t\n\tself.view.custom.newRow_City = ''\n\tself.view.custom.newRow_Country = ''\n\tself.view.custom.newRow_Population = None\n\t"
}
}
}
}
},
{
"type": "ia.input.button",
"version": 0,
"props": {
"text": "Delete Row",
"primary": false,
"image": {
"icon": {
"path": "material/playlist_play",
"color": "lightcoral"
}
}
},
"meta": {
"name": "Button"
},
"position": {
"shrink": 0,
"basis": "120px"
},
"custom": {},
"propConfig": {
"props.enabled": {
"binding": {
"type": "expr",
"config": {
"expression": "len({view.custom.selectedData}) > 0"
}
}
}
},
"events": {
"component": {
"onActionPerformed": {
"type": "script",
"scope": "G",
"config": {
"script": "\tdataIn = self.view.custom.editData\n\tselectedRow = self.view.custom.selectedRowIndex\n\t\n\tdataOut = system.dataset.deleteRow(dataIn, selectedRow)\n\tself.view.custom.editData = dataOut"
}
}
}
}
}
]
},
{
"type": "ia.display.table",
"version": 0,
"props": {
"selection": {
"selectedColumn": "country"
},
"columns": [
{
"field": "city",
"visible": true,
"editable": false,
"render": "auto",
"justify": "auto",
"align": "center",
"resizable": true,
"sortable": true,
"sort": "none",
"filter": {
"enabled": false,
"visible": "on-hover",
"string": {
"condition": "",
"value": ""
},
"number": {
"condition": "",
"value": ""
},
"boolean": {
"condition": ""
},
"date": {
"condition": "",
"value": ""
}
},
"viewPath": "",
"viewParams": {},
"boolean": "checkbox",
"number": "value",
"progressBar": {
"max": 100,
"min": 0,
"bar": {
"color": "",
"style": {
"classes": ""
}
},
"track": {
"color": "",
"style": {
"classes": ""
}
},
"value": {
"enabled": true,
"format": "0,0.##",
"justify": "center",
"style": {
"classes": ""
}
}
},
"toggleSwitch": {
"color": {
"selected": "",
"unselected": ""
}
},
"nullFormat": {
"includeNullStrings": false,
"strict": false,
"nullFormatValue": ""
},
"numberFormat": "0,0.##",
"dateFormat": "MM/DD/YYYY",
"width": "",
"strictWidth": false,
"style": {
"classes": ""
},
"header": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
},
"footer": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
}
},
{
"field": "country",
"visible": true,
"editable": false,
"render": "auto",
"justify": "auto",
"align": "center",
"resizable": true,
"sortable": true,
"sort": "none",
"filter": {
"enabled": false,
"visible": "on-hover",
"string": {
"condition": "",
"value": ""
},
"number": {
"condition": "",
"value": ""
},
"boolean": {
"condition": ""
},
"date": {
"condition": "",
"value": ""
}
},
"viewPath": "",
"viewParams": {},
"boolean": "checkbox",
"number": "value",
"progressBar": {
"max": 100,
"min": 0,
"bar": {
"color": "",
"style": {
"classes": ""
}
},
"track": {
"color": "",
"style": {
"classes": ""
}
},
"value": {
"enabled": true,
"format": "0,0.##",
"justify": "center",
"style": {
"classes": ""
}
}
},
"toggleSwitch": {
"color": {
"selected": "",
"unselected": ""
}
},
"nullFormat": {
"includeNullStrings": false,
"strict": false,
"nullFormatValue": ""
},
"numberFormat": "0,0.##",
"dateFormat": "MM/DD/YYYY",
"width": "",
"strictWidth": false,
"style": {
"classes": ""
},
"header": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
},
"footer": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
}
},
{
"field": "population",
"visible": true,
"editable": true,
"render": "auto",
"justify": "auto",
"align": "center",
"resizable": true,
"sortable": true,
"sort": "none",
"filter": {
"enabled": false,
"visible": "on-hover",
"string": {
"condition": "",
"value": ""
},
"number": {
"condition": "",
"value": ""
},
"boolean": {
"condition": ""
},
"date": {
"condition": "",
"value": ""
}
},
"viewPath": "",
"viewParams": {},
"boolean": "checkbox",
"number": "value",
"progressBar": {
"max": 100,
"min": 0,
"bar": {
"color": "",
"style": {
"classes": ""
}
},
"track": {
"color": "",
"style": {
"classes": ""
}
},
"value": {
"enabled": true,
"format": "0,0.##",
"justify": "center",
"style": {
"classes": ""
}
}
},
"toggleSwitch": {
"color": {
"selected": "",
"unselected": ""
}
},
"nullFormat": {
"includeNullStrings": false,
"strict": false,
"nullFormatValue": ""
},
"numberFormat": "0,0.##",
"dateFormat": "MM/DD/YYYY",
"width": "",
"strictWidth": false,
"style": {
"classes": ""
},
"header": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
},
"footer": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
}
}
],
"rows": {
"striped": {
"color": {
"even": "#FFFFFF",
"odd": "#D5D5D5"
}
}
},
"pager": {
"bottom": false
}
},
"meta": {
"name": "DiffTable"
},
"position": {
"basis": "400px"
},
"custom": {},
"propConfig": {
"props.data": {
"binding": {
"type": "property",
"config": {
"path": "view.custom.diffData"
}
}
},
"props.selection.data": {
"binding": {
"type": "property",
"config": {
"path": "view.custom.selectedData",
"bidirectional": true
}
}
},
"props.selection.selectedRow": {
"binding": {
"type": "property",
"config": {
"path": "view.custom.selectedRowIndex",
"bidirectional": true
}
}
}
},
"events": {
"component": {
"onEditCellCommit": {
"type": "script",
"scope": "G",
"config": {
"script": "\tdataIn = self.view.custom.editData\n\tr = event.row\n\tc = event.column\n\t\n\tdataOut = system.dataset.setValue(dataIn, r, c, event.value)\n\tself.view.custom.editData = dataOut"
}
}
}
}
},
{
"type": "ia.display.label",
"version": 0,
"props": {
"text": "Edited Data",
"textStyle": {
"fontWeight": "bold"
}
},
"meta": {
"name": "Label_0"
},
"position": {
"basis": "50px"
},
"custom": {}
},
{
"type": "ia.display.table",
"version": 0,
"props": {
"selection": {
"selectedRow": ""
},
"rows": {
"striped": {
"color": {
"even": "#FFFFFF",
"odd": "#D5D5D5"
}
}
},
"pager": {
"bottom": false
}
},
"meta": {
"name": "EditTable"
},
"position": {
"basis": "400px"
},
"custom": {},
"propConfig": {
"props.data": {
"binding": {
"config": {
"path": "view.custom.editData"
},
"type": "property"
}
}
}
},
{
"type": "ia.display.label",
"version": 0,
"props": {
"text": "RawData",
"textStyle": {
"fontWeight": "bold"
}
},
"meta": {
"name": "Label"
},
"position": {
"basis": "50px"
},
"custom": {}
},
{
"type": "ia.display.table",
"version": 0,
"props": {
"rows": {
"striped": {
"color": {
"even": "#FFFFFF",
"odd": "#D5D5D5"
}
}
},
"pager": {
"bottom": false
}
},
"meta": {
"name": "RawTable"
},
"position": {
"basis": "400px"
},
"custom": {},
"propConfig": {
"props.data": {
"binding": {
"config": {
"path": "view.custom.rawData"
},
"type": "property"
}
}
}
}
]
}
]