@@ -12,6 +12,9 @@ import { getExportFormats } from 'schemas';
12
12
import { range as arrayRange } from 'lodash' ;
13
13
import { deepMerge } from '../lib/utils/objects' ;
14
14
import Validator from './Validator' ;
15
+ import i18next from 'i18next' ;
16
+
17
+ const SCHEMAMENUS = [ 'SchemaTypeMenu' , 'SchemaClassMenu' , 'SchemaSlotMenu' , 'SchemaSlotGroupMenu' , 'SchemaEnumMenu' ] ;
15
18
16
19
class AppConfig {
17
20
constructor ( template_path = null ) {
@@ -20,7 +23,6 @@ class AppConfig {
20
23
}
21
24
}
22
25
export default class AppContext {
23
- //schema_tree = {};
24
26
dhs = { } ;
25
27
current_data_harmonizer_name = null ;
26
28
currentSelection = null ;
@@ -100,13 +102,9 @@ export default class AppContext {
100
102
// Ensure dynamic Enums are added so picklist source / range references are
101
103
// detected and pulldown/multiselect menus are crafted; and validation works
102
104
if ( schema . name === 'DH_LinkML' ) {
103
- [ 'SchemaTypeMenu' , 'SchemaClassMenu' , 'SchemaEnumMenu' , 'SchemaSlotGroupMenu' ]
104
- . forEach ( ( item ) => {
105
+ SCHEMAMENUS . forEach ( ( item ) => {
105
106
if ( ! ( item in schema . enums ) ) {
106
- schema . enums [ item ] = {
107
- name : item ,
108
- permissible_values : { test : { text : 'test' , title : 'a title' } }
109
- }
107
+ schema . enums [ item ] = { name : item } //, permissible_values: {}
110
108
}
111
109
} ) ;
112
110
} ;
@@ -117,11 +115,6 @@ export default class AppContext {
117
115
this . crudGetDependentRows ( this . current_data_harmonizer_name ) ;
118
116
this . crudUpdateRecordPath ( ) ;
119
117
$ ( "#record-hierarchy-div" ) . toggle ( Object . keys ( this . relations ) . length > 1 ) ;
120
-
121
- // Upgrade to Handsontable 15.0.0 causes following to error out?!
122
- // undefined "schema.enums.SchemaSlotGroupMenu"
123
- //schema.enums.SchemaSlotGroupMenu.permissible_values['testo'] = {text: 'testo', title: 'a title'};
124
-
125
118
return this ;
126
119
}
127
120
@@ -141,7 +134,7 @@ export default class AppContext {
141
134
* @param {Array } enums list of special enumeration menus. Default list
142
135
* covers all menus that schema editor might have changed dynamically.
143
136
*/
144
- refreshSchemaEditorMenus ( enums = [ 'SchemaTypeMenu' , 'SchemaClassMenu' , 'SchemaEnumMenu' , 'SchemaSlotGroupMenu' ] ) {
137
+ refreshSchemaEditorMenus ( enums = SCHEMAMENUS ) {
145
138
const schema = this . template . current . schema ;
146
139
if ( schema . name === 'DH_LinkML' ) {
147
140
for ( const enum_name of enums ) {
@@ -191,6 +184,12 @@ export default class AppContext {
191
184
this . getDynamicMenu ( schema , schema . enums , 'Enum' , user_schema_name , permissible_values ) ;
192
185
break ;
193
186
187
+ case 'SchemaSlotMenu' :
188
+ // Get the enums from the Enums tab, filtered for schema
189
+ // selected in Schema tab.
190
+ this . getDynamicMenu ( schema , schema . slots , 'Slot' , user_schema_name , permissible_values ) ;
191
+ break ;
192
+
194
193
case 'SchemaSlotGroupMenu' :
195
194
/** Fabricate list of active class's SchemaSlotGroupMenu
196
195
* slot_group values and make menu for it. To prepare SlotGroup
@@ -312,13 +311,15 @@ export default class AppContext {
312
311
. forEach ( ( obj , index ) => {
313
312
if ( obj . length > 0 ) {
314
313
const [ class_name , class_obj ] = obj ;
315
-
316
- // Move createDataHarmonizerTab to HTML utilities, and move prep there.
317
- // If it shares a key with another class which is its parent, this DH must be a child
318
- const is_child = ! ( class_name == template_name ) ; // && isEmpty(this.crudGetParents(class_name)) && !();
319
- let tooltip = Object . keys ( this . relations [ class_name ] ?. parent ) . join ( ', ' ) ;
320
- if ( tooltip . length )
321
- tooltip = `Requires key selection from: ${ tooltip } ` ;
314
+ // Move createDataHarmonizerTab() to HTML utilities, and move prep there.
315
+ // Tooltip lists any parents of this class whose keys must be satisfied.
316
+ const is_child = ! ( class_name == template_name ) ;
317
+ let tooltip = Object . keys ( this . relations [ class_name ] ?. parent )
318
+ . map ( ( parent_name ) => schema . classes [ parent_name ] . title )
319
+ . join ( ', ' ) ;
320
+ if ( tooltip . length ) {
321
+ tooltip = `<span data-i18n="tooltip-require-selection">${ i18next . t ( 'tooltip-require-selection' ) } </span>: ${ tooltip } ` ; //Requires key selection from
322
+ }
322
323
const dhId = `data-harmonizer-grid-${ index } ` ;
323
324
const tab_label = class_obj . title ? class_obj . title : class_name ;
324
325
const dhTab = createDataHarmonizerTab ( dhId , tab_label , class_name , tooltip , index === 0 ) ;
@@ -1125,12 +1126,14 @@ export default class AppContext {
1125
1126
}
1126
1127
1127
1128
/**
1128
- * Show path from root to current template that user has made a selection in.
1129
- * A complexity is that a class's keys may be composed of slots from have two
1130
- * (or more) separate parents, each with parent(s) etc.
1129
+ * In focus display (usually in footer), show path from root to current
1130
+ * template that user has made a selection in. A complexity is that a
1131
+ * class's keys may be composed of slots from have two (or more) separate
1132
+ * parents, each with parent(s) etc.
1131
1133
*
1132
1134
*/
1133
1135
crudUpdateRecordPath ( ) {
1136
+ const schema = this . template . current . schema ;
1134
1137
const current_template_name = this . getCurrentDataHarmonizer ( ) . template_name ;
1135
1138
let class_name = current_template_name ; // current tab
1136
1139
let hierarchy_text = [ ] ;
@@ -1140,6 +1143,7 @@ export default class AppContext {
1140
1143
class_name = stack . pop ( ) ; // pop class_name
1141
1144
if ( class_name in done )
1142
1145
continue ;
1146
+ const class_title = schema . classes [ class_name ] . title ;
1143
1147
const dependent = this . dependent_rows . get ( class_name ) ;
1144
1148
let key_string = '' ;
1145
1149
let tooltip = '' ;
@@ -1151,8 +1155,8 @@ export default class AppContext {
1151
1155
key_string = value + ( key_string ? ', ' : '' ) + key_string ;
1152
1156
tooltip = key + ( tooltip ? ', ' : '' ) + tooltip ;
1153
1157
} ) ;
1154
- let tooltip_text = `<span class="tooltipytext">${ class_name } [ ${ tooltip } ]</span>` ;
1155
- done [ class_name ] = `<b>${ class_name } </b> <span class="tooltipy">[${ key_string } ]${ tooltip_text } </span> ` ;
1158
+ let tooltip_text = `<span class="tooltipytext">${ class_title } [ ${ tooltip } ]</span>` ;
1159
+ done [ class_name ] = `<b>${ class_title } </b> <span class="tooltipy">[${ key_string } ]${ tooltip_text } </span> ` ;
1156
1160
1157
1161
// SEVERAL parents are possible - need them all displayed.
1158
1162
let parents = Object . keys ( this . relations [ class_name ] . parent ) ;
0 commit comments