inhaus-plugin-kleinanzeigen/dist/pages/Editor.js
Friederich Loheide f05c44733f Kleinanzeigen-Plugin 1.0.0
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 17:06:02 +00:00

1 line
No EOL
8.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{t as e}from"../chunks/createLucideIcon-CYyWUN7r.js";import{n as t,t as n}from"../chunks/loader-circle-DBP4Qhm5.js";import{Fragment as r,computed as i,createBlock as a,createCommentVNode as o,createElementBlock as s,createElementVNode as c,createTextVNode as l,createVNode as u,openBlock as d,ref as f,renderList as p,toDisplayString as m,unref as h,vModelRadio as g,vModelSelect as _,withCtx as v,withDirectives as y,withModifiers as b}from"vue";import{Link as x,useForm as S}from"@inertiajs/vue3";import{AppLayout as ee,Button as C,FormField as w,Input as T,PageHeader as E,Panel as D,Switch as O,Textarea as te,toast as ne}from"@inhaus/ui";var re=e({name:`image-plus`,size:24,node:[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]}),k=e({name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]}),A=e({name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]}),j={key:0,class:`ih:mb-4 ih:flex ih:items-start ih:gap-2 ih:rounded-md ih:border ih:border-destructive/30 ih:bg-destructive/5 ih:p-3 ih:text-sm`},M={class:`ih:grid ih:gap-5`},N={class:`ih:flex ih:flex-wrap ih:gap-2`},P=[`value`],F=[`value`],I={key:0,class:`ih:grid ih:gap-4 ih:sm:grid-cols-2`},L={key:0,class:`ih:flex ih:items-center ih:gap-3 ih:self-end ih:pb-2 ih:text-sm`},R={class:`ih:grid ih:gap-4 ih:sm:grid-cols-2`},z=[`src`],B=[`onClick`],V=[`src`],H=[`onClick`],U={key:0,class:`ih:mt-2 ih:text-[13px] ih:text-destructive`},W={class:`ih:flex ih:flex-wrap ih:items-center ih:gap-3`},G={class:`ih:text-xs ih:text-muted-foreground`},K={__name:`Editor`,props:{listing:{type:Object,default:null},types:{type:Object,required:!0},categories:{type:Object,required:!0},maxPhotos:{type:Number,default:8},defaultLocation:{type:String,default:null}},setup(e){let K=e,q=K.listing,J=S({type:q?.type??`sell`,category:q?.category??``,title:q?.title??``,description:q?.description??``,price:q?.price??``,negotiable:q?.negotiable??!1,location:q?.location??K.defaultLocation??``,phone:q?.phone??``,photos:[],remove_photos:[]}),Y=f(q?.photos??[]),X=f([]),Z=f(null),ie=i(()=>[`sell`,`search`].includes(J.type)),Q=i(()=>Y.value.length+J.photos.length);function $(e){for(let t of e)if(t.type.startsWith(`image/`)){if(Q.value>=K.maxPhotos){ne.error(`Höchstens ${K.maxPhotos} Fotos.`);break}J.photos.push(t),X.value.push(URL.createObjectURL(t))}}function ae(e){URL.revokeObjectURL(X.value[e]),J.photos.splice(e,1),X.value.splice(e,1)}function oe(e){J.remove_photos.push(e.id),Y.value=Y.value.filter(t=>t.id!==e.id)}function se(){J.post(q?`/kleinanzeigen/${q.id}`:`/kleinanzeigen`,{forceFormData:!0,preserveScroll:!0})}let ce=i(()=>q&&[`active`,`rejected`,`expired`].includes(q.status));return(i,f)=>(d(),a(h(ee),{title:h(q)?`Anzeige bearbeiten`:`Anzeige aufgeben`},{default:v(()=>[u(h(E),{title:h(q)?`Anzeige bearbeiten`:`Anzeige aufgeben`,breadcrumbs:[{label:`Kleinanzeigen`,href:`/kleinanzeigen`}]},null,8,[`title`]),h(q)?.review_note?(d(),s(`p`,j,[u(h(k),{class:`ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-destructive`}),l(` Hinweis der Moderation: `+m(h(q).review_note),1)])):o(``,!0),c(`form`,{class:`ih:grid ih:max-w-3xl ih:gap-6`,onSubmit:b(se,[`prevent`])},[u(h(D),null,{default:v(()=>[c(`div`,M,[c(`fieldset`,null,[f[12]||=c(`legend`,{class:`ih:mb-2 ih:text-sm ih:font-medium`},`Ich …`,-1),c(`div`,N,[(d(!0),s(r,null,p(e.types,(e,t)=>(d(),s(`label`,{key:t,class:`ih:cursor-pointer ih:rounded-full ih:border ih:px-4 ih:py-1.5 ih:text-sm ih:has-[:checked]:border-brand ih:has-[:checked]:bg-brand ih:has-[:checked]:text-brand-foreground ih:has-[:focus-visible]:ring-3 ih:has-[:focus-visible]:ring-ring/30`},[y(c(`input`,{"onUpdate:modelValue":f[0]||=e=>h(J).type=e,type:`radio`,name:`type`,value:t,class:`ih:sr-only`},null,8,P),[[g,h(J).type]]),l(m(e.toLowerCase()),1)]))),128))])]),u(h(w),{id:`ka-title`,label:`Titel`,error:h(J).errors.title},{default:v(()=>[u(h(T),{id:`ka-title`,modelValue:h(J).title,"onUpdate:modelValue":f[1]||=e=>h(J).title=e,maxlength:`120`,placeholder:`z. B. Kinderfahrrad 20 Zoll, blau`},null,8,[`modelValue`])]),_:1},8,[`error`]),u(h(w),{id:`ka-category`,label:`Kategorie`,error:h(J).errors.category},{default:v(()=>[y(c(`select`,{id:`ka-category`,"onUpdate:modelValue":f[2]||=e=>h(J).category=e,class:`ih:h-9 ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-card ih:px-2 ih:text-sm`},[f[13]||=c(`option`,{value:``,disabled:``},`Bitte wählen`,-1),(d(!0),s(r,null,p(e.categories,(e,t)=>(d(),s(`option`,{key:t,value:t},m(e),9,F))),128))],512),[[_,h(J).category]])]),_:1},8,[`error`]),u(h(w),{id:`ka-description`,label:`Beschreibung`,error:h(J).errors.description,hint:`Zustand, Maße, Abholung – alles, was Interessierte wissen möchten.`},{default:v(()=>[u(h(te),{id:`ka-description`,modelValue:h(J).description,"onUpdate:modelValue":f[3]||=e=>h(J).description=e,rows:`6`,maxlength:`5000`},null,8,[`modelValue`])]),_:1},8,[`error`]),ie.value?(d(),s(`div`,I,[u(h(w),{id:`ka-price`,label:h(J).type===`search`?`Budget (optional)`:`Preis in € (leer = auf Anfrage)`,error:h(J).errors.price},{default:v(()=>[u(h(T),{id:`ka-price`,modelValue:h(J).price,"onUpdate:modelValue":f[4]||=e=>h(J).price=e,inputmode:`decimal`,placeholder:`z. B. 25 oder 12,50`},null,8,[`modelValue`])]),_:1},8,[`label`,`error`]),h(J).type===`sell`?(d(),s(`label`,L,[u(h(O),{modelValue:h(J).negotiable,"onUpdate:modelValue":f[5]||=e=>h(J).negotiable=e},null,8,[`modelValue`]),f[14]||=l(` Verhandlungsbasis (VB)`,-1)])):o(``,!0)])):o(``,!0),c(`div`,R,[u(h(w),{id:`ka-location`,label:`Ort bzw. Abholung`,error:h(J).errors.location},{default:v(()=>[u(h(T),{id:`ka-location`,modelValue:h(J).location,"onUpdate:modelValue":f[6]||=e=>h(J).location=e,maxlength:`120`,placeholder:`z. B. Haus A oder Mainz-Gonsenheim`},null,8,[`modelValue`])]),_:1},8,[`error`]),u(h(w),{id:`ka-phone`,label:`Telefon (optional)`,error:h(J).errors.phone,hint:`Wird in der Anzeige gezeigt.`},{default:v(()=>[u(h(T),{id:`ka-phone`,modelValue:h(J).phone,"onUpdate:modelValue":f[7]||=e=>h(J).phone=e,type:`tel`,maxlength:`40`},null,8,[`modelValue`])]),_:1},8,[`error`])])])]),_:1}),u(h(D),{title:`Fotos (${Q.value}/${e.maxPhotos})`},{default:v(()=>[c(`div`,{class:`ih:grid ih:grid-cols-3 ih:gap-3 ih:sm:grid-cols-4`,onDragover:f[9]||=b(()=>{},[`prevent`]),onDrop:f[10]||=b(e=>$([...e.dataTransfer.files]),[`prevent`])},[(d(!0),s(r,null,p(Y.value,e=>(d(),s(`div`,{key:e.id,class:`ih:relative ih:aspect-[4/3] ih:overflow-hidden ih:rounded-md ih:border`},[c(`img`,{src:e.url,alt:``,class:`ih:size-full ih:object-cover`},null,8,z),c(`button`,{type:`button`,class:`ih:absolute ih:top-1 ih:right-1 ih:grid ih:size-6 ih:place-items-center ih:rounded-full ih:bg-foreground/75 ih:text-background`,"aria-label":`Foto entfernen`,onClick:t=>oe(e)},[u(h(A),{class:`ih:size-3.5`})],8,B)]))),128)),(d(!0),s(r,null,p(X.value,(e,t)=>(d(),s(`div`,{key:e,class:`ih:relative ih:aspect-[4/3] ih:overflow-hidden ih:rounded-md ih:border`},[c(`img`,{src:e,alt:``,class:`ih:size-full ih:object-cover`},null,8,V),c(`button`,{type:`button`,class:`ih:absolute ih:top-1 ih:right-1 ih:grid ih:size-6 ih:place-items-center ih:rounded-full ih:bg-foreground/75 ih:text-background`,"aria-label":`Foto entfernen`,onClick:e=>ae(t)},[u(h(A),{class:`ih:size-3.5`})],8,H)]))),128)),Q.value<e.maxPhotos?(d(),s(`button`,{key:0,type:`button`,class:`ih:flex ih:aspect-[4/3] ih:flex-col ih:items-center ih:justify-center ih:gap-1 ih:rounded-md ih:border-2 ih:border-dashed ih:text-sm ih:text-muted-foreground ih:hover:border-brand ih:hover:text-brand-text`,onClick:f[8]||=e=>Z.value?.click()},[u(h(re),{class:`ih:size-6`}),f[15]||=l(` Fotos hinzufügen `,-1)])):o(``,!0)],32),c(`input`,{ref_key:`fileInput`,ref:Z,type:`file`,accept:`image/*`,multiple:``,class:`ih:hidden`,onChange:f[11]||=e=>{$([...e.target.files]),e.target.value=``}},null,544),h(J).errors.photos||h(J).errors[`photos.0`]?(d(),s(`p`,U,m(h(J).errors.photos||h(J).errors[`photos.0`]),1)):o(``,!0),f[16]||=c(`p`,{class:`ih:mt-3 ih:text-xs ih:text-muted-foreground`},`Das erste Foto erscheint in der Übersicht. Fotos sind nur für angemeldete Mitarbeitende sichtbar.`,-1)]),_:1},8,[`title`]),c(`div`,W,[u(h(C),{type:`submit`,disabled:h(J).processing},{default:v(()=>[h(J).processing?(d(),a(h(n),{key:0,class:`ih:animate-spin`})):o(``,!0),l(` `+m(h(q)?`Speichern`:`Zur Freigabe einreichen`),1)]),_:1},8,[`disabled`]),u(h(C),{variant:`ghost`,"as-child":``},{default:v(()=>[u(h(x),{href:h(q)?`/kleinanzeigen/meine`:`/kleinanzeigen`},{default:v(()=>[u(h(t)),f[17]||=l(` Abbrechen`,-1)]),_:1},8,[`href`])]),_:1}),c(`p`,G,m(h(q)?ce.value?`Änderungen an Inhalt oder Fotos werden erneut geprüft.`:``:`Die Moderation prüft Ihre Anzeige; danach ist sie 30 Tage online.`),1)])],32)]),_:1},8,[`title`]))}};export{K as default};