2021-05-04 07:15:57 -05:00
|
|
|
<template>
|
2021-12-10 00:33:01 -06:00
|
|
|
<MkSpacer :content-max="900">
|
|
|
|
<div class="uqshojas">
|
|
|
|
<div v-for="ad in ads" class="_panel _formRoot ad">
|
2021-10-23 14:03:07 -05:00
|
|
|
<MkAd v-if="ad.url" :specify="ad"/>
|
2021-12-10 00:33:01 -06:00
|
|
|
<MkInput v-model="ad.url" type="url" class="_formBlock">
|
2021-10-23 14:03:07 -05:00
|
|
|
<template #label>URL</template>
|
|
|
|
</MkInput>
|
2021-12-10 00:33:01 -06:00
|
|
|
<MkInput v-model="ad.imageUrl" class="_formBlock">
|
2021-10-23 14:03:07 -05:00
|
|
|
<template #label>{{ $ts.imageUrl }}</template>
|
|
|
|
</MkInput>
|
2021-12-10 00:33:01 -06:00
|
|
|
<FormRadios v-model="ad.place" class="_formBlock">
|
|
|
|
<template #label>Form</template>
|
|
|
|
<option value="square">square</option>
|
|
|
|
<option value="horizontal">horizontal</option>
|
|
|
|
<option value="horizontal-big">horizontal-big</option>
|
|
|
|
</FormRadios>
|
2021-10-23 14:03:07 -05:00
|
|
|
<!--
|
|
|
|
<div style="margin: 32px 0;">
|
|
|
|
{{ $ts.priority }}
|
|
|
|
<MkRadio v-model="ad.priority" value="high">{{ $ts.high }}</MkRadio>
|
|
|
|
<MkRadio v-model="ad.priority" value="middle">{{ $ts.middle }}</MkRadio>
|
|
|
|
<MkRadio v-model="ad.priority" value="low">{{ $ts.low }}</MkRadio>
|
|
|
|
</div>
|
|
|
|
-->
|
2021-12-30 06:47:48 -06:00
|
|
|
<FormSplit>
|
2021-12-10 00:33:01 -06:00
|
|
|
<MkInput v-model="ad.ratio" type="number">
|
|
|
|
<template #label>{{ $ts.ratio }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="ad.expiresAt" type="date">
|
|
|
|
<template #label>{{ $ts.expiration }}</template>
|
|
|
|
</MkInput>
|
2021-12-30 06:47:48 -06:00
|
|
|
</FormSplit>
|
2021-12-10 00:33:01 -06:00
|
|
|
<MkTextarea v-model="ad.memo" class="_formBlock">
|
2021-10-23 14:03:07 -05:00
|
|
|
<template #label>{{ $ts.memo }}</template>
|
|
|
|
</MkTextarea>
|
2021-12-10 00:33:01 -06:00
|
|
|
<div class="buttons _formBlock">
|
|
|
|
<MkButton class="button" inline primary style="margin-right: 12px;" @click="save(ad)"><i class="fas fa-save"></i> {{ $ts.save }}</MkButton>
|
2021-11-19 04:36:12 -06:00
|
|
|
<MkButton class="button" inline danger @click="remove(ad)"><i class="fas fa-trash-alt"></i> {{ $ts.remove }}</MkButton>
|
2021-10-23 14:03:07 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-12-10 00:33:01 -06:00
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
2021-05-04 07:15:57 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkTextarea from '@/components/form/textarea.vue';
|
2021-12-10 00:33:01 -06:00
|
|
|
import FormRadios from '@/components/form/radios.vue';
|
2021-12-30 06:47:48 -06:00
|
|
|
import FormSplit from '@/components/form/split.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2021-05-04 07:15:57 -05:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkTextarea,
|
2021-12-10 00:33:01 -06:00
|
|
|
FormRadios,
|
2021-12-30 06:47:48 -06:00
|
|
|
FormSplit,
|
2021-05-04 07:15:57 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: this.$ts.ads,
|
2021-10-02 09:11:21 -05:00
|
|
|
icon: 'fas fa-audio-description',
|
|
|
|
bg: 'var(--bg)',
|
2021-10-08 22:33:08 -05:00
|
|
|
actions: [{
|
|
|
|
asFullButton: true,
|
|
|
|
icon: 'fas fa-plus',
|
|
|
|
text: this.$ts.add,
|
|
|
|
handler: this.add,
|
|
|
|
}],
|
|
|
|
},
|
2021-05-04 07:15:57 -05:00
|
|
|
ads: [],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
os.api('admin/ad/list').then(ads => {
|
|
|
|
this.ads = ads;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
add() {
|
|
|
|
this.ads.unshift({
|
|
|
|
id: null,
|
|
|
|
memo: '',
|
|
|
|
place: 'square',
|
|
|
|
priority: 'middle',
|
2021-05-07 00:22:13 -05:00
|
|
|
ratio: 1,
|
2021-05-04 07:15:57 -05:00
|
|
|
url: '',
|
|
|
|
imageUrl: null,
|
|
|
|
expiresAt: null,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
remove(ad) {
|
2021-11-18 03:45:58 -06:00
|
|
|
os.confirm({
|
2021-05-04 07:15:57 -05:00
|
|
|
type: 'warning',
|
|
|
|
text: this.$t('removeAreYouSure', { x: ad.url }),
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
this.ads = this.ads.filter(x => x != ad);
|
|
|
|
os.apiWithDialog('admin/ad/delete', {
|
|
|
|
id: ad.id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
save(ad) {
|
|
|
|
if (ad.id == null) {
|
|
|
|
os.apiWithDialog('admin/ad/create', {
|
|
|
|
...ad,
|
|
|
|
expiresAt: new Date(ad.expiresAt).getTime()
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
os.apiWithDialog('admin/ad/update', {
|
|
|
|
...ad,
|
|
|
|
expiresAt: new Date(ad.expiresAt).getTime()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.uqshojas {
|
2021-12-10 00:33:01 -06:00
|
|
|
> .ad {
|
|
|
|
padding: 32px;
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
|
|
|
}
|
2021-05-04 07:15:57 -05:00
|
|
|
}
|
|
|
|
</style>
|