Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nextcloud-forms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Milan Jaros
nextcloud-forms
Commits
67dd1757
Unverified
Commit
67dd1757
authored
4 years ago
by
John Molakvoæ
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #520 from nextcloud/fix/dropdown-insert
Fix dropdown submission insert
parents
52cfe8c1
d9ff7a18
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/Controller/ApiController.php
+8
-3
8 additions, 3 deletions
lib/Controller/ApiController.php
src/components/Questions/QuestionDropdown.vue
+11
-14
11 additions, 14 deletions
src/components/Questions/QuestionDropdown.vue
src/views/Submit.vue
+1
-0
1 addition, 0 deletions
src/views/Submit.vue
with
20 additions
and
17 deletions
lib/Controller/ApiController.php
+
8
−
3
View file @
67dd1757
...
...
@@ -40,14 +40,15 @@ use OCA\Forms\Db\SubmissionMapper;
use
OCA\Forms\Service\FormsService
;
use
OCP\AppFramework\Controller
;
use
OCP\AppFramework\Db\DoesNotExistException
;
use
OCP\AppFramework\Db\IMapperException
;
use
OCP\AppFramework\Http
;
use
OCP\ILogger
;
use
OCP\IL10N
;
use
OCP\ILogger
;
use
OCP\IRequest
;
use
OCP\IUser
;
use
OCP\IUserSession
;
use
OCP\IUserManager
;
use
OCP\IUserSession
;
use
OCP\Security\ISecureRandom
;
class
ApiController
extends
Controller
{
...
...
@@ -725,7 +726,11 @@ class ApiController extends Controller {
}
foreach
(
$answerArray
as
$answer
)
{
if
(
$question
[
'type'
]
===
'multiple'
||
$question
[
'type'
]
===
'multiple_unique'
)
{
// Are we using answer ids as values
if
(
$question
[
'type'
]
===
'multiple'
||
$question
[
'type'
]
===
'multiple_unique'
||
$question
[
'type'
]
===
'dropdown'
)
{
// Search corresponding option, skip processing if not found
$optionIndex
=
array_search
(
$answer
,
array_column
(
$question
[
'options'
],
'id'
));
if
(
$optionIndex
===
false
)
{
...
...
This diff is collapsed.
Click to expand it.
src/components/Questions/QuestionDropdown.vue
+
11
−
14
View file @
67dd1757
...
...
@@ -40,13 +40,15 @@
:name=
"text"
:multiple=
"isMultiple"
:required=
"mandatory"
class=
"question__content"
>
class=
"question__content"
@
change=
"onChange"
>
<option
value=
""
>
{{
selectOptionPlaceholder
}}
</option>
<option
v-for=
"answer in options"
:key=
"answer.id"
:value=
"answer.id"
>
:value=
"answer.id"
:selected=
"isChecked(answer.id)"
>
{{
answer
.
text
}}
</option>
</select>
...
...
@@ -152,25 +154,20 @@ export default {
},
methods
:
{
onChange
(
event
,
answerId
)
{
const
isChecked
=
event
.
target
.
checked
===
true
let
values
=
this
.
values
.
slice
()
onChange
(
event
)
{
// Get all selected options
const
answerIds
=
[...
event
.
target
.
options
]
.
filter
(
option
=>
option
.
selected
)
.
map
(
option
=>
parseInt
(
option
.
value
,
10
))
// Simple select
if
(
!
this
.
isMultiple
)
{
this
.
$emit
(
'
update:values
'
,
[
answerId
])
this
.
$emit
(
'
update:values
'
,
[
answerId
s
[
0
]
])
return
}
// Select with multiple
if
(
isChecked
)
{
values
.
push
(
answerId
)
}
else
{
values
=
values
.
filter
(
id
=>
id
!==
answerId
)
}
// Emit values and remove duplicates
this
.
$emit
(
'
update:values
'
,
[...
new
Set
(
value
s
)])
this
.
$emit
(
'
update:values
'
,
[...
new
Set
(
answerId
s
)])
},
/**
...
...
This diff is collapsed.
Click to expand it.
src/views/Submit.vue
+
1
−
0
View file @
67dd1757
...
...
@@ -167,6 +167,7 @@ export default {
onKeydownEnter
(
event
)
{
const
formInputs
=
Array
.
from
(
this
.
$refs
.
form
)
const
sourceInputIndex
=
formInputs
.
findIndex
(
input
=>
input
===
event
.
originalTarget
)
// Focus next form element
formInputs
[
sourceInputIndex
+
1
].
focus
()
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment