forked from pkp/ui-library
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp/pkp-lib#3594 Allow showing two language inputs at once
- Loading branch information
Showing
8 changed files
with
156 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
<div v-if="locales.length" class="pkpFormLocales"> | ||
<pkp-button v-for="locale in locales" | ||
:key="locale.key" | ||
:label="locale.label" | ||
:isLink="primaryLocale !== locale.key && !active.includes(locale.key)" | ||
:isActive="primaryLocale === locale.key || active.includes(locale.key)" | ||
@click="toggleLocale(locale.key)" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import PkpButton from '@/components/Button/Button.vue'; | ||
export default { | ||
name: 'FormLocales', | ||
components: { | ||
PkpButton, | ||
}, | ||
props: { | ||
locales: { | ||
type: Array, | ||
required: true, | ||
}, | ||
active: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
data: function () { | ||
return { | ||
primaryLocale: $.pkp.app.primaryLocale, | ||
}; | ||
}, | ||
methods: { | ||
/** | ||
* Toggle the active locale when clicked | ||
* | ||
* If a locale is already selected, it will be removed from teh active locales. If a locale is not | ||
* already selected, it will be displayed with the primary locale and any other active locale | ||
* will be removed. The primary locale is always visible. | ||
* | ||
* @param string localeKey "en_US" | ||
*/ | ||
toggleLocale: function (localeKey) { | ||
// Don't allow the primary locale to be disabled | ||
if (localeKey === $.pkp.app.primaryLocale) { | ||
return; | ||
} | ||
let selected = [this.primaryLocale]; | ||
if (!this.active.includes(localeKey)) { | ||
selected.push(localeKey); | ||
} | ||
this.updateLocales(selected); | ||
}, | ||
/** | ||
* Emit an event with updated locales | ||
* | ||
* @param array selected Selected locales which should be new active array | ||
*/ | ||
updateLocales: function (selected) { | ||
this.$emit('updateLocales', selected); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="less"> | ||
@import '../../styles/_import'; | ||
.pkpFormLocales { | ||
padding: @half @base; | ||
border-bottom: @bg-border-light; | ||
.pkpButton + .pkpButton { | ||
margin-left: @half; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters