GithubHelp home page GithubHelp logo

Ace Type as Array about jsonform HOT 10 CLOSED

jasondalycan avatar jasondalycan commented on May 31, 2024
Ace Type as Array

from jsonform.

Comments (10)

sdetweil avatar sdetweil commented on May 31, 2024

set draggable:false in the array form definition

from jsonform.

jasondalycan avatar jasondalycan commented on May 31, 2024

Thanks that resolves the dragging issue. The height parameter for the Ace editor doesn't seem to take effect in this case though. For example, using the following the height is ignored and falls back to the default:

myAceField: { title: "My Ace Field", type: "ace", aceMode: "javascript", height: "80px" }

from jsonform.

sdetweil avatar sdetweil commented on May 31, 2024

well, 80px for a custom font, mukti-line text editor .....

maybe Ace has a minimum size
did u try using css to style it?

see https://ourcodeworld.com/articles/read/1642/how-to-change-the-line-height-in-ace-editor

from jsonform.

jasondalycan avatar jasondalycan commented on May 31, 2024

The height: "80px" parameter works fine if added within the form section of the definition, it's just not recognized if added within the schema portion of the definition. Is this only supported within the form section?

from jsonform.

sdetweil avatar sdetweil commented on May 31, 2024

yes config of the elements is done in the form section

from jsonform.

jasondalycan avatar jasondalycan commented on May 31, 2024

Ok thanks. In that case is there a way to set ace as the type for an object's property within the form section? I haven't noticed a way to do this within the documentation and was wondering if this is supported.

from jsonform.

sdetweil avatar sdetweil commented on May 31, 2024

its not the object type.. that is string (input/output for editor)
aceMode says what kind of syntax assist to use

i add

  type: "ace",
  aceMode: "json",
  aceTheme: "twilight",
  width: "100%",
  height: "100px"

its right there in playground
https://jsonform.github.io/jsonform/playground/index.html?example=fields-ace
and in the doc
https://github.com/jsonform/jsonform/wiki#fields-ace

{
  "schema": {
    "code": {
      "type": "string",
      "title": "Some JSON"
    }
  },
  "form": [
    {
      "key": "code",
      "type": "ace",
      "aceMode": "json",
      "aceTheme": "twilight",
      "width": "100%",
      "height": "200px"
    }
  ]
}

here we have a single schema element, code, which is a string type , and its form field title set in the schema section,
or could be set in the form section

remember 'key': connects the form element to the schema element

then we have to form section which contains one field, linked by 'key'..
then other attributes, to use in the form execution,,, exactly like adding draggable:false
this says, instead of the 'string' editor (input field), use the ace type, which is the full editor, .. the output is presented in the schema field on submit

from jsonform.

jasondalycan avatar jasondalycan commented on May 31, 2024

Ok thanks. And sorry if I've missed this somewhere, but what I'm trying to understand though is how to set the property of a field of type object to the ace type. Please see the following example, I'm not clear on how to set the object field property setStatus.statusExpression to the ace field type within the form section:

schema: 
{   setStatus:
	{   type: "object",
		properties:
		{   menuTitle:
			{   title: "Menu Title",
				type: "string"
			},
			statusExpression:
			{   title: "Status Expression",
	                    type: "string"
			}                            
		}
	}
},
form: 
[   {   title: "Actions",
		type: "array",
		items:
		[   {   type: "selectfieldset",
				title: "Action Type",
				items:
				[   {   key: "setStatus",
						legend: "Set Status"
					}
				]
			}                                
		]
	},
	{   type: "submit",
		title: "Save"
	}
]

from jsonform.

sdetweil avatar sdetweil commented on May 31, 2024

given your example, (as json, needs to be json)

{"schema":{

"setStatus":
{
"type":"object",
	"properties":
		{"menuTitle":
			{
				"title":"MenuTitle",
				"type":"string"
			},
			"statusExpression":
			{
				"title":"StatusExpression",
				"type":"string"
			}
		}
	}
},
"form":
[
	{"title":"Actions",
			"type":"array",
			"items":
			[
				{
				"type":"selectfieldset",
				"title":"ActionType",
				"items":
				[
					{
					"key":"setStatus.statusExpression",
					"title":"SetStatus1",
					"type":"ace"
					}
				]
				}
			]
	},
	{
"type":"submit",
		"title":"Save"
	}
]
}

using playground to test the form definition, copy/paste to the playground window

Screenshot_2022-12-24_12-56-38

from jsonform.

jasondalycan avatar jasondalycan commented on May 31, 2024

That works: thanks! cheers

from jsonform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.