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 > { {
$t ( "You'll need to transmit the group URL so people may access the group's profile." )
} } < / 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-07-09 17:24:28 +02:00
< b -button native -type = " submit " type = "is-primary" > { { $t ( "Update group" ) } } < / b - b u t t o n >
< / form >
< / section >
< / div >
< / template >
< script lang = "ts" >
import { Component , Vue } from "vue-property-decorator" ;
import RouteName from "../../router/name" ;
import { FETCH _GROUP , UPDATE _GROUP } from "../../graphql/actor" ;
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" ;
2020-08-05 16:44:08 +02:00
import FullAddressAutoComplete from "@/components/Event/FullAddressAutoComplete.vue" ;
2020-07-09 17:24:28 +02:00
@ Component ( {
apollo : {
group : {
query : FETCH _GROUP ,
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 ;
// 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
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 >