@@ -152,7 +152,7 @@ export class SchemaEditor {
152152 // ONLY reprogrammable for multiselects.
153153 // Reset menu's permissible_values to latest.
154154 if ( ! ( enum_name in schema . enums ) ) {
155- console . log ( "Adding enumeration" , enum_name ) ;
155+ // console.log("Adding enumeration", enum_name);
156156 schema . enums [ enum_name ] = { name : enum_name } ;
157157
158158 }
@@ -392,20 +392,21 @@ export class SchemaEditor {
392392 return true ;
393393 } ;
394394
395+ /* Empty table render will still trigger .cells () for all row 0 columns
396+ */
395397 initTab ( dh , class_name , hot_settings ) {
396398
397399 if ( class_name === 'Slot' ) {
398- const slot_table_attribute_column = [ 'rank' , 'inlined' , 'inlined_as_list' ] . map ( ( x ) => dh . slot_name_to_column [ x ] ) ;
400+ const slot_table_attribute_column = [ 'rank' , 'slot_group' , ' inlined', 'inlined_as_list' ] . map ( ( x ) => dh . slot_name_to_column [ x ] ) ;
399401
400402 // See https://forum.handsontable.com/t/how-to-unhide-columns-after-hiding-them/5086/6
401403 hot_settings . contextMenu . items [ 'hidden_columns_hide' ] = { } ;
402404 hot_settings . contextMenu . items [ 'hidden_columns_show' ] = { } ;
403-
404405 // Could be turning off/on based on expert user
405406 hot_settings . hiddenColumns = {
406407 // set columns that are hidden by default
407408 columns : slot_table_attribute_column ,
408- indicators : true
409+ indicators : false
409410 }
410411
411412 hot_settings . fixedColumnsLeft = 4 ; // Freeze both schema and slot name.
@@ -417,21 +418,51 @@ export class SchemaEditor {
417418 // We can't lookup existing .getCellMeta() without causing stack overflow.
418419 // ISSUE: We have to disable sorting for 'Slot' table because
419420 // separate reporting controls are at work.
421+
422+ // ASSUMES alphabetical order with schema fields at top
423+
424+ // ISSUE: user clicking on "toggle expert user mode" doesn't visually
425+ // take effect until after dh.render(), so cellProp.readOnly doesn't
426+ // work right away.
420427 hot_settings . cells = function ( row , col ) {
421428 let cellProp = { } ;
429+ let read_only = ! ( dh . context . expert_user === true ) ;
430+ //console.log("EXPERT", row, col, class_name, dh.context.expert_user);
431+
432+ // slot, slot_usage, attribute
422433 let slot_type = dh . hot . getSourceDataAtCell ( row , dh . slot_type_column ) ;
423- let slot_report = $ ( '#report_select_type' ) . val ( ) === 'slot' ;
424- let read_only = ! slot_report || col == dh . slot_class_name_column ;
425- if ( slot_type === 'slot' ) {
426- cellProp . className = 'schemaSlot' + ( read_only ? ' hatched' : '' ) ;
427- // block changing slot class name when working on Schema classes.
428- cellProp . readOnly = read_only ;
434+ cellProp . className = 'tabFieldTd_' + slot_type ;
435+
436+ if ( read_only ) {
437+ // Here we tweak the read-only nature of this field.
438+ if ( slot_type === 'slot' ) {
439+ }
440+ else { // slot_usage or attribute here
441+ read_only = false ;
442+ if ( col in [ dh . schema_name_column ] ) //dh.slot_class_name_column);
443+ read_only = true ;
444+ // ADD LOGIC TO copy display and read only of slot values.
445+ if ( slot_type === 'slot_usage' ) {
446+
447+ }
448+ }
449+
429450 }
451+
452+ /* Handsontable assigns .htDimmed to any cell with .readOnly = true
453+ * see https://handsontable.com/docs/javascript-data-grid/disabled-cells/
454+ */
455+ cellProp . readOnly = read_only ;
456+ //if (row==2 && col == dh.slot_class_name_column) {
457+ // console.log("READONLY", cellProp, dh.slot_class_name_column)
458+ //}
459+
430460 return cellProp ;
431461 }
432-
433- /*
434- hot_settings.columnSorting = {
462+ //hot_settings.multiColumnSorting = false;
463+ //hot_settings.columnSorting = false; // NOT USING single column sorting.
464+
465+ hot_settings . multiColumnSorting = {
435466 // let the end user sort data by clicking on the column name (set by default)
436467 headerAction : false ,
437468 // don't sort empty cells – move rows that contain empty cells to the bottom (set by default)
@@ -440,28 +471,29 @@ export class SchemaEditor {
440471 indicator : false ,
441472
442473 // at initialization, sort data by the first column, in descending order
443- //initialConfig: {
444- // column: 1, // slot name
445- // sortOrder: 'asc',
446- //},
447-
448- // implement your own comparator
449- compareFunctionFactory(sortOrder, columnMeta) {
450- return function (value, nextValue) {
451- // here, add a compare function
452- // that returns `-1`, or `0`, or `1`
453- // ADD OTHER COLUMN VALUES...
454- if (value < nextValue) {
455- return -1
456- }
457- if (value > nextValue) {
458- return 1
459- }
460- return 0
461- };
462- },
474+ // FOR MULTICOLUMN SORTING PROVIDE AN ARRAY, essentially REVERSE ORDER
475+ //initialConfig: [],
476+
463477 }
464- */
478+
479+ // Somehow putting this above doesn't enable memory of it, as though initial
480+ // condition is being wiped out.
481+ dh . defaultMultiColumnSortConfig = [
482+ {
483+ column : 3 , // slot.name
484+ sortOrder : 'asc'
485+ } ,
486+ /*
487+ {
488+ column: 1, // slot type
489+ sortOrder: 'asc'
490+ },
491+ {
492+ column: 3, // schema
493+ sortOrder: 'asc'
494+ }
495+ */
496+ ] ;
465497 }
466498 else { }
467499 }
0 commit comments