Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to hide/unhide columns from column popup menu #103

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cdb/Data.hx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typedef Column = {
var name : String;
var type : ColumnType;
var typeStr : String;
@:optional var hidden : Bool;
@:optional var opt : Bool;
@:optional var display : DisplayType;
@:optional var kind : ColumnKind;
Expand Down
54 changes: 53 additions & 1 deletion src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,36 @@ class Main extends Model {
var nleft = new MenuItem( { label : "Move Left" } );
var nright = new MenuItem( { label : "Move Right" } );
var ndel = new MenuItem( { label : "Delete" } );

var nhide = new MenuItem({label: "Hide Column"});
var nshowcols = new MenuItem({label: "Show Columns"});
var ncols = new Menu();
for (col in sheet.columns) {
var ncol = new MenuItem({
label: col.name,
type: MenuItemType.checkbox
});
if (col.hidden)
ncol.checked = false;
else
ncol.checked = true;
ncol.click = function() {
col.hidden = !ncol.checked;
refresh();
save();
}
ncols.append(ncol);
}
var nsep = new MenuItem({type: MenuItemType.separator});
ncols.append(nsep);
var nshowall = new MenuItem({label: "Show All"});
ncols.append(nshowall);

nshowcols.submenu = ncols;

var ndisp = new MenuItem( { label : "Display Column", type : MenuItemType.checkbox } );
var nicon = new MenuItem( { label : "Display Icon", type : MenuItemType.checkbox } );
for( m in [nedit, nins, nleft, nright, ndel, ndisp, nicon] )
for( m in [nedit, nins, nleft, nright, ndel, nhide, nshowcols, ndisp, nicon] )
n.append(m);

switch( c.type ) {
Expand Down Expand Up @@ -860,6 +887,19 @@ class Main extends Model {
if( !isProperties || js.Browser.window.confirm("Do you really want to delete this property for all objects?") )
deleteColumn(sheet, c.name);
};
nhide.click = function() {
c.hidden = true;
refresh();
save();
}
nshowall.click = function() {
for (col in sheet.columns) {
if (col.hidden)
col.hidden = false;
}
refresh();
save();
}
ndisp.click = function() {
if( sheet.props.displayColumn == c.name ) {
sheet.props.displayColumn = null;
Expand Down Expand Up @@ -1534,8 +1574,20 @@ class Main extends Model {
var colCount = sheet.columns.length;
if( sheet.isLevel() ) colCount++;

// count hidden columns
for( cindex in 0...sheet.columns.length ) {
var c = sheet.columns[cindex];
if (c.hidden) {
colCount--;
}
}

for( cindex in 0...sheet.columns.length ) {
var c = sheet.columns[cindex];
if (c.hidden) {
continue;
}

var col = J("<th>");
col.text(c.name);
col.addClass( "t_"+c.type.getName().substr(1).toLowerCase() );
Expand Down