Skip to content

Commit

Permalink
Resize content tab sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Paxa committed Aug 30, 2021
1 parent 7d8175f commit 2453e8c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/db_screen_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class DbScreenView {
"Refresh Tables": this.reloadStructure.bind(this)
});

new SidebarResize(this.content.find('.resize-handler'));
this.sidebarResizer = new SidebarResize(this.content.find('.resize-handler'));
}

// Public API
Expand Down
18 changes: 18 additions & 0 deletions app/views/panes/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class Content extends PaneBase {

this.footer = this.content.find('.summary-and-pages');

this.initFooterResize();

this.nextPageEl = this.footer.find('.pages.next');
this.prevPageEl = this.footer.find('.pages.prev');

Expand Down Expand Up @@ -424,6 +426,11 @@ class Content extends PaneBase {
initContextMenu () {
var table = this.content.find('.rescol-content-wrapper table');

// this may heppen when there is render error
if (table.length == 0) {
return;
}

// bind for delete button
if (this.currentTableType == 'BASE TABLE') {
$u(table).on('generic-table-init', () => {
Expand Down Expand Up @@ -498,6 +505,17 @@ class Content extends PaneBase {
}
}

// Move footer according to left sidebar resize
initFooterResize() {
if (!this.footer[0]) {
return;
}
this.footer[0].style.marginLeft = '' + (this.handler.view.sidebarResizer.currentWith - 1) + 'px';
this.handler.view.content.on('sidebar-resize', (e, newWidth) => {
this.footer[0].style.marginLeft = '' + (newWidth - 1) + 'px';
})
}

async deleteRow (row) {
if (this.currentTableType != 'BASE TABLE') {
$u.alert("Can't delete from " + this.currentTableType);
Expand Down
5 changes: 5 additions & 0 deletions lib/sidebar_resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class SidebarResize {
/*::
following: boolean
minWidth: number
currentWith: number
element: JQuery<HTMLElement>
sidebar: JQuery<HTMLElement>
mainbar: JQuery<HTMLElement>
Expand All @@ -20,12 +21,16 @@ class SidebarResize {
this.doc[0].addEventListener('mousemove', (move_ev) => {
if (this.following) this.onChanged(move_ev);
});

this.currentWith = parseInt(this.sidebar[0].style.width, 10);
}

onChanged (event) {
var width = event.pageX > this.minWidth ? event.pageX : this.minWidth;
this.currentWith = width;
this.mainbar[0].style.marginLeft = '' + width + 'px';
this.sidebar[0].style.width = '' + width + 'px';
this.mainbar.trigger("sidebar-resize", width);
}

startTracking () {
Expand Down
5 changes: 4 additions & 1 deletion vendor/datasets/different_types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ CREATE TABLE different_types (
col_matrix_3x3 integer[3][3],
col_array_text text[],
song text[][],
json_array jsonb[],
col_hstore hstore,
col_gender human_gender,
);

-- insert all nulls
insert into different_types (id) values (nextval('different_types_id_seq'::regclass));

insert into different_types (col_array_int, col_matrix_3x3, col_array_text, col_hstore, col_gender) values
insert into different_types (col_array_int, col_matrix_3x3, col_array_text, song, json_array, col_hstore, col_gender) values
(
'{1, 2, 3, 4, 5}',
'{ {1, 2, 3}, {11, 12, 13}, {21, 22, 23} }',
'{"apple", "orange", "banana", "mangga"}',
'{ {"Hello", "darkness", "my", "old", "friend"}, {"I\'ve", "come", "to", "talk", "with", "you", "again"} }',
'{ "{\"x\": 123}", "{\"y\": 456}"}',
'author => "Katherine Dunn", pages => 368, category => fiction',
'male'
);

0 comments on commit 2453e8c

Please sign in to comment.