oxen-electron-gui-wallet/src/components/address_header.vue

137 lines
3.0 KiB
Vue
Raw Normal View History

2018-09-08 23:44:19 +02:00
<template>
2020-03-03 04:16:23 +01:00
<q-item class="address-header">
2018-09-08 23:44:19 +02:00
<q-item-main class="self-start">
2020-03-03 04:16:23 +01:00
<q-item-tile sublabel class="title non-selectable">{{ title }}</q-item-tile>
<q-item-tile class="break-all" label>{{ address }}</q-item-tile>
<q-item-tile v-if="paymentId" sublabel>{{ $t("fieldLabels.paymentId") }}: {{ paymentId }}</q-item-tile>
2020-03-03 04:16:23 +01:00
<q-item-tile v-if="extra" sublabel class="extra non-selectable">{{ extra }}</q-item-tile>
2018-09-08 23:44:19 +02:00
</q-item-main>
<q-item-side v-if="showCopy">
2020-03-03 04:16:23 +01:00
<q-btn ref="copy" color="primary" style="width:25px;" size="sm" icon="file_copy" @click="copyAddress">
<q-tooltip anchor="center left" self="center right" :offset="[5, 10]">
{{ $t("menuItems.copyAddress") }}
</q-tooltip>
</q-btn>
</q-item-side>
<q-context-menu>
2020-03-03 04:16:23 +01:00
<q-list link separator style="min-width: 150px; max-height: 300px;">
<q-item v-close-overlay @click.native="copyAddress($event)">
<q-item-main :label="$t('menuItems.copyAddress')" />
</q-item>
</q-list>
</q-context-menu>
2020-03-03 04:16:23 +01:00
</q-item>
2018-09-08 23:44:19 +02:00
</template>
<script>
2020-03-03 04:16:23 +01:00
const { clipboard } = require("electron");
2018-09-08 23:44:19 +02:00
export default {
2020-03-03 04:16:23 +01:00
name: "AddressHeader",
props: {
title: {
type: String,
required: true
2018-09-08 23:44:19 +02:00
},
2020-03-03 04:16:23 +01:00
address: {
type: String,
required: true
2018-09-08 23:44:19 +02:00
},
2020-03-03 04:16:23 +01:00
paymentId: {
type: String,
required: false,
default: undefined
},
extra: {
type: String,
required: false,
default: undefined
},
2020-03-03 04:16:23 +01:00
showCopy: {
type: Boolean,
required: false,
default: true
2018-09-08 23:44:19 +02:00
}
2020-03-03 04:16:23 +01:00
},
data() {
return {};
},
methods: {
copyAddress(event) {
if (event) {
event.stopPropagation();
}
if (this.$refs.copy) {
this.$refs.copy.$el.blur();
}
clipboard.writeText(this.address);
if (this.paymentId) {
2020-03-03 04:16:23 +01:00
this.$q
.dialog({
title: this.$t("dialog.copyAddress.title"),
message: this.$t("dialog.copyAddress.message"),
ok: {
label: this.$t(`dialog.copyAddress.ok`)
}
})
.catch(() => null)
.then(() => {
this.$q.notify({
type: "positive",
timeout: 1000,
message: this.$t("notification.positive.addressCopied")
});
});
} else {
this.$q.notify({
type: "positive",
timeout: 1000,
message: this.$t("notification.positive.addressCopied")
});
}
}
}
};
2018-09-08 23:44:19 +02:00
</script>
<style lang="scss">
.address-header {
2020-03-03 04:16:23 +01:00
padding: 0;
img {
float: left;
margin-right: 15px;
}
h3 {
margin: 15px 0 0;
}
p {
word-break: break-all;
}
&::after {
content: "";
clear: both;
display: table;
}
2018-09-08 23:44:19 +02:00
2020-03-03 04:16:23 +01:00
.q-item-main {
.q-item-label {
font-weight: 400;
}
2020-03-03 04:16:23 +01:00
.q-item-sublabel,
.q-list-header {
font-size: 13px;
}
2020-03-03 04:16:23 +01:00
.title {
font-size: 14px;
margin-bottom: 2px;
}
2020-03-03 04:16:23 +01:00
.extra {
margin-top: 8px;
2018-09-08 23:44:19 +02:00
}
2020-03-03 04:16:23 +01:00
}
2018-09-08 23:44:19 +02:00
}
</style>