Package and individual mail sender, new report, and other changes
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -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