Package and individual mail sender, new report, and other changes
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -64,6 +64,7 @@ import "quill/dist/quill.snow.css";
|
||||
|
||||
const props = defineProps({
|
||||
template: { type: Object, default: null },
|
||||
actions: { type: Array, default: () => [] },
|
||||
});
|
||||
|
||||
const form = useForm({
|
||||
@@ -75,6 +76,9 @@ const form = useForm({
|
||||
entity_types: props.template?.entity_types ?? ["client", "contract"],
|
||||
allow_attachments: props.template?.allow_attachments ?? false,
|
||||
active: props.template?.active ?? true,
|
||||
client: props.template?.client ?? false,
|
||||
action_id: props.template?.action_id ?? null,
|
||||
decision_id: props.template?.decision_id ?? null,
|
||||
});
|
||||
|
||||
const preview = ref({ subject: "", html: "", text: "" });
|
||||
@@ -732,7 +736,8 @@ const placeholderGroups = computed(() => {
|
||||
"contract.id",
|
||||
"contract.uuid",
|
||||
"contract.reference",
|
||||
"contract.amount",
|
||||
"contract.account.balance_amount",
|
||||
"contract.account.initial_amount",
|
||||
"contract.meta.some_key",
|
||||
]);
|
||||
}
|
||||
@@ -747,6 +752,13 @@ const placeholderGroups = computed(() => {
|
||||
]);
|
||||
// Extra is always useful for ad-hoc data
|
||||
add("extra", "Extra", ["extra.some_key"]);
|
||||
// Profile signature tokens (resolved from the active mail profile at send time)
|
||||
add("profile", "Profil / Podpis", [
|
||||
"profile.signature.ime",
|
||||
"profile.signature.naziv",
|
||||
"profile.signature.telefon",
|
||||
"profile.signature.email",
|
||||
]);
|
||||
return groups;
|
||||
});
|
||||
|
||||
@@ -1028,6 +1040,49 @@ watch(
|
||||
/>
|
||||
<Label for="active" class="font-normal cursor-pointer">Aktivno</Label>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<Switch
|
||||
id="client"
|
||||
:default-value="form.client"
|
||||
@update:model-value="(val) => (form.client = val)"
|
||||
/>
|
||||
<Label for="client" class="font-normal cursor-pointer">Samo za stranke</Label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Activity after send: action + decision -->
|
||||
<div>
|
||||
<Label class="mb-2 block">Aktivnost po pošiljanju</Label>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div class="space-y-2">
|
||||
<Label for="action_id">Akcija</Label>
|
||||
<Select v-model="form.action_id" @update:model-value="(val) => { form.action_id = val; form.decision_id = null; }">
|
||||
<SelectTrigger id="action_id">
|
||||
<SelectValue placeholder="Brez" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem :value="null">Brez</SelectItem>
|
||||
<SelectItem v-for="a in props.actions" :key="a.id" :value="a.id">{{ a.name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<Label for="decision_id">Odločitev</Label>
|
||||
<Select v-model="form.decision_id" :disabled="!form.action_id">
|
||||
<SelectTrigger id="decision_id">
|
||||
<SelectValue placeholder="Brez" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem :value="null">Brez</SelectItem>
|
||||
<SelectItem
|
||||
v-for="d in props.actions?.find((x) => x.id === form.action_id)?.decisions || []"
|
||||
:key="d.id"
|
||||
:value="d.id"
|
||||
>{{ d.name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
@@ -1223,6 +1278,25 @@ watch(
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Special tokens -->
|
||||
<div class="space-y-2">
|
||||
<div class="text-sm font-medium text-muted-foreground">Posebni žetoni</div>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
<code class="font-mono">{{ body_text }}</code> — pri pošiljanju ga nadomesti besedilo, ki ga vnese pošiljatelj.
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
@click="insertPlaceholder('body_text')"
|
||||
class="font-mono text-xs"
|
||||
>
|
||||
<PlusCircleIcon class="h-3 w-3 mr-1" />
|
||||
body_text
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
PencilIcon,
|
||||
SendIcon,
|
||||
MoreVerticalIcon,
|
||||
Trash2Icon,
|
||||
} from "lucide-vue-next";
|
||||
import {
|
||||
Card,
|
||||
@@ -62,6 +63,32 @@ const createOpen = ref(false); // create modal
|
||||
const editOpen = ref(false); // edit modal
|
||||
const editTarget = ref(null); // profile being edited
|
||||
|
||||
// Signature items — array of {key, value} pairs edited in the dialog
|
||||
const signatureItems = ref([{ key: "", value: "" }]);
|
||||
|
||||
function addSignatureItem() {
|
||||
signatureItems.value.push({ key: "", value: "" });
|
||||
}
|
||||
function removeSignatureItem(index) {
|
||||
signatureItems.value.splice(index, 1);
|
||||
if (signatureItems.value.length === 0)
|
||||
signatureItems.value.push({ key: "", value: "" });
|
||||
}
|
||||
function signatureToObject() {
|
||||
const obj = {};
|
||||
signatureItems.value.forEach(({ key, value }) => {
|
||||
const k = (key || "").trim();
|
||||
if (k) obj[k] = value ?? "";
|
||||
});
|
||||
return Object.keys(obj).length ? obj : null;
|
||||
}
|
||||
function signatureFromObject(sig) {
|
||||
const entries = Object.entries(sig || {});
|
||||
return entries.length
|
||||
? entries.map(([key, value]) => ({ key, value }))
|
||||
: [{ key: "", value: "" }];
|
||||
}
|
||||
|
||||
const form = useForm({
|
||||
name: "",
|
||||
host: "",
|
||||
@@ -76,6 +103,7 @@ const form = useForm({
|
||||
|
||||
function openCreate() {
|
||||
form.reset();
|
||||
signatureItems.value = [{ key: "", value: "" }];
|
||||
createOpen.value = true;
|
||||
editTarget.value = null;
|
||||
}
|
||||
@@ -93,6 +121,7 @@ function openEdit(p) {
|
||||
form.from_name = p.from_name || "";
|
||||
form.priority = p.priority ?? 10;
|
||||
editTarget.value = p;
|
||||
signatureItems.value = signatureFromObject(p.signature);
|
||||
editOpen.value = true;
|
||||
}
|
||||
|
||||
@@ -102,12 +131,14 @@ function closeCreate() {
|
||||
}
|
||||
|
||||
function submitCreate() {
|
||||
form.post(route("admin.mail-profiles.store"), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
createOpen.value = false;
|
||||
},
|
||||
});
|
||||
form
|
||||
.transform((data) => ({ ...data, signature: signatureToObject() }))
|
||||
.post(route("admin.mail-profiles.store"), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
createOpen.value = false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function closeEdit() {
|
||||
@@ -128,6 +159,7 @@ function submitEdit() {
|
||||
from_address: form.from_address,
|
||||
from_name: form.from_name || null,
|
||||
priority: form.priority,
|
||||
signature: signatureToObject(),
|
||||
};
|
||||
if (form.password && form.password.trim() !== "") {
|
||||
payload.password = form.password.trim();
|
||||
@@ -351,6 +383,43 @@ const statusClass = (p) => {
|
||||
<Input id="create-priority" v-model.number="form.priority" type="number" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between">
|
||||
<Label>Podpis (signature)</Label>
|
||||
<Button type="button" size="sm" variant="outline" @click="addSignatureItem">
|
||||
<PlusIcon class="h-3 w-3 mr-1" />
|
||||
Dodaj vrstico
|
||||
</Button>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
Vrednosti so dostopne v predlogah kot
|
||||
<code class="font-mono" v-pre>{{ profile.signature.ključ }}</code
|
||||
>.
|
||||
</p>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="(item, i) in signatureItems"
|
||||
:key="i"
|
||||
class="flex gap-2 items-start"
|
||||
>
|
||||
<Input
|
||||
v-model="item.key"
|
||||
placeholder="Ključ (npr. ime)"
|
||||
class="w-36 shrink-0 font-mono text-xs"
|
||||
/>
|
||||
<Input v-model="item.value" placeholder="Vrednost" class="flex-1" />
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@click="removeSignatureItem(i)"
|
||||
>
|
||||
<Trash2Icon class="h-4 w-4 text-destructive" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" @click="closeCreate" :disabled="form.processing"
|
||||
@@ -419,6 +488,43 @@ const statusClass = (p) => {
|
||||
<Input id="edit-priority" v-model.number="form.priority" type="number" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between">
|
||||
<Label>Podpis (signature)</Label>
|
||||
<Button type="button" size="sm" variant="outline" @click="addSignatureItem">
|
||||
<PlusIcon class="h-3 w-3 mr-1" />
|
||||
Dodaj vrstico
|
||||
</Button>
|
||||
</div>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
Vrednosti so dostopne v predlogah kot
|
||||
<code class="font-mono" v-pre>{{ profile.signature.ključ }}</code
|
||||
>.
|
||||
</p>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="(item, i) in signatureItems"
|
||||
:key="i"
|
||||
class="flex gap-2 items-start"
|
||||
>
|
||||
<Input
|
||||
v-model="item.key"
|
||||
placeholder="Ključ (npr. ime)"
|
||||
class="w-36 shrink-0 font-mono text-xs"
|
||||
/>
|
||||
<Input v-model="item.value" placeholder="Vrednost" class="flex-1" />
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@click="removeSignatureItem(i)"
|
||||
>
|
||||
<Trash2Icon class="h-4 w-4 text-destructive" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm text-muted-foreground">
|
||||
Pusti geslo prazno, če želiš obdržati obstoječe.
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user