Skip to content

Commit 46201f4

Browse files
committed
Merge branch 'app' into app-publish
2 parents bfbf2ff + 73d2731 commit 46201f4

30 files changed

+529
-174
lines changed

api/ChatAPI.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,8 @@ export default class ChatAPI extends BaseAPI {
111111
typing(chatid) {
112112
return this.$post('/chatrooms', { id: chatid, action: 'Typing' })
113113
}
114+
115+
referToSupport(chatid) {
116+
return this.$post('/chatrooms', { id: chatid, action: 'ReferToSupport' })
117+
}
114118
}

components/ChatFooter.vue

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@
123123
<external-link v-if="chat && chat.chattype === 'User2Mod' && mod" href="https://discourse.ilovefreegle.org/c/central" class="nocolor btn btn-secondary">
124124
<v-icon name="question-circle" /> Central
125125
</external-link>
126-
<ModSpammerReport v-if="showSpamModal" ref="spamConfirm" :user="otheruser" />
126+
<b-btn
127+
v-if="chat && chat.chattype === 'User2Mod' && mod"
128+
v-b-tooltip.hover.top
129+
title="Ask Support for help"
130+
variant="secondary"
131+
@click="confirmReferToSupport"
132+
>
133+
<v-icon name="question-circle" /> Refer to Support
134+
</b-btn>
127135
</span>
128136
<b-btn variant="primary" class="float-right ml-1" @click="send">
129137
Send&nbsp;
@@ -168,6 +176,12 @@
168176
Central
169177
</div>
170178
</div>
179+
<div v-if="chat && chat.chattype === 'User2Mod' && mod" v-b-tooltip.hover.top title="Ask Support for help" class="mr-2" @click="confirmReferToSupport">
180+
<v-icon scale="2" name="question-circle" class="fa-mob" />
181+
<div class="mobtext text--smallest">
182+
Support
183+
</div>
184+
</div>
171185
<div v-if="chat && chat.chattype === 'User2User' && otheruser && !tooSoonToNudge && !simple" v-b-tooltip.hover.top title="Waiting for a reply? Nudge this freegler." class="mr-2" @click="nudge">
172186
<v-icon scale="2" name="bell" class="fa-mob" />
173187
<div class="mobtext text--smallest">
@@ -206,6 +220,8 @@
206220
<NudgeTooSoonWarningModal ref="nudgetoosoonwarning" @confirm="doNudge" />
207221
<NudgeWarningModal ref="nudgewarning" @confirm="doNudge" />
208222
<MicroVolunteering v-if="showMicrovolunteering" />
223+
<ConfirmModal ref="referConfirm" title="Refer this chat to Support?" message="The Support volunteers will have a look at the chat and get back to you by email." @confirm="referToSupport" />
224+
<ModSpammerReport v-if="showSpamModal" ref="spamConfirm" :user="otheruser" />
209225
</div>
210226
</template>
211227
<script>
@@ -215,6 +231,7 @@ import chat from '@/mixins/chat.js'
215231
import chatCollate from '@/mixins/chatCollate.js'
216232
import ExternalLink from './ExternalLink'
217233
import ModComments from './ModComments'
234+
import ConfirmModal from '~/components/ConfirmModal'
218235
219236
// Don't use dynamic imports because it stops us being able to scroll to the bottom after render.
220237
Vue.use(TooltipPlugin)
@@ -245,7 +262,8 @@ export default {
245262
ProfileModal,
246263
AddressModal,
247264
ChatRSVPModal,
248-
MicroVolunteering
265+
MicroVolunteering,
266+
ConfirmModal
249267
},
250268
mixins: [chat, chatCollate],
251269
data: function() {
@@ -297,6 +315,14 @@ export default {
297315
})
298316
299317
setTimeout(this.saveDraft, 5000)
318+
},
319+
async referToSupport() {
320+
await this.$store.dispatch('chats/referToSupport', {
321+
id: this.id
322+
})
323+
},
324+
confirmReferToSupport() {
325+
this.$refs.referConfirm.show()
300326
}
301327
}
302328
}

