1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
<!--
- @copyright Copyright (c) 2019 Marco Ambrosini <marcoambrosini@pm.me>
-
- @author Marco Ambrosini <marcoambrosini@pm.me>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<template>
<Modal
size="full"
@close="onCancel">
<!-- Wrapper for content & navigation -->
<div class="entity-picker">
<!-- Search -->
<div class="entity-picker__new">
<input
ref="input"
v-model="circleName"
:placeholder="t('contacts', 'New circle name')"
class="entity-picker__new-input"
type="text"
@keypress.enter="onSubmit">
</div>
<div class="entity-picker__content">
<p> {{ t('contacts', 'Circles allow you to create groups with other users on a Nextcloud instance and share with them.') }}</p>
<br>
<!-- Personal circle, TODO: IMPLEMENT -->
<template v-if="false">
<CheckboxRadioSwitch
:checked.sync="isPersonal"
:disabled="loading !== false">
{{ t('contacts', 'Personal circle') }}
</CheckboxRadioSwitch>
<p>
{{ t('contacts', 'This circle will only be visible to you. Other members will not be able to see or use it.') }}
</p>
</template>
<!-- Local circle -->
<template v-if="isGlobalScale">
<CheckboxRadioSwitch
:checked.sync="isLocal"
:disabled="loading !== false">
{{ t('contacts', 'Local circle') }}
</CheckboxRadioSwitch>
<p>
{{ t('contacts', 'This circle will not be shared with the other instances of the global scale') }}
</p>
</template>
</div>
<div class="entity-picker__navigation">
<button
class="navigation__button-left"
@click="onCancel">
{{ t('contacts', 'Cancel') }}
</button>
<button
:disabled="isEmptyName"
class="navigation__button-right primary"
@click="onSubmit">
{{ t('contacts', 'Create circle') }}
</button>
</div>
</div>
</modal>
</template>
<script>
import { getCapabilities } from '@nextcloud/capabilities'
import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/CheckboxRadioSwitch'
import Modal from '@nextcloud/vue/dist/Components/Modal'
export default {
name: 'NewCircleIntro',
components: {
CheckboxRadioSwitch,
Modal,
},
props: {
loading: {
type: Boolean,
default: false,
},
},
data() {
return {
circleName: '',
isPersonal: false,
isLocal: false,
}
},
computed: {
isEmptyName() {
return this.circleName.trim() === ''
},
isGlobalScale() {
return getCapabilities().circles?.status?.globalScale !== false
},
},
mounted() {
this.$nextTick(() => {
this.$refs.input.focus()
this.$refs.input.select()
})
},
methods: {
onCancel() {
/**
* Emitted when the user closed or cancelled
*/
this.$emit('close')
},
onSubmit() {
/**
* Emitted when user submit the form
* @type {Array} the selected entities
*/
this.$emit('submit', this.circleName, this.isPersonal, this.isLocal)
},
},
}
</script>
<style lang="scss" scoped>
// Dialog variables
$dialog-margin: 20px;
$dialog-width: 320px;
$dialog-height: 480px;
$entity-spacing: 4px;
// https://uxplanet.org/7-rules-for-mobile-ui-button-design-e9cf2ea54556
// recommended is 48px
// 44px is what we choose and have very good visual-to-usability ratio
$clickable-area: 44px;
// background icon size
// also used for the scss icon font
$icon-size: 16px;
// icon padding for a $clickable-area width and a $icon-size icon
// ( 44px - 16px ) / 2
$icon-margin: ($clickable-area - $icon-size) / 2;
.entity-picker {
position: relative;
display: flex;
flex-direction: column;
justify-content: space-between;
/** This next 2 rules are pretty hacky, with the modal component somehow
the margin applied to the content is added to the total modal width,
so here we subtract it to the width and height of the content.
*/
width: $dialog-width;
max-width: 100vw;
height: $dialog-height;
max-height: calc(100vh - #{$dialog-margin} * 2 - 10px);
margin: $dialog-margin;
&__new {
position: relative;
display: flex;
align-items: center;
&-input {
width: 100%;
height: $clickable-area - $entity-spacing !important;
margin: $entity-spacing 0;
font-size: 16px;
line-height: $clickable-area - $entity-spacing;
}
}
&__content {
flex: 1 1 100%;
padding: 20px 0;
}
&__navigation {
z-index: 1;
display: flex;
// define our base width, no shrinkage
flex: 0 0;
justify-content: space-between;
// Same as above
width: 100%;
box-shadow: 0 -10px 5px var(--color-main-background);
&__button-right {
margin-left: auto;
}
}
}
// Make the checkboxes span full width
::v-deep .checkbox-radio-switch__label {
width: 100%;
}
// Properly center Entity Picker empty content
.empty-content {
margin: 0;
}
/** Size full in the modal component doesn't have border radius, this adds
it back */
::v-deep .modal-container {
border-radius: var(--border-radius-large) !important;
}
</style>
|