Does SurveyJS have a built-in way to specify "show N questions per page" - surveyjs

We are using Survey Creator to allow our users to build questionnaires. However, we want to keep it simple and we don't want them to have to deal with pagination.
In other words, in the builder, we want to disable pages (showPagesToolbox = false) and have them create a set of questions all on a single page.
When we present this to respondents, we want them to see a single question per page. I.e. Q1 is on page 1, Q2 is on page 2, etc.
Does the SurveyJS library provide a way of handling this situation, i.e. here are all the questions, show them with N questions per page?

There is an option, whch allows you to automatically display one question per page. To enable this you need to set "questionsOnPageMode": "questionPerPage" on the survey level. Here's an example:
{
"pages": [
{
"name": "page1",
"elements": [
{
"type": "text",
"name": "question1"
},
{
"type": "checkbox",
"name": "question2",
"choices": [
"item1",
"item2",
"item3"
]
}
]
}
],
"questionsOnPageMode": "questionPerPage"
}
This is also configurable through the SurveyJS creator by opening the "Survey Settings" dialog, then going to the "Navigation" section, and finally setting the "Questions on page mode" value.
Unfortunately at this time there is no option to specify N number of questions per page. The documentation for this setting is here.

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"
}
}
}
}

Docusaurus categories in sidebars.json don't show correctly

I have mutiple (more than 2) categories in the sidebars.json,it only render the first and the last one in the page,I can't find how to fix online. thanks.
Here is a producible repo: https://github.com/nianiaJR/doc-demo
Here is my sidebars.json: https://github.com/nianiaJR/doc-demo/blob/master/website/sidebars.json
I expect all navs config in the sidebars.json show in the page. But only the first and the last one show.
{
"type": "subcategory",
"label": "Quick Start",
"ids": [
"doc1",
"doc2",
"doc3"
]
},
{
"type": "subcategory",
"label": "design-and-architecture",
"ids": [
"doc1",
"doc2",
"doc3"
]
}
You have duplicates ids in a different category. You should not do that. The docs is confused whether 'doc1' belong to quick start or design and architecture
https://github.com/nianiaJR/doc-demo/blob/6323eb2207b63cb53918e677681593a9cda9a08d/website/sidebars.json#L13-L29
In my case I had a file named docker-compose.md with an id=docker-compose. My .dockerignore file contained an entry **/docker-compose.
In this case changing the entry to */docker-compose.yml fixed the issue.

Rendering same component (with synced data) twice on same page

I've read a lot of documentation but I can't get the following use case to work:
I've got a component 'product-filter'. This component contains the child component 'product-filter-option' which renders a individual filter option (checkbox with label)
The json data for a product-filter instance looks like:
"name": "category",
"title": "Category",
"options": [
{
"value": "value",
"label": "Label 1",
"active": true,
"amount": 8
},
{
"value": "value2",
"label": "Label 2",
"amount": 15
},
etc.
]
I've got multiple instances of product-filter (and a lot of product-filter-option instances) on my page. So far so good.
Now I'd like to render one of my filters (eg. the given Category filter) multiple times on my page (sort of current 'highlighted' filter, which can change during user interaction).
So I've tried to fix this with the following template code:
<filter-component v-if="activefilter"
:name="activefilter.name"
:type="activefilter.type"
:title="activefilter.title"
:tooltip="activefilter.tooltip"
:configuration="activefilter.configuration"
:options="activefilter.options">
</filter-component>
So this filter now shows up 2 times on my page (only when the activefilter property in the vue app is set). But as you might guess when changing an option in this 'cloned' filter the original filter doesn't change, because the data is not synced between these 'clones'.
How can I fix this with Vue?
Thanks for your help!
#roy-j, thanks for your comment about sync. I already tried that by setting:
<filter-component v-if="activefilter"
:name="activefilter.name"
:type="activefilter.type"
:title="activefilter.title"
:tooltip="activefilter.tooltip"
:configuration="activefilter.configuration"
:options.sync="activefilter.options">
</filter-component>
This didn't work. But You got got me thinking, the options sync was not the issue, the sync of the 'checked' state was the issue.
It worked by changing :checked="option.active" to :checked.sync="option.acitve" to the child component: 'filter-option-component'!
Thanks!!

REST API: fields of objects in a list of objects in response JSON

