Files
mixtape/zero.Backoffice.UI/app/components/ui-form-header.vue
T

224 lines
5.1 KiB
Vue
Raw Normal View History

2020-06-23 15:44:14 +02:00
<template>
2020-09-09 14:30:56 +02:00
<ui-header-bar class="ui-form-header" :back-button="true">
<template v-slot:title>
2021-12-14 14:21:48 +01:00
<h2 class="ui-header-bar-title" :class="{'is-empty': title && !value.name && !titleDisabled}">
2021-09-14 12:32:20 +02:00
<template v-for="prefix in prefixes">
<span class="-minor -prefix" v-localize:html="prefix"></span>
<ui-icon class="-chevron" symbol="fth-chevron-right" :size="14" />
</template>
2021-10-11 13:58:14 +02:00
<ui-error field="name" />
2021-12-14 14:21:48 +01:00
<input v-if="!titleDisabled" class="ui-form-header-title-input" type="text" v-model="value.name" v-localize:placeholder="title" :readonly="titleDisabled || disabled" />
<!--<ui-alias class="ui-form-header-title-alias" v-if="hasAlias" v-model="value.alias" :name="value.name" :disabled="disabled" />-->
<span v-if="titleDisabled" v-localize="forceTitle ? title : (value.name || title)"></span>
</h2>
</template>
2020-08-18 15:12:35 +02:00
<div class="ui-form-header-aside">
<slot></slot>
2021-12-14 14:21:48 +01:00
<div v-if="!activeDisabled && typeof value.isActive !== 'undefined'" class="ui-form-header-toggle">
<ui-toggle v-model:on="value.isActive" class="is-accent" off-content="@ui.inactive" :off-warning="true" on-content="@ui.active" :content-left="true" :disabled="disabled" />
2020-08-18 15:12:35 +02:00
</div>
2021-02-04 14:00:09 +01:00
<slot name="buttons"></slot>
2022-01-05 13:28:09 +01:00
<ui-dropdown v-if="actionsDefined" align="right" theme="default">
2020-08-18 15:12:35 +02:00
<template v-slot:button>
<ui-button type="light onbg" label="@ui.actions" caret="down" />
2020-08-18 15:12:35 +02:00
</template>
2020-08-18 11:46:32 +02:00
<slot name="actions"></slot>
<ui-dropdown-button v-if="canDelete" label="@ui.delete" icon="fth-trash" @click="onDelete" :disabled="disabled" />
2020-08-18 15:12:35 +02:00
</ui-dropdown>
2021-11-11 13:46:03 +01:00
<ui-button :submit="true" type="accent" :label="isCreate ? '@ui.create' :'@ui.update'" :state="state" v-if="!disabled" class="ui-form-header-primary-button" />
2020-08-18 15:12:35 +02:00
</div>
2020-06-23 15:44:14 +02:00
</ui-header-bar>
</template>
<script>
export default {
name: 'uiFormHeader',
props: {
2020-10-15 14:10:04 +02:00
title: {
type: String,
default: null
},
2021-09-08 15:06:56 +02:00
forceTitle: {
type: Boolean,
default: false
},
2021-09-11 14:54:28 +02:00
prefix: {
2021-09-14 12:32:20 +02:00
type: [String, Array]
2021-09-11 14:54:28 +02:00
},
2021-12-14 14:21:48 +01:00
value: {
type: Object,
default: {}
2020-10-15 14:10:04 +02:00
},
2020-06-23 15:44:14 +02:00
canDelete: {
type: Boolean,
default: true
},
2020-10-15 14:10:04 +02:00
disabled: {
type: Boolean,
default: false
},
titleDisabled: {
type: Boolean,
default: false
},
activeDisabled: {
2020-10-15 14:10:04 +02:00
type: Boolean,
default: false
},
state: {
type: String
},
isCreate: {
type: Boolean,
default: false
},
2020-10-10 15:22:51 +02:00
hasAlias: {
type: Boolean,
default: true
2020-06-23 15:44:14 +02:00
}
},
2020-09-12 18:09:22 +02:00
computed: {
actionsDefined()
{
return !this.isCreate && (this.canDelete || this.$scopedSlots.hasOwnProperty('actions'));
2021-09-14 12:32:20 +02:00
},
prefixes()
{
let items = Array.isArray(this.prefix) ? this.prefix : [this.prefix];
return items.filter(x => !!x);
2020-09-12 18:09:22 +02:00
}
},
2020-06-23 15:44:14 +02:00
methods: {
onDelete(item, opts)
{
this.$emit('delete', item, opts);
}
}
}
</script>
<style lang="scss">
2021-01-08 00:47:20 +01:00
.ui-form-header
{
/* width: 100%;
max-width: 1320px;
margin: 0 auto;*/
}
2020-08-18 15:12:35 +02:00
.ui-form-header-aside
{
display: flex;
align-items: center;
justify-content: flex-end;
> * + *
{
2020-09-09 14:30:56 +02:00
margin-left: var(--padding-s);
2020-08-18 15:12:35 +02:00
}
2020-06-23 15:44:14 +02:00
}
2020-08-13 11:14:10 +02:00
2020-08-18 15:12:35 +02:00
.ui-form-header-toggle
2020-08-13 11:14:10 +02:00
{
display: inline-flex;
justify-content: center;
align-items: center;
2020-08-18 15:12:35 +02:00
position: relative;
top: -1px;
2020-09-09 14:30:56 +02:00
margin-left: var(--padding-s);
2020-08-13 11:14:10 +02:00
2020-09-05 17:35:47 +02:00
.ui-toggle-off-warning
{
2021-01-09 19:09:31 +01:00
display: none;
2020-09-05 17:35:47 +02:00
color: var(--color-accent-red);
}
2021-01-09 19:09:31 +01:00
2021-01-16 16:52:50 +01:00
.ui-toggle-switch
{
background: var(--color-button-light-onbg);
box-shadow: var(--shadow-short) !important;
}
.ui-toggle-switch.is-active
{
2021-03-04 22:22:20 +01:00
background: var(--color-toggled);
2021-01-16 16:52:50 +01:00
box-shadow: none !important;
}
2021-01-09 19:09:31 +01:00
input:focus + .ui-toggle-switch
{
border-color: transparent;
}
2021-11-15 13:15:00 +01:00
& + .ui-button
{
margin-left: var(--padding);
}
2020-08-13 11:14:10 +02:00
}
2020-10-10 15:22:51 +02:00
.ui-header-bar-title
{
position: relative;
2021-10-11 13:58:14 +02:00
.ui-error
{
display: none;
}
.ui-error + input[type="text"].ui-form-header-title-input:not(:focus)
{
border-color: var(--color-accent-error);
}
2020-10-10 15:22:51 +02:00
}
input[type="text"].ui-form-header-title-input
{
font-family: var(--font);
color: var(--color-text);
font-size: var(--font-size-l);
font-weight: 700;
background: none;
2021-08-23 12:56:40 +02:00
border: 1px dashed var(--color-line-dashed-onbg);
/*&:hover, &:focus, .ui-header-bar-title.is-empty &
{
border: 1px dashed var(--color-text-dim-one);
}*/
2021-09-11 14:54:28 +02:00
.-prefix + &
{
margin-left: 5px;
}
}
2020-10-10 15:22:51 +02:00
.ui-form-header-title-alias
{
position: absolute;
right: 10px;
top: 11px;
z-index: 2;
.ui-alias-lock
{
background: none;
}
}
2021-01-08 00:47:20 +01:00
.ui-form-header-info-button
{
padding: 0;
justify-content: center;
width: 48px;
text-align: center;
}
.ui-form-header-info-button .ui-button-icon
{
margin: 0 !important;
font-size: 18px;
}
2020-06-23 15:44:14 +02:00
</style>