-
Notifications
You must be signed in to change notification settings - Fork 83
Variant generic unified main #4200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
artlog
wants to merge
18
commits into
nextcloud:main
Choose a base branch
from
artlog:variant_generic_unified_main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
60ea287
feat: add rank voting feature merge chosenrank with 8.1.4 refactorings
52f0b15
hide count/result for non simple votingVariant
b2fd011
merge generic variant in main ( after 8.2.0rc.2)
8e2dc10
lint github warnings
03e6908
reset VoteIndicator and use VoteItem
5408a3a
apply github review
30d947e
js/ts/vue/php lint - no functional change -
2df7723
merge main, review fix
389c0aa
Poll factory for test with chosenRank
937daea
variant creation selection is disabled by default
578085c
.vue lint fix
532f2ea
pull request checks fix
942d2be
chosen_rank Types:TEXT empty string nullable
c29fd97
remove chosenRank type, keep only column
4dc2cbe
support nullable chosenRank
0ec37e8
chosenRank string nullable
169ed37
Merge branch 'main' into variant_generic_unified_main
artlog 3a3faa1
Merge branch 'main' into variant_generic_unified_main
artlog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Polls\Exceptions; | ||
|
|
||
| use OCP\AppFramework\Http; | ||
|
|
||
| class InvalidVotingVariantException extends Exception { | ||
| public function __construct( | ||
| string $e = 'Invalid votingVariant value', | ||
| ) { | ||
| parent::__construct($e, Http::STATUS_CONFLICT); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2025 Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
|
|
||
| <template> | ||
| <div class="option-container"> | ||
| <!-- Menu to choose the rank for this poll --> | ||
| <select v-model="selectedOption"> | ||
| <option | ||
| v-for="(option, index) in internalChosenRank" | ||
| :key="index" | ||
| :value="option"> | ||
| {{ option }} | ||
| </option> | ||
| </select> | ||
| <!-- text field to add a new value to the rank --> | ||
| <NcTextField | ||
| v-model="newOption" | ||
| :placeholder="t('polls', 'Enter a new option')" | ||
| :label="t('polls', 'New option')" | ||
| class="nc-text-field" /> | ||
| <NcButton icon @click="addOption"> | ||
| <PlusIcon /> | ||
| </NcButton> | ||
| <!-- Delete selected rank from the select --> | ||
| <NcButton :disabled="!selectedOption" @click="removeOption"> | ||
| <CloseIcon /> | ||
| </NcButton> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import { ref, onMounted } from 'vue' | ||
| import { usePollStore } from '../../stores/poll.js' | ||
| import { t } from '@nextcloud/l10n' | ||
| import { NcButton, NcTextField } from '@nextcloud/vue' | ||
| import PlusIcon from 'vue-material-design-icons/Plus.vue' | ||
| import CloseIcon from 'vue-material-design-icons/Close.vue' | ||
| import { showError } from '@nextcloud/dialogs' | ||
|
|
||
| const pollStore = usePollStore() | ||
|
|
||
| // Parse chosenRank string from store into array | ||
| const internalChosenRank = ref([]) | ||
| const selectedOption = ref(null) | ||
| const newOption = ref('') | ||
|
|
||
| onMounted(() => { | ||
| try { | ||
| const initialValue = JSON.parse(pollStore.configuration.chosenRank || '[]') | ||
| if (Array.isArray(initialValue)) { | ||
| internalChosenRank.value = initialValue | ||
| } else { | ||
| internalChosenRank.value = [initialValue] | ||
| } | ||
| if (internalChosenRank.value.length > 0) { | ||
| selectedOption.value = internalChosenRank.value[0] | ||
| } | ||
| } catch (e) { | ||
| console.error('Erreur de parsing chosenRank:', e) | ||
| internalChosenRank.value = [] | ||
| } | ||
| }) | ||
|
|
||
| // update in store + API | ||
| async function updateChosenRank(newValue) { | ||
| try { | ||
| await pollStore.setChosenRank(newValue) | ||
| await pollStore.write() | ||
| } catch (err) { | ||
| console.error('Update failed:', err) | ||
| showError(t('polls', 'Failed to update options')) | ||
| } | ||
| } | ||
|
|
||
| async function addOption() { | ||
| const value = newOption.value.trim() | ||
| if (value && !internalChosenRank.value.includes(value)) { | ||
| const updated = [...internalChosenRank.value, value].sort() | ||
| internalChosenRank.value = updated | ||
| newOption.value = '' | ||
| selectedOption.value = updated[0] | ||
| await updateChosenRank(updated) | ||
| } | ||
| } | ||
|
|
||
| async function removeOption() { | ||
| const updated = internalChosenRank.value.filter( | ||
| (o) => o !== selectedOption.value, | ||
| ) | ||
| internalChosenRank.value = updated | ||
| selectedOption.value = updated[0] || null | ||
| await updateChosenRank(updated) | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .option-container { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 8px; | ||
| margin-bottom: 8px; | ||
| } | ||
|
|
||
| .nc-text-field { | ||
| flex-grow: 1; | ||
| margin-right: 8px; | ||
| margin-bottom: 8px; | ||
| width: 100px; | ||
| } | ||
|
|
||
| .option-item { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 4px; | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.