21
21
</NcActions>
22
22
<NcDialog :open.sync="editModalOpen"
23
23
:name="t('mail','Edit snippet')"
24
+ size="large"
24
25
:is-form="true"
25
- :buttons="buttons"
26
- size="normal" >
26
+ :buttons="buttons">
27
+ <h2>{{ t('mail','Content') }}</h2 >
27
28
<NcInputField :value.sync="localSnippet.title" :label="t('mail','Title of the snippet')" />
28
29
<TextEditor v-model="localSnippet.content"
29
30
:html="true"
30
31
:placeholder="t('mail','Content of the snippet')"
31
32
:bus="bus" />
33
+ <h2>{{ t('mail','Shares') }}</h2>
32
34
<NcSelect v-if="!shared"
33
35
v-model="share"
34
- :label="t('mail','Share with')"
35
36
class="snippet-list-item__shares"
36
37
:loading="loading"
37
38
:user-select="true"
38
39
:options="options"
39
40
:get-option-label="option => option.displayName"
40
41
@option:selecting="shareSnippet"
41
42
@search="asyncFind" />
42
- <p v-for="user in shares" :key="user.shareWith">
43
- {{ user.shareWith }}
44
- <NcActionButton icon="icon-delete" @click="removeShare(user)">
45
- {{ t('mail','Remove share') }}
46
- </NcActionButton>
47
- </p>
43
+ <template v-for="user in sortedShares">
44
+ <NcUserBubble v-if="user.type === 'group'"
45
+ :key="user.shareWith"
46
+ avatar-image="icon-group"
47
+ :display-name="user.shareWith">
48
+ <template #name>
49
+ <a href="#"
50
+ title="Remove group"
51
+ class="icon-close"
52
+ @click="removeShare(user)" />
53
+ </template>
54
+ </NcUserBubble>
55
+ <NcUserBubble v-else :key="user.shareWith" :user="user.shareWith">
56
+ <template #name>
57
+ <a href="#"
58
+ title="Remove user"
59
+ class="icon-close"
60
+ @click="removeShare(user)" />
61
+ </template>
62
+ </NcUserBubble>
63
+ </template>
48
64
</NcDialog>
49
65
</div>
50
66
</template>
51
67
52
68
<script>
53
- import { NcActions, NcActionButton, NcSelect, NcDialog, NcInputField } from '@nextcloud/vue'
69
+ import { NcActions, NcActionButton, NcSelect, NcDialog, NcInputField, NcUserBubble } from '@nextcloud/vue'
54
70
import { getShares, shareSnippet, unshareSnippet } from '../../service/SnippetService.js'
55
71
import TextEditor from '../TextEditor.vue'
56
72
import { showError, showSuccess } from '@nextcloud/dialogs'
@@ -73,6 +89,7 @@ export default {
73
89
NcDialog,
74
90
TextEditor,
75
91
NcInputField,
92
+ NcUserBubble,
76
93
},
77
94
props: {
78
95
snippet: {
@@ -115,6 +132,17 @@ export default {
115
132
options() {
116
133
return this.suggestions.filter(suggestion => !this.shares.find(share => share.name === suggestion.shareWith) && suggestion.shareWith !== getCurrentUser().uid)
117
134
},
135
+ sortedShares() {
136
+ return [...this.shares].sort((a, b) => {
137
+ if (a.type === 'user' && b.type === 'group') {
138
+ return -1
139
+ }
140
+ if (a.type === 'group' && b.type === 'user') {
141
+ return 1
142
+ }
143
+ return 0
144
+ })
145
+ },
118
146
},
119
147
async mounted() {
120
148
if (!this.shared) {
@@ -141,7 +169,7 @@ export default {
141
169
async removeShare(sharee) {
142
170
await unshareSnippet(this.snippet.id, sharee.shareWith).then(() => {
143
171
this.shares = this.shares.filter(share => share.shareWith !== sharee.shareWith)
144
- showSuccess(t('mail', 'Share deleted for {sharee }', { sharee }))
172
+ showSuccess(t('mail', 'Share deleted for {name }', { name: sharee.shareWith }))
145
173
}).catch(() => {
146
174
showError(t('mail', 'Failed to delete share with {name}', { name: sharee.shareWith }))
147
175
})
@@ -273,10 +301,10 @@ export default {
273
301
274
302
<style lang="scss" scoped>
275
303
.snippet-list-item{
276
- display: flex ;
277
- justify-content: space-between ;
278
- align-items: center ;
279
- padding: 5px;
304
+ display: grid ;
305
+ grid-template-columns: 1fr 4fr 1fr ;
306
+ gap: 5px ;
307
+ padding: 5px;
280
308
&__title{
281
309
white-space: nowrap;
282
310
padding-inline-end: 30px;
@@ -293,4 +321,8 @@ export default {
293
321
width: 100%;
294
322
}
295
323
}
324
+ .icon-close {
325
+ display: block;
326
+ height: 100%;
327
+ }
296
328
</style>
0 commit comments