Files
mixtape/zero.Backoffice.UI/old_app/components/pickers/linkPicker/overlay.vue
T

183 lines
4.0 KiB
Vue
Raw Normal View History

2021-01-29 17:01:32 +01:00
<template>
2021-01-30 16:52:36 +01:00
<ui-overlay-editor class="ui-linkpicker-overlay">
2021-01-29 17:01:32 +01:00
<template v-slot:header>
<ui-header-bar :title="config.title" :back-button="false" :close-button="true" />
</template>
<template v-slot:footer>
2021-01-30 16:52:36 +01:00
<ui-button type="light onbg" :label="config.closeLabel" :parent="config.rootId" @click="config.hide" />
2021-02-09 16:00:43 +01:00
<ui-button type="primary" label="@ui.confirm" @click="onSave" />
2021-01-29 17:01:32 +01:00
</template>
2021-01-30 16:52:36 +01:00
<div v-if="opened">
2021-02-08 15:45:25 +01:00
<!--<div class="ui-box ui-linkpicker-overlay-options">
2021-01-30 16:52:36 +01:00
<ui-property label="Open in a new tab">
<ui-toggle :value="link.target === 'blank'" @input="onTargetChange" />
</ui-property>
<template v-if="showOptions">
<hr />
<ui-property label="Title" :vertical="true">
<input v-model="link.title" type="text" class="ui-input" maxlength="160" />
</ui-property>
<hr />
<ui-button label="Hide options" @click="showOptions=false" />
</template>
<div v-if="!showOptions">
<hr />
<ui-button label="More options" @click="showOptions=true" caret="down" />
</div>
2021-02-08 15:45:25 +01:00
</div>-->
<div class="ui-linkpicker-overlay-area">
<ui-property :vertical="true">
2021-01-30 16:52:36 +01:00
<ui-select v-model="current" :items="areaItems"></ui-select>
</ui-property>
2021-02-05 13:42:09 +01:00
</div>
<div class="ui-box">
2021-02-10 14:53:56 +01:00
<component v-if="area && area.component" :is="area.component" :area="area" v-model="link" />
2021-01-30 16:52:36 +01:00
</div>
2021-01-29 17:01:32 +01:00
</div>
</ui-overlay-editor>
</template>
<script>
export default {
props: {
2021-02-09 16:00:43 +01:00
model: Object,
2021-01-29 17:01:32 +01:00
config: Object
},
data: () => ({
2021-01-30 16:52:36 +01:00
opened: false,
current: null,
area: null,
areas: [],
areaItems: [],
link: null,
template: {
area: null,
target: 'default',
urlSuffix: null,
title: null,
values: {}
},
showOptions: false
2021-01-29 17:01:32 +01:00
}),
2021-01-30 16:52:36 +01:00
watch: {
current()
2021-01-29 17:01:32 +01:00
{
2021-01-30 16:52:36 +01:00
this.reloadSelector();
2021-01-29 17:01:32 +01:00
}
},
mounted()
{
2021-01-30 16:52:36 +01:00
this.areas = this.zero.config.linkPicker.areas;
this.areaItems = this.areas.map(x =>
{
return {
key: x.alias,
value: x.name
};
});
2021-02-09 16:00:43 +01:00
this.link = JSON.parse(JSON.stringify(this.model || this.template));
2021-01-30 16:52:36 +01:00
2021-07-26 15:22:19 +02:00
if (this.model && this.model.area && this.areas.find(x => x.alias === this.model.area))
{
this.area = this.areas.find(x => x.alias === this.model.area);
}
else
{
this.area = this.areas[0];
}
this.current = this.area.alias;
this.link.area = this.current;
2021-02-10 14:53:56 +01:00
2021-01-29 17:01:32 +01:00
setTimeout(() => this.opened = true, 300);
},
methods: {
2021-01-30 16:52:36 +01:00
reloadSelector()
{
this.area = this.areas.find(x => x.alias === this.current);
},
2021-02-09 16:00:43 +01:00
onSave()
2021-01-29 17:01:32 +01:00
{
2021-07-26 15:22:19 +02:00
this.link.area = this.current;
2021-02-09 16:00:43 +01:00
this.config.confirm(this.link);
2021-01-29 17:01:32 +01:00
},
2021-01-30 16:52:36 +01:00
onTargetChange(ev)
{
this.link.target = ev ? 'blank' : 'default';
2021-01-29 17:01:32 +01:00
}
}
}
</script>
2021-02-09 16:00:43 +01:00
<style>
2021-02-08 15:45:25 +01:00
.ui-linkpicker-overlay-area
{
margin-bottom: var(--padding-s);
}
.ui-linkpicker-overlay .ui-property + .ui-property
{
margin-top: 15px;
}
.ui-linkpicker-overlay-area .ui-native-select
{
background: var(--color-box);
border-radius: var(--radius);
box-shadow: var(--shadow-short);
font-weight: bold;
2021-07-26 15:22:19 +02:00
border-color: transparent;
2021-02-08 15:45:25 +01:00
}
.ui-linkpicker-overlay-area .ui-native-select select
{
font-weight: bold;
}
.ui-linkpicker-overlay-area .ui-native-select select option
{
font-weight: normal;
}
2021-01-30 16:52:36 +01:00
.ui-linkpicker-overlay content
2021-01-29 17:01:32 +01:00
{
2021-01-30 16:52:36 +01:00
padding-top: 0;
2021-01-29 17:01:32 +01:00
}
2021-01-30 16:52:36 +01:00
.ui-linkpicker-overlay-options .ui-property
2021-01-29 17:01:32 +01:00
{
2021-01-30 16:52:36 +01:00
display: flex;
justify-content: space-between;
}
2021-01-29 17:01:32 +01:00
2021-01-30 16:52:36 +01:00
.ui-linkpicker-overlay-options .ui-property + .ui-property
{
margin-top: var(--padding-m);
}
.ui-linkpicker-overlay-options .ui-property-content
{
display: inline;
2021-02-08 15:45:25 +01:00
flex: 0 0 auto;
2021-01-30 16:52:36 +01:00
}
.ui-linkpicker-overlay-options .ui-property-label
{
padding-top: 1px;
}
2021-01-29 17:01:32 +01:00
</style>