Skip to content

Commit 348062d

Browse files
authored
Merge pull request #4028 from nextcloud/fix/misc-fixes
Some minor fixes/changes
2 parents 47ab8b3 + 8d097a1 commit 348062d

11 files changed

Lines changed: 64 additions & 52 deletions

File tree

lib/Db/Poll.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public function getConfigurationArray(): array {
257257
'allowProposals' => $this->getAllowProposals(),
258258
'anonymous' => boolval($this->getAnonymous()),
259259
'autoReminder' => $this->getAutoReminder(),
260+
'collapseDescription' => $this->getCollapseDescription(),
260261
'description' => $this->getDescription(),
261262
'expire' => $this->getExpire(),
262263
'hideBookedUp' => boolval($this->getHideBookedUp()),
@@ -322,6 +323,7 @@ public function deserializeArray(array $pollConfiguration): self {
322323
$this->setAllowProposals($pollConfiguration['allowProposals'] ?? $this->getAllowProposals());
323324
$this->setAnonymousSafe($pollConfiguration['anonymous'] ?? $this->getAnonymous());
324325
$this->setAutoReminder($pollConfiguration['autoReminder'] ?? $this->getAutoReminder());
326+
$this->setCollapseDescription($pollConfiguration['collapseDescription'] ?? $this->getCollapseDescription());
325327
$this->setExpire($pollConfiguration['expire'] ?? $this->getExpire());
326328
$this->setHideBookedUp($pollConfiguration['hideBookedUp'] ?? $this->getHideBookedUp());
327329
$this->setProposalsExpire($pollConfiguration['proposalsExpire'] ?? $this->getProposalsExpire());
@@ -389,10 +391,18 @@ private function setAutoReminder(bool|int $value): void {
389391
$this->setMiscSettingsByKey('autoReminder', (bool)$value);
390392
}
391393

394+
private function setCollapseDescription(bool|int $value): void {
395+
$this->setMiscSettingsByKey('collapseDescription', (bool)$value);
396+
}
397+
392398
private function getAutoReminder(): bool {
393399
return $this->getMiscSettingsArray()['autoReminder'] ?? false;
394400
}
395401

402+
private function getCollapseDescription(): bool {
403+
return $this->getMiscSettingsArray()['collapseDescription'] ?? true;
404+
}
405+
396406
// alias of getId()
397407
public function getPollId(): int {
398408
return $this->getId();

lib/Model/UserBase.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ public function getIsGuest(): bool {
154154
* used for telling internal from guest users
155155
*/
156156
public function getSimpleType(): string {
157-
return in_array($this->type, [User::TYPE, Admin::TYPE]) ? self::TYPE_USER : self::TYPE_GUEST;
157+
if (in_array($this->type, [User::TYPE, Admin::TYPE])) {
158+
return self::TYPE_USER;
159+
} elseif ($this->type === Ghost::TYPE) {
160+
return self::TYPE_GHOST;
161+
}
162+
163+
return self::TYPE_GUEST;
158164
}
159165

160166
public function getLanguageCode(): string {

src/components/Actions/modules/ActionAddOption.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import NcButton from '@nextcloud/vue/components/NcButton'
1111
import AddDateIcon from 'vue-material-design-icons/CalendarPlus.vue'
1212
import { Event } from '../../../Types'
1313
14-
const caption = defineProps<{ caption?: string }>()
14+
const { caption } = defineProps<{ caption?: string }>()
1515
const buttonAriaLabel = computed(() => caption ?? t('polls', 'Add option'))
1616
1717
async function clickAction() {

src/components/Base/modules/Collapsible.vue

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,76 +4,63 @@
44
-->
55

66
<script setup lang="ts">
7-
import { t } from '@nextcloud/l10n'
87
import { ref } from 'vue'
98
109
interface Props {
1110
initialCollapsed?: boolean
1211
noCollapse?: boolean
13-
showMoreCaption?: string
14-
closeCaption?: string
1512
}
16-
const {
17-
initialCollapsed = false,
18-
noCollapse = false,
19-
showMoreCaption = t('polls', 'Show more'),
20-
closeCaption = t('polls', 'Collapse'),
21-
} = defineProps<Props>()
13+
const { initialCollapsed = false, noCollapse = false } = defineProps<Props>()
2214
2315
const showMore = ref(!initialCollapsed || noCollapse)
2416
</script>
2517

2618
<template>
2719
<div class="collapsible">
20+
<div
21+
v-show="!noCollapse"
22+
:class="['collapsible-toggle', { open: showMore }]"
23+
@click="showMore = !showMore"></div>
2824
<div
2925
id="collapsible_container"
3026
:class="['collapsible_container', { open: showMore || noCollapse }]">
3127
<slot />
3228
</div>
33-
<div
34-
v-show="!noCollapse"
35-
:class="['collapsible-toggle', { open: showMore }]"
36-
@click="showMore = !showMore">
37-
{{ showMore ? closeCaption : showMoreCaption }}
38-
</div>
3929
</div>
4030
</template>
4131

4232
<style lang="scss">
4333
.collapsible {
44-
overflow: hidden;
34+
display: flex;
4535
4636
.collapsible-toggle {
4737
cursor: pointer;
4838
position: relative;
4939
line-height: 2rem;
5040
font-weight: bold;
5141
white-space: nowrap;
52-
overflow: hidden;
5342
text-overflow: ellipsis;
5443
max-width: 100%;
55-
background-color: var(--color-background-plain);
56-
color: var(--color-primary-element-text);
57-
border-radius: var(--border-radius-element);
44+
padding: 0.5rem 1rem;
5845
5946
&::before {
6047
content: '\25B8';
48+
font-size: 1.5rem;
6149
margin: 0 0.3em;
6250
display: inline-block;
63-
transform: rotate(90deg);
6451
transition: transform 0.3s ease-in-out;
6552
}
6653
&.open {
6754
&::before {
68-
transform: rotate(-90deg);
55+
transform: rotate(90deg);
6956
}
7057
}
7158
}
7259
7360
.collapsible_container {
7461
transition: max-height 0.3s ease-in-out;
75-
overflow: auto;
76-
max-height: 0;
62+
max-height: 6rem;
63+
overflow: hidden;
7764
7865
background:
7966
/* Shadow covers */
@@ -137,6 +124,7 @@ const showMore = ref(!initialCollapsed || noCollapse)
137124
138125
&.open {
139126
max-height: max(51vh, 6rem);
127+
overflow: auto;
140128
}
141129
}
142130
}

src/components/Configuration/ConfigDescription.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
-->
55

66
<script setup lang="ts">
7+
import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
78
import { usePollStore } from '../../stores/poll.ts'
9+
import { t } from '@nextcloud/l10n'
810
const pollStore = usePollStore()
911
</script>
1012

@@ -13,6 +15,12 @@ const pollStore = usePollStore()
1315
v-model="pollStore.configuration.description"
1416
class="edit-description"
1517
@change="pollStore.write()" />
18+
<NcCheckboxRadioSwitch
19+
v-model="pollStore.configuration.collapseDescription"
20+
type="switch"
21+
@update:model-value="pollStore.write()">
22+
{{ t('polls', 'Collapse long descriptions') }}
23+
</NcCheckboxRadioSwitch>
1624
</template>
1725

1826
<style lang="scss">

src/components/Poll/MarkUpDescription.vue renamed to src/components/Poll/MarkDownDescription.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ const pollStore = usePollStore()
1212
<!-- eslint-disable vue/no-v-html -->
1313
<div
1414
ref="desc"
15-
class="markup-description"
16-
v-html="pollStore.descriptionMarkUp" />
15+
class="markdown-description"
16+
v-html="pollStore.descriptionMarkDown" />
1717
<!-- eslint-enable vue/no-v-html -->
1818
</template>
1919

2020
<style lang="scss">
21-
.markup-description {
22-
padding: 0.5rem;
23-
margin: 0.25rem;
21+
.markdown-description {
2422
overflow: auto;
2523
2624
* {
@@ -29,9 +27,7 @@ const pollStore = usePollStore()
2927
text-decoration: revert;
3028
list-style: inside;
3129
}
32-
}
3330
34-
.markup-description {
3531
table {
3632
border-spacing: 2px;
3733
}

src/components/Shares/SharesList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import ShareItem from './ShareItem.vue'
1616
import UserSearch from '../User/UserSearch.vue'
1717
import SharePublicAdd from './SharePublicAdd.vue'
1818
import ShareItemAllUsers from './ShareItemAllUsers.vue'
19-
import MarkUpDescription from '../Poll/MarkUpDescription.vue'
19+
import MarkDownDescription from '../Poll/MarkDownDescription.vue'
2020
2121
import { usePollStore } from '../../stores/poll.ts'
2222
import { useSharesStore, Share } from '../../stores/shares.ts'
@@ -91,7 +91,7 @@ async function addShare(user: User) {
9191
:encode-text="qrText"
9292
class="modal__content">
9393
<template #description>
94-
<MarkUpDescription />
94+
<MarkDownDescription />
9595
</template>
9696
</QrModal>
9797
</NcModal>

src/components/SideBar/SideBarTabConfiguration.vue

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,12 @@ const votesStore = useVotesStore()
3939

4040
<template>
4141
<div>
42-
<CardDiv v-if="votesStore.hasVotes" type="warning">
43-
{{
44-
t(
45-
'polls',
46-
'Please be careful when changing options, because it can affect existing votes in an unwanted manner.',
47-
)
48-
}}
42+
<CardDiv v-if="!pollStore.currentUserStatus.isOwner" type="success">
43+
{{ t('polls', 'Administrative rights are delegated to you.') }}
4944
</CardDiv>
5045

51-
<CardDiv v-if="!pollStore.currentUserStatus.isOwner" type="success">
52-
{{ t('polls', 'As an admin you may edit this poll') }}
46+
<CardDiv v-if="votesStore.hasVotes" type="warning">
47+
{{ t('polls', 'Changes may affect existing votes.') }}
5348
</CardDiv>
5449

5550
<ConfigBox :name="t('polls', 'Title')">

src/components/User/UserSearch.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface Props {
2424
2525
const emit = defineEmits(['userSelected'])
2626
27-
const modelValue = defineModel<User | null>({ required: true })
27+
const modelValue = defineModel<User | null>()
2828
2929
const {
3030
placeholder = t('polls', 'Type to start searching ...'),

src/stores/poll.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export type PollConfiguration = {
8080
allowProposals: AllowProposals
8181
anonymous: boolean
8282
autoReminder: boolean
83+
collapseDescription: boolean
8384
description: string
8485
expire: number
8586
hideBookedUp: boolean
@@ -178,6 +179,7 @@ export const usePollStore = defineStore('poll', {
178179
allowProposals: AllowProposals.Disallow,
179180
anonymous: false,
180181
autoReminder: false,
182+
collapseDescription: true,
181183
expire: 0,
182184
hideBookedUp: false,
183185
proposalsExpire: 0,
@@ -374,7 +376,7 @@ export const usePollStore = defineStore('poll', {
374376
return this.countParticipants * optionsStore.count
375377
},
376378

377-
descriptionMarkUp(): string {
379+
descriptionMarkDown(): string {
378380
marked.use(gfmHeadingId(markedPrefix))
379381
return DOMPurify.sanitize(
380382
marked.parse(this.configuration.description).toString(),

0 commit comments

Comments
 (0)