create record wip

This commit is contained in:
2026-01-08 23:23:48 +02:00
parent 2a718ac9ee
commit 4470d922b7
42 changed files with 1048 additions and 556 deletions
+160
View File
@@ -0,0 +1,160 @@
<script>
const icons = {
"trash-can": {
path: '<path d="M135.2 17.69C140.6 6.848 151.7 0 163.8 0H284.2C296.3 0 307.4 6.848 312.8 17.69L320 32H416C433.7 32 448 46.33 448 64C448 81.67 433.7 96 416 96H32C14.33 96 0 81.67 0 64C0 46.33 14.33 32 32 32H128L135.2 17.69zM31.1 128H416V448C416 483.3 387.3 512 352 512H95.1C60.65 512 31.1 483.3 31.1 448V128zM111.1 208V432C111.1 440.8 119.2 448 127.1 448C136.8 448 143.1 440.8 143.1 432V208C143.1 199.2 136.8 192 127.1 192C119.2 192 111.1 199.2 111.1 208zM207.1 208V432C207.1 440.8 215.2 448 223.1 448C232.8 448 240 440.8 240 432V208C240 199.2 232.8 192 223.1 192C215.2 192 207.1 199.2 207.1 208zM304 208V432C304 440.8 311.2 448 320 448C328.8 448 336 440.8 336 432V208C336 199.2 328.8 192 320 192C311.2 192 304 199.2 304 208z"/>',
viewBox: "0 0 448 512",
},
"circle-chevron-down": {
path: '<path d="M256 0C114.6 0 0 114.6 0 256c0 141.4 114.6 256 256 256s256-114.6 256-256C512 114.6 397.4 0 256 0zM390.6 246.6l-112 112C272.4 364.9 264.2 368 256 368s-16.38-3.125-22.62-9.375l-112-112c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L256 290.8l89.38-89.38c12.5-12.5 32.75-12.5 45.25 0S403.1 234.1 390.6 246.6z"/>',
viewBox: "0 0 512 512",
},
"circle-chevron-up": {
path: '<path d="M256 0C114.6 0 0 114.6 0 256c0 141.4 114.6 256 256 256s256-114.6 256-256C512 114.6 397.4 0 256 0zM390.6 310.6c-12.5 12.5-32.75 12.5-45.25 0L256 221.3L166.6 310.6c-12.5 12.5-32.75 12.5-45.25 0s-12.5-32.75 0-45.25l112-112C239.6 147.1 247.8 144 256 144s16.38 3.125 22.62 9.375l112 112C403.1 277.9 403.1 298.1 390.6 310.6z"/>',
viewBox: "0 0 512 512",
},
ellipsis: {
path: '<path d="M120 256C120 286.9 94.93 312 64 312C33.07 312 8 286.9 8 256C8 225.1 33.07 200 64 200C94.93 200 120 225.1 120 256zM280 256C280 286.9 254.9 312 224 312C193.1 312 168 286.9 168 256C168 225.1 193.1 200 224 200C254.9 200 280 225.1 280 256zM328 256C328 225.1 353.1 200 384 200C414.9 200 440 225.1 440 256C440 286.9 414.9 312 384 312C353.1 312 328 286.9 328 256z"/>',
viewBox: "0 0 448 512",
},
"ellipsis-vertical": {
path: '<path d="M64 360C94.93 360 120 385.1 120 416C120 446.9 94.93 472 64 472C33.07 472 8 446.9 8 416C8 385.1 33.07 360 64 360zM64 200C94.93 200 120 225.1 120 256C120 286.9 94.93 312 64 312C33.07 312 8 286.9 8 256C8 225.1 33.07 200 64 200zM64 152C33.07 152 8 126.9 8 96C8 65.07 33.07 40 64 40C94.93 40 120 65.07 120 96C120 126.9 94.93 152 64 152z"/>',
viewBox: "0 0 128 512",
},
"angles-down": {
path: '<path d="M169.4 278.6C175.6 284.9 183.8 288 192 288s16.38-3.125 22.62-9.375l160-160c12.5-12.5 12.5-32.75 0-45.25s-32.75-12.5-45.25 0L192 210.8L54.63 73.38c-12.5-12.5-32.75-12.5-45.25 0s-12.5 32.75 0 45.25L169.4 278.6zM329.4 265.4L192 402.8L54.63 265.4c-12.5-12.5-32.75-12.5-45.25 0s-12.5 32.75 0 45.25l160 160C175.6 476.9 183.8 480 192 480s16.38-3.125 22.62-9.375l160-160c12.5-12.5 12.5-32.75 0-45.25S341.9 252.9 329.4 265.4z"/>',
viewBox: "0 0 384 512",
},
"angle-right": {
path: '<path d="M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"/>',
viewBox: "0 0 256 512",
},
"photo-film": {
path: '<path d="M352 432c0 8.836-7.164 16-16 16H176c-8.838 0-16-7.164-16-16L160 128H48C21.49 128 .0003 149.5 .0003 176v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48L512 384h-160L352 432zM104 439c0 4.969-4.031 9-9 9h-30c-4.969 0-9-4.031-9-9v-30c0-4.969 4.031-9 9-9h30c4.969 0 9 4.031 9 9V439zM104 335c0 4.969-4.031 9-9 9h-30c-4.969 0-9-4.031-9-9v-30c0-4.969 4.031-9 9-9h30c4.969 0 9 4.031 9 9V335zM104 231c0 4.969-4.031 9-9 9h-30c-4.969 0-9-4.031-9-9v-30C56 196 60.03 192 65 192h30c4.969 0 9 4.031 9 9V231zM408 409c0-4.969 4.031-9 9-9h30c4.969 0 9 4.031 9 9v30c0 4.969-4.031 9-9 9h-30c-4.969 0-9-4.031-9-9V409zM591.1 0H239.1C213.5 0 191.1 21.49 191.1 48v256c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48v-256C640 21.49 618.5 0 591.1 0zM303.1 64c17.68 0 32 14.33 32 32s-14.32 32-32 32C286.3 128 271.1 113.7 271.1 96S286.3 64 303.1 64zM574.1 279.6C571.3 284.8 565.9 288 560 288H271.1C265.1 288 260.5 284.6 257.7 279.3C255 273.9 255.5 267.4 259.1 262.6l70-96C332.1 162.4 336.9 160 341.1 160c5.11 0 9.914 2.441 12.93 6.574l22.35 30.66l62.74-94.11C442.1 98.67 447.1 96 453.3 96c5.348 0 10.34 2.672 13.31 7.125l106.7 160C576.6 268 576.9 274.3 574.1 279.6z"/>',
viewBox: "0 0 640 512",
},
file: {
path: '<path d="M0 64C0 28.65 28.65 0 64 0H224V128C224 145.7 238.3 160 256 160H384V448C384 483.3 355.3 512 320 512H64C28.65 512 0 483.3 0 448V64zM256 128V0L384 128H256z"/>',
viewBox: "0 0 384 512",
},
"circle-info": {
path: '<path d="M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256s256-114.6 256-256S397.4 0 256 0zM256 128c17.67 0 32 14.33 32 32c0 17.67-14.33 32-32 32S224 177.7 224 160C224 142.3 238.3 128 256 128zM296 384h-80C202.8 384 192 373.3 192 360s10.75-24 24-24h16v-64H224c-13.25 0-24-10.75-24-24S210.8 224 224 224h32c13.25 0 24 10.75 24 24v88h16c13.25 0 24 10.75 24 24S309.3 384 296 384z"/>',
viewBox: "0 0 512 512",
},
"table-columns": {
path: '<path d="M0 96C0 60.65 28.65 32 64 32H448C483.3 32 512 60.65 512 96V416C512 451.3 483.3 480 448 480H64C28.65 480 0 451.3 0 416V96zM64 416H224V160H64V416zM448 160H288V416H448V160z"/>',
viewBox: "0 0 512 512",
},
"arrow-down-a-z": {
path: '<path d="M239.6 373.1c11.94-13.05 11.06-33.31-1.969-45.27c-13.55-12.42-33.76-10.52-45.22 1.973L160 366.1V64.03c0-17.7-14.33-32.03-32-32.03S96 46.33 96 64.03v302l-32.4-35.39C51.64 317.7 31.39 316.7 18.38 328.7c-13.03 11.95-13.9 32.22-1.969 45.27l87.1 96.09c12.12 13.26 35.06 13.26 47.19 0L239.6 373.1zM448 416h-50.75l73.38-73.38c9.156-9.156 11.89-22.91 6.938-34.88S460.9 288 447.1 288H319.1C302.3 288 288 302.3 288 320s14.33 32 32 32h50.75l-73.38 73.38c-9.156 9.156-11.89 22.91-6.938 34.88S307.1 480 319.1 480h127.1C465.7 480 480 465.7 480 448S465.7 416 448 416zM492.6 209.3l-79.99-160.1c-10.84-21.81-46.4-21.81-57.24 0L275.4 209.3c-7.906 15.91-1.5 35.24 14.31 43.19c15.87 7.922 35.04 1.477 42.93-14.4l7.154-14.39h88.43l7.154 14.39c6.174 12.43 23.97 23.87 42.93 14.4C494.1 244.6 500.5 225.2 492.6 209.3zM367.8 167.4L384 134.7l16.22 32.63H367.8z"/>',
viewBox: "0 0 512 512",
},
"arrow-up-short-wide": {
path: '<path d="M544 416h-223.1c-17.67 0-32 14.33-32 32s14.33 32 32 32H544c17.67 0 32-14.33 32-32S561.7 416 544 416zM320 96h32c17.67 0 31.1-14.33 31.1-32s-14.33-32-31.1-32h-32c-17.67 0-32 14.33-32 32S302.3 96 320 96zM320 224H416c17.67 0 32-14.33 32-32s-14.33-32-32-32h-95.1c-17.67 0-32 14.33-32 32S302.3 224 320 224zM320 352H480c17.67 0 32-14.33 32-32s-14.33-32-32-32h-159.1c-17.67 0-32 14.33-32 32S302.3 352 320 352zM151.6 41.95c-12.12-13.26-35.06-13.26-47.19 0l-87.1 96.09C4.475 151.1 5.35 171.4 18.38 183.3c6.141 5.629 13.89 8.414 21.61 8.414c8.672 0 17.3-3.504 23.61-10.39L96 145.9v302C96 465.7 110.3 480 128 480s32-14.33 32-32.03V145.9L192.4 181.3C204.4 194.3 224.6 195.3 237.6 183.3c13.03-11.95 13.9-32.22 1.969-45.27L151.6 41.95z"/>',
viewBox: "0 0 576 512",
},
"arrow-down-wide-short": {
path: '<path d="M416 288h-95.1c-17.67 0-32 14.33-32 32s14.33 32 32 32H416c17.67 0 32-14.33 32-32S433.7 288 416 288zM544 32h-223.1c-17.67 0-32 14.33-32 32s14.33 32 32 32H544c17.67 0 32-14.33 32-32S561.7 32 544 32zM352 416h-32c-17.67 0-32 14.33-32 32s14.33 32 32 32h32c17.67 0 31.1-14.33 31.1-32S369.7 416 352 416zM480 160h-159.1c-17.67 0-32 14.33-32 32s14.33 32 32 32H480c17.67 0 32-14.33 32-32S497.7 160 480 160zM192.4 330.7L160 366.1V64.03C160 46.33 145.7 32 128 32S96 46.33 96 64.03v302L63.6 330.7c-6.312-6.883-14.94-10.38-23.61-10.38c-7.719 0-15.47 2.781-21.61 8.414c-13.03 11.95-13.9 32.22-1.969 45.27l87.1 96.09c12.12 13.26 35.06 13.26 47.19 0l87.1-96.09c11.94-13.05 11.06-33.31-1.969-45.27C224.6 316.8 204.4 317.7 192.4 330.7z"/>',
viewBox: "0 0 576 512",
},
"filter": {
path: '<path d="M3.853 54.87C10.47 40.9 24.54 32 40 32H472C487.5 32 501.5 40.9 508.1 54.87C514.8 68.84 512.7 85.37 502.1 97.33L320 320.9V448C320 460.1 313.2 471.2 302.3 476.6C291.5 482 278.5 480.9 268.8 473.6L204.8 425.6C196.7 419.6 192 410.1 192 400V320.9L9.042 97.33C-.745 85.37-2.765 68.84 3.854 54.87L3.853 54.87z"/>',
viewBox: "0 0 512 512",
},
"calendar": {
path: '<path d="M96 32C96 14.33 110.3 0 128 0C145.7 0 160 14.33 160 32V64H288V32C288 14.33 302.3 0 320 0C337.7 0 352 14.33 352 32V64H400C426.5 64 448 85.49 448 112V160H0V112C0 85.49 21.49 64 48 64H96V32zM448 464C448 490.5 426.5 512 400 512H48C21.49 512 0 490.5 0 464V192H448V464z"/>',
viewBox: "0 0 448 512",
},
"pencil": {
path: '<path d="M421.7 220.3L188.5 453.4L154.6 419.5L158.1 416H112C103.2 416 96 408.8 96 400V353.9L92.51 357.4C87.78 362.2 84.31 368 82.42 374.4L59.44 452.6L137.6 429.6C143.1 427.7 149.8 424.2 154.6 419.5L188.5 453.4C178.1 463.8 165.2 471.5 151.1 475.6L30.77 511C22.35 513.5 13.24 511.2 7.03 504.1C.8198 498.8-1.502 489.7 .976 481.2L36.37 360.9C40.53 346.8 48.16 333.9 58.57 323.5L291.7 90.34L421.7 220.3zM492.7 58.75C517.7 83.74 517.7 124.3 492.7 149.3L444.3 197.7L314.3 67.72L362.7 19.32C387.7-5.678 428.3-5.678 453.3 19.32L492.7 58.75z"/>',
viewBox: "0 0 512 512",
},
"database": {
path: '<path d="M448 80V128C448 172.2 347.7 208 224 208C100.3 208 0 172.2 0 128V80C0 35.82 100.3 0 224 0C347.7 0 448 35.82 448 80zM393.2 214.7C413.1 207.3 433.1 197.8 448 186.1V288C448 332.2 347.7 368 224 368C100.3 368 0 332.2 0 288V186.1C14.93 197.8 34.02 207.3 54.85 214.7C99.66 230.7 159.5 240 224 240C288.5 240 348.3 230.7 393.2 214.7V214.7zM54.85 374.7C99.66 390.7 159.5 400 224 400C288.5 400 348.3 390.7 393.2 374.7C413.1 367.3 433.1 357.8 448 346.1V432C448 476.2 347.7 512 224 512C100.3 512 0 476.2 0 432V346.1C14.93 357.8 34.02 367.3 54.85 374.7z"/>',
viewBox: "0 0 448 512",
},
"dice": {
path: '<path d="M447.1 224c0-12.56-4.781-25.13-14.35-34.76l-174.9-174.9C249.1 4.786 236.5 0 223.1 0C211.4 0 198.9 4.786 189.2 14.35L14.35 189.2C4.783 198.9-.0011 211.4-.0011 223.1c0 12.56 4.785 25.17 14.35 34.8l174.9 174.9c9.625 9.562 22.19 14.35 34.75 14.35s25.13-4.783 34.75-14.35l174.9-174.9C443.2 249.1 447.1 236.6 447.1 224zM96 248c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1S120 210.8 120 224S109.3 248 96 248zM224 376c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S237.3 376 224 376zM224 248c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1S248 210.8 248 224S237.3 248 224 248zM224 120c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S237.3 120 224 120zM352 248c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S365.3 248 352 248zM591.1 192l-118.7 0c4.418 10.27 6.604 21.25 6.604 32.23c0 20.7-7.865 41.38-23.63 57.14l-136.2 136.2v46.37C320 490.5 341.5 512 368 512h223.1c26.5 0 47.1-21.5 47.1-47.1V240C639.1 213.5 618.5 192 591.1 192zM479.1 376c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S493.2 376 479.1 376z"/>',
viewBox: "0 0 640 512",
},
"triangle-exclamation": {
path: '<path d="M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z"/>',
viewBox: "0 0 512 512",
},
"eye": {
path: '<path d="M279.6 160.4C282.4 160.1 285.2 160 288 160C341 160 384 202.1 384 256C384 309 341 352 288 352C234.1 352 192 309 192 256C192 253.2 192.1 250.4 192.4 247.6C201.7 252.1 212.5 256 224 256C259.3 256 288 227.3 288 192C288 180.5 284.1 169.7 279.6 160.4zM480.6 112.6C527.4 156 558.7 207.1 573.5 243.7C576.8 251.6 576.8 260.4 573.5 268.3C558.7 304 527.4 355.1 480.6 399.4C433.5 443.2 368.8 480 288 480C207.2 480 142.5 443.2 95.42 399.4C48.62 355.1 17.34 304 2.461 268.3C-.8205 260.4-.8205 251.6 2.461 243.7C17.34 207.1 48.62 156 95.42 112.6C142.5 68.84 207.2 32 288 32C368.8 32 433.5 68.84 480.6 112.6V112.6zM288 112C208.5 112 144 176.5 144 256C144 335.5 208.5 400 288 400C367.5 400 432 335.5 432 256C432 176.5 367.5 112 288 112z"/>',
viewBox: "0 0 576 512",
},
"circle-plus": {
path: '<path d="M0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256zM256 368C269.3 368 280 357.3 280 344V280H344C357.3 280 368 269.3 368 256C368 242.7 357.3 232 344 232H280V168C280 154.7 269.3 144 256 144C242.7 144 232 154.7 232 168V232H168C154.7 232 144 242.7 144 256C144 269.3 154.7 280 168 280H232V344C232 357.3 242.7 368 256 368z"/>',
viewBox: "0 0 512 512",
},
"magnifying-glass": {
path: '<path d="M500.3 443.7l-119.7-119.7c27.22-40.41 40.65-90.9 33.46-144.7C401.8 87.79 326.8 13.32 235.2 1.723C99.01-15.51-15.51 99.01 1.724 235.2c11.6 91.64 86.08 166.7 177.6 178.9c53.8 7.189 104.3-6.236 144.7-33.46l119.7 119.7c15.62 15.62 40.95 15.62 56.57 0C515.9 484.7 515.9 459.3 500.3 443.7zM79.1 208c0-70.58 57.42-128 128-128s128 57.42 128 128c0 70.58-57.42 128-128 128S79.1 278.6 79.1 208z"/>',
viewBox: "0 0 512 512",
},
"expand": {
path: '<path d="M128 32H32C14.31 32 0 46.31 0 64v96c0 17.69 14.31 32 32 32s32-14.31 32-32V96h64c17.69 0 32-14.31 32-32S145.7 32 128 32zM416 32h-96c-17.69 0-32 14.31-32 32s14.31 32 32 32h64v64c0 17.69 14.31 32 32 32s32-14.31 32-32V64C448 46.31 433.7 32 416 32zM128 416H64v-64c0-17.69-14.31-32-32-32s-32 14.31-32 32v96c0 17.69 14.31 32 32 32h96c17.69 0 32-14.31 32-32S145.7 416 128 416zM416 320c-17.69 0-32 14.31-32 32v64h-64c-17.69 0-32 14.31-32 32s14.31 32 32 32h96c17.69 0 32-14.31 32-32v-96C448 334.3 433.7 320 416 320z"/>',
viewBox: "0 0 448 512",
},
"compress": {
path: '<path d="M128 320H32c-17.69 0-32 14.31-32 32s14.31 32 32 32h64v64c0 17.69 14.31 32 32 32s32-14.31 32-32v-96C160 334.3 145.7 320 128 320zM416 320h-96c-17.69 0-32 14.31-32 32v96c0 17.69 14.31 32 32 32s32-14.31 32-32v-64h64c17.69 0 32-14.31 32-32S433.7 320 416 320zM320 192h96c17.69 0 32-14.31 32-32s-14.31-32-32-32h-64V64c0-17.69-14.31-32-32-32s-32 14.31-32 32v96C288 177.7 302.3 192 320 192zM128 32C110.3 32 96 46.31 96 64v64H32C14.31 128 0 142.3 0 160s14.31 32 32 32h96c17.69 0 32-14.31 32-32V64C160 46.31 145.7 32 128 32z"/>',
viewBox: "0 0 448 512",
},
"check": {
path: '<path d="M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z"/>',
viewBox: "0 0 448 512",
},
"close": {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18 17.94 6M18 18 6.06 6"/>',
viewBox: "0 0 24 24",
},
"arrow-left": {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12l4-4m-4 4 4 4"/>',
viewBox: "0 0 24 24",
},
"list": {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9 8h10M9 12h10M9 16h10M4.99 8H5m-.02 4h.01m0 4H5"/>',
viewBox: "0 0 24 24",
},
"ordered-list": {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6h8m-8 6h8m-8 6h8M4 16a2 2 0 1 1 3.321 1.5L4 20h5M4 5l2-1v6m-2 0h4"/>',
viewBox: "0 0 24 24",
},
"italic": {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8.874 19 6.143-14M6 19h6.33m-.66-14H18"/>',
viewBox: "0 0 24 24",
}
};
export let width = 16;
export let height = 16;
export let icon = "";
export let fill = "currentColor";
export let stroke = "currentColor";
let selectedIcon = icons[icon];
</script>
<svg
class="bi"
xmlns="http://www.w3.org/2000/svg"
{width}
{height}
viewBox={selectedIcon.viewBox}
aria-labelledby={icon}
role="presentation"
{stroke}
{fill}
>
{@html selectedIcon.path}
</svg>
<style>
svg {
vertical-align: text-top;
}
</style>
@@ -0,0 +1,128 @@
<script>
import { post } from "../../modules/remote";
import { getApp } from "../../app";
// import Tools from "./tools/Tools.svelte";
// import Pagination from "./pagination/Pagination.svelte";
// import ActionsOnSelected from "./ActionsOnSelected.svelte";
// import Table from "./Table.svelte";
let { channel, data } = $props();
let newRecordName = $state("");
const app = getApp();
// export let schema;
// export let users;
// export let records;
// export let graph;
// // export let visibleFields;
// export let systemFields;
// export let sortParam;
// export let sortField;
// export let operators;
// export let filter;
// export let limit;
// export let skip;
// export let total;
let inModal = false;
// export let modalUrl;
// export let selected = [];
// export let isWritable = false;
// function refresh(e) {
// const newUrl = e.detail;
// axios
// .get(newUrl)
// .then((response) => {
// records = response.data.records;
// sortParam = response.data.sortParam;
// sortField = response.data.sortField;
// operators = response.data.operators;
// filter = response.data.filter;
// skip = response.data.skip;
// limit = response.data.limit;
// total = response.data.total;
// modalUrl = response.data.modalUrl;
// document.querySelector("dialog h3").scrollIntoView();
// })
// .catch((error) => {
// console.log(error);
// });
// }
//
function handleRecordCreate(e) {
e.preventDefault();
post(
channel.lucentUrl + "/records",
{
schemaId: data.schema.id,
title: newRecordName,
},
(data, err) => {
if (err.isEmpty()) {
Turbo.visit(app.url("records/" + data.id));
}
},
);
}
</script>
<div class="">
<div class={inModal ? "mt-0" : "mt-5"}>
<h3 class="header-normal mb-5">
{data.schema.name}
</h3>
<details style="max-width: 400px;">
<summary>New Record</summary>
<form onsubmit={handleRecordCreate}>
<fieldset>
<input
bind:value={newRecordName}
placeholder="Record title"
required
/>
</fieldset>
<button type="submit">Create</button>
</form>
</details>
<!-- {#if selected.length > 0 && !inModal && isWritable}
<ActionsOnSelected {schema} {selected} {filter}/>
{:else}
<Tools
bind:schema
bind:records
{systemFields}
{sortParam}
{sortField}
{operators}
{filter}
{graph}
{inModal}
{modalUrl}
{isWritable}
on:refresh={refresh}
/>
{/if}
<Table
{records}
{graph}
{schema}
{sortParam}
{sortField}
{systemFields}
{inModal}
{users}
{isWritable}
bind:selected
/> -->
</div>
<!--
<Pagination
{limit}
{skip}
{total}
on:refresh={refresh}
{inModal}
{modalUrl}
/> -->
</div>
@@ -48,6 +48,14 @@
Edit <em>{data.field.type}</em> field {data.field.name}
</h3>
{#if data.field.alias == "_title"}
{@render titleField()}
{:else}
{@render normalfield()}
{/if}
{/snippet}
{#snippet normalfield()}
<form onsubmit={handleUpdate}>
<fieldset>
<label>
@@ -74,6 +82,14 @@
Developers will use this to reference the field
</small>
</label>
<label>
<input
bind:checked={data.field.translatable}
type="checkbox"
role="switch"
/>
Is Translatable
</label>
</fieldset>
{#if data.field.type === "text"}
@@ -88,3 +104,20 @@
{/snippet}
</DeleteButton>
{/snippet}
{#snippet titleField()}
<form onsubmit={handleUpdate}>
<fieldset>
<label>
<input
bind:checked={data.field.translatable}
type="checkbox"
role="switch"
/>
Is Translatable
</label>
</fieldset>
<button type="submit">Update</button>
</form>
{/snippet}
@@ -0,0 +1,20 @@
<script>
import AccountLayout from "../../layouts/AccountLayout.svelte";
import Step from "./Step.svelte";
let { channel, data } = $props();
</script>
<AccountLayout {body} {channel}></AccountLayout>
{#snippet body()}
<div class="wrapper-tiny">
{#each data.steps as step}
<Step {step}></Step>
{/each}
<div style="text-align: center;margin-top: 30px;">
{#if data.allSuccess}
<a href="/lucent/register" class="bt">Create the first user</a>
{/if}
</div>
</div>
{/snippet}
@@ -1,42 +1,36 @@
<script>
import Icon from "../common/Icon.svelte"
export let step;
import Icon from "../../common/Icon.svelte";
let { step } = $props();
</script>
<div class="step step-{step.status}">
<div class="step-icon">
{#if step.status === "success"}
<Icon icon="check"></Icon>
{:else}
<Icon icon="close"></Icon>
{/if}
</div>
<div style="width:100%">
<h4>{step.name}</h4>
<details>
<summary>Instuctions</summary>
<summary>
{#if step.status === "success"}
<Icon icon="check"></Icon> {step.name}
{:else}
<Icon icon="close"></Icon> {step.name}
{/if}
</summary>
<code class="instructions">{step.instructions}</code>
</details>
</div>
</div>
<style>
.step-success .step-icon{
.step-success .step-icon {
background: var(--suc10);
color: var(--suc100);
}
.step-fail .step-icon{
.step-fail .step-icon {
background: var(--err10);
color: var(--err100);
}
.step-icon{
.step-icon {
padding: 12px;
border-radius: 12px;
}
@@ -64,4 +58,4 @@
white-space: break-spaces;
display: block;
}
</style>
</style>
+4 -4
View File
@@ -6,11 +6,11 @@ import Register from "./svelte/account/Register.svelte";
import LoginEntry from "./entry/LoginEntry/LoginEntry.svelte";
import VerifyEntry from "./entry/VerifyEntry/VerifyEntry.svelte";
import Profile from "./svelte/account/Profile.svelte";
import SetupIndex from "./svelte/setup/Index.svelte";
import SetupEntry from "./entry/SetupEntry/SetupEntry.svelte";
import Members from "./svelte/members/Members.svelte";
import RecordNotFound from "./svelte/records/NotFound.svelte";
import RecordEdit from "./svelte/records/Edit.svelte";
import ContentIndex from "./svelte/content/Index.svelte";
import ContentEntry from "./entry/ContentEntry/ContentEntry.svelte";
import HomeEntry from "./entry/HomeEntry/HomeEntry.svelte";
import SchemaEntry from "./entry/SchemaEntry/SchemaEntry.svelte";
import FieldCreateEntry from "./entry/FieldCreateEntry/FieldCreateEntry.svelte";
@@ -23,14 +23,14 @@ const entryComponents = {
members: Members,
recordEdit: RecordEdit,
recordNotFound: RecordNotFound,
contentIndex: ContentIndex,
contentIndex: ContentEntry,
homeIndex: HomeEntry,
buildReport: BuildReport,
register: Register,
login: LoginEntry,
verify: VerifyEntry,
profile: Profile,
setup: SetupIndex,
setup: SetupEntry,
schemas: SchemaEntry,
fieldCreate: FieldCreateEntry,
fieldEdit: FieldEditEntry,
+1 -1
View File
@@ -34,7 +34,7 @@ export function post(url, postData, callback) {
// Turbo.visit(link(res.data.redirect));
return;
}
const errors = makeErrors(res.data.errors);
const errors = makeErrors(res.data?.errors ?? []);
if (errors.isNotEmpty()) {
callback?.(null, errors);
} else {
@@ -1,52 +1,44 @@
<script>
import Selectlist from "./Selectlist.svelte";
import Icon from "../common/Icon.svelte";
import Icon from "../../common/Icon.svelte";
let searchEl;
let search;
export let value;
export let field;
function handleSelect(){
function handleSelect() {
searchEl.focus();
searchEl.blur()
searchEl.blur();
}
</script>
<div class="autocomplete">
<input
type="search"
bind:value={search}
bind:this={searchEl}
placeholder="Search for options"
autocomplete="off"
type="search"
bind:value={search}
bind:this={searchEl}
placeholder="Search for options"
autocomplete="off"
/>
<div class="autocomplete-results">
<Selectlist
{field}
bind:value
bind:search
on:selected={handleSelect}
/>
<Selectlist {field} bind:value bind:search on:selected={handleSelect} />
</div>
</div>
{#if value}
<div class="autocomplete-selected-value">
<div class="autocomplete-selected-value">
{#if Array.isArray(field.selectOptions)}
{value}
{:else}
{field.selectOptions[value]}
{/if}
<button
on:click|preventDefault={(e) => (value = "")}
type="button"
class="button-text"
aria-label="Close"
on:click|preventDefault={(e) => (value = "")}
type="button"
class="button-text"
aria-label="Close"
>
<Icon width={12} height={12} icon="close"></Icon>
</button>
</div>
{/if}
{/if}
+22 -25
View File
@@ -56,23 +56,23 @@
path: '<path d="M416 288h-95.1c-17.67 0-32 14.33-32 32s14.33 32 32 32H416c17.67 0 32-14.33 32-32S433.7 288 416 288zM544 32h-223.1c-17.67 0-32 14.33-32 32s14.33 32 32 32H544c17.67 0 32-14.33 32-32S561.7 32 544 32zM352 416h-32c-17.67 0-32 14.33-32 32s14.33 32 32 32h32c17.67 0 31.1-14.33 31.1-32S369.7 416 352 416zM480 160h-159.1c-17.67 0-32 14.33-32 32s14.33 32 32 32H480c17.67 0 32-14.33 32-32S497.7 160 480 160zM192.4 330.7L160 366.1V64.03C160 46.33 145.7 32 128 32S96 46.33 96 64.03v302L63.6 330.7c-6.312-6.883-14.94-10.38-23.61-10.38c-7.719 0-15.47 2.781-21.61 8.414c-13.03 11.95-13.9 32.22-1.969 45.27l87.1 96.09c12.12 13.26 35.06 13.26 47.19 0l87.1-96.09c11.94-13.05 11.06-33.31-1.969-45.27C224.6 316.8 204.4 317.7 192.4 330.7z"/>',
viewBox: "0 0 576 512",
},
"filter": {
filter: {
path: '<path d="M3.853 54.87C10.47 40.9 24.54 32 40 32H472C487.5 32 501.5 40.9 508.1 54.87C514.8 68.84 512.7 85.37 502.1 97.33L320 320.9V448C320 460.1 313.2 471.2 302.3 476.6C291.5 482 278.5 480.9 268.8 473.6L204.8 425.6C196.7 419.6 192 410.1 192 400V320.9L9.042 97.33C-.745 85.37-2.765 68.84 3.854 54.87L3.853 54.87z"/>',
viewBox: "0 0 512 512",
},
"calendar": {
calendar: {
path: '<path d="M96 32C96 14.33 110.3 0 128 0C145.7 0 160 14.33 160 32V64H288V32C288 14.33 302.3 0 320 0C337.7 0 352 14.33 352 32V64H400C426.5 64 448 85.49 448 112V160H0V112C0 85.49 21.49 64 48 64H96V32zM448 464C448 490.5 426.5 512 400 512H48C21.49 512 0 490.5 0 464V192H448V464z"/>',
viewBox: "0 0 448 512",
},
"pencil": {
pencil: {
path: '<path d="M421.7 220.3L188.5 453.4L154.6 419.5L158.1 416H112C103.2 416 96 408.8 96 400V353.9L92.51 357.4C87.78 362.2 84.31 368 82.42 374.4L59.44 452.6L137.6 429.6C143.1 427.7 149.8 424.2 154.6 419.5L188.5 453.4C178.1 463.8 165.2 471.5 151.1 475.6L30.77 511C22.35 513.5 13.24 511.2 7.03 504.1C.8198 498.8-1.502 489.7 .976 481.2L36.37 360.9C40.53 346.8 48.16 333.9 58.57 323.5L291.7 90.34L421.7 220.3zM492.7 58.75C517.7 83.74 517.7 124.3 492.7 149.3L444.3 197.7L314.3 67.72L362.7 19.32C387.7-5.678 428.3-5.678 453.3 19.32L492.7 58.75z"/>',
viewBox: "0 0 512 512",
},
"database": {
database: {
path: '<path d="M448 80V128C448 172.2 347.7 208 224 208C100.3 208 0 172.2 0 128V80C0 35.82 100.3 0 224 0C347.7 0 448 35.82 448 80zM393.2 214.7C413.1 207.3 433.1 197.8 448 186.1V288C448 332.2 347.7 368 224 368C100.3 368 0 332.2 0 288V186.1C14.93 197.8 34.02 207.3 54.85 214.7C99.66 230.7 159.5 240 224 240C288.5 240 348.3 230.7 393.2 214.7V214.7zM54.85 374.7C99.66 390.7 159.5 400 224 400C288.5 400 348.3 390.7 393.2 374.7C413.1 367.3 433.1 357.8 448 346.1V432C448 476.2 347.7 512 224 512C100.3 512 0 476.2 0 432V346.1C14.93 357.8 34.02 367.3 54.85 374.7z"/>',
viewBox: "0 0 448 512",
},
"dice": {
dice: {
path: '<path d="M447.1 224c0-12.56-4.781-25.13-14.35-34.76l-174.9-174.9C249.1 4.786 236.5 0 223.1 0C211.4 0 198.9 4.786 189.2 14.35L14.35 189.2C4.783 198.9-.0011 211.4-.0011 223.1c0 12.56 4.785 25.17 14.35 34.8l174.9 174.9c9.625 9.562 22.19 14.35 34.75 14.35s25.13-4.783 34.75-14.35l174.9-174.9C443.2 249.1 447.1 236.6 447.1 224zM96 248c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1S120 210.8 120 224S109.3 248 96 248zM224 376c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S237.3 376 224 376zM224 248c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1S248 210.8 248 224S237.3 248 224 248zM224 120c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S237.3 120 224 120zM352 248c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S365.3 248 352 248zM591.1 192l-118.7 0c4.418 10.27 6.604 21.25 6.604 32.23c0 20.7-7.865 41.38-23.63 57.14l-136.2 136.2v46.37C320 490.5 341.5 512 368 512h223.1c26.5 0 47.1-21.5 47.1-47.1V240C639.1 213.5 618.5 192 591.1 192zM479.1 376c-13.25 0-23.1-10.75-23.1-23.1s10.75-23.1 23.1-23.1s23.1 10.75 23.1 23.1S493.2 376 479.1 376z"/>',
viewBox: "0 0 640 512",
},
@@ -81,7 +81,7 @@
path: '<path d="M506.3 417l-213.3-364c-16.33-28-57.54-28-73.98 0l-213.2 364C-10.59 444.9 9.849 480 42.74 480h426.6C502.1 480 522.6 445 506.3 417zM232 168c0-13.25 10.75-24 24-24S280 154.8 280 168v128c0 13.25-10.75 24-23.1 24S232 309.3 232 296V168zM256 416c-17.36 0-31.44-14.08-31.44-31.44c0-17.36 14.07-31.44 31.44-31.44s31.44 14.08 31.44 31.44C287.4 401.9 273.4 416 256 416z"/>',
viewBox: "0 0 512 512",
},
"eye": {
eye: {
path: '<path d="M279.6 160.4C282.4 160.1 285.2 160 288 160C341 160 384 202.1 384 256C384 309 341 352 288 352C234.1 352 192 309 192 256C192 253.2 192.1 250.4 192.4 247.6C201.7 252.1 212.5 256 224 256C259.3 256 288 227.3 288 192C288 180.5 284.1 169.7 279.6 160.4zM480.6 112.6C527.4 156 558.7 207.1 573.5 243.7C576.8 251.6 576.8 260.4 573.5 268.3C558.7 304 527.4 355.1 480.6 399.4C433.5 443.2 368.8 480 288 480C207.2 480 142.5 443.2 95.42 399.4C48.62 355.1 17.34 304 2.461 268.3C-.8205 260.4-.8205 251.6 2.461 243.7C17.34 207.1 48.62 156 95.42 112.6C142.5 68.84 207.2 32 288 32C368.8 32 433.5 68.84 480.6 112.6V112.6zM288 112C208.5 112 144 176.5 144 256C144 335.5 208.5 400 288 400C367.5 400 432 335.5 432 256C432 176.5 367.5 112 288 112z"/>',
viewBox: "0 0 576 512",
},
@@ -93,19 +93,19 @@
path: '<path d="M500.3 443.7l-119.7-119.7c27.22-40.41 40.65-90.9 33.46-144.7C401.8 87.79 326.8 13.32 235.2 1.723C99.01-15.51-15.51 99.01 1.724 235.2c11.6 91.64 86.08 166.7 177.6 178.9c53.8 7.189 104.3-6.236 144.7-33.46l119.7 119.7c15.62 15.62 40.95 15.62 56.57 0C515.9 484.7 515.9 459.3 500.3 443.7zM79.1 208c0-70.58 57.42-128 128-128s128 57.42 128 128c0 70.58-57.42 128-128 128S79.1 278.6 79.1 208z"/>',
viewBox: "0 0 512 512",
},
"expand": {
expand: {
path: '<path d="M128 32H32C14.31 32 0 46.31 0 64v96c0 17.69 14.31 32 32 32s32-14.31 32-32V96h64c17.69 0 32-14.31 32-32S145.7 32 128 32zM416 32h-96c-17.69 0-32 14.31-32 32s14.31 32 32 32h64v64c0 17.69 14.31 32 32 32s32-14.31 32-32V64C448 46.31 433.7 32 416 32zM128 416H64v-64c0-17.69-14.31-32-32-32s-32 14.31-32 32v96c0 17.69 14.31 32 32 32h96c17.69 0 32-14.31 32-32S145.7 416 128 416zM416 320c-17.69 0-32 14.31-32 32v64h-64c-17.69 0-32 14.31-32 32s14.31 32 32 32h96c17.69 0 32-14.31 32-32v-96C448 334.3 433.7 320 416 320z"/>',
viewBox: "0 0 448 512",
},
"compress": {
compress: {
path: '<path d="M128 320H32c-17.69 0-32 14.31-32 32s14.31 32 32 32h64v64c0 17.69 14.31 32 32 32s32-14.31 32-32v-96C160 334.3 145.7 320 128 320zM416 320h-96c-17.69 0-32 14.31-32 32v96c0 17.69 14.31 32 32 32s32-14.31 32-32v-64h64c17.69 0 32-14.31 32-32S433.7 320 416 320zM320 192h96c17.69 0 32-14.31 32-32s-14.31-32-32-32h-64V64c0-17.69-14.31-32-32-32s-32 14.31-32 32v96C288 177.7 302.3 192 320 192zM128 32C110.3 32 96 46.31 96 64v64H32C14.31 128 0 142.3 0 160s14.31 32 32 32h96c17.69 0 32-14.31 32-32V64C160 46.31 145.7 32 128 32z"/>',
viewBox: "0 0 448 512",
},
"check": {
check: {
path: '<path d="M438.6 105.4C451.1 117.9 451.1 138.1 438.6 150.6L182.6 406.6C170.1 419.1 149.9 419.1 137.4 406.6L9.372 278.6C-3.124 266.1-3.124 245.9 9.372 233.4C21.87 220.9 42.13 220.9 54.63 233.4L159.1 338.7L393.4 105.4C405.9 92.88 426.1 92.88 438.6 105.4H438.6z"/>',
viewBox: "0 0 448 512",
},
"close": {
close: {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18 17.94 6M18 18 6.06 6"/>',
viewBox: "0 0 24 24",
},
@@ -113,7 +113,7 @@
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M5 12l4-4m-4 4 4 4"/>',
viewBox: "0 0 24 24",
},
"list": {
list: {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-width="2" d="M9 8h10M9 12h10M9 16h10M4.99 8H5m-.02 4h.01m0 4H5"/>',
viewBox: "0 0 24 24",
},
@@ -121,13 +121,12 @@
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6h8m-8 6h8m-8 6h8M4 16a2 2 0 1 1 3.321 1.5L4 20h5M4 5l2-1v6m-2 0h4"/>',
viewBox: "0 0 24 24",
},
"italic": {
italic: {
path: '<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m8.874 19 6.143-14M6 19h6.33m-.66-14H18"/>',
viewBox: "0 0 24 24",
}
},
};
export let width = 16;
export let height = 16;
export let icon = "";
@@ -138,16 +137,15 @@
</script>
<svg
class="bi"
xmlns="http://www.w3.org/2000/svg"
{width}
{height}
viewBox={selectedIcon.viewBox}
aria-labelledby={icon}
role="presentation"
{stroke}
{fill}
class="bi"
xmlns="http://www.w3.org/2000/svg"
{width}
{height}
viewBox={selectedIcon.viewBox}
aria-labelledby={icon}
role="presentation"
{stroke}
{fill}
>
{@html selectedIcon.path}
</svg>
@@ -155,6 +153,5 @@
<style>
svg {
vertical-align: text-top;
}
</style>
@@ -1,15 +1,14 @@
<script>
import {createEventDispatcher, getContext} from "svelte";
import Icon from "../../common/Icon.svelte";
import { createEventDispatcher, getContext } from "svelte";
import Icon from "../../../common/Icon.svelte";
const channel = getContext("channel");
const channel = getContext("channel");
const dispatch = createEventDispatcher();
export let inModal;
export let modalUrl;
const url = new URL(modalUrl ?? window.location.href);
function removeFilter(k) {
const url = new URL(modalUrl ?? window.location.href);
url.searchParams.set("skip", "0");
url.searchParams.delete("notlinked");
@@ -20,16 +19,17 @@
}
}
</script>
{#if url.searchParams.get("notlinked")}
<span class="applied-filter">
{#if url.searchParams.get("notlinked")}
<span class="applied-filter">
Not linked
<button
on:click|preventDefault={() => removeFilter()}
type="button"
class="button-text"
aria-label="Close"
><Icon width={12} height={12} icon="close"></Icon></button>
</span>
{/if}
on:click|preventDefault={() => removeFilter()}
type="button"
class="button-text"
aria-label="Close"
><Icon width={12} height={12} icon="close"></Icon></button
>
</span>
{/if}
+67 -59
View File
@@ -1,6 +1,6 @@
<script>
import Icon from "../../common/Icon.svelte";
import {createEventDispatcher} from "svelte";
import Icon from "../../../common/Icon.svelte";
import { createEventDispatcher } from "svelte";
import Dropdown from "../../common/Dropdown.svelte";
const dispatch = createEventDispatcher();
@@ -12,14 +12,22 @@
export let systemFields = [];
$: sortableFields = schema.fields.filter(
(f) => !["reference", "file", "json", "id", "rich", "markdown", "block"].includes(f.info.name)
(f) =>
![
"reference",
"file",
"json",
"id",
"rich",
"markdown",
"block",
].includes(f.info.name),
);
$: systemFieldsFiltered = systemFields;
$: if (schema.type === "collection") {
systemFieldsFiltered = systemFields.filter((f) => f.files === false);
}
function triggerSortField(fieldSort) {
const url = new URL(modalUrl ?? window.location.href);
url.searchParams.set("sort", fieldSort);
@@ -32,91 +40,91 @@
function sortAsc(e, field) {
e.preventDefault();
let prefix = systemFields.map((el) => el.name).includes(field.name) ? "" : "data.";
let prefix = systemFields.map((el) => el.name).includes(field.name)
? ""
: "data.";
return triggerSortField(prefix + field.name);
}
function sortDesc(e, field) {
e.preventDefault();
let prefix = systemFields.map((el) => el.name).includes(field.name) ? "" : "data.";
let prefix = systemFields.map((el) => el.name).includes(field.name)
? ""
: "data.";
return triggerSortField("-" + prefix + field.name);
}
</script>
<Dropdown>
<div slot="button">
{#if sortParam.startsWith("-")}
<Icon icon="arrow-down-wide-short"/>
<Icon icon="arrow-down-wide-short" />
{:else}
<Icon icon="arrow-up-short-wide"/>
<Icon icon="arrow-up-short-wide" />
{/if}
<span class="ms-1">{sortField.label}</span>
</div>
<div>
{#each sortableFields as field}
<div class="dropdown-item">
<button
{#each sortableFields as field}
<div class="dropdown-item">
<button
on:click={(e) => sortAsc(e, field)}
title="Sort Ascending"
class="button button-icon {field.name == sortField.name && !sortParam.startsWith("-")
? 'active'
: ''} "
>
<Icon icon="arrow-up-short-wide"/>
</button>
<button
class="button button-icon {field.name == sortField.name &&
!sortParam.startsWith('-')
? 'active'
: ''} "
>
<Icon icon="arrow-up-short-wide" />
</button>
<button
on:click={(e) => sortDesc(e, field)}
title="Sort Descending"
class="button button-icon {field.name == sortField.name && sortParam.startsWith("-")
? 'active'
: ''} "
>
<Icon icon="arrow-down-wide-short"/>
</button>
<button
class="button button-icon {field.name == sortField.name &&
sortParam.startsWith('-')
? 'active'
: ''} "
>
<Icon icon="arrow-down-wide-short" />
</button>
<button
title="Sort Ascending"
on:click={(e) => sortAsc(e, field)}
class="button"
>
{field.label}
</button>
</div>
{/each}
<h6 class="dropdown-header">System</h6>
{#each systemFieldsFiltered as field}
<div class="dropdown-item">
<button
>
{field.label}
</button>
</div>
{/each}
<h6 class="dropdown-header">System</h6>
{#each systemFieldsFiltered as field}
<div class="dropdown-item">
<button
on:click={(e) => sortAsc(e, field)}
title="Sort Ascending"
class="button button-icon {field.name == sortParam
? 'active'
: ''} "
>
<Icon icon="arrow-up-short-wide"/>
</button>
<button
class="button button-icon {field.name == sortParam
? 'active'
: ''} "
>
<Icon icon="arrow-up-short-wide" />
</button>
<button
on:click={(e) => sortDesc(e, field)}
title="Sort Descending"
class="button button-icon {'-' + field.name == sortParam
? 'active'
: ''} "
>
<Icon icon="arrow-down-wide-short"/>
</button>
<button
class="button button-icon {'-' + field.name == sortParam
? 'active'
: ''} "
>
<Icon icon="arrow-down-wide-short" />
</button>
<button
title="Sort Ascending"
on:click={(e) => sortAsc(e, field)}
class="button"
>
{field.label}
</button>
</div>
{/each}
>
{field.label}
</button>
</div>
{/each}
</div>
</Dropdown>
+46 -58
View File
@@ -1,10 +1,10 @@
<script>
import FilterFields from "./FilterFields.svelte";
import Uploader from "../../files/Uploader.svelte";
import Icon from "../../common/Icon.svelte";
import Icon from "../../../common/Icon.svelte";
import SortFields from "./SortFields.svelte";
import AppliedFilter from "./AppliedFilter.svelte";
import {createEventDispatcher, getContext} from "svelte";
import { createEventDispatcher, getContext } from "svelte";
import Dropdown from "../../common/Dropdown.svelte";
import AppliedFilterNotLinked from "./AppliedFilterNotLinked.svelte";
@@ -41,7 +41,6 @@
} else {
window.location = url;
}
}
function uploadComplete(e) {
@@ -51,110 +50,99 @@
<div class="toolbar">
<div class="toolbar-filters">
<SortFields
{schema}
{sortParam}
{sortField}
{systemFields}
{inModal}
{modalUrl}
on:refresh
{schema}
{sortParam}
{sortField}
{systemFields}
{inModal}
{modalUrl}
on:refresh
/>
<FilterFields
bind:schema
{systemFields}
{operators}
{filter}
{inModal}
{modalUrl}
on:refresh
bind:schema
{systemFields}
{operators}
{filter}
{inModal}
{modalUrl}
on:refresh
/>
<form method="GET" on:submit={search}>
<input type="search" name="filter[search_regex]" placeholder="Search"
class="search" required>
<input
type="search"
name="filter[search_regex]"
placeholder="Search"
class="search"
required
/>
</form>
</div>
<div style="display:flex;align-items: center;gap:4px">
{#if schema.type === "collection"}
{#if !inModal && isWritable}
<a
href="{channel.lucentUrl}/records/new?schema={schema.name}"
class="button"
href="{channel.lucentUrl}/records/new?schema={schema.name}"
class="button"
>
New Record
</a>
{/if}
{:else }
{:else}
<div>
<Uploader {schema} on:uploadComplete={uploadComplete}/>
<Uploader {schema} on:uploadComplete={uploadComplete} />
</div>
{/if}
{#if !inModal}
<Dropdown orientation="right">
<div slot="button">
<Icon icon="ellipsis-vertical"/>
<Icon icon="ellipsis-vertical" />
</div>
{#if filter["status_in"] === "trashed"}
{#if isWritable}
<a
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}/emptyTrash"
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}/emptyTrash"
>
Empty trash
</a>
{/if}
{:else}
<a class="dropdown-item" href={csvUrl}>Export to CSV</a>
<a
class="dropdown-item"
href={csvUrl}
>Export to CSV</a
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}?filter[status_in]=trashed"
>View trashed records</a
>
<a
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}?filter[status_in]=trashed"
>View trashed records</a
>
<a
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}?notlinked=*"
>View unlinked records</a
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}?notlinked=*"
>View unlinked records</a
>
{/if}
</Dropdown>
{/if}
</div>
</div>
<div class="applied-filters">
<AppliedFilterNotLinked
{inModal}
{modalUrl}
on:refresh
<AppliedFilterNotLinked {inModal} {modalUrl} on:refresh
></AppliedFilterNotLinked>
{#if Object.entries(filter).length > 0}
{#each Object.entries(filter) as [k, v]}
<AppliedFilter
{schema}
{operators}
key={k}
value={v}
{inModal}
{modalUrl}
{graph}
on:refresh
{schema}
{operators}
key={k}
value={v}
{inModal}
{modalUrl}
{graph}
on:refresh
/>
{/each}
{/if}
</div>
+22 -26
View File
@@ -1,7 +1,6 @@
<script>
import {createEventDispatcher, getContext} from "svelte";
import Icon from "../common/Icon.svelte";
import { createEventDispatcher, getContext } from "svelte";
import Icon from "../../common/Icon.svelte";
import Index from "../content/Index.svelte";
import axios from "axios";
@@ -15,13 +14,12 @@
// load();
// });
export function close(e) {
if(e){
if (e) {
e.preventDefault();
}
dialogEl.close()
dialogEl.close();
selectedRecords = [];
}
@@ -52,42 +50,41 @@
}
export function open(schema) {
dialogEl.showModal()
dialogEl.showModal();
load(schema);
}
</script>
<dialog bind:this={dialogEl}>
{#if data.schema}
<div class="dialog-header">
<button
type="button"
class="button"
on:click={insert}
disabled={selectedRecords.length === 0}
type="button"
class="button"
on:click={insert}
disabled={selectedRecords.length === 0}
>
Insert
</button>
<button
type="button"
class="button"
on:click={replace}
disabled={selectedRecords.length === 0}
type="button"
class="button"
on:click={replace}
disabled={selectedRecords.length === 0}
>
Replace
</button>
{#if selectedRecords.length > 0}
<span class="">
{selectedRecords.length} records selected
</span>
<span class="">
{selectedRecords.length} records selected
</span>
{/if}
<button
on:click|preventDefault={close}
type="button"
class="button close"
aria-label="Close"
on:click|preventDefault={close}
type="button"
class="button close"
aria-label="Close"
>
<Icon icon="close"></Icon>
</button>
@@ -96,6 +93,5 @@
<div class="dialog-body">
<Index {...data} bind:selected={selectedRecords}></Index>
</div>
{/if}
</dialog>
</dialog>
+10 -13
View File
@@ -1,6 +1,5 @@
<script>
import Icon from "../common/Icon.svelte";
import Icon from "../../common/Icon.svelte";
let dialogEl;
@@ -10,29 +9,27 @@
if (e) {
e.preventDefault();
}
dialogEl.close()
dialogEl.close();
}
export function open() {
dialogEl.showModal()
dialogEl.showModal();
}
</script>
<dialog bind:this={dialogEl}>
<div class="dialog-header">
<button
on:click|preventDefault={close}
type="button"
class="button close"
aria-label="Close"
on:click|preventDefault={close}
type="button"
class="button close"
aria-label="Close"
>
<Icon icon="close"></Icon>
</button>
</div>
<div class="dialog-body" style="min-width: 900px">
<slot/>
<slot />
</div>
</dialog>
</dialog>
+23 -24
View File
@@ -1,7 +1,7 @@
<script>
import Icon from "../common/Icon.svelte";
import {imgurl} from "./imageserver.js";
import {getContext} from "svelte";
import Icon from "../../common/Icon.svelte";
import { imgurl } from "./imageserver.js";
import { getContext } from "svelte";
export let record;
const channel = getContext("channel");
@@ -28,50 +28,49 @@
fontSize = "13";
}
</script>
<div style="display: flex;align-items: center;gap: 5px;">
{#if record}
{#if record._file.mime.startsWith("image")}
<!-- href={imgurl(record)} -->
<a
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.originalName}
style="width:{imageSide}px;height:{imageSide}px"
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.originalName}
style="width:{imageSide}px;height:{imageSide}px"
>
<img
class="rounded w-100"
src={imgurl(channel,record)}
alt={record._file.path}
class="rounded w-100"
src={imgurl(channel, record)}
alt={record._file.path}
/>
</a>
{:else}
<a
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.path}
class="file-preview-small"
style="width:{imageSide}px;height:{imageSide}px"
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.path}
class="file-preview-small"
style="width:{imageSide}px;height:{imageSide}px"
>
<Icon icon="file" width={fileSide} height={fileSide}/>
<Icon icon="file" width={fileSide} height={fileSide} />
<span class="ms-2"
>.{record._file.path.split(".").pop().toLowerCase()}</span
>.{record._file.path.split(".").pop().toLowerCase()}</span
>
</a>
{/if}
{/if}
{#if showFilename}
<a
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.path}
class="preview-file-filename lx-small-text text-decoration-none"
>{record._file.path} </a
>
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.path}
class="preview-file-filename lx-small-text text-decoration-none"
>{record._file.path}
</a>
{/if}
</div>
<style>
img{
img {
border-radius: 12px;
padding: 4px;
}
</style>
</style>
+1 -1
View File
@@ -2,7 +2,7 @@
import { friendlyDate } from "../../helpers";
import Avatar from "../../common/Avatar.svelte";
import { usernameById } from "../account/users";
import Icon from "../common/Icon.svelte";
import Icon from "../../common/Icon.svelte";
import RevisionCell from "./revisions/RevisionCell.svelte";
import { getContext } from "svelte";
import RevisionEdgeRow from "./revisions/RevisionEdgeRow.svelte";
@@ -1,6 +1,6 @@
<script>
import {createEventDispatcher, getContext} from "svelte";
import Icon from "../../common/Icon.svelte";
import { createEventDispatcher, getContext } from "svelte";
import Icon from "../../../common/Icon.svelte";
import InlineEdit from "../InlineEdit.svelte";
import Dialog from "../../dialog/Dialog.svelte";
import DialogRecord from "../../dialog/DialogRecord.svelte";
@@ -24,7 +24,7 @@
e.preventDefault();
console.log("Save inline");
inLineCreateRecord = null;
dialogRecord.close()
dialogRecord.close();
dispatch("save", {
records: e.detail.records,
after: recordId,
@@ -48,7 +48,7 @@
.get(channel.lucentUrl + "/records/newInline?schema=" + schemaUId)
.then((response) => {
inLineCreateRecord = response.data;
dialogRecord.open()
dialogRecord.open();
})
.catch((error) => {
console.log(error);
@@ -57,60 +57,53 @@
</script>
{#if schemas.length > 1}
<div
style="display: flex;align-items: center;gap:4px"
>
<div style="display: flex;align-items: center;gap:4px">
<Dropdown>
<div slot="button">New</div>
{#each schemas as schema}
<button
class=" button"
on:click={(e) =>
createInlineReference(e, schema.name)}
>{schema.label}
class=" button"
on:click={(e) => createInlineReference(e, schema.name)}
>{schema.label}
</button>
{/each}
</Dropdown>
<Dropdown>
<div slot="button"> <Icon icon="magnifying-glass"/></div>
<div slot="button"><Icon icon="magnifying-glass" /></div>
{#each schemas as schema}
<button
class="button"
on:click={(e) => openBrowseModal(e, schema.name)}
>{schema.label}
class="button"
on:click={(e) => openBrowseModal(e, schema.name)}
>{schema.label}
</button>
{/each}
</Dropdown>
</div>
{:else}
<div style="display:flex;align-items: center;gap: 4px">
<button
class="button"
on:click={(e) => createInlineReference(e, schemas[0].name)}
>New
class="button"
on:click={(e) => createInlineReference(e, schemas[0].name)}
>New
</button>
<button
class="button"
on:click={(e) => openBrowseModal(e, schemas[0].name)}
>
<Icon icon="magnifying-glass"/>
</button
class="button"
on:click={(e) => openBrowseModal(e, schemas[0].name)}
>
<Icon icon="magnifying-glass" />
</button>
</div>
{/if}
<DialogRecord bind:this={dialogRecord}>
{#if inLineCreateRecord}
<InlineEdit
{...inLineCreateRecord}
isCreateMode={true}
on:cancel={(e) => (inLineCreateRecord = null)}
on:inlinesaved={save}
{...inLineCreateRecord}
isCreateMode={true}
on:cancel={(e) => (inLineCreateRecord = null)}
on:inlinesaved={save}
/>
{/if}
</DialogRecord>
<Dialog bind:this={browseModal} on:insert={insert}/>
<Dialog bind:this={browseModal} on:insert={insert} />
@@ -3,7 +3,7 @@
import { previewTitle } from "../Preview";
import { getErrorMessage } from "./errorMessage";
import { insertEdges } from "./reference.js";
import Icon from "../../common/Icon.svelte";
import Icon from "../../../common/Icon.svelte";
const channel = getContext("channel");
export let field;
+1 -1
View File
@@ -1,6 +1,6 @@
<script>
import { getContext } from "svelte";
import Icon from "../../common/Icon.svelte";
import Icon from "../../../common/Icon.svelte";
import { getErrorMessage } from "./errorMessage";
const channelurl = getContext("channelurl");
export let validationErrors;
@@ -1,6 +1,6 @@
<script>
import {getContext} from "svelte";
import Icon from "../../common/Icon.svelte";
import { getContext } from "svelte";
import Icon from "../../../common/Icon.svelte";
import Dropdown from "../../common/Dropdown.svelte";
import StatusSelect from "./StatusSelect.svelte";
@@ -12,45 +12,44 @@
function clone(e) {
e.preventDefault();
axios.post(channel.lucentUrl + "/records/clone/" + record.id).then(response => {
window.location = channel.lucentUrl + "/records/" + response.data.id;
}).catch(error => {
});
axios
.post(channel.lucentUrl + "/records/clone/" + record.id)
.then((response) => {
window.location =
channel.lucentUrl + "/records/" + response.data.id;
})
.catch((error) => {});
}
</script>
<div style="display: flex;align-items: center; gap:10px;">
{#if !isCreateMode}
<Dropdown >
<Dropdown>
<div slot="button">
<Icon icon="ellipsis"/>
<Icon icon="ellipsis" />
</div>
<h6 class="dropdown-header">Record Actions</h6>
<a
class="dropdown-item"
href="{channel.lucentUrl}/records/new?schema={schema.name}"
>Create new</a
class="dropdown-item"
href="{channel.lucentUrl}/records/new?schema={schema.name}"
>Create new</a
>
{#if !isCreateMode}
<a
class="dropdown-item"
on:click={clone}
href={channel.lucentUrl}
class="dropdown-item"
on:click={clone}
href={channel.lucentUrl}
>
Clone
</a>
{/if}
<a
on:click|preventDefault={(e) =>
(activeContentTab = "_info")}
class="dropdown-item"
href="{channel.lucentUrl}">Revisions</a
on:click|preventDefault={(e) => (activeContentTab = "_info")}
class="dropdown-item"
href={channel.lucentUrl}>Revisions</a
>
</Dropdown>
{/if}
<StatusSelect bind:status={record.status} {record}></StatusSelect>
</div>
<StatusSelect bind:status={record.status} {record}></StatusSelect>
</div>
@@ -1,10 +1,10 @@
<script>
import Icon from "../../common/Icon.svelte";
import Icon from "../../../common/Icon.svelte";
import {createEventDispatcher, getContext} from "svelte";
import { createEventDispatcher, getContext } from "svelte";
import Preview from "../../files/Preview.svelte";
import {previewTitle} from "./../Preview";
import {fileurl, htmlurl} from "../../files/imageserver.js"
import { previewTitle } from "./../Preview";
import { fileurl, htmlurl } from "../../files/imageserver.js";
import Status from "./../Status.svelte";
import Dropdown from "../../common/Dropdown.svelte";
@@ -14,7 +14,9 @@
export let hasDelete = false;
export let hasInsert = false;
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
let schema = channel.schemas.find(
(aschema) => aschema.name === record.schema,
);
let cardTitle = previewTitle(channel.schemas, record);
let imagePresets = Object.keys(channel.imageFilters);
@@ -25,67 +27,69 @@
function insert(e, preset) {
e.preventDefault();
let html = htmlurl(channel, record, preset)
let url = !preset ? `/${record._file.path}` : `/templates/${preset}/${record._file.path}`;
let html = htmlurl(channel, record, preset);
let url = !preset
? `/${record._file.path}`
: `/templates/${preset}/${record._file.path}`;
dispatch("editor-insert", {
html: html,
url: channel.filesUrl + url,
originalUrl: channel.filesUrl + "/" + record._file.path,
record: record
url: channel.filesUrl + url,
originalUrl: channel.filesUrl + "/" + record._file.path,
record: record,
});
}
</script>
<div class="preview-file">
<div style="display: flex;align-items: center;gap: 10px;">
<div class="image">
<Preview {record} size="small"/>
<Preview {record} size="small" />
</div>
<div class="title">
<div>
<a
class="record-title"
href="{channel.lucentUrl}/records/{record.id}"
class="record-title"
href="{channel.lucentUrl}/records/{record.id}"
>
{cardTitle}
</a>
<small class="d-block">
from {schema.label}
{#if record.status === "draft"}
<Status status={record.status}/>
<Status status={record.status} />
{/if}
</small>
</div>
</div>
</div>
<div style="display: flex;gap:4px; align-items: center; margin-right: 10px;">
<div
style="display: flex;gap:4px; align-items: center; margin-right: 10px;"
>
{#if hasInsert}
<div class="reference-action">
<Dropdown>
<div slot="button">
<Icon icon="photo-film"/>
<Icon icon="photo-film" />
</div>
<button class="dropdown-item button" on:click={e => insert(e,null)}>original</button>
<button
class="dropdown-item button"
on:click={(e) => insert(e, null)}>original</button
>
{#each imagePresets as preset}
<button class="dropdown-item button" on:click={e => insert(e,preset)}>{preset}</button>
<button
class="dropdown-item button"
on:click={(e) => insert(e, preset)}>{preset}</button
>
{/each}
</Dropdown>
</div>
{/if}
{#if hasDelete}
<div class="reference-action">
<button
class="button"
on:click={remove}
>
<Icon icon="trash-can"/>
<button class="button" on:click={remove}>
<Icon icon="trash-can" />
</button>
</div>
{/if}
</div>
</div>
@@ -1,8 +1,8 @@
<script>
import Icon from "../../common/Icon.svelte";
import Icon from "../../../common/Icon.svelte";
import {createEventDispatcher, getContext} from "svelte";
import {previewTitle} from "./../Preview";
import { createEventDispatcher, getContext } from "svelte";
import { previewTitle } from "./../Preview";
import Status from "./../Status.svelte";
import Preview from "../../files/Preview.svelte";
@@ -12,10 +12,16 @@
export let record;
export let hasDelete = false;
let schema = channel.schemas.find((aschema) => aschema.name === record.schema);
let schema = channel.schemas.find(
(aschema) => aschema.name === record.schema,
);
let cardTitle = previewTitle(channel.schemas, record, graph);
const cardImageEdge = graph.edges.find(e => e.source === record.id && e.field === schema.cardImage);
let cardImageRecord = graph.records.find(r => r.id === cardImageEdge?.target);
const cardImageEdge = graph.edges.find(
(e) => e.source === record.id && e.field === schema.cardImage,
);
let cardImageRecord = graph.records.find(
(r) => r.id === cardImageEdge?.target,
);
function remove(e) {
e.preventDefault();
@@ -23,43 +29,35 @@
}
</script>
<div class="preview-reference">
<div style="display: flex;align-items: center;gap: 10px;">
{#if cardImageRecord}
<div class="image">
<Preview record={cardImageRecord} size="small"/>
<Preview record={cardImageRecord} size="small" />
</div>
{/if}
<div class="title">
<div>
<a
class="record-title"
href="{channel.lucentUrl}/records/{record.id}"
class="record-title"
href="{channel.lucentUrl}/records/{record.id}"
>
{cardTitle}
</a>
<small class="d-block">
from {schema.label}
{#if record.status === "draft"}
<Status status={record.status}/>
<Status status={record.status} />
{/if}
</small>
</div>
</div>
</div>
{#if hasDelete}
<div class="reference-action">
<button
class="button"
on:click={remove}
>
<Icon icon="trash-can"/>
<button class="button" on:click={remove}>
<Icon icon="trash-can" />
</button>
</div>
{/if}
</div>
-20
View File
@@ -1,20 +0,0 @@
<script>
import Step from "./Step.svelte"
export let steps;
export let allSuccess = false;
console.log(steps);
</script>
<div class="wrapper-tiny">
{#each steps as step}
<Step {step}></Step>
{/each}
<div style="text-align: center;margin-top: 30px;">
{#if allSuccess}
<a href="/lucent/register" class="bt">Create the first user</a>
{/if}
</div>
</div>
+18
View File
@@ -1,6 +1,8 @@
<?php namespace Lucent\Core\Auth;
use Illuminate\Support\Facades\Session;
use Lucent\Core\Repository\UserRepo;
use Lucent\LucentException;
class AuthModule
{
@@ -19,4 +21,20 @@ class AuthModule
{
return !empty(static::getCurrentUserId());
}
public static function refreshSession()
{
$user = UserRepo::findById(static::getCurrentUserId());
if (empty($user)) {
throw new LucentException("Your account was not found");
}
// @todo
// if ($user->get()->isRemoved()) {
// throw new LucentException("Your account is not active");
// }
Session::put(["user" => toArray($user)]);
}
}
+6 -1
View File
@@ -7,6 +7,11 @@ class ChannelModule
public static function get(): Channel
{
$appUrl = rtrim(config("lucent.url") ?? "", "/");
return new Channel(url: $appUrl, lucentUrl: $appUrl . "/lucent");
return new Channel(
name: config("lucent.name"),
locales: config("lucent.locales") ?? [],
url: $appUrl,
lucentUrl: $appUrl . "/lucent",
);
}
}
+6 -1
View File
@@ -2,5 +2,10 @@
class Channel
{
public function __construct(public string $url, public string $lucentUrl) {}
public function __construct(
public string $name,
public array $locales,
public string $url,
public string $lucentUrl,
) {}
}
+23
View File
@@ -0,0 +1,23 @@
<?php namespace Lucent\Core\Data;
use Carbon\Carbon;
class Record
{
/**
* @param RecordField[] $draftData
* @param RecordField[] $liveData
*/
public function __construct(
public string $id,
public string $schemaId,
public array $draftData,
public array $liveData,
public Carbon $createdAt,
public string $createdBy,
public ?Carbon $publishedAt,
public ?string $publishedBy,
public ?Carbon $trashedAt,
public ?string $trashedBy,
) {}
}
+17
View File
@@ -0,0 +1,17 @@
<?php namespace Lucent\Core\Data;
use Carbon\Carbon;
class RecordField
{
public function __construct(
public string $id,
public string $locale,
public mixed $value,
public Carbon $createdAt,
public string $createdBy,
public Carbon $updatedAt,
public string $updatedBy,
public int $version,
) {}
}
+15
View File
@@ -0,0 +1,15 @@
<?php
namespace Lucent\Core\Data;
class User
{
/**
* @param array<string> $roles
*/
function __construct(
public string $id,
public string $name,
public string $email,
) {}
}
+84
View File
@@ -0,0 +1,84 @@
<?php namespace Lucent\Core\Record;
use Carbon\Carbon;
use Lucent\Core\Data\Record;
use Lucent\Core\Data\RecordField;
use stdClass;
class RecordModule
{
public static function toDb(Record $record): array
{
return [
"id" => $record->id,
"schema_id" => $record->schemaId,
"draft_data" => json_encode(
array_map(static::recordFieldToDb(...), $record->draftData),
),
"live_data" => json_encode(
array_map(static::recordFieldToDb(...), $record->liveData),
),
"created_at" => $record->createdAt->toJSON(),
"created_by" => $record->createdBy,
"published_at" => empty($record->publishedAt)
? null
: record->publishedAt->toJSON(),
"published_by" => $record->publishedBy,
"trashed_at" => empty($record->trashedAt)
? null
: record->trashedAt->toJSON(),
"trashed_by" => $record->trashedBy,
];
}
public static function fromDb(stdClass $data): Record
{
$draftDataArr = json_decode(data_get($data, "draft_data"), true);
$liveDataArr = json_decode(data_get($data, "live_data"), true);
return new Record(
id: data_get($data, "id"),
schemaId: data_get($data, "schema_id"),
draftData: array_map(static::recordFieldFromDb(...), $draftDataArr),
liveData: array_map(static::recordFieldFromDb(...), $liveDataArr),
createdAt: Carbon::parse(data_get($data, "created_at")),
createdBy: data_get($data, "created_by"),
publishedAt: empty(data_get($data, "published_at"))
? null
: Carbon::parse(data_get($data, "published_at")),
publishedBy: data_get($data, "published_by"),
trashedAt: empty(data_get($data, "trashed_at"))
? null
: Carbon::parse(data_get($data, "trashed_at")),
trashedBy: data_get($data, "trashed_by"),
);
}
public static function recordFieldFromDb(array $field): RecordField
{
return new RecordField(
id: data_get($field, "id"),
locale: data_get($field, "locale", []),
value: data_get($field, "value"),
createdAt: Carbon::parse(data_get($field, "created_at")),
createdBy: data_get($field, "created_by"),
updatedAt: Carbon::parse(data_get($field, "updated_at")),
updatedBy: data_get($field, "updated_by"),
version: data_get($field, "version"),
);
}
public static function recordFieldToDb(RecordField $field): array
{
return [
"id" => $field->id,
"locale" => $field->locale,
"value" => $field->value,
"created_at" => $field->createdAt->toJSON(),
"created_by" => $field->createdBy,
"updated_at" => $field->updatedAt->toJSON(),
"updated_by" => $field->updatedBy,
"version" => $field->version,
];
}
}
-1
View File
@@ -3,7 +3,6 @@
use Illuminate\Support\Facades\DB;
use Lucent\Core\Schema\Data\Field;
use Lucent\Core\Schema\FieldModule;
use Lucent\Core\Schema\SchemaModule;
class FieldRepo
{
+15
View File
@@ -0,0 +1,15 @@
<?php namespace Lucent\Core\Repository;
use Illuminate\Support\Facades\DB;
use Lucent\Core\Data\Record;
use Lucent\Core\Record\RecordModule;
class RecordRepo
{
const TABLE_NAME = "records";
public static function insert(Record $record): void
{
DB::table(self::TABLE_NAME)->insert(RecordModule::toDb($record));
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php namespace Lucent\Core\Repository;
use Illuminate\Support\Facades\DB;
use Lucent\Core\Data\User;
use Lucent\Core\User\UserModule;
class UserRepo
{
const TABLE_NAME = "users";
public static function findById(string $id): ?User
{
return DB::table(self::TABLE_NAME)
->where("id", $id)
->get()
->map(UserModule::fromDb(...))
->first();
}
}
+1
View File
@@ -10,6 +10,7 @@ class Field
public string $name,
public string $type,
public string $schemaId,
public bool $translatable,
public int $rank,
public IFieldProp $props,
) {}
+2
View File
@@ -24,6 +24,7 @@ class FieldModule
"name" => $field->name,
"type" => $field->type,
"rank" => $field->rank,
"translatable" => $field->translatable,
"props" => json_encode($field->props),
"schema_id" => $field->schemaId,
];
@@ -38,6 +39,7 @@ class FieldModule
type: data_get($data, "type"),
schemaId: data_get($data, "schema_id"),
rank: data_get($data, "rank"),
translatable: data_get($data, "translatable"),
props: FieldProp::fromDb(
data_get($data, "type"),
data_get($data, "props"),
+16
View File
@@ -0,0 +1,16 @@
<?php namespace Lucent\Core\User;
use Lucent\Core\Data\User;
use stdClass;
class UserModule
{
public static function fromDb(stdClass $data): User
{
return new User(
id: data_get($data, "id"),
name: data_get($data, "name"),
email: data_get($data, "email"),
);
}
}
+6
View File
@@ -51,6 +51,10 @@ class FieldController
$fields = FieldRepo::all();
$newRank = collect($fields)->last()->rank + 1;
if ($alias === "_title") {
return response()->json(["errors" => "System Reserved alias"], 422);
}
$validator = Validator::make($request->all(), [
"name" => "required|string|max:30|min:2",
"alias" => "required|alpha_dash:ascii|max:30|min:2",
@@ -74,6 +78,7 @@ class FieldController
type: $fieldType,
props: $fieldProps,
rank: $newRank,
translatable: false,
);
FieldRepo::insert($field);
@@ -132,6 +137,7 @@ class FieldController
schemaId: $field->schemaId,
name: data_get($fieldData, "name"),
alias: data_get($fieldData, "alias"),
translatable: data_get($fieldData, "translatable"),
type: $field->type,
rank: $field->rank,
props: $fieldProps,
+107 -146
View File
@@ -2,24 +2,28 @@
namespace Lucent\Http\Controller;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Lucent\Account\AccountService;
use Lucent\Channel\ChannelService;
use Lucent\Core\Auth\AuthModule;
use Lucent\Core\Data\RecordField;
use Lucent\Core\Repository\SchemaRepo;
use Lucent\Id\Id;
use Lucent\LucentException;
use Lucent\Query\Operator\OperatorRegistry;
use Lucent\Query\Query;
use Lucent\Record\InputData\EdgeInputData;
use Lucent\Record\InputData\RecordInputData;
use Lucent\Record\Manager;
use Lucent\Record\QueryRecord;
use Lucent\Core\Repository\RecordRepo;
use Lucent\Record\RecordService;
use Lucent\Record\Status;
use Lucent\Schema\System;
use Lucent\Schema\Ui\Reference;
use Lucent\Schema\Validator\ValidatorException;
use Lucent\Svelte\Svelte;
use Lucent\ViewModel\ViewModel;
use Lucent\Core\Data\Record;
use function Lucent\Response\fail;
use function Lucent\Response\ok;
@@ -38,90 +42,84 @@ class RecordController
public function index(Request $request)
{
$schemaName = $request->route("schemaName");
$schemaId = $request->route("id");
$schemas = SchemaRepo::all();
$schema = collect($schemas)->firstWhere("id", $schemaId);
// $users = $this->accountService->all();
$users = [];
// $schema = $this->channelService->getSchema($schemaName)->get();
// $urlParams = $request->all();
// $sort = data_get($urlParams, "sort") ?? $schema->sortBy;
// $filter = data_get($urlParams, "filter") ?? [];
if (
!in_array(
$schemaName,
$this->accountService->currentReadableSchemas(),
)
) {
return Svelte::view("recordNotFound", "Schema Not Found", []);
}
// $arguments = array_merge(
// [
// "schema" => $schema->name,
// "status_in" => "draft,published",
// ],
// $filter,
// );
$users = $this->accountService->all();
$schema = $this->channelService->getSchema($schemaName)->get();
$urlParams = $request->all();
$sort = data_get($urlParams, "sort") ?? $schema->sortBy;
$filter = data_get($urlParams, "filter") ?? [];
$arguments = array_merge(
[
"schema" => $schema->name,
"status_in" => "draft,published",
],
$filter,
);
$skip = data_get($urlParams, "skip") ?? 0;
// $skip = data_get($urlParams, "skip") ?? 0;
$skip = 0;
$limit = 30;
$records = [];
$graphArray = null;
// $graphArray = null;
$graph = $this->query
->filter($arguments)
->notLinked($request->input("notlinked") ?? "")
->limit($limit)
->status(explode(",", $arguments["status_in"]))
->skip($skip)
->sort($sort)
->childrenFields($schema?->visible ?? [])
->childrenDepth(1)
->parentsDepth(0)
->runWithCount();
// $graph = $this->query
// ->filter($arguments)
// ->notLinked($request->input("notlinked") ?? "")
// ->limit($limit)
// ->status(explode(",", $arguments["status_in"]))
// ->skip($skip)
// ->sort($sort)
// ->childrenFields($schema?->visible ?? [])
// ->childrenDepth(1)
// ->parentsDepth(0)
// ->runWithCount();
$records = $graph->getRootRecords()->toArray();
// $records = $graph->getRootRecords()->toArray();
$data = [
"schemas" => $this->channelService->channel->schemas,
"schemas" => $schemas,
"schema" => $schema,
"users" => $users,
"records" => $records,
"graph" => toArray($graph),
"systemFields" => array_values(System::list()),
"operators" => $this->operatorRegistry->all(),
"sortParam" => $sort,
"sortField" => $schema->fields
->merge(array_values(System::list()))
->firstWhere(
fn($field) => $field->name === $sort ||
"-" . $field->name === $sort ||
"data." . $field->name === $sort ||
"-data." . $field->name === $sort,
),
"limit" => $limit,
"skip" => $skip,
"total" => $graph->total ?? 0,
"filter" => $request->input("filter") ?? [],
"inModal" => true,
"isWritable" => in_array(
$schemaName,
$this->accountService->currentWritableSchemas(),
),
// "graph" => toArray($graph),
// "systemFields" => array_values(System::list()),
// "operators" => $this->operatorRegistry->all(),
// "sortParam" => $sort,
// "sortField" => $schema->fields
// ->merge(array_values(System::list()))
// ->firstWhere(
// fn($field) => $field->name === $sort ||
// "-" . $field->name === $sort ||
// "data." . $field->name === $sort ||
// "-data." . $field->name === $sort,
// ),
// "limit" => $limit,
// "skip" => $skip,
// "total" => $graph->total ?? 0,
// "filter" => $request->input("filter") ?? [],
// "inModal" => true,
// "isWritable" => in_array(
// $schemaName,
// $this->accountService->currentWritableSchemas(),
// ),
];
if ($request->ajax()) {
$data["modalUrl"] = $request->fullUrl();
if (str_starts_with(config("lucent.url"), "https")) {
$data["modalUrl"] = str_replace(
"http://",
"https://",
$request->fullUrl(),
);
}
return $data;
}
$data["inModal"] = false;
// if ($request->ajax()) {
// $data["modalUrl"] = $request->fullUrl();
// if (str_starts_with(config("lucent.url"), "https")) {
// $data["modalUrl"] = str_replace(
// "http://",
// "https://",
// $request->fullUrl(),
// );
// }
// return $data;
// }
// $data["inModal"] = false;
return Svelte::view(
view: "contentIndex",
title: "Records",
@@ -219,78 +217,6 @@ class RecordController
}, []);
}
public function new(Request $request)
{
if (
!in_array(
$request->input("schema"),
$this->accountService->currentWritableSchemas(),
)
) {
return $this->svelte->render(
layout: "channel",
view: "recordNotFound",
title: "Schema Not Found",
);
}
$schema = $this->channelService->channel->schemas
->where("name", $request->input("schema"))
->first();
$recordHistory = $this->recordManager
->fromSession($request->session())
->getRecords();
$record = $this->recordService->createEmpty($schema);
$queryRecord = QueryRecord::fromRecord($record);
return $this->svelte->render(
layout: "channel",
view: "recordEdit",
title: "New Record",
data: [
"schema" => $schema,
"record" => $queryRecord,
"recordHistory" => $recordHistory,
"isCreateMode" => true,
"isWritable" => in_array(
$record->schema,
$this->accountService->currentWritableSchemas(),
),
],
);
}
public function newInline(Request $request)
{
if (
!in_array(
$request->input("schema"),
$this->accountService->currentWritableSchemas(),
)
) {
return $this->svelte->render(
layout: "channel",
view: "recordNotFound",
title: "Schema Not Found",
);
}
$schema = $this->channelService
->getSchema($request->input("schema"))
->get();
$record = $this->recordService->createEmpty($schema);
$queryRecord = QueryRecord::fromRecord($record);
return [
"schema" => $schema,
"record" => $queryRecord,
"isCreateMode" => true,
"isWritable" => in_array(
$record->schema,
$this->accountService->currentWritableSchemas(),
),
];
}
public function edit(Request $request)
{
$rid = $request->route("rid");
@@ -381,6 +307,41 @@ class RecordController
return ok($records->toArray());
}
public function postCreate(Request $request)
{
$schemaId = $request->input("schemaId");
$title = $request->input("title");
$now = Carbon::now();
$userId = AuthModule::getCurrentUserId();
$titleField = new RecordField(
id: "_title",
locale: "main",
value: $title,
createdAt: $now,
createdBy: $userId,
updatedAt: $now,
updatedBy: $userId,
version: 1,
);
$record = new Record(
id: Id::new(),
schemaId: $schemaId,
draftData: [$titleField],
liveData: [],
createdAt: $now,
createdBy: $userId,
publishedAt: null,
publishedBy: null,
trashedAt: null,
trashedBy: null,
);
RecordRepo::insert($record);
return ok(toArray($record));
}
public function save(Request $request)
{
$recordId = $request->input("record.id");
+22
View File
@@ -5,6 +5,9 @@ namespace Lucent\Http\Controller;
use Illuminate\Http\Request;
use Lucent\Core\Repository\SchemaRepo;
use Lucent\Core\Repository\FieldRepo;
use Lucent\Core\Schema\Data\Field;
use Lucent\Core\Schema\Data\FieldProp\FieldProp;
use Lucent\Core\Schema\Data\FieldProp\TextFieldProp;
use Lucent\Core\Schema\Data\Schema;
use Lucent\Id\Id;
use Lucent\Svelte\Svelte;
@@ -45,6 +48,25 @@ class SchemaController
);
SchemaRepo::insert($schema);
$field = new Field(
id: Id::new(),
schemaId: $schema->id,
name: "Title",
alias: "_title",
type: "text",
props: new TextFieldProp(
required: true,
readonly: false,
hidden: false,
default: "",
min: 1,
max: 255,
help: "",
),
rank: 0,
translatable: false,
);
FieldRepo::insert($field);
return response()->json(
["message" => "Schema created successfully"],
+2 -1
View File
@@ -41,6 +41,7 @@ class SetupController
]),
[],
);
$allSuccess = array_reduce(
$steps,
fn(bool $carry, SetupStep $step) => !$carry
@@ -57,7 +58,7 @@ class SetupController
}
}
return $this->svelte->render(
return Svelte::view(
view: "setup",
title: "Setup Lucent",
data: [
+7 -11
View File
@@ -8,6 +8,8 @@ use Illuminate\Support\Facades\View;
use Lucent\Account\AccountService;
use Lucent\Account\AuthService;
use Lucent\Channel\ChannelService;
use Lucent\Core\Auth\AuthModule;
use Lucent\Core\Channel\ChannelModule;
use Lucent\ViewModel\ViewModel;
readonly class AuthMiddleware
@@ -16,21 +18,15 @@ readonly class AuthMiddleware
private AuthService $authService,
private AccountService $accountService,
private ChannelService $channelService,
private ViewModel $viewModel
)
{
}
private ViewModel $viewModel,
) {}
public function handle(Request $request, Closure $next)
{
if (!$this->authService->isLoggedIn()) {
return redirect($this->channelService->channel->lucentUrl . "/login");
if (!AuthModule::isLoggedIn()) {
return redirect(ChannelModule::get()->lucentUrl . "/login");
}
$this->authService->refreshSession();
View::share("channel",$this->channelService->channel);
View::share("user",session("user"));
View::share("schemas",$this->channelService->channel->schemas->whereIn("name",$this->accountService->currentReadableSchemas())->values());
View::share("viewModel",$this->viewModel);
AuthModule::refreshSession();
return $next($request);
}
+6 -5
View File
@@ -67,10 +67,11 @@ Route::group(
]);
// CONTENT
Route::get("content/{schemaName}", [
RecordController::class,
"index",
]);
Route::get("content/{id}", [RecordController::class, "index"]);
// RECORD
Route::get("records/{id}", [RecordController::class, "edit"]);
Route::post("records", [RecordController::class, "postCreate"]);
});
//OLD
@@ -124,7 +125,7 @@ Route::group(
RecordController::class,
"parents",
]);
Route::post("/", [RecordController::class, "save"]);
// Route::post("/", [RecordController::class, "save"]);
Route::post("/status/{status}", [
RecordController::class,
"status",