Skip to content

Commit 1cc707e

Browse files
authored
Merge pull request #7189 from LibreSign/backport/7181/stable32
[stable32] chore: migration to vue3
2 parents 9ca2484 + 0b06d09 commit 1cc707e

33 files changed

Lines changed: 1436 additions & 1506 deletions

src/components/InputAction/InputAction.vue

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,45 @@
1313
</form>
1414
</template>
1515

16-
<script>
16+
<script setup lang="ts">
1717
import { t } from '@nextcloud/l10n'
18+
import { ref } from 'vue'
1819
19-
export default {
20+
defineOptions({
2021
name: 'InputAction',
21-
emits: ['submit'],
22-
props: {
23-
type: {
24-
type: String,
25-
required: false,
26-
default: 'text',
27-
},
28-
placeholder: {
29-
type: String,
30-
required: false,
31-
default: '',
32-
},
33-
disabled: {
34-
type: Boolean,
35-
required: false,
36-
default: false,
37-
},
38-
loading: {
39-
type: Boolean,
40-
required: false,
41-
default: false,
42-
},
43-
},
22+
})
4423
45-
data() {
46-
return {
47-
value: '',
48-
}
49-
},
24+
withDefaults(defineProps<{
25+
type?: string
26+
placeholder?: string
27+
disabled?: boolean
28+
loading?: boolean
29+
}>(), {
30+
type: 'text',
31+
placeholder: '',
32+
disabled: false,
33+
loading: false,
34+
})
5035
51-
methods: {
52-
t,
53-
clearInput() {
54-
this.value = ''
55-
},
56-
onSubmit(event) {
57-
this.$emit('submit', this.value)
58-
},
59-
},
36+
const emit = defineEmits<{
37+
(e: 'submit', value: string): void
38+
}>()
39+
40+
const value = ref('')
41+
42+
function clearInput() {
43+
value.value = ''
6044
}
45+
46+
function onSubmit() {
47+
emit('submit', value.value)
48+
}
49+
50+
defineExpose({
51+
value,
52+
clearInput,
53+
onSubmit,
54+
})
6155
</script>
6256

6357
<style lang="scss" scoped>

src/components/LeftSidebar/LeftSidebar.vue

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@
5858
</NcAppNavigation>
5959
</template>
6060

61-
<script>
61+
<script setup lang="ts">
6262
import { t } from '@nextcloud/l10n'
63+
import { computed } from 'vue'
64+
import { getCurrentInstance } from 'vue'
6365
import {
6466
mdiAccountCheck,
6567
mdiFileCheck,
@@ -81,51 +83,37 @@ import Settings from '../Settings/Settings.vue'
8183
8284
import { useFilesStore } from '../../store/files.js'
8385
84-
export default {
86+
defineOptions({
8587
name: 'LeftSidebar',
86-
components: {
87-
NcAppNavigation,
88-
NcAppNavigationItem,
89-
NcAppNavigationSettings,
90-
NcIconSvgWrapper,
91-
Settings,
92-
},
93-
setup() {
94-
const filesStore = useFilesStore()
95-
return {
96-
filesStore,
97-
mdiFileSign,
98-
mdiFolder,
99-
mdiFileCheck,
100-
mdiAccountCheck,
101-
mdiShieldLock,
102-
}
103-
},
104-
data() {
105-
return {
106-
canRequestSign: loadState('libresign', 'can_request_sign', false),
107-
config: loadState('libresign', 'config', {
108-
identificationDocumentsFlow: false,
109-
isApprover: false,
110-
}),
111-
}
112-
},
113-
computed: {
114-
isAdmin() {
115-
const user = getCurrentUser()
116-
return user?.isAdmin ?? false
117-
},
118-
},
119-
methods: {
120-
t,
121-
unselectFile() {
122-
this.filesStore.selectFile()
123-
},
124-
goToSign() {
125-
const route = this.$router.resolve({ name: 'SignPDF' })
88+
})
12689
127-
window.location = route.href
128-
},
129-
},
90+
const filesStore = useFilesStore()
91+
const canRequestSign = loadState('libresign', 'can_request_sign', false)
92+
const config = loadState('libresign', 'config', {
93+
identificationDocumentsFlow: false,
94+
isApprover: false,
95+
})
96+
97+
const isAdmin = computed(() => {
98+
const user = getCurrentUser()
99+
return user?.isAdmin ?? false
100+
})
101+
102+
function unselectFile() {
103+
filesStore.selectFile()
130104
}
105+
106+
function goToSign() {
107+
const router = getCurrentInstance()?.proxy?.$router
108+
if (!router) {
109+
return
110+
}
111+
const route = router.resolve({ name: 'SignPDF' })
112+
window.location = route.href as unknown as Location
113+
}
114+
115+
defineExpose({
116+
isAdmin,
117+
goToSign,
118+
})
131119
</script>

src/components/Request/SignDetail/partials/SignerRow.vue

Lines changed: 49 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -23,76 +23,65 @@
2323
</NcListItem>
2424
</template>
2525

26-
<script>
26+
<script setup lang="ts">
2727
import { t } from '@nextcloud/l10n'
28+
import { computed } from 'vue'
2829
2930
import { emit } from '@nextcloud/event-bus'
3031
import Moment from '@nextcloud/moment'
3132
3233
import NcAvatar from '@nextcloud/vue/components/NcAvatar'
3334
import NcListItem from '@nextcloud/vue/components/NcListItem'
3435
35-
export default {
36+
defineOptions({
3637
name: 'SignerRow',
3738
inheritAttrs: false,
38-
components: {
39-
NcListItem,
40-
NcAvatar,
41-
},
42-
props: {
43-
signer: {
44-
type: Object,
45-
required: true,
46-
},
47-
to: {
48-
type: Object,
49-
required: false,
50-
default: undefined,
51-
},
52-
event: {
53-
type: String,
54-
required: false,
55-
default: '',
56-
},
57-
},
58-
computed: {
59-
displayName() {
60-
const { signer } = this
61-
62-
if (signer.displayName) {
63-
return signer.displayName
64-
}
65-
66-
if (signer.email) {
67-
return signer.email
68-
}
69-
70-
return t('libresign', 'Account does not exist')
71-
},
72-
status() {
73-
const { signer } = this
74-
return signer.signed ? 'signed' : 'pending'
75-
},
76-
signDate() {
77-
const { signer } = this
78-
79-
return signer.signed
80-
? Moment(signer.signed, 'YYYY-MM-DD').toDate()
81-
: ''
82-
},
83-
element() {
84-
return this.signer.element || {}
85-
},
86-
hasElement() {
87-
return this.element.elementId > 0
88-
},
89-
},
90-
methods: {
91-
t,
92-
signerClickAction(signer) {
93-
emit(this.event, this.signer)
94-
},
95-
},
39+
})
40+
41+
type Signer = {
42+
displayName?: string
43+
email?: string
44+
signed?: string | boolean
45+
element?: {
46+
elementId?: number
47+
}
48+
}
49+
50+
const props = withDefaults(defineProps<{
51+
signer: Signer
52+
to?: Record<string, unknown>
53+
event?: string
54+
}>(), {
55+
to: undefined,
56+
event: '',
57+
})
58+
59+
const displayName = computed(() => {
60+
if (props.signer.displayName) {
61+
return props.signer.displayName
62+
}
63+
64+
if (props.signer.email) {
65+
return props.signer.email
66+
}
67+
68+
return t('libresign', 'Account does not exist')
69+
})
70+
71+
const status = computed(() => (props.signer.signed ? 'signed' : 'pending'))
72+
73+
const signDate = computed(() => (
74+
props.signer.signed
75+
? Moment(props.signer.signed, 'YYYY-MM-DD').toDate()
76+
: ''
77+
))
78+
79+
const element = computed(() => props.signer.element || {})
80+
81+
const hasElement = computed(() => (element.value.elementId || 0) > 0)
82+
83+
function signerClickAction() {
84+
emit(props.event, props.signer)
9685
}
9786
</script>
9887

0 commit comments

Comments
 (0)