PageSourceSearch

https://www.clarionlabs.ai/assets/CustomObjectRecords-ByAPCY4L-1790978053425.js

js clarionlabs.ai collected 2026-10-05 13:51:26 UTC 15,644 bytes, 1 lines download raw bytes

1import{l as ge,e as ye,f as _e,u as we,r as l,j as e,L as re,a as Se}from"./react-vendor-CWwlbjRo-1790978053425.js";import"./CreateLeadModal-BSWhBK9--1790978053425.js";import{S as le,aa as Ce,O as ve,J as ke,Y as Le,X as $e,d as Re,e as Ee,f as Ae,g as Pe,h as Fe}from"./index-DsAuDdHa-1790978053425.js";import"./crm-multiselect-field-uHspvH-j-1790978053425.js";import"./ben-CbEv7h_G-1790978053425.js";import"./SettingsShell-CdMucJZR-1790978053425.js";/* empty css                                     */import{g as De,a as Q}from"./CRMLayout-Bqsl90uv-1790978053425.js";import{e as H,C as ie,a as W}from"./CrmSettingsStates-FvwA5pep-1790978053425.js";/* empty css                                          */import{C as Me}from"./ConfirmDialog-VUyXg9u0-1790978053425.js";import{c as E,d as Oe,A as Ie}from"./customObjectsApi-D7NVF3i--1790978053425.js";import{R as Ue}from"./RecordPicker-rok1KkCg-1790978053425.js";/* empty css                                        *//* empty css                                   */import{S as ce}from"./settings-2-A5WCmDtN-1790978053425.js";import{B as qe}from"./boxes-Drr6M8uU-1790978053425.js";import"./mail-DKnD_OIn-1790978053425.js";import"./FilterSelect-D6djYx78-1790978053425.js";import"./SearchableSelect-fd2SkgrT-1790978053425.js";import"./circle-check-CMk7dTHi-1790978053425.js";import"./shellPaths-BtLch0ST-1790978053425.js";import"./useLayoutConfig-zkwSCOgf-1790978053425.js";import"./onboardingV2Api-bWnONEh1-1790978053425.js";import"./useSFTransition-BYP_ti7v-1790978053425.js";import"./trophy-CW1gdJoH-1790978053425.js";import"./circle-user-round-DDy3ZngB-1790978053425.js";import"./clipboard-check-C5A1FNIV-1790978053425.js";import"./calendar-days-C_OVIfuQ-1790978053425.js";import"./gauge-V69bakM3-1790978053425.js";import"./wand-sparkles--0av4RCp-1790978053425.js";import"./user-cog-HjeqZ7Uq-1790978053425.js";import"./crmOpportunityApi-D3lqPqnw-1790978053425.js";const O=50,oe=6;function St(){var ae;const{apiName:t=""}=ge(),s=De(),r=ye(),[x,N]=_e(),g=(((ae=we().state)==null?void 0:ae.toLabel)??null)||null,[o,m]=l.useState([]),[i,y]=l.useState(null),[V,v]=l.useState([]),[k,P]=l.useState(""),[L,F]=l.useState(""),A=l.useRef(""),_=l.useRef(0),[w,a]=l.useState(null),[c,u]=l.useState(null),[p,de]=l.useState([]),[$,me]=l.useState(0),[b,ue]=l.useState(0),[I,Z]=l.useState(!0),[Y,ee]=l.useState(null),[K,D]=l.useState(null),[te,X]=l.useState(null),[U,q]=l.useState(!1),[h,R]=l.useState(null),[z,T]=l.useState(null),j=l.useCallback(async(n=0,d=A.current)=>{A.current=d;const C=++_.current;Z(!0),ee(null);try{const[B,xe,ne,je]=await Promise.all([E.list(!0),E.fieldDefs(t),E.records(t,{limit:O,offset:n,q:d}),E.relationships({from:t})]);if(C!==_.current)return;m(B),v(je),y(B.find(M=>M.api_name===t)??null),u(xe.filter(M=>M.is_active).sort((M,Ne)=>M.display_order-Ne.display_order)),de(ne.records),me(ne.total),ue(n)}catch(B){C===_.current&&ee(H(B,"Could not load these records."))}finally{C===_.current&&Z(!1)}},[t]);l.useEffect(()=>{P(""),F(""),j(0,"")},[j]),l.useEffect(()=>{if(k===L)return;const n=window.setTimeout(()=>{F(k),j(0,k)},300);return()=>window.clearTimeout(n)},[k,L,j]),l.useEffect(()=>{if(x.get("new")!=="1")return;const n=x.get("link"),d=x.get("to");a(n&&d?{values:{[n]:d},labels:{[n]:g}}:{values:{},labels:{}}),R("new"),N({},{replace:!0})},[x,N,g]);const he=l.useCallback(n=>{var d;return((d=o.find(C=>C.api_name===n))==null?void 0:d.label)??n},[o]),G=l.useMemo(()=>(i==null?void 0:i.name_field)||Oe(c??[]),[i,c]),pe=(i==null?void 0:i.name_field)===Ie,se=l.useMemo(()=>(c??[]).filter(n=>n.field_name!==G).slice(0,oe),[c,G]),S=(i==null?void 0:i.label_plural)||(i==null?void 0:i.label)||t,f=(i==null?void 0:i.label)||t,be=async n=>{q(!0),D(null),X(null);try{if(h==="new"){const d=await E.createRecord(t,n);R(null),a(null),r(`${s}/objects/${encodeURIComponent(t)}/${encodeURIComponent(d.id)}`);return}else h&&(await E.updateRecord(t,h.id,n),X(`${f} saved.`));R(null),await j(b)}catch(d){D(H(d,"Could not save that."))}finally{q(!1)}},fe=async()=>{if(z){q(!0),D(null);try{await E.deleteRecord(t,z.id),X(`${f} removed.`),T(null);const n=p.length===1&&b>0?b-O:b;await j(n)}catch(n){D(H(n,"Could not remove that record.")),T(null)}finally{q(!1)}}};if(I&&c===null&&!Y)return e.jsx(Q,{title:S,loading:!0,loadingMessage:"Loading…",children:null});if(Y)return e.jsx(Q,{title:S,children:e.jsx("div",{className:"crm-settings fp-form cor",children:e.jsx(ie,{detail:Y,onRetry:()=>void j(b)})})});if(!i)return e.jsx(Q,{title:"Not found",children:e.jsxs("div",{className:"crm-settings fp-form cor-missing",children:[e.jsxs("h2",{children:["There’s no record type called “",t,"”"]}),e.jsx("p",{children:"It may have been removed, or the link may be wrong. The record types this organization has are listed in settings."}),e.jsxs(re,{className:"btn btn-primary btn-sm",to:`${s}/settings?tab=custom_objects`,children:[e.jsx(ce,{className:"w-3.5 h-3.5"})," See record types"]})]})});const J=(c??[]).length===0;return e.jsxs(Q,{title:S,children:[e.jsxs("div",{className:"crm-settings fp-form cor",children:[e.jsxs("header",{className:"cor-head",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"cor-title",children:S}),e.jsx("p",{className:"cor-sub",children:i.is_active?e.jsxs(e.Fragment,{children:[$.toLocaleStr
1ing()," ",$===1?"record":"records"]}):e.jsx(e.Fragment,{children:"This record type is hidden, so it doesn’t appear elsewhere in the CRM. You can still see and edit what’s here."})})]}),e.jsxs("div",{className:"cor-head-actions",children:[!J&&($>0||L)&&e.jsxs("label",{className:"cor-search",children:[e.jsx(le,{className:"cor-search-icon","aria-hidden":"true"}),e.jsx("input",{className:"cor-search-input",type:"search",value:k,placeholder:`Search ${S.toLowerCase()}…`,"aria-label":`Search ${S.toLowerCase()}`,onChange:n=>P(n.target.value)})]}),e.jsxs("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>void j(b),disabled:I,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"})," Refresh"]}),!J&&p.length>0&&e.jsxs("button",{type:"button",className:"btn btn-primary btn-sm",onClick:()=>R("new"),children:[e.jsx(ve,{className:"w-3.5 h-3.5"})," Add ",f.toLowerCase()]})]})]}),te&&e.jsx("div",{className:"setting-note cor-notice","aria-live":"polite",children:e.jsx("span",{children:te})}),K&&!h&&e.jsx(ie,{title:"That didn’t work",detail:K}),J?e.jsx("div",{className:"card cor-card",children:e.jsx(W,{icon:e.jsx(ce,{className:"w-5 h-5"}),title:`“${f}” doesn’t have any fields yet`,sub:`A record needs somewhere to put information. Add the fields a ${f.toLowerCase()} should have — a name, a date, a status — and they become the form you fill in here.`,action:{label:"Add fields",onClick:()=>r(`${s}/settings?tab=fields&object=${encodeURIComponent(t)}`)}})}):p.length===0&&L?e.jsx("div",{className:"card cor-card",children:e.jsx(W,{icon:e.jsx(le,{className:"w-5 h-5"}),title:`No ${S.toLowerCase()} match “${L}”`,sub:"Search looks at each record’s name and every field.",action:{label:"Clear search",onClick:()=>P("")}})}):p.length===0?e.jsx("div",{className:"card cor-card",children:e.jsx(W,{icon:e.jsx(qe,{className:"w-5 h-5"}),title:`No ${S.toLowerCase()} yet`,sub:`Everything you add here is kept alongside your leads and contacts, with the ${(c??[]).length} field${(c??[]).length===1?"":"s"} you defined for it.`,action:{label:`Add ${f.toLowerCase()}`,onClick:()=>R("new")}})}):e.jsxs("div",{className:"card cor-card",children:[e.jsx("div",{className:"crm-table-wrap cor-table-wrap",children:e.jsxs("table",{className:"crm-table cor-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:pe?"Number":"Name"}),se.map(n=>e.jsx("th",{children:n.field_label},n.field_name)),e.jsx("th",{className:"cor-c-when",children:"Added"}),e.jsx("th",{className:"cor-c-act",children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:p.map(n=>e.jsxs("tr",{children:[e.jsx("td",{className:"cor-c-name",children:e.jsx(re,{className:"cor-name",to:`${s}/objects/${encodeURIComponent(t)}/${encodeURIComponent(n.id)}`,children:n.display_name||`Untitled ${f.toLowerCase()}`})}),se.map(d=>{var C;return e.jsx("td",{children:e.jsx(Be,{def:d,value:(C=n.values)==null?void 0:C[d.field_name]})},d.field_name)}),e.jsx("td",{className:"cor-c-when cor-mute",children:n.created_at?new Date(n.created_at).toLocaleDateString():"—"}),e.jsx("td",{className:"cor-c-act",children:e.jsxs("div",{className:"crm-table-actions",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","aria-label":`Edit this ${f.toLowerCase()}`,disabled:U,onClick:()=>R(n),children:e.jsx(ke,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm","aria-label":`Remove this ${f.toLowerCase()}`,disabled:U,onClick:()=>T(n),children:e.jsx(Le,{className:"w-3.5 h-3.5"})})]})})]},n.id))})]})}),(c??[]).length-(G?1:0)>oe&&e.jsx("p",{className:"cor-morefields",children:"More fields on each record — open one to see them all."}),$>O&&e.jsxs("div",{className:"cor-pager",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",disabled:b===0||I,onClick:()=>void j(Math.max(0,b-O)),children:"Previous"}),e.jsxs("span",{className:"cor-pager-at",children:[b+1,"–",Math.min(b+p.length,$)," of"," ",$.toLocaleString()]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",disabled:b+p.length>=$||I,onClick:()=>void j(b+O),children:"Next"})]})]})]}),h&&c&&e.jsx(Qe,{title:h==="new"?`New ${f.toLowerCase()}`:`Edit ${f.toLowerCase()}`,defs:c,links:V,labelOf:he,initial:h==="new"?(w==null?void 0:w.values)??{}:h.values??{},stored:h==="new"?{}:h.values??{},linkLabels:h==="new"?(w==null?void 0:w.labels)??{}:Object.fromEntries(Object.entries(h.relationship_labels??{}).map(([n,d])=>[n,d.label])),busy:U,problem:K,onCancel:()=>{R(null),a(null),D(null)},onSave:be},h==="new"?"new":h.id),e.jsx(Me,{open:!!z,title:`Remove this ${f.toLowerCase()}?`,message:"It will no longer appear anywhere in the CRM.",confirmLabel:"Remove",destructive:!0,busy:U,onConfirm:()=>void fe(),onCancel:()=>T(null)})]})}function Te(t){const s=/^(\d{4})-(\d{2})-(\d{2})/.exec(t);if(!s)return null;const r=new Date(Number(s[1]),Number(s[2])-1,Number(s[3]));return Number.isNaN(r.getTime())?null:r}function Be({def:t,value:s}){if(s==null||s==="")return e.jsx("span",{className:"cor-blank",children:"—"});if(t.field_type==="checkbox")return e.jsx("span",{className:s?"badge badge-ok":"badge badge-mute",children:s?"Yes":"No"});if(t.field_type==="multi_select"&&Array.isArray(s))return e.jsx("span",{className:"cor-multi",children:s.map(r=>e.jsx("span",{className:"badge badge-mute",children:String(r)},String(r)))});if(t.field_type==="currency"){const r=Number(s);return e.jsx("span",{className:"cor-num",children:Number.isFinite(r)?`$${r.toLocaleStr
1ing()}`:String(s)})}if(t.field_type==="percent"){const r=Number(s);return e.jsx("span",{className:"cor-num",children:Number.isFinite(r)?`${r}%`:String(s)})}if(t.field_type==="number"){const r=Number(s);return e.jsx("span",{className:"cor-num",children:Number.isFinite(r)?r.toLocaleString():String(s)})}if(t.field_type==="date"){const r=Te(String(s));return e.jsx("span",{children:r?r.toLocaleDateString():String(s)})}if(t.field_type==="datetime"){const r=new Date(String(s));return e.jsx("span",{children:Number.isNaN(r.getTime())?String(s):r.toLocaleString()})}return t.field_type==="url"?e.jsx("a",{className:"cor-link",href:String(s),target:"_blank",rel:"noopener noreferrer",children:String(s)}):t.field_type==="email"?e.jsx("a",{className:"cor-link",href:`mailto:${String(s)}`,children:String(s)}):e.jsx("span",{children:String(s)})}function Qe({title:t,defs:s,links:r,labelOf:x,initial:N,stored:g,linkLabels:o,busy:m,problem:i,onCancel:y,onSave:V}){const[v,k]=l.useState(N),[P,L]=l.useState(o);l.useEffect(()=>{const a=c=>{c.key==="Escape"&&(c.stopPropagation(),y())};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[y]);const F=(a,c)=>k(u=>({...u,[a]:c})),A=a=>a==null||a==="",_=[...s.filter(a=>a.is_required&&A(v[a.field_name])).map(a=>a.field_label),...r.filter(a=>(a.relationship_type==="master_detail"||a.is_required)&&A(v[a.api_name])).map(a=>a.label)],w=()=>{const a={},c=[...s.map(u=>u.field_name),...r.map(u=>u.api_name)];for(const u of c){const p=v[u];p!==g[u]&&(A(p)&&g[u]===void 0||(a[u]=p===""||p===void 0?null:p))}V(a)};return Se.createPortal(e.jsx("div",{className:"settings-shell settings-portal",children:e.jsx("div",{className:"pb-delete-overlay",role:"dialog","aria-modal":"true","aria-label":t,children:e.jsxs("div",{className:"pb-delete-modal cor-modal",children:[e.jsxs("div",{className:"cor-modal-head",children:[e.jsx("h3",{children:t}),e.jsx("button",{type:"button",className:"cor-x","aria-label":"Close",onClick:y,children:e.jsx($e,{className:"w-4 h-4"})})]}),r.length>0&&e.jsx("div",{className:"cor-links",children:r.map(a=>e.jsx(Ue,{label:a.label,targetObject:a.to_object,targetLabel:x(a.to_object),value:v[a.api_name],valueLabel:P[a.api_name],required:a.relationship_type==="master_detail"||a.is_required,onChange:c=>{F(a.api_name,c?c.id:null),L(u=>({...u,[a.api_name]:c?c.label:null}))}},a.id))}),e.jsx("div",{className:"cor-form",children:s.map(a=>e.jsx(Ve,{def:a,value:v[a.field_name],onChange:c=>F(a.field_name,c)},a.field_name))}),i&&e.jsx("div",{className:"cor-bad",children:i}),_.length>0&&e.jsxs("div",{className:"cor-hint",children:["Still needed: ",_.join(", ")]}),e.jsxs("div",{className:"pb-delete-actions",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:y,disabled:m,children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",disabled:m||_.length>0,onClick:w,children:m?"Saving…":"Save"})]})]})})}),document.body)}function Ve({def:t,value:s,onChange:r}){const x=`cor-f-${t.field_name}`,N=e.jsxs("label",{className:"cor-label",htmlFor:x,children:[t.field_label,t.is_required&&e.jsx("span",{className:"cor-req","aria-label":"required",children:" *"})]});if(t.field_type==="checkbox")return e.jsxs("div",{className:"cor-field cor-field-check",children:[e.jsx("input",{id:x,type:"checkbox",checked:!!s,onChange:o=>r(o.target.checked)}),e.jsx("label",{className:"cor-label",htmlFor:x,children:t.field_label})]});if(t.field_type==="dropdown")return e.jsxs("div",{className:"cor-field",children:[N,e.jsxs(Re,{value:s?String(s):"",onValueChange:o=>r(o),children:[e.jsx(Ee,{className:"cor-select","aria-label":t.field_label,children:e.jsx(Ae,{placeholder:"Choose one…"})}),e.jsx(Pe,{children:(t.options??[]).map(o=>e.jsx(Fe,{value:o,children:o},o))})]})]});if(t.field_type==="multi_select"){const o=Array.isArray(s)?s.map(String):[];return e.jsxs("div",{className:"cor-field",children:[N,e.jsx("div",{className:"cor-checks",role:"group","aria-label":t.field_label,children:(t.options??[]).map(m=>e.jsxs("label",{className:"cor-check",children:[e.jsx("input",{type:"checkbox",checked:o.includes(m),onChange:i=>r(i.target.checked?[...o,m]:o.filter(y=>y!==m))}),e.jsx("span",{children:m})]},m))})]})}const g=t.field_type==="date"?"date":t.field_type==="datetime"?"datetime-local":t.field_type==="number"||t.field_type==="currency"||t.field_type==="percent"?"number":t.field_type==="email"?"email":t.field_type==="url"?"url":t.field_type==="phone"?"tel":"text";return e.jsxs("div",{className:"cor-field",children:[N,e.jsx("input",{id:x,className:"input",type:g,value:s==null?"":String(s),onChange:o=>{const m=o.target.value;if(m===""){r("");return}if(g==="number"){const i=Number(m);r(Number.isFinite(i)?i:m);return}r(m)}})]})}export{St as default,Te as localDate};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.