2020-07-09 17:24:28 +02:00
< template >
< div >
< nav class = "breadcrumb" aria -label = " breadcrumbs " >
< ul >
< li >
< router -link
: to = " {
name : RouteName . GROUP ,
params : { preferredUsername : usernameWithDomain ( group ) } ,
} "
> { { group . name } } < / r o u t e r - l i n k
>
< / li >
< li >
< router -link
: to = " {
name : RouteName . GROUP _SETTINGS ,
params : { preferredUsername : usernameWithDomain ( group ) } ,
} "
> { { $t ( "Settings" ) } } < / r o u t e r - l i n k
>
< / li >
< li class = "is-active" >
< router -link
: to = " {
name : RouteName . GROUP _PUBLIC _SETTINGS ,
params : { preferredUsername : usernameWithDomain ( group ) } ,
} "
> { { $t ( "Group settings" ) } } < / r o u t e r - l i n k
>
< / li >
< / ul >
< / nav >
< section class = "container section" >
< form @submit.prevent ="updateGroup" >
< b -field : label = "$t('Group name')" >
< b -input v -model = " group.name " / >
< / b - f i e l d >
< b -field : label = "$t('Group short description')" >
< b -input type = "textarea" v -model = " group.summary "
/ > < / b - f i e l d >
2020-08-05 16:44:08 +02:00
< p class = "label" > { { $t ( "Group visibility" ) } } < / p >
< div class = "field" >
< b -radio
v - model = "group.visibility"
name = "groupVisibility"
: native - value = "GroupVisibility.PUBLIC"
>
{ { $t ( "Visible everywhere on the web" ) } } < br / >
< small > { {
$t (
"The group will be publicly listed in search results and may be suggested in the explore section. Only public informations will be shown on it's page."
)
} } < / small >
< / b - r a d i o >
< / div >
< div class = "field" >
< b -radio
v - model = "group.visibility"
name = "groupVisibility"
: native - value = "GroupVisibility.UNLISTED"
> { { $t ( "Only accessible through link" ) } } < br / >
< small > { {
2020-09-02 10:00:39 +02:00
$t (
"You'll need to transmit the group URL so people may access the group's profile. The group won't be findable in Mobilizon's search or regular search engines."
)
2020-08-05 16:44:08 +02:00
} } < / small >
< / b - r a d i o >
< p class = "control" >
< code > { { group . url } } < / code >
< b -tooltip
v - if = "canShowCopyButton"
: label = "$t('URL copied to clipboard')"
: active = "showCopiedTooltip"
always
type = "is-success"
position = "is-left"
>
< b -button
type = "is-primary"
icon - right = "content-paste"
native - type = "button"
@ click = "copyURL"
@ keyup . enter = "copyURL"
/ >
< / b - t o o l t i p >
< / p >
< / div >
< full -address -auto -complete
: label = "$t('Group address')"
v - model = "group.physicalAddress"
: value = "currentAddress"
/ >
2020-08-27 11:53:24 +02:00
< div class = "buttons" >
< b -button native -type = " submit " type = "is-primary" > { { $t ( "Update group" ) } } < / b - b u t t o n >
< b -button @click ="confirmDeleteGroup" type = "is-danger" > { { $t ( "Delete group" ) } } < / b - b u t t o n >
< / div >
2020-07-09 17:24:28 +02:00
< / form >
< / section >
< / div >
< / template >
< script lang = "ts" >
import { Component , Vue } from "vue-property-decorator" ;
2020-08-31 12:40:30 +02:00
import FullAddressAutoComplete from "@/components/Event/FullAddressAutoComplete.vue" ;
2020-07-09 17:24:28 +02:00
import RouteName from "../../router/name" ;
2020-08-27 11:53:24 +02:00
import { FETCH _GROUP , UPDATE _GROUP , DELETE _GROUP } from "../../graphql/group" ;
2020-07-09 17:24:28 +02:00
import { IGroup , usernameWithDomain } from "../../types/actor" ;
2020-08-05 16:44:08 +02:00
import { Address , IAddress } from "../../types/address.model" ;
2020-07-09 17:24:28 +02:00
import { IMember , Group } from "../../types/actor/group.model" ;
import { Paginate } from "../../types/paginate" ;
@ Component ( {
apollo : {
group : {
query : FETCH _GROUP ,
2020-08-27 11:53:24 +02:00
fetchPolicy : "cache-and-network" ,
2020-07-09 17:24:28 +02:00
variables ( ) {
return {
name : this . $route . params . preferredUsername ,
} ;
} ,
skip ( ) {
return ! this . $route . params . preferredUsername ;
} ,
} ,
} ,
2020-08-05 16:44:08 +02:00
components : {
FullAddressAutoComplete ,
} ,
2020-07-09 17:24:28 +02:00
} )
export default class GroupSettings extends Vue {
group : IGroup = new Group ( ) ;
loading = true ;
RouteName = RouteName ;
newMemberUsername = "" ;
usernameWithDomain = usernameWithDomain ;
2020-08-05 16:44:08 +02:00
GroupVisibility = {
PUBLIC : "PUBLIC" ,
UNLISTED : "UNLISTED" ,
} ;
showCopiedTooltip = false ;
2020-07-09 17:24:28 +02:00
async updateGroup ( ) {
2020-08-05 16:44:08 +02:00
const variables = { ... this . group } ;
// eslint-disable-next-line
// @ts-ignore
delete variables . _ _typename ;
2020-08-27 11:53:24 +02:00
if ( variables . physicalAddress ) {
// eslint-disable-next-line
// @ts-ignore
delete variables . physicalAddress . _ _typename ;
}
2020-07-09 17:24:28 +02:00
await this . $apollo . mutate < { updateGroup : IGroup } > ( {
mutation : UPDATE _GROUP ,
2020-08-05 16:44:08 +02:00
variables ,
2020-07-09 17:24:28 +02:00
} ) ;
}
2020-08-05 16:44:08 +02:00
2020-08-27 11:53:24 +02:00
confirmDeleteGroup ( ) {
this . $buefy . dialog . confirm ( {
title : this . $t ( "Delete group" ) as string ,
message : this . $t (
"Are you sure you want to <b>completely delete</b> this group? All members - including remote ones - will be notified and removed from the group, and <b>all of the group data (events, posts, discussions, todos…) will be irretrievably destroyed</b>."
) as string ,
confirmText : this . $t ( "Delete group" ) as string ,
cancelText : this . $t ( "Cancel" ) as string ,
type : "is-danger" ,
hasIcon : true ,
onConfirm : ( ) => this . deleteGroup ( ) ,
} ) ;
}
async deleteGroup ( ) {
await this . $apollo . mutate < { deleteGroup : IGroup } > ( {
mutation : DELETE _GROUP ,
variables : {
groupId : this . group . id ,
} ,
} ) ;
return this . $router . push ( { name : RouteName . MY _GROUPS } ) ;
}
2020-08-05 16:44:08 +02:00
async copyURL ( ) {
await window . navigator . clipboard . writeText ( this . group . url ) ;
this . showCopiedTooltip = true ;
setTimeout ( ( ) => {
this . showCopiedTooltip = false ;
} , 2000 ) ;
}
get canShowCopyButton ( ) : boolean {
return window . isSecureContext ;
}
get currentAddress ( ) : IAddress {
return new Address ( this . group . physicalAddress ) ;
}
2020-07-09 17:24:28 +02:00
}
< / script >