2018-03-03 06:32:58 +00:00
< template lang = 'pug' >
v - container ( fluid , fill - height , grid - list - lg )
v - layout ( row wrap )
v - flex ( xs12 )
2018-03-04 02:48:28 +00:00
. headline . primary -- text Locale
2018-03-03 06:32:58 +00:00
. subheading . grey -- text Set localization options for your wiki
v - form . pt - 3
v - layout ( row wrap )
v - flex ( lg6 xs12 )
v - card
2018-05-12 20:13:04 +00:00
v - toolbar ( color = 'primary' , dark , dense , flat )
2018-03-03 06:32:58 +00:00
v - toolbar - title
2018-03-12 04:09:54 +00:00
. subheading Locale Settings
2018-03-03 06:32:58 +00:00
v - card - text
2018-05-12 22:35:31 +00:00
v - select (
: items = 'installedLocales'
prepend - icon = 'language'
2018-04-29 21:55:36 +00:00
v - model = 'selectedLocale'
2018-05-06 21:33:41 +00:00
item - value = 'code'
2018-04-29 21:55:36 +00:00
item - text = 'name'
2018-05-12 22:35:31 +00:00
: label = 'namespacing ? "Base Locale" : "Site Locale"'
2018-04-29 21:55:36 +00:00
persistent - hint
hint = 'All UI text elements will be displayed in selected language.'
)
2018-03-03 06:32:58 +00:00
template ( slot = 'item' , slot - scope = 'data' )
2018-04-29 21:55:36 +00:00
template ( v - if = 'typeof data.item !== "object"' )
v - list - tile - content ( v - text = 'data.item' )
template ( v - else )
v - list - tile - avatar
v - avatar . blue . white -- text ( tile , size = '40' , v - html = 'data.item.code.toUpperCase()' )
v - list - tile - content
v - list - tile - title ( v - html = 'data.item.name' )
v - list - tile - sub - title ( v - html = 'data.item.nativeName' )
2018-03-03 06:32:58 +00:00
v - divider
2018-04-29 21:55:36 +00:00
v - switch (
v - model = 'autoUpdate'
label = 'Update Automatically'
color = 'primary'
persistent - hint
2018-05-12 22:35:31 +00:00
: hint = 'namespacing ? "Automatically download updates to all namespaced locales enabled below." : "Automatically download updates to this locale as they become available."'
2018-04-29 21:55:36 +00:00
)
2018-05-12 20:13:04 +00:00
v - divider . my - 0
v - card - actions . grey . lighten - 4
v - spacer
2018-05-06 21:33:41 +00:00
v - btn ( color = 'primary' , : loading = 'loading' , @ click = 'save' )
v - icon ( left ) chevron _right
span Save
2018-05-12 22:35:31 +00:00
v - card . mt - 3
v - toolbar ( color = 'primary' , dark , dense , flat )
v - toolbar - title
. subheading Multilingual Namespacing
v - card - text
v - switch (
v - model = 'namespacing'
label = 'Multilingual Namespaces'
color = 'primary'
persistent - hint
hint = 'Enables multiple language versions of the same page.'
)
v - alert . mt - 3 (
outline
color = 'orange'
: value = 'true'
icon = 'warning'
)
2018-05-28 23:36:35 +00:00
span The locale code will be prefixed to all paths . ( e . g . / { { selectedLocale } } / page - name )
2018-05-12 22:35:31 +00:00
. caption . grey -- text Paths without a locale code will be automatically redirected to the base locale defined above .
v - divider
v - select (
: disabled = '!namespacing'
: items = 'installedLocales'
prepend - icon = 'language'
multiple
chips
deletable - chips
v - model = 'namespaces'
item - value = 'code'
item - text = 'name'
label = 'Active Namespaces'
persistent - hint
hint = 'List of locales enabled for multilingual namespacing. The base locale defined above will always be included regardless of this selection.'
)
template ( slot = 'item' , slot - scope = 'data' )
template ( v - if = 'typeof data.item !== "object"' )
v - list - tile - content ( v - text = 'data.item' )
template ( v - else )
v - list - tile - avatar
v - avatar . blue . white -- text ( tile , size = '40' , v - html = 'data.item.code.toUpperCase()' )
v - list - tile - content
v - list - tile - title ( v - html = 'data.item.name' )
v - list - tile - sub - title ( v - html = 'data.item.nativeName' )
v - list - tile - action
v - checkbox ( : input - value = 'data.tile.props.value' , color = 'primary' , value )
v - divider . my - 0
v - card - actions . grey . lighten - 4
v - spacer
v - btn ( color = 'primary' , : loading = 'loading' , @ click = 'save' )
v - icon ( left ) chevron _right
span Save
2018-03-03 06:32:58 +00:00
v - flex ( lg6 xs12 )
v - card
2018-03-12 04:09:54 +00:00
v - toolbar ( color = 'teal' , dark , dense , flat )
2018-03-03 06:32:58 +00:00
v - toolbar - title
. subheading Download Locale
2018-05-12 22:35:31 +00:00
v - list ( two - line , dense )
template ( v - for = '(lc, idx) in locales' )
v - list - tile ( : key = 'lc.code' )
v - list - tile - avatar
v - avatar . teal . white -- text ( size = '40' ) { { lc . code . toUpperCase ( ) } }
v - list - tile - content
v - list - tile - title ( v - html = 'lc.name' )
v - list - tile - sub - title ( v - html = 'lc.nativeName' )
v - list - tile - action ( v - if = 'lc.isRTL' )
v - chip ( label , small ) . caption . grey -- text . text -- darken - 2 RTL
v - list - tile - action ( v - if = 'lc.isInstalled && lc.installDate < lc.updatedAt' , @ click = 'download(lc.code)' )
v - icon . blue -- text cached
v - list - tile - action ( v - else - if = 'lc.isInstalled' )
v - icon . green -- text check
v - list - tile - action ( v - else - if = 'lc.isDownloading' )
v - progress - circular ( indeterminate , color = 'blue' , size = '20' , : width = '3' )
v - list - tile - action ( v - else )
v - btn ( icon , @ click = 'download(lc)' )
v - icon . grey -- text cloud _download
v - divider . my - 0 ( inset , v - if = 'idx < locales.length - 1' )
2018-03-03 06:32:58 +00:00
< / template >
< script >
2018-04-29 21:55:36 +00:00
import _ from 'lodash'
import localesQuery from 'gql/admin-locale-query-list.gql'
2018-05-07 03:21:48 +00:00
import localesDownloadMutation from 'gql/admin-locale-mutation-download.gql'
import localesSaveMutation from 'gql/admin-locale-mutation-save.gql'
2018-04-29 21:55:36 +00:00
2018-03-03 06:32:58 +00:00
export default {
data ( ) {
return {
2018-05-06 21:33:41 +00:00
loading : false ,
2018-04-29 21:55:36 +00:00
locales : [ ] ,
2018-03-03 06:32:58 +00:00
selectedLocale : 'en' ,
2018-05-12 22:35:31 +00:00
autoUpdate : false ,
namespacing : false ,
namespaces : [ ]
2018-04-29 21:55:36 +00:00
}
} ,
computed : {
installedLocales ( ) {
return _ . filter ( this . locales , [ 'isInstalled' , true ] )
}
} ,
2018-05-06 21:33:41 +00:00
methods : {
2018-05-07 03:21:48 +00:00
async download ( lc ) {
lc . isDownloading = true
const respRaw = await this . $apollo . mutate ( {
mutation : localesDownloadMutation ,
variables : {
locale : lc . code
}
} )
const resp = _ . get ( respRaw , 'data.localization.downloadLocale.responseResult' , { } )
if ( resp . succeeded ) {
lc . isDownloading = false
lc . isInstalled = true
this . $store . commit ( 'showNotification' , {
message : ` Locale ${ lc . name } has been installed successfully. ` ,
style : 'success' ,
icon : 'get_app'
} )
} else {
this . $store . commit ( 'showNotification' , {
message : ` Error: ${ resp . message } ` ,
style : 'error' ,
icon : 'warning'
} )
}
this . isDownloading = false
} ,
2018-05-06 21:33:41 +00:00
async save ( ) {
this . loading = true
const respRaw = await this . $apollo . mutate ( {
2018-05-07 03:21:48 +00:00
mutation : localesSaveMutation ,
2018-05-06 21:33:41 +00:00
variables : {
locale : this . selectedLocale ,
2018-05-28 23:36:35 +00:00
autoUpdate : this . autoUpdate ,
namespacing : this . namespacing ,
namespaces : this . namespaces
2018-05-06 21:33:41 +00:00
}
} )
const resp = _ . get ( respRaw , 'data.localization.updateLocale.responseResult' , { } )
if ( resp . succeeded ) {
this . $store . commit ( 'showNotification' , {
message : 'Locale settings updated successfully.' ,
style : 'success' ,
icon : 'check'
} )
} else {
this . $store . commit ( 'showNotification' , {
message : ` Error: ${ resp . message } ` ,
style : 'error' ,
icon : 'warning'
} )
}
this . loading = false
}
} ,
2018-04-29 21:55:36 +00:00
apollo : {
locales : {
query : localesQuery ,
2018-05-07 03:21:48 +00:00
update : ( data ) => data . localization . locales . map ( lc => ( { ... lc , isDownloading : false } ) ) ,
2018-04-29 21:55:36 +00:00
watchLoading ( isLoading ) {
this . $store . commit ( ` loading ${ isLoading ? 'Start' : 'Stop' } ` , 'admin-locale-refresh' )
}
2018-05-06 21:33:41 +00:00
} ,
selectedLocale : {
query : localesQuery ,
update : ( data ) => data . localization . config . locale
} ,
autoUpdate : {
query : localesQuery ,
update : ( data ) => data . localization . config . autoUpdate
2018-05-28 23:36:35 +00:00
} ,
namespacing : {
query : localesQuery ,
update : ( data ) => data . localization . config . namespacing
} ,
namespaces : {
query : localesQuery ,
update : ( data ) => data . localization . config . namespaces
2018-03-03 06:32:58 +00:00
}
}
}
< / script >