Skip to content

Commit

Permalink
fix: Adjust API version, fix API test and make code naming consistent
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Dec 18, 2023
1 parent 2928d33 commit a7058f0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 68 deletions.
64 changes: 32 additions & 32 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
'verb' => 'OPTIONS',
'requirements' => [
'path' => '.+',
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],

Expand All @@ -83,31 +83,31 @@
'url' => '/api/{apiVersion}/forms',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#newForm',
'url' => '/api/{apiVersion}/form',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#getForm',
'url' => '/api/{apiVersion}/form/{id}',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#cloneForm',
'url' => '/api/{apiVersion}/form/clone/{id}',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
// TODO: Remove POST in next API release
Expand All @@ -116,47 +116,47 @@
'url' => '/api/{apiVersion}/form/update',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#updateForm',
'url' => '/api/{apiVersion}/form/update',
'verb' => 'PATCH',
'requirements' => [
'apiVersion' => 'v2.2'
'apiVersion' => 'v2\.[2-3]'
]
],
[
'name' => 'api#transferOwner',
'url' => '/api/{apiVersion}/form/transfer',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2.2'
'apiVersion' => 'v2\.[2-3]'
]
],
[
'name' => 'api#deleteForm',
'url' => '/api/{apiVersion}/form/{id}',
'verb' => 'DELETE',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#getPartialForm',
'url' => '/api/{apiVersion}/partial_form/{hash}',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#getSharedForms',
'url' => '/api/{apiVersion}/shared_forms',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],

Expand All @@ -166,7 +166,7 @@
'url' => '/api/{apiVersion}/question',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
// TODO: Remove POST in next API release
Expand All @@ -175,15 +175,15 @@
'url' => '/api/{apiVersion}/question/update',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#updateQuestion',
'url' => '/api/{apiVersion}/question/update',
'verb' => 'PATCH',
'requirements' => [
'apiVersion' => 'v2.2'
'apiVersion' => 'v2\.[2-3]'
]
],
// TODO: Remove POST in next API release
Expand All @@ -192,31 +192,31 @@
'url' => '/api/{apiVersion}/question/reorder',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#reorderQuestions',
'url' => '/api/{apiVersion}/question/reorder',
'verb' => 'PUT',
'requirements' => [
'apiVersion' => 'v2.2'
'apiVersion' => 'v2\.[2-3]'
]
],
[
'name' => 'api#deleteQuestion',
'url' => '/api/{apiVersion}/question/{id}',
'verb' => 'DELETE',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#duplicateQuestion',
'name' => 'api#cloneQuestion',
'url' => '/api/{apiVersion}/question/clone/{id}',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2.1'
'apiVersion' => 'v2.3'
]
],

Expand All @@ -226,7 +226,7 @@
'url' => '/api/{apiVersion}/option',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
// TODO: Remove POST in next API release
Expand All @@ -235,23 +235,23 @@
'url' => '/api/{apiVersion}/option/update',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#updateOption',
'url' => '/api/{apiVersion}/option/update',
'verb' => 'PATCH',
'requirements' => [
'apiVersion' => 'v2.2'
'apiVersion' => 'v2\.[2-3]'
]
],
[
'name' => 'api#deleteOption',
'url' => '/api/{apiVersion}/option/{id}',
'verb' => 'DELETE',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],

Expand All @@ -261,15 +261,15 @@
'url' => '/api/{apiVersion}/share',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'shareApi#deleteShare',
'url' => '/api/{apiVersion}/share/{id}',
'verb' => 'DELETE',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
// TODO: Remove POST in next API release
Expand All @@ -286,7 +286,7 @@
'url' => '/api/{apiVersion}/share/update',
'verb' => 'PATCH',
'requirements' => [
'apiVersion' => 'v2.2'
'apiVersion' => 'v2\.[2-3]'
]
],

Expand All @@ -296,47 +296,47 @@
'url' => '/api/{apiVersion}/submissions/{hash}',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#exportSubmissions',
'url' => '/api/{apiVersion}/submissions/export/{hash}',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#exportSubmissionsToCloud',
'url' => '/api/{apiVersion}/submissions/export',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#deleteAllSubmissions',
'url' => '/api/{apiVersion}/submissions/{formId}',
'verb' => 'DELETE',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#insertSubmission',
'url' => '/api/{apiVersion}/submission/insert',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
[
'name' => 'api#deleteSubmission',
'url' => '/api/{apiVersion}/submission/{id}',
'verb' => 'DELETE',
'requirements' => [
'apiVersion' => 'v2(\.[1-2])?'
'apiVersion' => 'v2(\.[1-3])?'
]
],
]
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -717,14 +717,14 @@ public function deleteQuestion(int $id): DataResponse {
* @CORS
* @NoAdminRequired
*
* Duplicate a question
* Clone a question
*
* @param int $id the question id
* @return DataResponse
* @throws OCSBadRequestException|OCSForbiddenException
*/
public function duplicateQuestion(int $id): DataResponse {
$this->logger->debug('Question to be duplicated: {id}', [
public function cloneQuestion(int $id): DataResponse {
$this->logger->debug('Question to be cloned: {id}', [
'id' => $id
]);

Check warning on line 729 in lib/Controller/ApiController.php

View check run for this annotation

Codecov / codecov/patch

lib/Controller/ApiController.php#L726-L729

Added lines #L726 - L729 were not covered by tests

Expand Down
8 changes: 4 additions & 4 deletions src/components/Questions/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</template>
{{ t('forms', 'Technical name') }}
</NcActionInput>
<NcActionButton @click="onDuplicate">
<NcActionButton @click="onClone">
<template #icon>
<IconContentDuplicate :size="20" />
</template>
Expand Down Expand Up @@ -315,10 +315,10 @@ export default {
},
/**
* Duplicate this question
* Clone this question
*/
onDuplicate() {
this.$emit('duplicate')
onClone() {
this.$emit('clone')
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions src/mixins/QuestionMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export default {
*/
commonListeners() {
return {
clone: this.onClone,
delete: this.onDelete,
duplicate: this.onDuplicate,
'update:text': this.onTitleChange,
'update:description': this.onDescriptionChange,
'update:isRequired': this.onRequiredChange,
Expand Down Expand Up @@ -292,10 +292,10 @@ export default {
},

/**
* Duplicate this question.
* Clone this question.
*/
onDuplicate() {
this.$emit('duplicate')
onClone() {
this.$emit('clone')
},

/**
Expand Down
10 changes: 5 additions & 5 deletions src/views/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
:index="index + 1"
:max-string-lengths="maxStringLengths"
v-bind.sync="form.questions[index]"
@clone="cloneQuestion(question)"
@delete="deleteQuestion(question)"
@duplicate="duplicateQuestion(question)"
@move-down="onMoveDown(index)"
@move-up="onMoveUp(index)" />
</transition-group>
Expand Down Expand Up @@ -395,15 +395,15 @@ export default {
},
/**
* Duplicate a question
* Clone a question
*
* @param {number} id the question id to duplicate in the current form
* @param {number} id the question id to clone in the current form
*/
async duplicateQuestion({ id }) {
async cloneQuestion({ id }) {
this.isLoadingQuestions = true
try {
const response = await axios.post(generateOcsUrl('apps/forms/api/v2.1/question/clone/{id}', { id }))
const response = await axios.post(generateOcsUrl('apps/forms/api/v2.3/question/clone/{id}', { id }))
const question = OcsResponse2Data(response)
this.form.questions.push(Object.assign({
Expand Down
Loading

0 comments on commit a7058f0

Please sign in to comment.