Skip to content

Commit 327ff13

Browse files
committed
fixing behavour for Table Keys report
1 parent bb5307a commit 327ff13

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

lib/AppContext.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,35 @@ export default class AppContext {
7474
let dh = this.getCurrentDataHarmonizer();
7575
let class_name = dh.template_name;
7676
let report_type = $('#report_select_type').val();
77+
const class_dh = this.dhs['Class'];
78+
const class_row = class_dh?.hot.getSelected()?.[0]?.[0] ?? -1; // -1 = undefined
7779

7880
//console.log("REFRESHTABDISPLAY", class_name, this.schemaEditor, report_type)
7981

8082
// Display Focus path only if there is some path > 1 element.
8183
$("#record-hierarchy-div").toggle(Object.keys(this.dhs).length > 1);
8284

83-
// Record hierarchy only shown for "Records by 1-many key"
85+
// Record hierarchy cookie crumbs on Display line at top of toolbar are
86+
// only shown for "Records by 1-many key"
8487
$('#record-hierarchy').toggle(report_type === "");
8588

89+
// A Display menu item which is only shown with Schema Editor interface
90+
// if user is on Slot tab.
91+
//$('#slot_report_type, #slot_report_type_option')
92+
// .toggle(this.schemaEditor !== undefined && class_name === 'Slot');
93+
8694
// The Schema tab always displays a full list, even with "record(s) by selected key" option set in menu.
8795
if (this.schemaEditor !== undefined && class_name === 'Schema') {
8896
// Report type override
8997
report_type = 'all';
9098
}
9199

92-
// A Schema Editor interface item that is visible only if Slot tab is showing.
93-
$('#slot_report_type, #slot_report_type option')
94-
.toggle(this.schemaEditor !== undefined && class_name === 'Slot');
95-
96100
// Save, deselect, and then set cursor, Otherwise selected cell gets
97101
// set to same column but first row after filter!!!
102+
/*
98103
let cursor = dh.hot.getSelected();
99104
dh.hot.deselectCell();
105+
*/
100106

101107
// Schema editor SCHEMA tab should never be filtered.
102108
// ONLY DEPENDENT TABS/TABLES SHOULD BE FILTERED.
@@ -108,6 +114,7 @@ export default class AppContext {
108114
this.slotTypeFilter(dh); // Done via hidden fields. no constraint (no keys)
109115
break;
110116

117+
// The following Display > menu is specific to the Field / Slots display
111118
case 'slot':
112119
//this.slotTypeFilter(dh, ['slot']);
113120
//dh.hot.getPlugin('multiColumnSorting').sort() ; //{ column: 3, sortOrder: 'asc' }
@@ -135,10 +142,24 @@ export default class AppContext {
135142
// Records by selected key case
136143
case '':
137144
default:
138-
let dependent_report = this.dependent_rows.get(class_name);
139-
this.tabFilter(dh, dependent_report.fkey_vals); // filter by selected keys.
145+
146+
let fkey_vals = this.dependent_rows.get(class_name).fkey_vals;
147+
// Some reports should show all class's entries if none selected in Class (Table) tab.
148+
149+
if (this.schemaEditor !== undefined && dh.template_name === 'UniqueKey') {
150+
// If no row is selected in the Class (Table) tab, remove the class_id
151+
// filter so all unique keys for the selected schema are shown.
152+
alert(class_row)
153+
if (class_row < 0) {
154+
delete fkey_vals['class_id'];
155+
//alert("here")
156+
}
157+
}
158+
159+
this.tabFilter(dh, fkey_vals); // filter by selected keys.
140160
}
141161

162+
/*
142163
// DON'T RESTORE CURSOR UNTIL WE KNOW THAT IT IS POINTING TO SAME KEY AS BEFORE FILTER?
143164
// Refreshes dependent record list.
144165
if (cursor) {
@@ -150,6 +171,7 @@ export default class AppContext {
150171
// Note this will cause a "double event" of selecting same cell twice.
151172
152173
}
174+
*/
153175

154176
//columnsorting cannot be disabled. If it is, below code will error.
155177
const columnSorting = dh.hot.getPlugin('multiColumnSorting');
@@ -1235,7 +1257,7 @@ export default class AppContext {
12351257
// And dependent slots within this class via other's foreign keys
12361258
// Only one dependent can depend on a slot.
12371259
relations[class_name].dependent_slots[slot_name] = {
1238-
foreign_class: foreign_class,
1260+
foreign_class: foreign_class,
12391261
foreign_slot: foreign_slot_name
12401262
};
12411263

0 commit comments

Comments
 (0)