@jsenv/navi 0.10.2 → 0.11.1
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/jsenv_navi.js +13838 -23291
- package/dist/jsenv_navi.js.map +1281 -0
- package/package.json +6 -8
- package/index.js +0 -122
- package/src/action_private_properties.js +0 -11
- package/src/action_proxy_test.html +0 -353
- package/src/action_run_states.js +0 -5
- package/src/actions.js +0 -1401
- package/src/browser_integration/browser_integration.js +0 -216
- package/src/browser_integration/document_back_and_forward.js +0 -17
- package/src/browser_integration/document_loading_signal.js +0 -100
- package/src/browser_integration/document_state_signal.js +0 -9
- package/src/browser_integration/document_url_signal.js +0 -9
- package/src/browser_integration/use_is_visited.js +0 -19
- package/src/browser_integration/via_history.js +0 -232
- package/src/browser_integration/via_navigation.js +0 -168
- package/src/components/action_execution/form_context.js +0 -5
- package/src/components/action_execution/render_actionable_component.jsx +0 -29
- package/src/components/action_execution/use_action.js +0 -99
- package/src/components/action_execution/use_execute_action.js +0 -193
- package/src/components/action_execution/use_run_on_mount.js +0 -9
- package/src/components/action_renderer.jsx +0 -125
- package/src/components/callout/callout.js +0 -990
- package/src/components/callout/callout_demo.html +0 -201
- package/src/components/callout/test_dynamic_positioning.html +0 -161
- package/src/components/callout/test_html_document_iframe.html +0 -182
- package/src/components/demos/0_button_demo.html +0 -707
- package/src/components/demos/10_column_reordering_debug.html +0 -277
- package/src/components/demos/11_table_selection_debug.html +0 -432
- package/src/components/demos/1_checkbox_demo.html +0 -754
- package/src/components/demos/2_input_textual_demo.html +0 -286
- package/src/components/demos/3_radio_demo.html +0 -874
- package/src/components/demos/4_select_demo.html +0 -100
- package/src/components/demos/5_list_scrollable_demo.html +0 -153
- package/src/components/demos/6_tablist_demo.html +0 -77
- package/src/components/demos/7_table_selection_demo.html +0 -176
- package/src/components/demos/8_table_fixed_headers_demo.html +0 -584
- package/src/components/demos/9_table_column_drag_demo.html +0 -325
- package/src/components/demos/action/0_button_demo.html +0 -204
- package/src/components/demos/action/10_shortcuts_demo.html +0 -189
- package/src/components/demos/action/11_nested_shortcuts_demo.xhtml +0 -401
- package/src/components/demos/action/1_input_text_demo.html +0 -876
- package/src/components/demos/action/2_form_multiple.html +0 -303
- package/src/components/demos/action/3_details_demo.html +0 -203
- package/src/components/demos/action/4_input_checkbox_demo.html +0 -731
- package/src/components/demos/action/5_input_checkbox_state_demo.html +0 -270
- package/src/components/demos/action/6_checkbox_list_demo.html +0 -341
- package/src/components/demos/action/7_radio_list_demo.html +0 -357
- package/src/components/demos/action/8_editable_demo.html +0 -431
- package/src/components/demos/action/9_link_demo.html +0 -194
- package/src/components/demos/demo.md +0 -0
- package/src/components/demos/route/basic/basic.html +0 -14
- package/src/components/demos/route/basic/basic_route_demo.jsx +0 -224
- package/src/components/demos/route/multi/multi.html +0 -14
- package/src/components/demos/route/multi/multi_route_demo.jsx +0 -277
- package/src/components/demos/ui_transition/0_action_renderer_ui_transition_demo.html +0 -695
- package/src/components/demos/ui_transition/1_nested_ui_transition_demo.html +0 -429
- package/src/components/demos/ui_transition/2_height_transition_test.html +0 -295
- package/src/components/details/details.jsx +0 -245
- package/src/components/details/summary_marker.jsx +0 -141
- package/src/components/edition/editable.jsx +0 -186
- package/src/components/error_boundary_context.js +0 -9
- package/src/components/field/README.md +0 -247
- package/src/components/field/button.jsx +0 -429
- package/src/components/field/checkbox_list.jsx +0 -185
- package/src/components/field/collect_form_element_values.js +0 -82
- package/src/components/field/custom_field.js +0 -106
- package/src/components/field/form.jsx +0 -209
- package/src/components/field/input.jsx +0 -16
- package/src/components/field/input_checkbox.jsx +0 -434
- package/src/components/field/input_radio.jsx +0 -432
- package/src/components/field/input_textual.jsx +0 -389
- package/src/components/field/label.jsx +0 -46
- package/src/components/field/radio_list.jsx +0 -183
- package/src/components/field/select.jsx +0 -256
- package/src/components/field/use_action_events.js +0 -132
- package/src/components/field/use_form_events.js +0 -59
- package/src/components/field/use_ui_state_controller.js +0 -506
- package/src/components/item_tracker/README.md +0 -461
- package/src/components/item_tracker/use_isolated_item_tracker.jsx +0 -209
- package/src/components/item_tracker/use_isolated_item_tracker_demo.html +0 -148
- package/src/components/item_tracker/use_isolated_item_tracker_demo.jsx +0 -460
- package/src/components/item_tracker/use_item_tracker.jsx +0 -143
- package/src/components/item_tracker/use_item_tracker_demo.html +0 -207
- package/src/components/item_tracker/use_item_tracker_demo.jsx +0 -216
- package/src/components/keyboard_shortcuts/active_keyboard_shortcuts.jsx +0 -87
- package/src/components/keyboard_shortcuts/aria_key_shortcuts.js +0 -61
- package/src/components/keyboard_shortcuts/keyboard_key_meta.js +0 -17
- package/src/components/keyboard_shortcuts/keyboard_shortcuts.js +0 -371
- package/src/components/keyboard_shortcuts/os.js +0 -9
- package/src/components/layout/demos/demo_flex.html +0 -638
- package/src/components/layout/demos/demo_layout_style_buttons.html +0 -351
- package/src/components/layout/demos/demo_layout_style_input.html +0 -226
- package/src/components/layout/demos/demo_layout_style_text.html +0 -514
- package/src/components/layout/flex.jsx +0 -109
- package/src/components/layout/layout_context.jsx +0 -3
- package/src/components/layout/spacing.jsx +0 -20
- package/src/components/layout/use_layout_style.js +0 -249
- package/src/components/link/link.jsx +0 -267
- package/src/components/link/link_with_icon.jsx +0 -52
- package/src/components/loader/loader_background.jsx +0 -372
- package/src/components/loader/loading_spinner.jsx +0 -68
- package/src/components/loader/network_speed.js +0 -83
- package/src/components/loader/rectangle_loading.jsx +0 -244
- package/src/components/props_composition/demos/demo_with_props_style.html +0 -81
- package/src/components/props_composition/with_props_class_name.js +0 -37
- package/src/components/props_composition/with_props_style.js +0 -26
- package/src/components/route.jsx +0 -19
- package/src/components/selection/selection.jsx +0 -1583
- package/src/components/svg/font_sized_svg.jsx +0 -59
- package/src/components/svg/icon_and_text.jsx +0 -21
- package/src/components/svg/svg_mask_overlay.jsx +0 -105
- package/src/components/table/drag/table_drag.jsx +0 -506
- package/src/components/table/resize/table_resize.jsx +0 -650
- package/src/components/table/resize/table_size.js +0 -43
- package/src/components/table/selection/table_selection.js +0 -106
- package/src/components/table/selection/table_selection.jsx +0 -203
- package/src/components/table/sticky/sticky_group.js +0 -354
- package/src/components/table/sticky/table_sticky.js +0 -25
- package/src/components/table/sticky/table_sticky.jsx +0 -501
- package/src/components/table/table.jsx +0 -721
- package/src/components/table/table_css.js +0 -211
- package/src/components/table/table_ui.jsx +0 -49
- package/src/components/table/use_cells_and_columns.js +0 -90
- package/src/components/table/use_object_array_to_cells.js +0 -46
- package/src/components/table/z_indexes.js +0 -23
- package/src/components/tablist/tablist.jsx +0 -99
- package/src/components/text/demos/demo_text_and_icon.html +0 -421
- package/src/components/text/overflow.jsx +0 -15
- package/src/components/text/text.jsx +0 -83
- package/src/components/text/text_and_count.jsx +0 -28
- package/src/components/ui_transition.jsx +0 -128
- package/src/components/use_auto_focus.js +0 -94
- package/src/components/use_batch_during_render.js +0 -33
- package/src/components/use_debounce_true.js +0 -31
- package/src/components/use_dependencies_diff.js +0 -35
- package/src/components/use_focus_group.js +0 -20
- package/src/components/use_initial_value.js +0 -78
- package/src/components/use_is_visited.js +0 -19
- package/src/components/use_ref_array.js +0 -38
- package/src/components/use_signal_sync.js +0 -50
- package/src/components/use_stable_callback.js +0 -68
- package/src/components/use_state_array.js +0 -47
- package/src/docs/actions.md +0 -250
- package/src/docs/demos/resource/action_status.jsx +0 -42
- package/src/docs/demos/resource/demo.md +0 -1
- package/src/docs/demos/resource/resource_demo_0.html +0 -84
- package/src/docs/demos/resource/resource_demo_10_post_gc.html +0 -364
- package/src/docs/demos/resource/resource_demo_11_describe_many.html +0 -362
- package/src/docs/demos/resource/resource_demo_2.html +0 -173
- package/src/docs/demos/resource/resource_demo_3_filtered_users.html +0 -415
- package/src/docs/demos/resource/resource_demo_4_details.html +0 -284
- package/src/docs/demos/resource/resource_demo_5_renderer_lazy.html +0 -115
- package/src/docs/demos/resource/resource_demo_6_gc.html +0 -217
- package/src/docs/demos/resource/resource_demo_7_child_gc.html +0 -240
- package/src/docs/demos/resource/resource_demo_8_proxy_gc.html +0 -319
- package/src/docs/demos/resource/resource_demo_9_describe_one.html +0 -472
- package/src/docs/demos/resource/tata.jsx +0 -3
- package/src/docs/demos/resource/toto.jsx +0 -3
- package/src/docs/demos/user_nav/user_nav.html +0 -12
- package/src/docs/demos/user_nav/user_nav.jsx +0 -330
- package/src/docs/resource_dependencies.md +0 -103
- package/src/docs/resource_with_params.md +0 -80
- package/src/navi_css_vars.js +0 -14
- package/src/notes.md +0 -34
- package/src/route/route.js +0 -596
- package/src/route/route.xtest.html +0 -228
- package/src/store/array_signal_store.js +0 -537
- package/src/store/local_storage_signal.js +0 -17
- package/src/store/resource_graph.js +0 -1304
- package/src/store/tests/resource_graph_autoreload_demo.html +0 -12
- package/src/store/tests/resource_graph_autoreload_demo.jsx +0 -964
- package/src/store/tests/resource_graph_dependencies.test_manual.js +0 -95
- package/src/store/value_in_local_storage.js +0 -187
- package/src/symbol_object_signal.js +0 -1
- package/src/use_action_data.js +0 -10
- package/src/use_action_status.js +0 -47
- package/src/utils/add_many_event_listeners.js +0 -15
- package/src/utils/array_add_remove.js +0 -61
- package/src/utils/array_signal.js +0 -15
- package/src/utils/compare_two_js_values.js +0 -172
- package/src/utils/execute_with_cleanup.js +0 -21
- package/src/utils/get_caller_info.js +0 -85
- package/src/utils/is_signal.js +0 -20
- package/src/utils/js_value_weak_map.js +0 -162
- package/src/utils/js_value_weak_map_demo.html +0 -690
- package/src/utils/merge_two_js_values.js +0 -53
- package/src/utils/stringify_for_display.js +0 -131
- package/src/utils/weak_effect.js +0 -48
- package/src/validation/constraints/confirm_constraint.js +0 -14
- package/src/validation/constraints/create_unique_value_constraint.js +0 -27
- package/src/validation/constraints/native_constraints.js +0 -338
- package/src/validation/constraints/readonly_constraint.js +0 -41
- package/src/validation/constraints/same_as_constraint.js +0 -42
- package/src/validation/constraints/single_space_constraint.js +0 -13
- package/src/validation/custom_constraint_validation.js +0 -793
- package/src/validation/custom_message.js +0 -18
- package/src/validation/demos/browser_style.png +0 -0
- package/src/validation/demos/demo_same_as_constraint.html +0 -259
- package/src/validation/demos/form_validation_demo.html +0 -142
- package/src/validation/demos/form_validation_demo_preact.html +0 -87
- package/src/validation/demos/form_validation_native_popover_demo.html +0 -168
- package/src/validation/demos/form_validation_vs_native_demo.html +0 -172
- package/src/validation/hooks/use_constraints.js +0 -23
- package/src/validation/hooks/use_custom_validation_ref.js +0 -73
- package/src/validation/hooks/use_validation_message.js +0 -19
- package/src/validation/input_change_effect.js +0 -106
|
@@ -1,472 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" href="data:," />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Resource demo describe one</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root" style="position: relative; width: 600px"></div>
|
|
11
|
-
|
|
12
|
-
<script type="module" jsenv-type="module/jsx">
|
|
13
|
-
import { render } from "preact";
|
|
14
|
-
import { useState, useEffect, useRef } from "preact/hooks";
|
|
15
|
-
import {
|
|
16
|
-
resource,
|
|
17
|
-
// eslint-disable-next-line no-unused-vars
|
|
18
|
-
ActionRenderer,
|
|
19
|
-
} from "@jsenv/navi";
|
|
20
|
-
import {
|
|
21
|
-
// eslint-disable-next-line no-unused-vars
|
|
22
|
-
ActionStatus,
|
|
23
|
-
} from "./action_status.jsx";
|
|
24
|
-
import { localStorageSignal } from "../../../store/local_storage_signal.js";
|
|
25
|
-
|
|
26
|
-
const tables = [
|
|
27
|
-
{ id: "table_1", name: "table_1", owner: "user_1" },
|
|
28
|
-
{ id: "table_2", name: "table_2", owner: "user_2" },
|
|
29
|
-
];
|
|
30
|
-
const users = [
|
|
31
|
-
{ id: "user_1", name: "User 1" },
|
|
32
|
-
{ id: "user_2", name: "User 2" },
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
const getUser = ({ userId }) => {
|
|
36
|
-
const user = users.find((user) => user.id === userId);
|
|
37
|
-
user.tables = tables.filter((table) => table.owner?.id === userId);
|
|
38
|
-
return user;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const USER = resource("user", {
|
|
42
|
-
idKey: "id",
|
|
43
|
-
mutableIdKey: "name",
|
|
44
|
-
GET: getUser,
|
|
45
|
-
GET_MANY: () => users,
|
|
46
|
-
PUT: ({ name, field, value }) => {
|
|
47
|
-
let userToUpdate = users.find((u) => u.name === name);
|
|
48
|
-
const id = userToUpdate.id;
|
|
49
|
-
userToUpdate[field] = value;
|
|
50
|
-
return { id, [field]: value };
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
USER.RENAME = USER.PUT.bindParams({ field: "name" });
|
|
54
|
-
const TABLE = resource("table", {
|
|
55
|
-
idKey: "id",
|
|
56
|
-
mutableIdKey: "name",
|
|
57
|
-
GET: ({ name }) => {
|
|
58
|
-
const table = tables.find((table) => table.name === name);
|
|
59
|
-
if (!table) {
|
|
60
|
-
throw new Error(`Table with name "${name}" not found`);
|
|
61
|
-
}
|
|
62
|
-
return table;
|
|
63
|
-
},
|
|
64
|
-
GET_MANY: () => tables,
|
|
65
|
-
PUT: ({ name, field, value }) => {
|
|
66
|
-
let tableToUpdate = tables.find((t) => t.name === name);
|
|
67
|
-
const id = tableToUpdate.id;
|
|
68
|
-
tableToUpdate[field] = value;
|
|
69
|
-
return { id, [field]: value };
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
TABLE.RENAME = TABLE.PUT.bindParams({ field: "name" });
|
|
73
|
-
USER.many("tables", TABLE, {
|
|
74
|
-
GET: ({ userId }) => {
|
|
75
|
-
return tables.filter((table) => table.owner?.id === userId);
|
|
76
|
-
},
|
|
77
|
-
POST: ({ tableId }) => {
|
|
78
|
-
const tableToAdd = tables.find((t) => t.id === tableId);
|
|
79
|
-
return tableToAdd;
|
|
80
|
-
},
|
|
81
|
-
DELETE: ({ tableId }) => {
|
|
82
|
-
return tableId;
|
|
83
|
-
},
|
|
84
|
-
POST_MANY: ({ tableIds }) => {
|
|
85
|
-
const tablesToAdd = tables.filter((t) => tableIds.includes(t.id));
|
|
86
|
-
return tablesToAdd;
|
|
87
|
-
},
|
|
88
|
-
DELETE_MANY: ({ tableIds }) => {
|
|
89
|
-
return tableIds;
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
const TABLE_OWNER = TABLE.one("owner", USER, {
|
|
93
|
-
GET: ({ tableId, owner }) => {
|
|
94
|
-
if (!owner) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
id: tableId,
|
|
99
|
-
owner: getUser({ userId: owner.id }),
|
|
100
|
-
};
|
|
101
|
-
},
|
|
102
|
-
PUT: ({ tableId, newOwnerId }) => {
|
|
103
|
-
const newOwner = users.find((u) => u.id === newOwnerId);
|
|
104
|
-
const tableToUpdate = tables.find((t) => t.id === tableId);
|
|
105
|
-
tableToUpdate.owner = newOwner;
|
|
106
|
-
return {
|
|
107
|
-
id: tableId,
|
|
108
|
-
owner: newOwner,
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
DELETE: ({ tableId }) => {
|
|
112
|
-
const tableToUpdate = tables.find((t) => t.id === tableId);
|
|
113
|
-
tableToUpdate.owner = null;
|
|
114
|
-
return {
|
|
115
|
-
id: tableId,
|
|
116
|
-
owner: null,
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Signal pour la table courante
|
|
122
|
-
const currentTableNameSignal = localStorageSignal("current_table_name");
|
|
123
|
-
const currentTableAction = TABLE.GET.bindParams({
|
|
124
|
-
name: currentTableNameSignal,
|
|
125
|
-
});
|
|
126
|
-
if (currentTableNameSignal.value) {
|
|
127
|
-
currentTableAction.load();
|
|
128
|
-
}
|
|
129
|
-
TABLE.store.registerPropertyChangeCallback("name", (tableName) => {
|
|
130
|
-
currentTableNameSignal.value = tableName;
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
TABLE.GET_MANY.load();
|
|
134
|
-
USER.GET_MANY.load();
|
|
135
|
-
|
|
136
|
-
// eslint-disable-next-line no-unused-vars
|
|
137
|
-
const App = () => {
|
|
138
|
-
return (
|
|
139
|
-
<div style={{ display: "flex", gap: "20px" }}>
|
|
140
|
-
<div style={{ flex: 1 }}>
|
|
141
|
-
<h2>Tables</h2>
|
|
142
|
-
<TablesList />
|
|
143
|
-
|
|
144
|
-
<h2>Current Table</h2>
|
|
145
|
-
<CurrentTable />
|
|
146
|
-
</div>
|
|
147
|
-
|
|
148
|
-
<div style={{ flex: 1 }}>
|
|
149
|
-
<h2>Users</h2>
|
|
150
|
-
<UsersList />
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// eslint-disable-next-line no-unused-vars
|
|
157
|
-
const TablesList = () => {
|
|
158
|
-
return (
|
|
159
|
-
<ActionRenderer action={TABLE.GET_MANY}>
|
|
160
|
-
{(tables) => (
|
|
161
|
-
<div>
|
|
162
|
-
{tables.map((table) => (
|
|
163
|
-
<TableItem key={table.id} table={table} />
|
|
164
|
-
))}
|
|
165
|
-
</div>
|
|
166
|
-
)}
|
|
167
|
-
</ActionRenderer>
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// eslint-disable-next-line no-unused-vars
|
|
172
|
-
const TableItem = ({ table }) => {
|
|
173
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
174
|
-
const [editName, setEditName] = useState(table.name);
|
|
175
|
-
// ✅ NEW: State for editing owner
|
|
176
|
-
const [isEditingOwner, setIsEditingOwner] = useState(false);
|
|
177
|
-
const [editOwnerId, setEditOwnerId] = useState(table.owner?.id);
|
|
178
|
-
|
|
179
|
-
const handleSave = async () => {
|
|
180
|
-
await TABLE.RENAME.bindParams({
|
|
181
|
-
name: table.name,
|
|
182
|
-
value: editName,
|
|
183
|
-
}).reload();
|
|
184
|
-
setIsEditing(false);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const handleCancel = () => {
|
|
188
|
-
setEditName(table.name);
|
|
189
|
-
setIsEditing(false);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// ✅ NEW: Handle owner update
|
|
193
|
-
const handleOwnerSave = async () => {
|
|
194
|
-
if (editOwnerId) {
|
|
195
|
-
await TABLE_OWNER.PUT.bindParams({
|
|
196
|
-
tableId: table.id,
|
|
197
|
-
newOwnerId: editOwnerId,
|
|
198
|
-
}).reload();
|
|
199
|
-
setIsEditingOwner(false);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
await TABLE_OWNER.DELETE.bindParams({ tableId: table.id }).reload();
|
|
203
|
-
setIsEditingOwner(false);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const handleOwnerCancel = () => {
|
|
207
|
-
setEditOwnerId(table.owner?.id);
|
|
208
|
-
setIsEditingOwner(false);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
const inputRef = useRef();
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (isEditing) {
|
|
214
|
-
inputRef.current.focus();
|
|
215
|
-
inputRef.current.select();
|
|
216
|
-
}
|
|
217
|
-
}, [isEditing]);
|
|
218
|
-
|
|
219
|
-
// ✅ Get current owner name for display
|
|
220
|
-
const currentOwner = users.find((u) => u.id === table.owner?.id);
|
|
221
|
-
|
|
222
|
-
return (
|
|
223
|
-
<div
|
|
224
|
-
style={{
|
|
225
|
-
border: "1px solid #ccc",
|
|
226
|
-
padding: "10px",
|
|
227
|
-
margin: "5px 0",
|
|
228
|
-
backgroundColor:
|
|
229
|
-
currentTableNameSignal.value === table.name
|
|
230
|
-
? "#e6f3ff"
|
|
231
|
-
: "white",
|
|
232
|
-
}}
|
|
233
|
-
>
|
|
234
|
-
<div style={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
|
235
|
-
{isEditing ? (
|
|
236
|
-
<>
|
|
237
|
-
<input
|
|
238
|
-
ref={inputRef}
|
|
239
|
-
value={editName}
|
|
240
|
-
onChange={(e) => setEditName(e.target.value)}
|
|
241
|
-
style={{ flex: 1 }}
|
|
242
|
-
/>
|
|
243
|
-
<button onClick={handleSave}>Save</button>
|
|
244
|
-
<button onClick={handleCancel}>Cancel</button>
|
|
245
|
-
</>
|
|
246
|
-
) : (
|
|
247
|
-
<>
|
|
248
|
-
<strong style={{ flex: 1 }}>{table.name}</strong>
|
|
249
|
-
<button onClick={() => setIsEditing(true)}>Rename</button>
|
|
250
|
-
<button
|
|
251
|
-
onClick={() => {
|
|
252
|
-
currentTableNameSignal.value = table.name;
|
|
253
|
-
currentTableAction.reload();
|
|
254
|
-
}}
|
|
255
|
-
disabled={currentTableNameSignal.value === table.name}
|
|
256
|
-
>
|
|
257
|
-
Select
|
|
258
|
-
</button>
|
|
259
|
-
</>
|
|
260
|
-
)}
|
|
261
|
-
</div>
|
|
262
|
-
|
|
263
|
-
{/* ✅ NEW: Owner editing section */}
|
|
264
|
-
<div style={{ marginTop: "10px", fontSize: "12px", color: "#666" }}>
|
|
265
|
-
<div
|
|
266
|
-
style={{ display: "flex", alignItems: "center", gap: "10px" }}
|
|
267
|
-
>
|
|
268
|
-
{isEditingOwner ? (
|
|
269
|
-
<>
|
|
270
|
-
<span>Owner:</span>
|
|
271
|
-
<select
|
|
272
|
-
value={editOwnerId}
|
|
273
|
-
onChange={(e) => {
|
|
274
|
-
const value = e.target.value;
|
|
275
|
-
setEditOwnerId(value === "" ? null : e.target.value);
|
|
276
|
-
}}
|
|
277
|
-
style={{ fontSize: "12px" }}
|
|
278
|
-
>
|
|
279
|
-
<option value=""></option>
|
|
280
|
-
{users.map((user) => (
|
|
281
|
-
<option key={user.id} value={user.id}>
|
|
282
|
-
{user.name}
|
|
283
|
-
</option>
|
|
284
|
-
))}
|
|
285
|
-
</select>
|
|
286
|
-
<button
|
|
287
|
-
onClick={handleOwnerSave}
|
|
288
|
-
style={{ fontSize: "10px", padding: "2px 6px" }}
|
|
289
|
-
>
|
|
290
|
-
Save
|
|
291
|
-
</button>
|
|
292
|
-
<button
|
|
293
|
-
onClick={handleOwnerCancel}
|
|
294
|
-
style={{ fontSize: "10px", padding: "2px 6px" }}
|
|
295
|
-
>
|
|
296
|
-
Cancel
|
|
297
|
-
</button>
|
|
298
|
-
</>
|
|
299
|
-
) : (
|
|
300
|
-
<>
|
|
301
|
-
<span>Owner: {currentOwner?.name || "Unknown"}</span>
|
|
302
|
-
<button
|
|
303
|
-
onClick={() => {
|
|
304
|
-
setEditOwnerId(table.owner?.id);
|
|
305
|
-
setIsEditingOwner(true);
|
|
306
|
-
}}
|
|
307
|
-
style={{ fontSize: "10px", padding: "2px 6px" }}
|
|
308
|
-
>
|
|
309
|
-
Change Owner
|
|
310
|
-
</button>
|
|
311
|
-
</>
|
|
312
|
-
)}
|
|
313
|
-
</div>
|
|
314
|
-
</div>
|
|
315
|
-
</div>
|
|
316
|
-
);
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
// eslint-disable-next-line no-unused-vars
|
|
320
|
-
const CurrentTable = () => {
|
|
321
|
-
if (!currentTableNameSignal.value) {
|
|
322
|
-
return <p>No table selected</p>;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return (
|
|
326
|
-
<div>
|
|
327
|
-
<ActionStatus action={currentTableAction} />
|
|
328
|
-
<ActionRenderer action={currentTableAction}>
|
|
329
|
-
{(table) => <TableDetails table={table} />}
|
|
330
|
-
</ActionRenderer>
|
|
331
|
-
</div>
|
|
332
|
-
);
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
// eslint-disable-next-line no-unused-vars
|
|
336
|
-
const TableDetails = ({ table }) => {
|
|
337
|
-
const getTableOwner = TABLE_OWNER.GET.bindParams({
|
|
338
|
-
tableId: table.id,
|
|
339
|
-
owner: table.owner,
|
|
340
|
-
});
|
|
341
|
-
// const { idle } = useActionStatus(getTableOwner);
|
|
342
|
-
|
|
343
|
-
return (
|
|
344
|
-
<div style={{ border: "2px solid #007acc", padding: "15px" }}>
|
|
345
|
-
<h3>{table.name}</h3>
|
|
346
|
-
<p>ID: {table.id}</p>
|
|
347
|
-
|
|
348
|
-
<details
|
|
349
|
-
onToggle={(e) => {
|
|
350
|
-
if (e.target.open) {
|
|
351
|
-
getTableOwner.load();
|
|
352
|
-
} else {
|
|
353
|
-
getTableOwner.abort();
|
|
354
|
-
}
|
|
355
|
-
}}
|
|
356
|
-
>
|
|
357
|
-
<summary>Owner Details</summary>
|
|
358
|
-
<ActionRenderer action={getTableOwner}>
|
|
359
|
-
{(owner) => {
|
|
360
|
-
if (!owner) {
|
|
361
|
-
return <p>No owner assigned</p>;
|
|
362
|
-
}
|
|
363
|
-
return (
|
|
364
|
-
<div
|
|
365
|
-
style={{
|
|
366
|
-
marginTop: "10px",
|
|
367
|
-
padding: "10px",
|
|
368
|
-
backgroundColor: "#f0f0f0",
|
|
369
|
-
}}
|
|
370
|
-
>
|
|
371
|
-
<p>
|
|
372
|
-
<strong>Owner:</strong> {owner.name}
|
|
373
|
-
</p>
|
|
374
|
-
<p>
|
|
375
|
-
<strong>Owner ID:</strong> {owner.id}
|
|
376
|
-
</p>
|
|
377
|
-
</div>
|
|
378
|
-
);
|
|
379
|
-
}}
|
|
380
|
-
</ActionRenderer>
|
|
381
|
-
</details>
|
|
382
|
-
</div>
|
|
383
|
-
);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
// eslint-disable-next-line no-unused-vars
|
|
387
|
-
const UsersList = () => {
|
|
388
|
-
return (
|
|
389
|
-
<ActionRenderer action={USER.GET_MANY}>
|
|
390
|
-
{(users) => (
|
|
391
|
-
<div>
|
|
392
|
-
{users.map((user) => (
|
|
393
|
-
<UserItem key={user.id} user={user} />
|
|
394
|
-
))}
|
|
395
|
-
</div>
|
|
396
|
-
)}
|
|
397
|
-
</ActionRenderer>
|
|
398
|
-
);
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
// eslint-disable-next-line no-unused-vars
|
|
402
|
-
const UserItem = ({ user }) => {
|
|
403
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
404
|
-
const [editName, setEditName] = useState(user.name);
|
|
405
|
-
|
|
406
|
-
const handleSave = async () => {
|
|
407
|
-
await USER.RENAME.bindParams({
|
|
408
|
-
name: user.name,
|
|
409
|
-
value: editName,
|
|
410
|
-
}).load();
|
|
411
|
-
setIsEditing(false);
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
const handleCancel = () => {
|
|
415
|
-
setEditName(user.name);
|
|
416
|
-
setIsEditing(false);
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
const inputRef = useRef();
|
|
420
|
-
useEffect(() => {
|
|
421
|
-
if (isEditing) {
|
|
422
|
-
inputRef.current.focus();
|
|
423
|
-
inputRef.current.select();
|
|
424
|
-
}
|
|
425
|
-
}, [isEditing]);
|
|
426
|
-
|
|
427
|
-
// Compter combien de tables appartiennent à cet utilisateur
|
|
428
|
-
const userTables = user.tables || [];
|
|
429
|
-
|
|
430
|
-
return (
|
|
431
|
-
<div
|
|
432
|
-
style={{
|
|
433
|
-
border: "1px solid #ccc",
|
|
434
|
-
padding: "10px",
|
|
435
|
-
margin: "5px 0",
|
|
436
|
-
backgroundColor: "#f9f9f9",
|
|
437
|
-
}}
|
|
438
|
-
>
|
|
439
|
-
<div style={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
|
440
|
-
{isEditing ? (
|
|
441
|
-
<>
|
|
442
|
-
<input
|
|
443
|
-
ref={inputRef}
|
|
444
|
-
value={editName}
|
|
445
|
-
onChange={(e) => setEditName(e.target.value)}
|
|
446
|
-
style={{ flex: 1 }}
|
|
447
|
-
/>
|
|
448
|
-
<button onClick={handleSave}>Save</button>
|
|
449
|
-
<button onClick={handleCancel}>Cancel</button>
|
|
450
|
-
</>
|
|
451
|
-
) : (
|
|
452
|
-
<>
|
|
453
|
-
<strong style={{ flex: 1 }}>{user.name}</strong>
|
|
454
|
-
<button onClick={() => setIsEditing(true)}>Rename</button>
|
|
455
|
-
</>
|
|
456
|
-
)}
|
|
457
|
-
</div>
|
|
458
|
-
|
|
459
|
-
<div style={{ marginTop: "10px", fontSize: "12px", color: "#666" }}>
|
|
460
|
-
ID: {user.id} | Tables owned: {userTables.length}
|
|
461
|
-
{userTables.length > 0 && (
|
|
462
|
-
<span> ({userTables.map((t) => t.name).join(", ")})</span>
|
|
463
|
-
)}
|
|
464
|
-
</div>
|
|
465
|
-
</div>
|
|
466
|
-
);
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
render(<App />, document.querySelector("#root"));
|
|
470
|
-
</script>
|
|
471
|
-
</body>
|
|
472
|
-
</html>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>User Navigation Test</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app"></div>
|
|
10
|
-
<script type="module" src="user_nav.jsx"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|