Suppose we are building one-page app with two views: list view and detail view.
In list view, we present a list of objects with just their names and maybe some more minimal data.
In detail view, we present all possible fields of particular object.
Hence the question: when we GET /api/items/, should we or should not to JSON-encode all fields of the objects listed, or just those presented in list view?
In other words, if we show list of food like
Name Price
Potato 1
Milk 2
does our API need to respond with JSON like this:
{
[
{
"name": "Potato",
"quantity": "1 kg",
"origin": "Egypt",
"manufacturer": "Egypt Farmers",
"price": 1,
"packaging": "String bag",
"_type": "Food"
},
{
"name": "Milk",
"quantity": "1 litre",
"origin": "Finland",
"manufacturer": "Valio",
"price": 2,
"packaging": "Tetra Pak",
"_type": "Food"
},
]
}
or like this:
{
[
{
"name": "Potato",
"price": 1,
"_type": "Food"
},
{
"name": "Milk",
"price": 2,
"_type": "Food"
},
]
}
The RESTful API should concentrate on the resources that are represented, not necessarily how those resources are used.
In a master/detail scenario, typically the master will contain details of the master object, and include a list of its details (including a link to the API for each detail resource. So /api/items/ might look like this:
{
items: [
{ name: 'item 1', href: '/api/items/1' },
{ name: 'item 2', href: '/api/items/2' }
]
}
The detail resource would contain properties of an individual item in the items list. So the /api/items/{itemName} api might look like this:
{
name: 'item 1',
color: 'blue',
weight: 100,
id: '/api/items/1'
}
So this would probably be closest to your second scenario. There are a number of advantages to this model: it probably matches the domain model that your api is accessing, it makes each api very simple and single-purpose, it's easy to scale, even to very large lists. The disadvantage is that it may lead to more complexity on the client.
The answer as usual may be: it all depends ;)
In case of the connection is limited or unstable (e.g. mobile connection like LTE or even wifi) the best idea is to return the whole list of resources with all fields filled and use the same data on both views. In the company I work for we often take this approach since our backend almost always provide data for mobile applications.
The second idea is to use a mechanism called field or resource expansion. In general a request is made to the endpoint and fields of resources to be returned are included in this request:
/api/items?fields=(name, quantity, origin, whatever)
This mechanism is very convenient since you can use this endpoint to server multiple views without any performance loss.
Personally I'd use two endpoints. An /api/items/ endpoint with field/resource expansion mechanism built-in (with a limited list of fields that can be expanded) and the second one /api/items/{itemID}/ to return a particular item with all the data. This is also the most RESTful approach.

Does the JIRA REST API require submitting a transition ID when transitioning an issue?

If I POST an issue transition like this:
{
"fields" : {
"resolution" : {
"name" : "Fixed"
}
}
}
...I get this error:
{
"errorMessages" : ["Missing 'transition' identifier"],
"errors" : {}
}
This seems to imply that I need to include a transition ID along with my list of changed fields. https://stackoverflow.com/a/14642966/565869 seems to say the same. Fine.
However, transition IDs appear to be global. It's not enough to look up the highest transition ID for this issue and increment it; such an ID is probably in use elsewhere. At some expense, I could get the highest transaction ID used anywhere in the system; this might be 68,000 at this moment. But if I were then to use transaction ID 68,001 there's a real chance that a GUI user would attempt a transition of their own and use this ID before I could.
I could use transaction IDs in the range of 1,000,001 and up, but if the JIRA web GUI uses the highest previously used transaction ID when generating new IDs I'll just collide in this range instead of the 68,000 range. I could use 69,000 and trust that there won't be a thousand transitions in the length of time it takes to get the highest transaction ID.
These both seem terribly clumsy, however. Is there no way to post a transition and let JIRA generate its own unique ID? I don't need to retrieve the generated IDs, I just want to update issues' statuses and resolutions.
You're getting mixed up a bit. So lets see if I can explain it better for you.
To transition a JIRA Issue, you use the Transition ID to identify what transition to apply to the issue. You aren't specifying an ID for a transaction or a transition ID to identify that the transition occurred, JIRA takes care of this for you.
The easiest way to understand it is to see it.
So first you can look at what transitions are available to an Issue by doing a GET to the API Call:
/rest/api/2/issue/${issueIdOrKey}/transitions
Example:
/rest/api/2/issue/ABC-123/transitions
Which will show something like this:
{
"expand": "transitions",
"transitions": [
{
"id": "161",
"name": "Resolve",
"to": {
"description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.",
"iconUrl": "https://localhost:8080/images/icons/statuses/resolved.png",
"id": "5",
"name": "Resolved",
"self": "https://localhost:8080/rest/api/2/status/5"
}
}
]
}
So you can see only 1 transition is available for issue ABC-123 and it has an ID of 161.
If you were to browse to that JIRA Issue through the GUI, you would see only 1 Transition available and it would match the API Call. In fact if you inspected the element you should see it having an a tag and in the href something like action=161
So should you want to transition this issue, you'll need to do a POST to the following URL:
/rest/api/2/issue/ABC-123/transitions
With JSON like this:
{
"update": {
"comment": [
{
"add": {
"body": "Bug has been fixed."
}
}
]
},
"fields": {
"assignee": {
"name": "bob"
},
"resolution": {
"name": "Fixed"
}
},
"transition": {
"id": "161"
}
}
Which uses the transition ID found from the call that shows all transitions. I also update the resolution and assignee and add comments at the same time.
That make a bit more sense?