-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Resul Avan
authored and
Resul Avan
committed
Jun 21, 2020
1 parent
d985cf0
commit b33b647
Showing
10 changed files
with
220 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<template> | ||
<div> | ||
<pre>{{ error}}</pre> | ||
</div> | ||
<pre>{{ error}}</pre> | ||
</template> | ||
|
||
<script lang="ts"> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<template> | ||
<ValidationProvider | ||
:vid="vid" | ||
:name="$attrs.name || $attrs.label" | ||
:rules="rules" | ||
v-slot="{ errors, valid }" | ||
validate="input" | ||
> | ||
<b-field | ||
v-bind="$attrs" | ||
:type="{ 'is-danger': errors[0], 'is-success': valid }" | ||
:message="errors" | ||
:horizontal="horizontal" | ||
:label="$attrs.label" | ||
:label-position="labelPosition" | ||
> | ||
<b-dropdown :value="value" @input="input" aria-role="list" class="has-margin-top-10"> | ||
<b-button v-if="selectedPrivacyType" slot="trigger" :class="selectedPrivacyType.type" :outlined="!value"> | ||
<b-icon :icon="selectedPrivacyType.icon" class="has-margin-left-5"/> | ||
<span class="has-margin-left-5">{{$t(`privacy.${selectedPrivacyType.privacyType}.title`)}}</span> | ||
<b-icon icon="menu-down"></b-icon> | ||
</b-button> | ||
|
||
<b-button v-else slot="trigger" class="is-primary" :outlined="!value"> | ||
<b-icon icon="account-remove-outline" class="has-margin-left-5"/> | ||
<span class="has-margin-left-5">{{$t(`privacy.notSelected`)}}</span> | ||
<b-icon icon="menu-down"></b-icon> | ||
</b-button> | ||
|
||
<b-dropdown-item v-for="(privacy, index) in privacyList" | ||
:key="index" | ||
:value="privacy.privacyType" | ||
aria-role="listitem"> | ||
<div class="media" :class="privacy.type"> | ||
<b-icon class="media-left" :icon="privacy.icon"></b-icon> | ||
<div class="media-content"> | ||
<h3>{{$t(`privacy.${privacy.privacyType}.title`)}}</h3> | ||
<h4>{{$t(`privacy.${privacy.privacyType}.subtitle`)}}</h4> | ||
<small>{{$t(`privacy.${privacy.privacyType}.description`)}}</small> | ||
</div> | ||
</div> | ||
</b-dropdown-item> | ||
</b-dropdown> | ||
<small v-if="value" class="has-margin-top-5 has-margin-left-5">{{$t(`privacy.${value}.description`)}}</small> | ||
</b-field> | ||
</ValidationProvider> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Emit, Model, Prop, Vue } from 'nuxt-property-decorator'; | ||
import { PrivacyList, PrivacyType } from '~/types'; | ||
import { ValidationProvider } from 'vee-validate'; | ||
@Component({ | ||
components: { ValidationProvider } | ||
}) | ||
export default class PrivacyDropdown extends Vue { | ||
@Model('input', { required: true }) readonly value!: PrivacyType; | ||
@Prop({ type: String, required: true }) vid !: string; | ||
@Prop({ type: String, required: true }) rules !: string; | ||
@Prop({ type: Boolean, required: false, default: false }) horizontal !: boolean; | ||
@Prop({ type: Boolean, required: false, default: false }) disabled !: boolean; | ||
@Prop({ type: String, required: false, default: '' }) labelPosition !: string; | ||
@Emit() | ||
input(newValue: PrivacyType) { | ||
return newValue | ||
} | ||
get selectedPrivacyType() { | ||
return PrivacyList.find(value => value.privacyType === this.value) | ||
} | ||
get privacyList() { | ||
return PrivacyList | ||
} | ||
} | ||
</script> |
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
Oops, something went wrong.