sveltekit-ui 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Components/Content/index.svelte.js +11 -47
- package/dist/Components/TableAdvanced/ColumnInput/index.svelte.js +1 -2
- package/dist/Components/TableAdvanced/index.svelte.js +108 -81
- package/dist/client/index.js +49 -1
- package/package.json +1 -1
- package/src/lib/Components/Content/index.svelte.js +11 -47
- package/src/lib/Components/TableAdvanced/ColumnInput/index.svelte.js +1 -2
- package/src/lib/Components/TableAdvanced/index.svelte.js +108 -81
- package/src/lib/client/index.js +49 -1
- package/src/routes/[component]/Showcase/TableAdvanced/index.svelte +46 -175
|
@@ -26,7 +26,15 @@ import { create_qr_manager } from "../Qr/index.svelte.js"
|
|
|
26
26
|
import { create_file_input_manager } from "../FileInput/index.svelte.js"
|
|
27
27
|
import { create_cron_input_manager } from "../CronInput/index.svelte.js"
|
|
28
28
|
import { create_button_manager } from "../Button/index.svelte.js"
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
node_types,
|
|
31
|
+
deep_copy,
|
|
32
|
+
set_closurable,
|
|
33
|
+
create_unique_id,
|
|
34
|
+
copy_to_clipboard,
|
|
35
|
+
get_def_from_variable_path,
|
|
36
|
+
is_defined,
|
|
37
|
+
} from "../../client/index.js"
|
|
30
38
|
|
|
31
39
|
export function create_content_manager(config) {
|
|
32
40
|
const id = create_unique_id(null, 20)
|
|
@@ -36,57 +44,13 @@ export function create_content_manager(config) {
|
|
|
36
44
|
let mapkit_js_token = $derived(set_closurable(config?.mapkit_js_token, null))
|
|
37
45
|
let val_prepped = $state(null)
|
|
38
46
|
|
|
39
|
-
function get_def(input) {
|
|
40
|
-
for (let item of definition_stack) {
|
|
41
|
-
if (item.hasOwnProperty(input)) {
|
|
42
|
-
return item?.[input]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function get_def_from_variable_path(input) {
|
|
49
|
-
let val = null
|
|
50
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
51
|
-
val = get_def(input?.[0])
|
|
52
|
-
for (let i = 1; i < input.length; i++) {
|
|
53
|
-
if (Array.isArray(input?.[i])) {
|
|
54
|
-
const res = get_def_from_variable_path(input?.[i])
|
|
55
|
-
val = val?.[res]
|
|
56
|
-
} else {
|
|
57
|
-
val = val?.[input?.[i]]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return val
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function is_defined(input) {
|
|
65
|
-
for (let item of definition_stack) {
|
|
66
|
-
if (item.hasOwnProperty(input)) {
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function set_def(identifier, value) {
|
|
74
|
-
console.log("set_def", identifier, value)
|
|
75
|
-
for (let i = 0; i < definition_stack.length; i++) {
|
|
76
|
-
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
77
|
-
definition_stack[i][identifier] = value
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
console.log("definition_stack_after_Set", definition_stack)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
47
|
function clean_attributes_from_variable_path(attributes) {
|
|
84
48
|
let cleaned_attributes = attributes
|
|
85
49
|
if (Object.keys(attributes || {}).length) {
|
|
86
50
|
for (let [att_key, att_val] of Object.entries(attributes)) {
|
|
87
51
|
if (att_key.endsWith("_from_variable_path") && att_val != null) {
|
|
88
52
|
const att_key_to_set = att_key.split("_from_variable_path")?.[0]
|
|
89
|
-
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val)
|
|
53
|
+
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val, definition_stack)
|
|
90
54
|
}
|
|
91
55
|
}
|
|
92
56
|
}
|
|
@@ -128,7 +92,7 @@ export function create_content_manager(config) {
|
|
|
128
92
|
function clean_variable_path(input) {
|
|
129
93
|
let cleaned_path = []
|
|
130
94
|
if (Array.isArray(input) && input.length > 0) {
|
|
131
|
-
let is_def = is_defined(input?.[0])
|
|
95
|
+
let is_def = is_defined(input?.[0], definition_stack)
|
|
132
96
|
if (!is_def) {
|
|
133
97
|
return []
|
|
134
98
|
}
|
|
@@ -50,7 +50,6 @@ export function create_column_input_manager(config) {
|
|
|
50
50
|
let rows_data_from_variable_path = $derived(set_closurable(config?.rows_data_from_variable_path, null))
|
|
51
51
|
let columns = $derived(set_closurable(config?.columns, null))
|
|
52
52
|
let columns_length = $derived(Object.keys(columns || {}).length)
|
|
53
|
-
let row_data_type = $derived(set_closurable(config?.row_data_type, null))
|
|
54
53
|
let column_id = $derived(set_closurable(config?.column_id, null))
|
|
55
54
|
let definition_stack = $derived(set_closurable(config?.definition_stack, null))
|
|
56
55
|
let is_column_update = $derived(set_closurable(config?.is_column_update, true))
|
|
@@ -189,7 +188,7 @@ export function create_column_input_manager(config) {
|
|
|
189
188
|
column_db_data_type_input_manager = create_data_type_input_manager({
|
|
190
189
|
// data_sample: () => variables,
|
|
191
190
|
table_options: config?.table_options,
|
|
192
|
-
val: config?.val?.db_data_type
|
|
191
|
+
val: config?.val?.db_data_type,
|
|
193
192
|
on_finish: (input) => {
|
|
194
193
|
let default_content_input_astc = variables_data_type_remaining_to_astc(input, "input", ["rows"])
|
|
195
194
|
column_default_value_content_manager = create_content_manager({
|
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
json_to_csv,
|
|
15
15
|
csv_to_json,
|
|
16
16
|
create_unique_id,
|
|
17
|
-
set_closurable,
|
|
18
|
-
get_data_type_at_path,
|
|
19
17
|
set_definition_stack,
|
|
18
|
+
set_def,
|
|
19
|
+
get_def_from_variable_path,
|
|
20
|
+
variables_data_type_remaining_to_astc,
|
|
20
21
|
} from "../../client/index.js"
|
|
21
22
|
import { tick } from "svelte"
|
|
22
23
|
import { browser } from "$app/environment"
|
|
@@ -95,6 +96,7 @@ export function create_table_advanced_manager(config) {
|
|
|
95
96
|
let column_edit_input_manager = $state(null)
|
|
96
97
|
let column_edit_upsert_column_button_manager = $state(null)
|
|
97
98
|
|
|
99
|
+
let row_edit_def_identifier = $state("edit_row_1001234")
|
|
98
100
|
let row_edit_index = $state(null)
|
|
99
101
|
let preempt_insert_row_popover_manager = $state(null)
|
|
100
102
|
let row_edit_content_manager = $state(null)
|
|
@@ -106,9 +108,7 @@ export function create_table_advanced_manager(config) {
|
|
|
106
108
|
let is_loading_rows = $state(false)
|
|
107
109
|
let loading_rows_progress = $state(0)
|
|
108
110
|
|
|
109
|
-
let rows_data = $derived(get_def_from_variable_path(rows_data_from_variable_path))
|
|
110
|
-
let row_data_type = $state(null)
|
|
111
|
-
|
|
111
|
+
let rows_data = $derived(get_def_from_variable_path(rows_data_from_variable_path, definition_stack))
|
|
112
112
|
let row_indexes_display_order = $derived(get_available_row_indexes())
|
|
113
113
|
let row_indexes_display_order_shown = $derived(get_row_indexes_shown())
|
|
114
114
|
|
|
@@ -126,53 +126,6 @@ export function create_table_advanced_manager(config) {
|
|
|
126
126
|
: []
|
|
127
127
|
)
|
|
128
128
|
|
|
129
|
-
function get_def(input, definition_stack_loc) {
|
|
130
|
-
let definition_stack_to_use = definition_stack_loc ?? definition_stack
|
|
131
|
-
if (Array.isArray(definition_stack_to_use)) {
|
|
132
|
-
for (let item of definition_stack_to_use) {
|
|
133
|
-
if (item.hasOwnProperty(input)) {
|
|
134
|
-
return item?.[input]
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return null
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function get_def_from_variable_path(input, definition_stack_loc) {
|
|
142
|
-
let val = null
|
|
143
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
144
|
-
val = get_def(input?.[0], definition_stack_loc)
|
|
145
|
-
for (let i = 1; i < input.length; i++) {
|
|
146
|
-
if (Array.isArray(input?.[i])) {
|
|
147
|
-
const res = get_def_from_variable_path(input?.[i], definition_stack_loc)
|
|
148
|
-
val = val?.[res]
|
|
149
|
-
} else {
|
|
150
|
-
val = val?.[input?.[i]]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return val
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function is_defined(input) {
|
|
158
|
-
for (let item of definition_stack) {
|
|
159
|
-
if (item.hasOwnProperty(input)) {
|
|
160
|
-
return true
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return false
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function set_def(identifier, value) {
|
|
167
|
-
console.log("set_def", identifier, value)
|
|
168
|
-
for (let i = 0; i < definition_stack.length; i++) {
|
|
169
|
-
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
170
|
-
definition_stack[i][identifier] = value
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
console.log("definition_stack_after_Set", definition_stack)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
129
|
function get_available_row_indexes() {
|
|
177
130
|
let row_indexes = []
|
|
178
131
|
if (
|
|
@@ -414,11 +367,9 @@ export function create_table_advanced_manager(config) {
|
|
|
414
367
|
column_input_options: config?.column_input_options,
|
|
415
368
|
table_options: config?.table_options,
|
|
416
369
|
on_search_table_row_ids: config?.on_search_table_row_ids,
|
|
417
|
-
|
|
418
|
-
definition_stack: () => definition_stack,
|
|
370
|
+
definition_stack: definition_stack,
|
|
419
371
|
columns: () => columns_prepped,
|
|
420
372
|
rows_data_from_variable_path: () => rows_data_from_variable_path,
|
|
421
|
-
row_data_type: () => row_data_type,
|
|
422
373
|
on_delete: async () => {
|
|
423
374
|
if (typeof config?.on_event == "function") {
|
|
424
375
|
const res = await config?.on_event({
|
|
@@ -518,39 +469,28 @@ export function create_table_advanced_manager(config) {
|
|
|
518
469
|
|
|
519
470
|
function edit_row(row_i) {
|
|
520
471
|
row_edit_index = row_i
|
|
521
|
-
let definition_stack_loc = $state([{ [row_iter_identifier]: row_i }, ...definition_stack])
|
|
522
472
|
const path_to_set = [...rows_data_from_variable_path, Number.isInteger(row_i) ? row_i : 0]
|
|
473
|
+
let editable_row = null
|
|
523
474
|
if (!Number.isInteger(row_i)) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (target === undefined) break
|
|
529
|
-
}
|
|
530
|
-
const last_key = path_to_set[path_to_set.length - 1]
|
|
531
|
-
if (Array.isArray(target[last_key])) {
|
|
532
|
-
target[last_key].splice(0, 0, row_default_to_insert)
|
|
533
|
-
} else {
|
|
534
|
-
target[last_key] = row_default_to_insert
|
|
535
|
-
}
|
|
475
|
+
console.log("columns_prepped", columns_prepped)
|
|
476
|
+
editable_row = {}
|
|
477
|
+
} else {
|
|
478
|
+
editable_row = get_def_from_variable_path([...rows_data_from_variable_path, row_i], definition_stack)
|
|
536
479
|
}
|
|
480
|
+
let row_definition_stack = $state([{ [row_edit_def_identifier]: editable_row }, ...definition_stack])
|
|
537
481
|
row_edit_content_manager = null
|
|
538
482
|
setTimeout(() => {
|
|
539
483
|
// quick fix for when update row then edit a diff row the data for other doesnt remain in place
|
|
540
|
-
console.log("row_input_content2222", { row_input_content, ds: [{ row_i }, ...definition_stack] })
|
|
541
484
|
row_edit_content_manager = create_content_manager({
|
|
542
485
|
val: row_input_content ?? null,
|
|
543
|
-
|
|
544
|
-
table_options: config?.table_options,
|
|
486
|
+
definition_stack: row_definition_stack,
|
|
545
487
|
mapkit_js_token: mapkit_js_token,
|
|
488
|
+
storage_items: null, // tbd
|
|
546
489
|
on_search_table_row_ids: config?.on_search_table_row_ids,
|
|
547
|
-
definition_stack: [{ row_i }, ...definition_stack],
|
|
548
490
|
on_event: (input) => {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
definition_stack_loc = res?.definition_stack
|
|
553
|
-
const row_data = get_def_from_variable_path(path_to_set, definition_stack_loc)
|
|
491
|
+
const res = set_definition_stack(input, row_definition_stack)
|
|
492
|
+
row_definition_stack = res?.definition_stack
|
|
493
|
+
const row_data = get_def_from_variable_path([row_edit_def_identifier], row_definition_stack)
|
|
554
494
|
return {
|
|
555
495
|
is_success: true,
|
|
556
496
|
data: {
|
|
@@ -566,8 +506,8 @@ export function create_table_advanced_manager(config) {
|
|
|
566
506
|
is_loading: () => upsert_row_is_loading,
|
|
567
507
|
on_click: async () => {
|
|
568
508
|
upsert_row_is_loading = true
|
|
569
|
-
const row_data = get_def_from_variable_path(
|
|
570
|
-
console.log("edited_row", {
|
|
509
|
+
const row_data = get_def_from_variable_path([row_edit_def_identifier], row_definition_stack)
|
|
510
|
+
console.log("edited_row", { row_i, row_data })
|
|
571
511
|
if (Number.isInteger(row_i)) {
|
|
572
512
|
if (typeof config?.on_event == "function") {
|
|
573
513
|
const res = await config?.on_event({
|
|
@@ -603,6 +543,7 @@ export function create_table_advanced_manager(config) {
|
|
|
603
543
|
row: row_data,
|
|
604
544
|
path: path_to_set,
|
|
605
545
|
})
|
|
546
|
+
console.log("insert_row_res", { res, columns_prepped })
|
|
606
547
|
if (res?.is_success) {
|
|
607
548
|
preempt_insert_row_popover_manager.show_temp_message(
|
|
608
549
|
"Successfully inserted row",
|
|
@@ -677,9 +618,81 @@ export function create_table_advanced_manager(config) {
|
|
|
677
618
|
})
|
|
678
619
|
}
|
|
679
620
|
|
|
621
|
+
function guess_row_input_content(columns) {
|
|
622
|
+
return {
|
|
623
|
+
type_id: "div",
|
|
624
|
+
selector_id: create_unique_id(null, 8),
|
|
625
|
+
children: Object.entries(columns || {})
|
|
626
|
+
.sort(([a_column_id, a_val], [b_column_id, b_val]) => {
|
|
627
|
+
const a_order = a_val?.display_order ?? 0
|
|
628
|
+
const b_order = b_val?.display_order ?? 0
|
|
629
|
+
return a_order - b_order
|
|
630
|
+
})
|
|
631
|
+
.map(([column_id, val]) => {
|
|
632
|
+
if (val?.is_autogenerated) {
|
|
633
|
+
// let guessed_column_display_content = variables_data_type_remaining_to_astc(val?.db_data_type, "display", [
|
|
634
|
+
// "variables",
|
|
635
|
+
// "rows",
|
|
636
|
+
// ["row_i"],
|
|
637
|
+
// column_id,
|
|
638
|
+
// ])
|
|
639
|
+
return {
|
|
640
|
+
type_id: "div",
|
|
641
|
+
selector_id: create_unique_id(null, 8),
|
|
642
|
+
children: [
|
|
643
|
+
{
|
|
644
|
+
type_id: "span",
|
|
645
|
+
selector_id: create_unique_id(null, 8),
|
|
646
|
+
children: [
|
|
647
|
+
{
|
|
648
|
+
type_id: "strong",
|
|
649
|
+
selector_id: create_unique_id(null, 8),
|
|
650
|
+
children: [],
|
|
651
|
+
attributes: { content: column_id },
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
type_id: "em",
|
|
655
|
+
selector_id: create_unique_id(null, 8),
|
|
656
|
+
children: [],
|
|
657
|
+
attributes: { content: " autogenerated " },
|
|
658
|
+
},
|
|
659
|
+
],
|
|
660
|
+
attributes: {},
|
|
661
|
+
},
|
|
662
|
+
// guessed_column_display_content,
|
|
663
|
+
{
|
|
664
|
+
type_id: "br",
|
|
665
|
+
selector_id: create_unique_id(null, 8),
|
|
666
|
+
children: [],
|
|
667
|
+
attributes: {},
|
|
668
|
+
},
|
|
669
|
+
],
|
|
670
|
+
attributes: {},
|
|
671
|
+
}
|
|
672
|
+
} else {
|
|
673
|
+
let guessed_column_input_content = variables_data_type_remaining_to_astc(val?.db_data_type, "input", [
|
|
674
|
+
row_edit_def_identifier,
|
|
675
|
+
column_id,
|
|
676
|
+
])
|
|
677
|
+
if (guessed_column_input_content?.hasOwnProperty("attributes")) {
|
|
678
|
+
if (!guessed_column_input_content.attributes) {
|
|
679
|
+
guessed_column_input_content.attributes = {}
|
|
680
|
+
}
|
|
681
|
+
guessed_column_input_content.attributes.label = column_id
|
|
682
|
+
}
|
|
683
|
+
return {
|
|
684
|
+
type_id: "div",
|
|
685
|
+
selector_id: create_unique_id(null, 8),
|
|
686
|
+
children: [guessed_column_input_content],
|
|
687
|
+
attributes: {},
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}),
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
680
694
|
function set_attributes(attributes) {
|
|
681
695
|
rows_data_from_variable_path = attributes?.rows_data_from_variable_path
|
|
682
|
-
row_input_content = attributes?.row_input_content
|
|
683
696
|
is_data_editable = attributes?.is_data_editable ?? false
|
|
684
697
|
nav_items = Array.isArray(attributes?.nav_items)
|
|
685
698
|
? attributes.nav_items.filter((item) =>
|
|
@@ -702,6 +715,18 @@ export function create_table_advanced_manager(config) {
|
|
|
702
715
|
table_row_max_height = attributes?.table_row_max_height ?? null
|
|
703
716
|
const columns_prepped_loc = set_columns_prepped(attributes?.columns)
|
|
704
717
|
set_rows_prepped(columns_prepped_loc)
|
|
718
|
+
row_input_content = attributes?.row_input_content ?? guess_row_input_content(attributes?.columns)
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function reset_definition_stack(input) {
|
|
722
|
+
console.log("reset_definition_stack", deep_copy(input))
|
|
723
|
+
definition_stack = input
|
|
724
|
+
set_rows_prepped(columns_prepped)
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function set_columns(input) {
|
|
728
|
+
set_columns_prepped(input)
|
|
729
|
+
set_rows_prepped(columns_prepped)
|
|
705
730
|
}
|
|
706
731
|
|
|
707
732
|
function init(config) {
|
|
@@ -709,7 +734,7 @@ export function create_table_advanced_manager(config) {
|
|
|
709
734
|
table_name = config?.table_name
|
|
710
735
|
table_description = config?.table_description
|
|
711
736
|
rows_data_from_variable_path = config?.rows_data_from_variable_path
|
|
712
|
-
row_iter_identifier = config?.row_iter_identifier
|
|
737
|
+
row_iter_identifier = config?.row_iter_identifier ?? "row_i"
|
|
713
738
|
definition_stack = config?.definition_stack
|
|
714
739
|
mapkit_js_token = config?.mapkit_js_token
|
|
715
740
|
set_attributes(config)
|
|
@@ -1417,5 +1442,7 @@ export function create_table_advanced_manager(config) {
|
|
|
1417
1442
|
download_csv,
|
|
1418
1443
|
copy_structure,
|
|
1419
1444
|
set_attributes,
|
|
1445
|
+
reset_definition_stack,
|
|
1446
|
+
set_columns,
|
|
1420
1447
|
}
|
|
1421
1448
|
}
|
package/dist/client/index.js
CHANGED
|
@@ -551,8 +551,56 @@ export function get_data_type_at_path(path, full_data_type) {
|
|
|
551
551
|
return data_type_at_path_loc
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
export function get_def(input, definition_stack) {
|
|
555
|
+
if (Array.isArray(definition_stack)) {
|
|
556
|
+
for (let item of definition_stack) {
|
|
557
|
+
if (item.hasOwnProperty(input)) {
|
|
558
|
+
return item?.[input]
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return null
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export function get_def_from_variable_path(input, definition_stack) {
|
|
566
|
+
let val = null
|
|
567
|
+
if (Array.isArray(input) && input.length > 0) {
|
|
568
|
+
val = get_def(input?.[0], definition_stack)
|
|
569
|
+
for (let i = 1; i < input.length; i++) {
|
|
570
|
+
if (Array.isArray(input?.[i])) {
|
|
571
|
+
const res = get_def_from_variable_path(input?.[i], definition_stack)
|
|
572
|
+
val = val?.[res]
|
|
573
|
+
} else {
|
|
574
|
+
val = val?.[input?.[i]]
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return val
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export function is_defined(input, definition_stack) {
|
|
582
|
+
if (Array.isArray(definition_stack)) {
|
|
583
|
+
for (let item of definition_stack) {
|
|
584
|
+
if (item && typeof item == "object" && item.hasOwnProperty(input)) {
|
|
585
|
+
return true
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return false
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export function set_def(identifier, value, definition_stack) {
|
|
593
|
+
if (Array.isArray(definition_stack)) {
|
|
594
|
+
for (let i = 0; i < definition_stack.length; i++) {
|
|
595
|
+
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
596
|
+
definition_stack[i][identifier] = value
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return definition_stack
|
|
601
|
+
}
|
|
602
|
+
|
|
554
603
|
export function set_definition_stack(input, definition_stack, pass_event_down) {
|
|
555
|
-
console.log("set_definition_stack00", deep_copy({ input, definition_stack, pass_event_down }))
|
|
556
604
|
if (!Array.isArray(input?.variable_path_to_target) || !Array.isArray(definition_stack)) {
|
|
557
605
|
throw new Error("Path must be an array")
|
|
558
606
|
}
|
package/package.json
CHANGED
|
@@ -26,7 +26,15 @@ import { create_qr_manager } from "$lib/Components/Qr/index.svelte.js"
|
|
|
26
26
|
import { create_file_input_manager } from "$lib/Components/FileInput/index.svelte.js"
|
|
27
27
|
import { create_cron_input_manager } from "$lib/Components/CronInput/index.svelte.js"
|
|
28
28
|
import { create_button_manager } from "$lib/Components/Button/index.svelte.js"
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
node_types,
|
|
31
|
+
deep_copy,
|
|
32
|
+
set_closurable,
|
|
33
|
+
create_unique_id,
|
|
34
|
+
copy_to_clipboard,
|
|
35
|
+
get_def_from_variable_path,
|
|
36
|
+
is_defined,
|
|
37
|
+
} from "$lib/client/index.js"
|
|
30
38
|
|
|
31
39
|
export function create_content_manager(config) {
|
|
32
40
|
const id = create_unique_id(null, 20)
|
|
@@ -36,57 +44,13 @@ export function create_content_manager(config) {
|
|
|
36
44
|
let mapkit_js_token = $derived(set_closurable(config?.mapkit_js_token, null))
|
|
37
45
|
let val_prepped = $state(null)
|
|
38
46
|
|
|
39
|
-
function get_def(input) {
|
|
40
|
-
for (let item of definition_stack) {
|
|
41
|
-
if (item.hasOwnProperty(input)) {
|
|
42
|
-
return item?.[input]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function get_def_from_variable_path(input) {
|
|
49
|
-
let val = null
|
|
50
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
51
|
-
val = get_def(input?.[0])
|
|
52
|
-
for (let i = 1; i < input.length; i++) {
|
|
53
|
-
if (Array.isArray(input?.[i])) {
|
|
54
|
-
const res = get_def_from_variable_path(input?.[i])
|
|
55
|
-
val = val?.[res]
|
|
56
|
-
} else {
|
|
57
|
-
val = val?.[input?.[i]]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return val
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function is_defined(input) {
|
|
65
|
-
for (let item of definition_stack) {
|
|
66
|
-
if (item.hasOwnProperty(input)) {
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function set_def(identifier, value) {
|
|
74
|
-
console.log("set_def", identifier, value)
|
|
75
|
-
for (let i = 0; i < definition_stack.length; i++) {
|
|
76
|
-
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
77
|
-
definition_stack[i][identifier] = value
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
console.log("definition_stack_after_Set", definition_stack)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
47
|
function clean_attributes_from_variable_path(attributes) {
|
|
84
48
|
let cleaned_attributes = attributes
|
|
85
49
|
if (Object.keys(attributes || {}).length) {
|
|
86
50
|
for (let [att_key, att_val] of Object.entries(attributes)) {
|
|
87
51
|
if (att_key.endsWith("_from_variable_path") && att_val != null) {
|
|
88
52
|
const att_key_to_set = att_key.split("_from_variable_path")?.[0]
|
|
89
|
-
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val)
|
|
53
|
+
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val, definition_stack)
|
|
90
54
|
}
|
|
91
55
|
}
|
|
92
56
|
}
|
|
@@ -128,7 +92,7 @@ export function create_content_manager(config) {
|
|
|
128
92
|
function clean_variable_path(input) {
|
|
129
93
|
let cleaned_path = []
|
|
130
94
|
if (Array.isArray(input) && input.length > 0) {
|
|
131
|
-
let is_def = is_defined(input?.[0])
|
|
95
|
+
let is_def = is_defined(input?.[0], definition_stack)
|
|
132
96
|
if (!is_def) {
|
|
133
97
|
return []
|
|
134
98
|
}
|
|
@@ -50,7 +50,6 @@ export function create_column_input_manager(config) {
|
|
|
50
50
|
let rows_data_from_variable_path = $derived(set_closurable(config?.rows_data_from_variable_path, null))
|
|
51
51
|
let columns = $derived(set_closurable(config?.columns, null))
|
|
52
52
|
let columns_length = $derived(Object.keys(columns || {}).length)
|
|
53
|
-
let row_data_type = $derived(set_closurable(config?.row_data_type, null))
|
|
54
53
|
let column_id = $derived(set_closurable(config?.column_id, null))
|
|
55
54
|
let definition_stack = $derived(set_closurable(config?.definition_stack, null))
|
|
56
55
|
let is_column_update = $derived(set_closurable(config?.is_column_update, true))
|
|
@@ -189,7 +188,7 @@ export function create_column_input_manager(config) {
|
|
|
189
188
|
column_db_data_type_input_manager = create_data_type_input_manager({
|
|
190
189
|
// data_sample: () => variables,
|
|
191
190
|
table_options: config?.table_options,
|
|
192
|
-
val: config?.val?.db_data_type
|
|
191
|
+
val: config?.val?.db_data_type,
|
|
193
192
|
on_finish: (input) => {
|
|
194
193
|
let default_content_input_astc = variables_data_type_remaining_to_astc(input, "input", ["rows"])
|
|
195
194
|
column_default_value_content_manager = create_content_manager({
|
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
json_to_csv,
|
|
15
15
|
csv_to_json,
|
|
16
16
|
create_unique_id,
|
|
17
|
-
set_closurable,
|
|
18
|
-
get_data_type_at_path,
|
|
19
17
|
set_definition_stack,
|
|
18
|
+
set_def,
|
|
19
|
+
get_def_from_variable_path,
|
|
20
|
+
variables_data_type_remaining_to_astc,
|
|
20
21
|
} from "$lib/client/index.js"
|
|
21
22
|
import { tick } from "svelte"
|
|
22
23
|
import { browser } from "$app/environment"
|
|
@@ -95,6 +96,7 @@ export function create_table_advanced_manager(config) {
|
|
|
95
96
|
let column_edit_input_manager = $state(null)
|
|
96
97
|
let column_edit_upsert_column_button_manager = $state(null)
|
|
97
98
|
|
|
99
|
+
let row_edit_def_identifier = $state("edit_row_1001234")
|
|
98
100
|
let row_edit_index = $state(null)
|
|
99
101
|
let preempt_insert_row_popover_manager = $state(null)
|
|
100
102
|
let row_edit_content_manager = $state(null)
|
|
@@ -106,9 +108,7 @@ export function create_table_advanced_manager(config) {
|
|
|
106
108
|
let is_loading_rows = $state(false)
|
|
107
109
|
let loading_rows_progress = $state(0)
|
|
108
110
|
|
|
109
|
-
let rows_data = $derived(get_def_from_variable_path(rows_data_from_variable_path))
|
|
110
|
-
let row_data_type = $state(null)
|
|
111
|
-
|
|
111
|
+
let rows_data = $derived(get_def_from_variable_path(rows_data_from_variable_path, definition_stack))
|
|
112
112
|
let row_indexes_display_order = $derived(get_available_row_indexes())
|
|
113
113
|
let row_indexes_display_order_shown = $derived(get_row_indexes_shown())
|
|
114
114
|
|
|
@@ -126,53 +126,6 @@ export function create_table_advanced_manager(config) {
|
|
|
126
126
|
: []
|
|
127
127
|
)
|
|
128
128
|
|
|
129
|
-
function get_def(input, definition_stack_loc) {
|
|
130
|
-
let definition_stack_to_use = definition_stack_loc ?? definition_stack
|
|
131
|
-
if (Array.isArray(definition_stack_to_use)) {
|
|
132
|
-
for (let item of definition_stack_to_use) {
|
|
133
|
-
if (item.hasOwnProperty(input)) {
|
|
134
|
-
return item?.[input]
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return null
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function get_def_from_variable_path(input, definition_stack_loc) {
|
|
142
|
-
let val = null
|
|
143
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
144
|
-
val = get_def(input?.[0], definition_stack_loc)
|
|
145
|
-
for (let i = 1; i < input.length; i++) {
|
|
146
|
-
if (Array.isArray(input?.[i])) {
|
|
147
|
-
const res = get_def_from_variable_path(input?.[i], definition_stack_loc)
|
|
148
|
-
val = val?.[res]
|
|
149
|
-
} else {
|
|
150
|
-
val = val?.[input?.[i]]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return val
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function is_defined(input) {
|
|
158
|
-
for (let item of definition_stack) {
|
|
159
|
-
if (item.hasOwnProperty(input)) {
|
|
160
|
-
return true
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return false
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function set_def(identifier, value) {
|
|
167
|
-
console.log("set_def", identifier, value)
|
|
168
|
-
for (let i = 0; i < definition_stack.length; i++) {
|
|
169
|
-
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
170
|
-
definition_stack[i][identifier] = value
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
console.log("definition_stack_after_Set", definition_stack)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
129
|
function get_available_row_indexes() {
|
|
177
130
|
let row_indexes = []
|
|
178
131
|
if (
|
|
@@ -414,11 +367,9 @@ export function create_table_advanced_manager(config) {
|
|
|
414
367
|
column_input_options: config?.column_input_options,
|
|
415
368
|
table_options: config?.table_options,
|
|
416
369
|
on_search_table_row_ids: config?.on_search_table_row_ids,
|
|
417
|
-
|
|
418
|
-
definition_stack: () => definition_stack,
|
|
370
|
+
definition_stack: definition_stack,
|
|
419
371
|
columns: () => columns_prepped,
|
|
420
372
|
rows_data_from_variable_path: () => rows_data_from_variable_path,
|
|
421
|
-
row_data_type: () => row_data_type,
|
|
422
373
|
on_delete: async () => {
|
|
423
374
|
if (typeof config?.on_event == "function") {
|
|
424
375
|
const res = await config?.on_event({
|
|
@@ -518,39 +469,28 @@ export function create_table_advanced_manager(config) {
|
|
|
518
469
|
|
|
519
470
|
function edit_row(row_i) {
|
|
520
471
|
row_edit_index = row_i
|
|
521
|
-
let definition_stack_loc = $state([{ [row_iter_identifier]: row_i }, ...definition_stack])
|
|
522
472
|
const path_to_set = [...rows_data_from_variable_path, Number.isInteger(row_i) ? row_i : 0]
|
|
473
|
+
let editable_row = null
|
|
523
474
|
if (!Number.isInteger(row_i)) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (target === undefined) break
|
|
529
|
-
}
|
|
530
|
-
const last_key = path_to_set[path_to_set.length - 1]
|
|
531
|
-
if (Array.isArray(target[last_key])) {
|
|
532
|
-
target[last_key].splice(0, 0, row_default_to_insert)
|
|
533
|
-
} else {
|
|
534
|
-
target[last_key] = row_default_to_insert
|
|
535
|
-
}
|
|
475
|
+
console.log("columns_prepped", columns_prepped)
|
|
476
|
+
editable_row = {}
|
|
477
|
+
} else {
|
|
478
|
+
editable_row = get_def_from_variable_path([...rows_data_from_variable_path, row_i], definition_stack)
|
|
536
479
|
}
|
|
480
|
+
let row_definition_stack = $state([{ [row_edit_def_identifier]: editable_row }, ...definition_stack])
|
|
537
481
|
row_edit_content_manager = null
|
|
538
482
|
setTimeout(() => {
|
|
539
483
|
// quick fix for when update row then edit a diff row the data for other doesnt remain in place
|
|
540
|
-
console.log("row_input_content2222", { row_input_content, ds: [{ row_i }, ...definition_stack] })
|
|
541
484
|
row_edit_content_manager = create_content_manager({
|
|
542
485
|
val: row_input_content ?? null,
|
|
543
|
-
|
|
544
|
-
table_options: config?.table_options,
|
|
486
|
+
definition_stack: row_definition_stack,
|
|
545
487
|
mapkit_js_token: mapkit_js_token,
|
|
488
|
+
storage_items: null, // tbd
|
|
546
489
|
on_search_table_row_ids: config?.on_search_table_row_ids,
|
|
547
|
-
definition_stack: [{ row_i }, ...definition_stack],
|
|
548
490
|
on_event: (input) => {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
definition_stack_loc = res?.definition_stack
|
|
553
|
-
const row_data = get_def_from_variable_path(path_to_set, definition_stack_loc)
|
|
491
|
+
const res = set_definition_stack(input, row_definition_stack)
|
|
492
|
+
row_definition_stack = res?.definition_stack
|
|
493
|
+
const row_data = get_def_from_variable_path([row_edit_def_identifier], row_definition_stack)
|
|
554
494
|
return {
|
|
555
495
|
is_success: true,
|
|
556
496
|
data: {
|
|
@@ -566,8 +506,8 @@ export function create_table_advanced_manager(config) {
|
|
|
566
506
|
is_loading: () => upsert_row_is_loading,
|
|
567
507
|
on_click: async () => {
|
|
568
508
|
upsert_row_is_loading = true
|
|
569
|
-
const row_data = get_def_from_variable_path(
|
|
570
|
-
console.log("edited_row", {
|
|
509
|
+
const row_data = get_def_from_variable_path([row_edit_def_identifier], row_definition_stack)
|
|
510
|
+
console.log("edited_row", { row_i, row_data })
|
|
571
511
|
if (Number.isInteger(row_i)) {
|
|
572
512
|
if (typeof config?.on_event == "function") {
|
|
573
513
|
const res = await config?.on_event({
|
|
@@ -603,6 +543,7 @@ export function create_table_advanced_manager(config) {
|
|
|
603
543
|
row: row_data,
|
|
604
544
|
path: path_to_set,
|
|
605
545
|
})
|
|
546
|
+
console.log("insert_row_res", { res, columns_prepped })
|
|
606
547
|
if (res?.is_success) {
|
|
607
548
|
preempt_insert_row_popover_manager.show_temp_message(
|
|
608
549
|
"Successfully inserted row",
|
|
@@ -677,9 +618,81 @@ export function create_table_advanced_manager(config) {
|
|
|
677
618
|
})
|
|
678
619
|
}
|
|
679
620
|
|
|
621
|
+
function guess_row_input_content(columns) {
|
|
622
|
+
return {
|
|
623
|
+
type_id: "div",
|
|
624
|
+
selector_id: create_unique_id(null, 8),
|
|
625
|
+
children: Object.entries(columns || {})
|
|
626
|
+
.sort(([a_column_id, a_val], [b_column_id, b_val]) => {
|
|
627
|
+
const a_order = a_val?.display_order ?? 0
|
|
628
|
+
const b_order = b_val?.display_order ?? 0
|
|
629
|
+
return a_order - b_order
|
|
630
|
+
})
|
|
631
|
+
.map(([column_id, val]) => {
|
|
632
|
+
if (val?.is_autogenerated) {
|
|
633
|
+
// let guessed_column_display_content = variables_data_type_remaining_to_astc(val?.db_data_type, "display", [
|
|
634
|
+
// "variables",
|
|
635
|
+
// "rows",
|
|
636
|
+
// ["row_i"],
|
|
637
|
+
// column_id,
|
|
638
|
+
// ])
|
|
639
|
+
return {
|
|
640
|
+
type_id: "div",
|
|
641
|
+
selector_id: create_unique_id(null, 8),
|
|
642
|
+
children: [
|
|
643
|
+
{
|
|
644
|
+
type_id: "span",
|
|
645
|
+
selector_id: create_unique_id(null, 8),
|
|
646
|
+
children: [
|
|
647
|
+
{
|
|
648
|
+
type_id: "strong",
|
|
649
|
+
selector_id: create_unique_id(null, 8),
|
|
650
|
+
children: [],
|
|
651
|
+
attributes: { content: column_id },
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
type_id: "em",
|
|
655
|
+
selector_id: create_unique_id(null, 8),
|
|
656
|
+
children: [],
|
|
657
|
+
attributes: { content: " autogenerated " },
|
|
658
|
+
},
|
|
659
|
+
],
|
|
660
|
+
attributes: {},
|
|
661
|
+
},
|
|
662
|
+
// guessed_column_display_content,
|
|
663
|
+
{
|
|
664
|
+
type_id: "br",
|
|
665
|
+
selector_id: create_unique_id(null, 8),
|
|
666
|
+
children: [],
|
|
667
|
+
attributes: {},
|
|
668
|
+
},
|
|
669
|
+
],
|
|
670
|
+
attributes: {},
|
|
671
|
+
}
|
|
672
|
+
} else {
|
|
673
|
+
let guessed_column_input_content = variables_data_type_remaining_to_astc(val?.db_data_type, "input", [
|
|
674
|
+
row_edit_def_identifier,
|
|
675
|
+
column_id,
|
|
676
|
+
])
|
|
677
|
+
if (guessed_column_input_content?.hasOwnProperty("attributes")) {
|
|
678
|
+
if (!guessed_column_input_content.attributes) {
|
|
679
|
+
guessed_column_input_content.attributes = {}
|
|
680
|
+
}
|
|
681
|
+
guessed_column_input_content.attributes.label = column_id
|
|
682
|
+
}
|
|
683
|
+
return {
|
|
684
|
+
type_id: "div",
|
|
685
|
+
selector_id: create_unique_id(null, 8),
|
|
686
|
+
children: [guessed_column_input_content],
|
|
687
|
+
attributes: {},
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}),
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
680
694
|
function set_attributes(attributes) {
|
|
681
695
|
rows_data_from_variable_path = attributes?.rows_data_from_variable_path
|
|
682
|
-
row_input_content = attributes?.row_input_content
|
|
683
696
|
is_data_editable = attributes?.is_data_editable ?? false
|
|
684
697
|
nav_items = Array.isArray(attributes?.nav_items)
|
|
685
698
|
? attributes.nav_items.filter((item) =>
|
|
@@ -702,6 +715,18 @@ export function create_table_advanced_manager(config) {
|
|
|
702
715
|
table_row_max_height = attributes?.table_row_max_height ?? null
|
|
703
716
|
const columns_prepped_loc = set_columns_prepped(attributes?.columns)
|
|
704
717
|
set_rows_prepped(columns_prepped_loc)
|
|
718
|
+
row_input_content = attributes?.row_input_content ?? guess_row_input_content(attributes?.columns)
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function reset_definition_stack(input) {
|
|
722
|
+
console.log("reset_definition_stack", deep_copy(input))
|
|
723
|
+
definition_stack = input
|
|
724
|
+
set_rows_prepped(columns_prepped)
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
function set_columns(input) {
|
|
728
|
+
set_columns_prepped(input)
|
|
729
|
+
set_rows_prepped(columns_prepped)
|
|
705
730
|
}
|
|
706
731
|
|
|
707
732
|
function init(config) {
|
|
@@ -709,7 +734,7 @@ export function create_table_advanced_manager(config) {
|
|
|
709
734
|
table_name = config?.table_name
|
|
710
735
|
table_description = config?.table_description
|
|
711
736
|
rows_data_from_variable_path = config?.rows_data_from_variable_path
|
|
712
|
-
row_iter_identifier = config?.row_iter_identifier
|
|
737
|
+
row_iter_identifier = config?.row_iter_identifier ?? "row_i"
|
|
713
738
|
definition_stack = config?.definition_stack
|
|
714
739
|
mapkit_js_token = config?.mapkit_js_token
|
|
715
740
|
set_attributes(config)
|
|
@@ -1417,5 +1442,7 @@ export function create_table_advanced_manager(config) {
|
|
|
1417
1442
|
download_csv,
|
|
1418
1443
|
copy_structure,
|
|
1419
1444
|
set_attributes,
|
|
1445
|
+
reset_definition_stack,
|
|
1446
|
+
set_columns,
|
|
1420
1447
|
}
|
|
1421
1448
|
}
|
package/src/lib/client/index.js
CHANGED
|
@@ -551,8 +551,56 @@ export function get_data_type_at_path(path, full_data_type) {
|
|
|
551
551
|
return data_type_at_path_loc
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
export function get_def(input, definition_stack) {
|
|
555
|
+
if (Array.isArray(definition_stack)) {
|
|
556
|
+
for (let item of definition_stack) {
|
|
557
|
+
if (item.hasOwnProperty(input)) {
|
|
558
|
+
return item?.[input]
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return null
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export function get_def_from_variable_path(input, definition_stack) {
|
|
566
|
+
let val = null
|
|
567
|
+
if (Array.isArray(input) && input.length > 0) {
|
|
568
|
+
val = get_def(input?.[0], definition_stack)
|
|
569
|
+
for (let i = 1; i < input.length; i++) {
|
|
570
|
+
if (Array.isArray(input?.[i])) {
|
|
571
|
+
const res = get_def_from_variable_path(input?.[i], definition_stack)
|
|
572
|
+
val = val?.[res]
|
|
573
|
+
} else {
|
|
574
|
+
val = val?.[input?.[i]]
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return val
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export function is_defined(input, definition_stack) {
|
|
582
|
+
if (Array.isArray(definition_stack)) {
|
|
583
|
+
for (let item of definition_stack) {
|
|
584
|
+
if (item && typeof item == "object" && item.hasOwnProperty(input)) {
|
|
585
|
+
return true
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return false
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export function set_def(identifier, value, definition_stack) {
|
|
593
|
+
if (Array.isArray(definition_stack)) {
|
|
594
|
+
for (let i = 0; i < definition_stack.length; i++) {
|
|
595
|
+
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
596
|
+
definition_stack[i][identifier] = value
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return definition_stack
|
|
601
|
+
}
|
|
602
|
+
|
|
554
603
|
export function set_definition_stack(input, definition_stack, pass_event_down) {
|
|
555
|
-
console.log("set_definition_stack00", deep_copy({ input, definition_stack, pass_event_down }))
|
|
556
604
|
if (!Array.isArray(input?.variable_path_to_target) || !Array.isArray(definition_stack)) {
|
|
557
605
|
throw new Error("Path must be an array")
|
|
558
606
|
}
|
|
@@ -225,102 +225,11 @@
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
let data = $state({
|
|
228
|
-
id: "
|
|
229
|
-
name: "
|
|
230
|
-
rows: [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
label: null,
|
|
234
|
-
fav_color: null,
|
|
235
|
-
db_epoch_created: 1723421882,
|
|
236
|
-
db_epoch_updated: 1723421882,
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
id: "wqhfxttzpwdpkawzusyt",
|
|
240
|
-
label: "tint bl",
|
|
241
|
-
fav_color: {
|
|
242
|
-
c: 16,
|
|
243
|
-
h: 17,
|
|
244
|
-
l: 5,
|
|
245
|
-
o: 16,
|
|
246
|
-
is_dark_theme_invert: true,
|
|
247
|
-
},
|
|
248
|
-
db_epoch_created: 1723421882,
|
|
249
|
-
db_epoch_updated: 1723422096,
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
id: "egrdjfqlcysykmpwudsp",
|
|
253
|
-
label: null,
|
|
254
|
-
fav_color: {
|
|
255
|
-
c: 10,
|
|
256
|
-
h: 4,
|
|
257
|
-
l: 1,
|
|
258
|
-
o: 24,
|
|
259
|
-
is_dark_theme_invert: true,
|
|
260
|
-
},
|
|
261
|
-
db_epoch_created: 1723422106,
|
|
262
|
-
db_epoch_updated: 1723422106,
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
id: "zbcqvteloefgebbcwrnd",
|
|
266
|
-
label: null,
|
|
267
|
-
fav_color: {
|
|
268
|
-
c: 10,
|
|
269
|
-
h: 4,
|
|
270
|
-
l: 1,
|
|
271
|
-
o: 24,
|
|
272
|
-
is_dark_theme_invert: true,
|
|
273
|
-
},
|
|
274
|
-
db_epoch_created: 1723423614,
|
|
275
|
-
db_epoch_updated: 1723423614,
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
id: "ennjpaemwacveifswbwq",
|
|
279
|
-
label: null,
|
|
280
|
-
fav_color: null,
|
|
281
|
-
db_epoch_created: 1723423614,
|
|
282
|
-
db_epoch_updated: 1723423614,
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
id: "redpwlvrmboleibyawxj",
|
|
286
|
-
label: "tint bl",
|
|
287
|
-
fav_color: {
|
|
288
|
-
c: 16,
|
|
289
|
-
h: 17,
|
|
290
|
-
l: 5,
|
|
291
|
-
o: 16,
|
|
292
|
-
is_dark_theme_invert: true,
|
|
293
|
-
},
|
|
294
|
-
db_epoch_created: 1723423614,
|
|
295
|
-
db_epoch_updated: 1723423614,
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
id: "ugarkuprolztkecxqody",
|
|
299
|
-
label: "not invert",
|
|
300
|
-
fav_color: {
|
|
301
|
-
c: 12,
|
|
302
|
-
h: 14,
|
|
303
|
-
l: 4,
|
|
304
|
-
o: 24,
|
|
305
|
-
is_dark_theme_invert: false,
|
|
306
|
-
},
|
|
307
|
-
db_epoch_created: 1723423614,
|
|
308
|
-
db_epoch_updated: 1723423678,
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
id: "dyfidxdkepupllmccxmb",
|
|
312
|
-
label: "yes invert",
|
|
313
|
-
fav_color: {
|
|
314
|
-
c: 12,
|
|
315
|
-
h: 14,
|
|
316
|
-
l: 4,
|
|
317
|
-
o: 24,
|
|
318
|
-
is_dark_theme_invert: true,
|
|
319
|
-
},
|
|
320
|
-
db_epoch_created: 1723421882,
|
|
321
|
-
db_epoch_updated: 1723423732,
|
|
322
|
-
},
|
|
323
|
-
],
|
|
228
|
+
id: "cbsemvrsoidhrzyhugue",
|
|
229
|
+
name: "test",
|
|
230
|
+
rows: [],
|
|
231
|
+
limit: 100,
|
|
232
|
+
offset: 0,
|
|
324
233
|
columns: {
|
|
325
234
|
id: {
|
|
326
235
|
is_fixed: true,
|
|
@@ -335,7 +244,7 @@
|
|
|
335
244
|
children: [],
|
|
336
245
|
attributes: {
|
|
337
246
|
size: 10,
|
|
338
|
-
content_from_variable_path: ["rows", ["
|
|
247
|
+
content_from_variable_path: ["variables", "rows", ["loops", 0], "id"],
|
|
339
248
|
},
|
|
340
249
|
selector_id: "hcsqz",
|
|
341
250
|
},
|
|
@@ -359,103 +268,50 @@
|
|
|
359
268
|
is_autogenerated: true,
|
|
360
269
|
is_force_uniqueness: false,
|
|
361
270
|
},
|
|
362
|
-
|
|
271
|
+
ttttt: {
|
|
363
272
|
is_fixed: false,
|
|
364
273
|
is_shown: true,
|
|
365
274
|
alignment: "left",
|
|
366
|
-
max_width:
|
|
367
|
-
min_width:
|
|
368
|
-
description:
|
|
275
|
+
max_width: 30,
|
|
276
|
+
min_width: 20,
|
|
277
|
+
description: "ffff",
|
|
369
278
|
is_nullable: true,
|
|
370
279
|
body_content: {
|
|
371
|
-
type_id: "
|
|
280
|
+
type_id: "number",
|
|
372
281
|
children: [],
|
|
373
282
|
attributes: {
|
|
374
|
-
|
|
375
|
-
content: null,
|
|
376
|
-
content_from_variable_path: ["rows", ["row_i"], "label"],
|
|
283
|
+
val_from_variable_path: ["rows", ["row_i"], "ttttt"],
|
|
377
284
|
},
|
|
378
|
-
selector_id: "
|
|
285
|
+
selector_id: "vukyefhw",
|
|
379
286
|
},
|
|
380
287
|
db_data_type: {
|
|
381
|
-
type: "
|
|
288
|
+
type: "int_literal",
|
|
382
289
|
attributes: {},
|
|
383
290
|
},
|
|
384
291
|
is_db_column: true,
|
|
292
|
+
is_updatable: false,
|
|
385
293
|
default_value: null,
|
|
386
294
|
display_order: 1,
|
|
387
|
-
postgres_type: "
|
|
388
|
-
header_content: {
|
|
389
|
-
type_id: "base_text",
|
|
390
|
-
children: [],
|
|
391
|
-
attributes: {
|
|
392
|
-
color: null,
|
|
393
|
-
content: "Label",
|
|
394
|
-
content_from_variable_path: null,
|
|
395
|
-
},
|
|
396
|
-
selector_id: "fbhid",
|
|
397
|
-
},
|
|
398
|
-
is_primary_key: false,
|
|
399
|
-
is_autogenerated: false,
|
|
400
|
-
is_force_uniqueness: false,
|
|
401
|
-
},
|
|
402
|
-
fav_color: {
|
|
403
|
-
is_fixed: false,
|
|
404
|
-
is_shown: true,
|
|
405
|
-
alignment: "right",
|
|
406
|
-
max_width: 25,
|
|
407
|
-
min_width: 3,
|
|
408
|
-
description: null,
|
|
409
|
-
is_nullable: true,
|
|
410
|
-
body_content: {
|
|
411
|
-
type_id: "color",
|
|
412
|
-
children: [],
|
|
413
|
-
attributes: {
|
|
414
|
-
val: {
|
|
415
|
-
c: 21,
|
|
416
|
-
h: 2,
|
|
417
|
-
l: 6,
|
|
418
|
-
o: 24,
|
|
419
|
-
is_dark_theme_invert: true,
|
|
420
|
-
},
|
|
421
|
-
val_from_variable_path: ["rows", ["row_i"], "fav_color"],
|
|
422
|
-
},
|
|
423
|
-
selector_id: "anpwr",
|
|
424
|
-
},
|
|
425
|
-
db_data_type: {
|
|
426
|
-
type: "color_literal",
|
|
427
|
-
attributes: {},
|
|
428
|
-
},
|
|
429
|
-
is_db_column: true,
|
|
430
|
-
default_value: null,
|
|
431
|
-
display_order: 2,
|
|
432
|
-
postgres_type: "jsonb",
|
|
295
|
+
postgres_type: "int",
|
|
433
296
|
header_content: {
|
|
434
297
|
type_id: "base_text",
|
|
435
298
|
children: [],
|
|
436
299
|
attributes: {
|
|
437
|
-
|
|
438
|
-
c: 10,
|
|
439
|
-
h: 15,
|
|
440
|
-
l: 19,
|
|
441
|
-
o: 24,
|
|
442
|
-
is_dark_theme_invert: true,
|
|
443
|
-
},
|
|
444
|
-
content: "Fav Color",
|
|
445
|
-
content_from_variable_path: null,
|
|
300
|
+
content: "Ttttt",
|
|
446
301
|
},
|
|
447
|
-
selector_id: "
|
|
302
|
+
selector_id: "lpcqsjlq",
|
|
448
303
|
},
|
|
449
304
|
is_primary_key: false,
|
|
450
305
|
is_autogenerated: false,
|
|
451
306
|
is_force_uniqueness: false,
|
|
307
|
+
is_use_in_short_display: false,
|
|
452
308
|
},
|
|
453
309
|
db_epoch_created: {
|
|
454
310
|
is_fixed: false,
|
|
455
311
|
is_shown: true,
|
|
456
312
|
alignment: "left",
|
|
457
313
|
max_width: 50,
|
|
458
|
-
min_width:
|
|
314
|
+
min_width: 20,
|
|
459
315
|
description: null,
|
|
460
316
|
is_nullable: false,
|
|
461
317
|
body_content: {
|
|
@@ -463,9 +319,9 @@
|
|
|
463
319
|
children: [],
|
|
464
320
|
attributes: {
|
|
465
321
|
format: "epoch",
|
|
466
|
-
val_from_variable_path: ["rows", ["
|
|
322
|
+
val_from_variable_path: ["variables", "rows", ["loops", 0], "db_epoch_created"],
|
|
467
323
|
},
|
|
468
|
-
selector_id: "
|
|
324
|
+
selector_id: "time_urzjm",
|
|
469
325
|
},
|
|
470
326
|
db_data_type: {
|
|
471
327
|
type: "epoch_literal",
|
|
@@ -473,7 +329,7 @@
|
|
|
473
329
|
},
|
|
474
330
|
is_db_column: true,
|
|
475
331
|
default_value: null,
|
|
476
|
-
display_order:
|
|
332
|
+
display_order: 2,
|
|
477
333
|
postgres_type: "bigint",
|
|
478
334
|
header_content: {
|
|
479
335
|
type_id: "base_text",
|
|
@@ -492,7 +348,7 @@
|
|
|
492
348
|
is_shown: true,
|
|
493
349
|
alignment: "left",
|
|
494
350
|
max_width: 50,
|
|
495
|
-
min_width:
|
|
351
|
+
min_width: 20,
|
|
496
352
|
description: null,
|
|
497
353
|
is_nullable: false,
|
|
498
354
|
body_content: {
|
|
@@ -500,9 +356,9 @@
|
|
|
500
356
|
children: [],
|
|
501
357
|
attributes: {
|
|
502
358
|
format: "epoch",
|
|
503
|
-
val_from_variable_path: ["rows", ["
|
|
359
|
+
val_from_variable_path: ["variables", "rows", ["loops", 0], "db_epoch_updated"],
|
|
504
360
|
},
|
|
505
|
-
selector_id: "
|
|
361
|
+
selector_id: "epoch_rozyy",
|
|
506
362
|
},
|
|
507
363
|
db_data_type: {
|
|
508
364
|
type: "epoch_literal",
|
|
@@ -510,7 +366,7 @@
|
|
|
510
366
|
},
|
|
511
367
|
is_db_column: true,
|
|
512
368
|
default_value: null,
|
|
513
|
-
display_order:
|
|
369
|
+
display_order: 3,
|
|
514
370
|
postgres_type: "bigint",
|
|
515
371
|
header_content: {
|
|
516
372
|
type_id: "base_text",
|
|
@@ -525,14 +381,22 @@
|
|
|
525
381
|
is_force_uniqueness: false,
|
|
526
382
|
},
|
|
527
383
|
},
|
|
528
|
-
account_id: "
|
|
529
|
-
total_rows:
|
|
530
|
-
description: "
|
|
384
|
+
account_id: "kmjexchofxophkkuqfvp",
|
|
385
|
+
total_rows: 0,
|
|
386
|
+
description: "need to make sure new loop stuff works",
|
|
531
387
|
default_sort: null,
|
|
532
|
-
row_input_content:
|
|
388
|
+
row_input_content: null,
|
|
533
389
|
row_searchable_content: null,
|
|
534
390
|
})
|
|
535
391
|
|
|
392
|
+
let row_data_type = {
|
|
393
|
+
type: "object_literal",
|
|
394
|
+
attributes: {},
|
|
395
|
+
properties: Object.fromEntries(Object.entries(data?.columns || {}).map(([key, val]) => [key, val?.db_data_type])),
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
console.log("row_data_type", row_data_type)
|
|
399
|
+
|
|
536
400
|
let table_manager = $state(null)
|
|
537
401
|
let variables = $state({ rows: data?.rows })
|
|
538
402
|
|
|
@@ -544,6 +408,7 @@
|
|
|
544
408
|
table_options: [{ key: "test", name: "Test" }],
|
|
545
409
|
definition_stack: [{ ...variables }],
|
|
546
410
|
rows_data_from_variable_path: ["rows"],
|
|
411
|
+
row_data_type: row_data_type,
|
|
547
412
|
row_iter_identifier: "row_i",
|
|
548
413
|
table_header_max_height: 8,
|
|
549
414
|
table_row_max_height: 8,
|
|
@@ -581,6 +446,7 @@
|
|
|
581
446
|
const last_key = path_to_set[path_to_set.length - 1]
|
|
582
447
|
target[last_key] = input?.row
|
|
583
448
|
variables = variables_loc
|
|
449
|
+
table_manager.reset_definition_stack([{ ...variables }])
|
|
584
450
|
return {
|
|
585
451
|
is_success: true,
|
|
586
452
|
row: target?.[last_key],
|
|
@@ -601,6 +467,7 @@
|
|
|
601
467
|
}
|
|
602
468
|
target.splice(last_key, 0, input?.row)
|
|
603
469
|
variables = variables_loc
|
|
470
|
+
table_manager.reset_definition_stack([{ ...variables }])
|
|
604
471
|
return {
|
|
605
472
|
is_success: true,
|
|
606
473
|
row: target?.[last_key],
|
|
@@ -622,6 +489,7 @@
|
|
|
622
489
|
}
|
|
623
490
|
target.splice(last_key, 0, input?.value)
|
|
624
491
|
variables = variables_loc
|
|
492
|
+
table_manager.reset_definition_stack([{ ...variables }])
|
|
625
493
|
return {
|
|
626
494
|
is_success: true,
|
|
627
495
|
rows: target?.[last_key],
|
|
@@ -643,6 +511,7 @@
|
|
|
643
511
|
}
|
|
644
512
|
variables = variables_loc
|
|
645
513
|
console.log("variables", deep_copy(variables))
|
|
514
|
+
table_manager.reset_definition_stack([{ ...variables }])
|
|
646
515
|
return {
|
|
647
516
|
is_success: true,
|
|
648
517
|
}
|
|
@@ -654,6 +523,7 @@
|
|
|
654
523
|
}
|
|
655
524
|
} else if (input?.type == "insert_column") {
|
|
656
525
|
console.log("insert_column", deep_copy(input))
|
|
526
|
+
table_manager.set_columns(data?.columns)
|
|
657
527
|
return {
|
|
658
528
|
is_success: true,
|
|
659
529
|
column: input?.column,
|
|
@@ -703,5 +573,6 @@
|
|
|
703
573
|
</script>
|
|
704
574
|
|
|
705
575
|
<div>
|
|
576
|
+
<pre>{JSON.stringify(variables, null, 2)}</pre>
|
|
706
577
|
<TableAdvanced manager={table_manager} />
|
|
707
578
|
</div>
|