components/GroupSelect.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ export default {
103103
type: Boolean,
104104
required: false,
105105
default: false
106+
},
107+
disabledExceptFor: {
108+
type: Array,
109+
required: false,
110+
default: null
106111
}
107112
},
108113
computed: {
@@ -153,7 +158,7 @@ export default {
153158
},
154159
155160
groupOptions() {
156-
const groups = []
161+
let groups = []
157162
158163
if (this.all) {
159164
groups.push({
@@ -218,6 +223,14 @@ export default {
218223
}
219224
}
220225
226+
if (this.disabledExceptFor !== null) {
227+
// Only show groups they are a member of. Mods are expected to add them if they want them to post on other
228+
// groups.
229+
groups = groups.filter(g => {
230+
return this.disabledExceptFor.includes(g.value)
231+
})
232+
}
233+
221234
return groups
222235
},
223236
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<template>
2+
<div>
3+
<b-modal
4+
id="banMemberModal"
5+
v-model="showModal"
6+
title="Ban Member"
7+
size="lg"
8+
no-stacking
9+
>
10+
<template slot="default">
11+
<NoticeMessage v-if="homeGroup" variant="danger" class="mb-2">
12+
<p>
13+
You are banning this member on their home group. This should be an absolute last resort - it's
14+
basically stopping them using Freegle at all.
15+
</p>
16+
<p>
17+
Please don't ban members on their home group because they've joined other groups. Let those other
18+
groups ban them if they wish.
19+
</p>
20+
</NoticeMessage>
21+
<NoticeMessage v-else variant="info" class="mb-2">
22+
Please be responsible in how you use this feature - it should
23+
be a last resort.
24+
</NoticeMessage>
25+
</template>
26+
<template slot="modal-footer" slot-scope="{ cancel }">
27+
<b-button variant="white" @click="cancel">
28+
Close
29+
</b-button>
30+
<b-button variant="primary" :disabled="!userid" @click="ban">
31+
Ban
32+
</b-button>
33+
</template>
34+
</b-modal>
35+
</div>
36+
</template>
37+
<script>
38+
import modal from '@/mixins/modal'
39+
import NoticeMessage from './NoticeMessage'
40+
41+
export default {
42+
components: { NoticeMessage },
43+
mixins: [modal],
44+
props: {
45+
userid: {
46+
type: Number,
47+
required: true
48+
},
49+
groupid: {
50+
type: Number,
51+
required: true
52+
}
53+
},
54+
data: function() {
55+
return {
56+
homeGroup: false
57+
}
58+
},
59+
computed: {
60+
group() {
61+
return this.$store.getters['group/get'](this.groupid)
62+
},
63+
user() {
64+
return this.$store.getters['user/get'](this.userid)
65+
}
66+
},
67+
mounted() {
68+
const area = this.group.poly || this.group.polyofficial
69+
console.log('Area', area)
70+
71+
const Wkt = require('wicket')
72+
const wkt = new Wkt.Wkt()
73+
wkt.read(area)
74+
const obj = wkt.toObject()
75+
const bounds = obj.getBounds()
76+
console.log('Bounds', bounds, this.user)
77+
78+
const lat = this.user.settings?.mylocation?.lat
79+
const lng = this.user.settings?.mylocation?.lng
80+
console.log(
81+
'Check home',
82+
this.user.memberof.length,
83+
bounds,
84+
lat,
85+
lng,
86+
bounds.contains([lat, lng])
87+
)
88+
89+
if (this.user.memberof.length === 1 || bounds.contains([lat, lng])) {
90+
this.homeGroup = true
91+
}
92+
},
93+
methods: {
94+
ban() {
95+
this.$emit('confirm')
96+
this.hide()
97+
}
98+
}
99+
}
100+
</script>

components/ModBanMemberModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<b-modal
4-
id="addMemberModal"
4+
id="banMemberModal"
55
v-model="showModal"
66
title="Ban Member"
77
size="lg"

components/ModChatModal.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<v-icon name="hashtag" class="text-muted" scale="0.8" />{{ user1.id }}
2323
</span>
2424
</div>
25+
<div v-if="chat2 && chat2.group">
26+
{{ chat2.group.namedisplay }} Volunteers
27+
</div>
2528
</div>
2629
<div v-else class="d-flex justify-content-between">
2730
<div v-if="user1">
@@ -36,6 +39,9 @@
3639
<v-icon name="hashtag" class="text-muted" scale="0.8" />{{ user2.id }}
3740
</span>
3841
</div>
42+
<div v-if="chat2 && chat2.group">
43+
{{ chat2.group.namedisplay }} Volunteers
44+
</div>
3945
</div>
4046
</div>
4147
</template>

components/ModChatNoteModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<b-button variant="white" @click="cancel">
3131
Close
3232
</b-button>
33-
<b-button variant="primary" @click="addit">
33+
<b-button variant="primary" :disabled="!note" @click="addit">
3434
Add Mod Message
3535
</b-button>
3636
</template>

components/ModChatReviewUser.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default {
5252
email() {
5353
let ret = null
5454
55-
if (this.user) {
55+
if (this.user && this.user.emails) {
5656
this.user.emails.forEach(e => {
5757
if (!e.ourdomain && (!ret || e.preferred)) {
5858
ret = e.email

components/ModMemberActions.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</b-btn>
1818
<ConfirmModal v-if="removeConfirm && groupname" ref="removeConfirm" :title="'Remove ' + displayname + ' from ' + groupname + '?'" @confirm="removeConfirmed" />
1919
<ConfirmModal v-if="removeConfirm && !groupname" ref="removeConfirm" title="Please select a group first." />
20-
<ConfirmModal v-if="banConfirm" ref="banConfirm" :title="'Ban ' + displayname + ' from ' + groupname + '?'" @confirm="banConfirmed" />
20+
<ModBanMemberConfirmModal v-if="banConfirm" ref="banConfirm" :userid="userid" :groupid="groupid" @confirm="banConfirmed" />
2121
<ModCommentAddModal v-if="addComment" ref="addComment" :user="user" :groupid="groupid" @added="updateComments" />
2222
<ModSpammerReport v-if="showSpamModal" ref="spamConfirm" :user="reportUser" :whitelist="whitelist" />
2323
</div>
@@ -26,9 +26,15 @@
2626
import ModCommentAddModal from './ModCommentAddModal'
2727
import ModSpammerReport from './ModSpammerReport'
2828
const ConfirmModal = () => import('./ConfirmModal')
29+
const ModBanMemberConfirmModal = () => import('./ModBanMemberConfirmModal')
2930
3031
export default {
31-
components: { ModSpammerReport, ModCommentAddModal, ConfirmModal },
32+
components: {
33+
ModSpammerReport,
34+
ModCommentAddModal,
35+
ConfirmModal,
36+
ModBanMemberConfirmModal
37+
},
3238
3339
props: {
3440
userid: {

components/ModMessage.vue

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="d-flex justify-content-between">
77
<div class="flex-grow-1">
88
<div v-if="editing" class="d-flex flex-wrap">
9-
<GroupSelect v-model="editgroup" modonly class="mr-1" size="lg" />
9+
<GroupSelect v-model="editgroup" modonly class="mr-1" size="lg" :disabled-except-for="memberGroupIds" />
1010
<div v-if="message.item && message.location" class="d-flex justify-content-start">
1111
<b-select v-model="message.type" :options="typeOptions" class="type mr-1" size="lg" />
1212
<b-input v-model="message.item.name" size="lg" class="mr-1" />
@@ -63,13 +63,22 @@
6363
{{ message.fromuser.displayname }}
6464
</div>
6565
<div v-if="expanded" class="d-flex">
66-
<div>
67-
<b-btn v-if="message.source === 'Email'" variant="white" @click="viewSource">
68-
<v-icon name="book-open" /><span class="d-none d-sm-inline"> View Email Source</span>
69-
</b-btn>
66+
<div class="d-flex flex-column align-content-end">
7067
<b-btn v-if="!editing" variant="white" @click="startEdit">
7168
<v-icon name="pen" /><span class="d-none d-sm-inline"> Edit</span>
7269
</b-btn>
70+
<b-btn v-if="message.source === 'Email'" variant="white" class="mt-2" @click="viewSource">
71+
<v-icon name="book-open" /><span class="d-none d-sm-inline"> View Email Source</span>
72+
</b-btn>
73+
<SpinButton
74+
v-if="message.groups[0].collection === 'Approved'"
75+
class="mt-2"
76+
variant="white"
77+
:handler="backToPending"
78+
name="reply"
79+
label="Back to Pending"
80+
confirm
81+
/>
7382
</div>
7483
<div class="ml-2">
7584
<b-btn v-if="summary" variant="white" @click="expanded = !expanded">
@@ -350,6 +359,7 @@ import GroupSelect from './GroupSelect'
350359
import MessageMap from './MessageMap'
351360
import ModMessageMicroVolunteering from './ModMessageMicroVolunteering'
352361
import twem from '~/assets/js/twem'
362+
import SpinButton from '~/components/SpinButton'
353363
const Highlighter = () => import('vue-highlight-words')
354364
const OurFilePond = () => import('~/components/OurFilePond')
355365
@@ -378,7 +388,8 @@ export default {
378388
MessageReplyInfo,
379389
MessageUserInfo,
380390
MessageHistory,
381-
Highlighter
391+
Highlighter,
392+
SpinButton
382393
},
383394
mixins: [keywords],
384395
props: {
@@ -622,6 +633,13 @@ export default {
622633
},
623634
duplicates() {
624635
return this.checkHistory(true)
636+
},
637+
memberGroupIds() {
638+
return this.message &&
639+
this.message.fromuser &&
640+
this.message.fromuser.memberof
641+
? this.message.fromuser.memberof.map(g => g.id)
642+
: []
625643
}
626644
},
627645
watch: {
@@ -880,6 +898,11 @@ export default {
880898
this.$store.dispatch('messages/fetch', {
881899
id: this.message.id
882900
})
901+
},
902+
backToPending() {
903+
this.$store.dispatch('messages/backToPending', {
904+
id: this.message.id
905+
})
883906
}
884907
}
885908
}

0 commit comments

Comments
 (0)