Neben "Von anderem Modell kopieren" (alle Pakete) lassen sich jetzt einzelne
Pakete kopieren: "Kopieren" im Paket-Panel, in der Auswahl (Nach Modell) und
in der Liste "Alle Pakete". Ein einzelnes Paket kann dabei als andere Stufe
landen (z. B. Drive als Grundlage fuer Prime im selben Modell). Gibt es die
Stufe im Ziel schon: ersetzen oder ueberspringen.
API: POST /packages/copy {items [{id, name?, sort_order?}], target_model_id,
include_upgrades, replace_existing}; copyPackages nutzt dieselbe
Kopierfunktion (copyOne).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H18w9G2ZdEdGJ3E3goxdQE
1 line
6.5 KiB
JavaScript
1 line
6.5 KiB
JavaScript
import{r as a,v as L,w as I,j as e,L as T,c as h}from"./index-C_s9-1Hj.js";import z from"./ImageUploadField-iyN6VaW2.js";import{S as G,s as O}from"./SortableList-CLUeg4wy.js";import{V as F}from"./ViewOnSite-BvmudjCF.js";import"./resizeImage-C6PvAwh0.js";import"./sortable.esm-6v9ZDa7m.js";import"./grip-vertical-DYdP3qiC.js";const b={name:"",gallery_brand_id:"",cover_image_path:"",sort_order:0};function H(){const[l,x]=a.useState([]),[y,C]=a.useState([]),[s,m]=a.useState(b),[R,N]=a.useState(b),[d,v]=a.useState(null),[_,w]=a.useState(""),[o,S]=a.useState("all"),P=a.useRef(null),u=L();I(JSON.stringify(s)!==JSON.stringify(R),"gallery-projects");const p=a.useMemo(()=>o==="all"?l:l.filter(t=>String(t.gallery_brand_id)===o),[l,o]),g=o!=="all",j=()=>{h.get("/gallery-projects").then(x),h.get("/gallery-brands").then(C)};a.useEffect(j,[]);const $=t=>{var n;const r={name:t.name,gallery_brand_id:t.gallery_brand_id,cover_image_path:t.cover_image_path||"",sort_order:t.sort_order};v(t.id),m(r),N(r),(n=P.current)==null||n.scrollIntoView({behavior:"smooth",block:"start"})},k=()=>{v(null),m(b),N(b)},M=async t=>{t.preventDefault(),w("");const r={...s,gallery_brand_id:Number(s.gallery_brand_id)};try{if(d)await h.put(`/gallery-projects/${d}`,r);else{const n=l.filter(c=>Number(c.gallery_brand_id)===r.gallery_brand_id).reduce((c,i)=>Math.max(c,Number(i.sort_order)||0),0)+10;await h.post("/gallery-projects",{...r,sort_order:n})}u.success(d?"Projekt gespeichert.":"Projekt angelegt."),k(),j()}catch(n){w(n.message)}},E=async t=>{if(confirm("Projekt inkl. aller Fotos wirklich löschen?"))try{await h.delete(`/gallery-projects/${t}`),d===t&&k(),u.success("Projekt gelöscht."),j()}catch(r){u.error(`Löschen fehlgeschlagen: ${r.message}`)}},A=async t=>{const r=l,n=new Set(t.map(i=>i.id)),c=i=>[...l.filter(B=>!n.has(B.id)),...i];x(c(t));try{x(c(await O("gallery-projects",t))),u.success("Reihenfolge gespeichert.")}catch(i){x(r),u.error(`Reihenfolge konnte nicht gespeichert werden: ${i.message}`)}},f="bg-white px-4 py-2 dark:bg-neutral-950";return e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("h1",{className:"text-xl font-bold text-neutral-900 dark:text-white",children:"Galerie-Projekte"}),e.jsx(F,{to:"/galerie"})]}),e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-neutral-600 dark:text-neutral-300",children:"Nach Marke filtern:"}),e.jsxs("select",{value:o,onChange:t=>S(t.target.value),className:"rounded-md border border-neutral-300 bg-white px-3 py-1.5 text-sm dark:border-neutral-700 dark:bg-neutral-900",children:[e.jsx("option",{value:"all",children:"Alle Marken"}),y.map(t=>e.jsx("option",{value:String(t.id),children:t.name},t.id))]}),o!=="all"&&e.jsx("button",{onClick:()=>S("all"),className:"text-sm text-brand-600 hover:underline",children:"Filter zurücksetzen"}),e.jsxs("span",{className:"text-sm text-neutral-400",children:[p.length," von ",l.length]})]}),e.jsx("p",{className:"mb-3 text-xs text-neutral-500 dark:text-neutral-400",children:g?"Reihenfolge am Griff links per Ziehen ändern.":"Zum Sortieren erst eine Marke auswählen."}),e.jsxs("div",{className:"overflow-x-auto rounded-xl border border-neutral-200 dark:border-neutral-800",children:[e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-neutral-50 text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400",children:e.jsxs("tr",{children:[g&&e.jsx("th",{className:"w-10 px-2 py-2",children:e.jsx("span",{className:"sr-only",children:"Reihenfolge"})}),e.jsx("th",{className:"px-4 py-2",children:"Marke"}),e.jsx("th",{className:"px-4 py-2",children:"Projekt"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Aktionen"})]})}),e.jsx(G,{items:p,onReorder:A,as:"tbody",disabled:!g,className:"divide-y divide-neutral-100 dark:divide-neutral-800",children:(t,r)=>e.jsxs(e.Fragment,{children:[g&&e.jsx("td",{className:"bg-white px-2 py-2 dark:bg-neutral-950",children:r}),e.jsx("td",{className:f,children:t.brand_name}),e.jsxs("td",{className:`${f} font-medium text-neutral-800 dark:text-neutral-100`,children:[t.name,e.jsx(F,{to:`/galerie/${t.brand_slug}/${t.slug}`,className:"ml-2"})]}),e.jsxs("td",{className:`${f} whitespace-nowrap text-right`,children:[e.jsx(T,{to:`/admin/gallery-projects/${t.id}/photos`,className:"mr-3 text-brand-600 hover:underline",children:"Fotos"}),e.jsx("button",{onClick:()=>$(t),className:"mr-3 text-brand-600 hover:underline",children:"Bearbeiten"}),e.jsx("button",{onClick:()=>E(t.id),className:"text-red-600 hover:underline",children:"Löschen"})]})]})})]}),p.length===0&&e.jsx("p",{className:"px-4 py-6 text-center text-sm text-neutral-400",children:l.length===0?"Noch keine Projekte angelegt.":"Keine Projekte für diese Marke."})]})]}),e.jsxs("form",{ref:P,onSubmit:M,className:"h-fit scroll-mt-20 space-y-4 rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900",children:[e.jsx("h2",{className:"font-bold text-neutral-900 dark:text-white",children:d?"Projekt bearbeiten":"Neues Projekt"}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Marke *"}),e.jsxs("select",{required:!0,value:s.gallery_brand_id,onChange:t=>m({...s,gallery_brand_id:t.target.value}),className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900",children:[e.jsx("option",{value:"",children:"Bitte wählen…"}),y.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300",children:"Projektname *"}),e.jsx("input",{required:!0,placeholder:"z. B. Audi TT",value:s.name,onChange:t=>m({...s,name:t.target.value}),className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"})]}),e.jsx(z,{value:s.cover_image_path,onChange:t=>m({...s,cover_image_path:t}),aspect:4/3,label:"Titelbild (optional)"}),_&&e.jsx("p",{className:"text-sm text-red-600",children:_}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",className:"rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600",children:d?"Speichern":"Anlegen"}),d&&e.jsx("button",{type:"button",onClick:k,className:"rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700",children:"Abbrechen"})]})]})]})}export{H as default};
|