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

[FIX] Directory sort and column sizes were wrong #10403

Merged
merged 7 commits into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.rc-directory {
display: flex;
flex-direction: column;

&-header {
display: flex;
Expand Down Expand Up @@ -34,35 +36,47 @@
display: flex;
align-items: center;
margin: 0 -9px;

overflow: hidden;
}

&-avatar {
width: 60px;
height: 60px;
margin: 0 9px;

flex: 0 0 auto;

background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}

&-info {
display: flex;
margin: 0 9px;

flex-direction: column;
width: 100%;
width: 1%;
flex-grow: 1;

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

&-name {
font-size: 1rem;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

&-description {
margin-top: 0.625rem;
color: var(--rc-color-primary-light);
overflow: hidden;
text-overflow: ellipsis;
text-overflow: ellipsis;
max-width: 200px;
}

Expand All @@ -72,14 +86,27 @@
}

.rc-directory-content {
width: 100%;
overflow-x: auto;
flex: 1 1 100%;
height: 100vh;

& .js-sort {
cursor: pointer;
}
}

.rc-table-td--createdAt,
.rc-table-td--users {
width: 120px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}

.rc-table-td--users {
width: 80px;
}

@media (width <= 500px) {
.rc-directory-content .rc-table-head {
display: none;
Expand Down
26 changes: 5 additions & 21 deletions packages/rocketchat-theme/client/imports/components/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
color: var(--rc-color-primary);
width: 100%;

&--fixed {
table-layout:fixed;
}

&-head {
color: var(--rc-color-primary-light);

Expand All @@ -24,31 +28,11 @@
}

&-td {
padding: 1.25rem 0;
padding: 1.25rem 1rem;
vertical-align: middle;

&:first-child {
padding-left: 1rem;
}

&:last-child {
padding-right: 1rem;
}

&--bold {
font-weight: 600;
}
}
}

.rtl .rc-table-td {
&:first-child {
padding-right: 1rem;
padding-left: 0;
}

&:last-child {
padding-right: 0;
padding-left: 1rem;
}
}
2 changes: 2 additions & 0 deletions packages/rocketchat-ui-master/public/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions packages/rocketchat-ui/client/views/app/directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
{{/header}}
<div class="rc-directory-content">
{{#if $eq searchType 'channels'}}
<table class="rc-table">
<table class="rc-table rc-table--fixed">
<thead class="rc-table-head">
<tr class="rc-table-tr">
<td class="rc-table-td js-sort" data-sort="name">Name {{> icon icon="sort" }}</td>
<td class="rc-table-td js-sort" data-sort="usernames">Users {{> icon icon="sort" }}</td>
<td class="rc-table-td js-sort" data-sort="createdAt">Created At {{> icon icon="sort" }}</td>
<td class="rc-table-td js-sort" data-sort="name">Name {{> icon icon=(sortIcon 'name')}}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Name is not i18n'd.

<td class="rc-table-td rc-table-td--users">Users</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Users is not i18n'd.

<td class="rc-table-td js-sort rc-table-td--createdAt" data-sort="createdAt">Created At {{> icon icon=(sortIcon 'createdAt') }}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Created At is not i18n'd.

</tr>
</thead>
<tbody class="rc-table-body">
Expand Down
42 changes: 32 additions & 10 deletions packages/rocketchat-ui/client/views/app/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ Template.directory.helpers({
},
searchType() {
return Template.instance().searchType.get();
},
sortIcon(key) {
const {
sortDirection,
searchSortBy
} = Template.instance();

return key === searchSortBy.get() && sortDirection.get() !== 'asc' ? 'sort-up' : 'sort-down';
}
});

Expand Down Expand Up @@ -101,22 +109,20 @@ Template.directory.events({
}
});

Template.directory.onCreated(function() {
this.searchText = new ReactiveVar('');
this.searchType = new ReactiveVar('channels');
this.searchSortBy = new ReactiveVar('name');
this.sortDirection = new ReactiveVar('asc');
this.page = new ReactiveVar(0);
this.end = new ReactiveVar(false);

this.results = new ReactiveVar([]);

Template.directory.onRendered(function() {
this.resize = () => {
const height = this.$('.rc-directory-content').height();
this.limit.set(Math.ceil((height / 100) + 5));
};
this.resize();
$(window).on('resize', this.resize);
Tracker.autorun(() => {
const searchConfig = {
text: this.searchText.get(),
type: this.searchType.get(),
sortBy: this.searchSortBy.get(),
sortDirection: this.sortDirection.get(),
limit: this.limit.get(),
page: this.page.get()
};
if (this.end.get() || this.loading) {
Expand All @@ -136,6 +142,22 @@ Template.directory.onCreated(function() {
});
});

Template.directory.onDestroyed(function() {
$(window).on('off', this.resize);
});

Template.directory.onCreated(function() {
this.searchText = new ReactiveVar('');
this.searchType = new ReactiveVar('channels');
this.searchSortBy = new ReactiveVar('name');
this.sortDirection = new ReactiveVar('asc');
this.limit = new ReactiveVar(0);
this.page = new ReactiveVar(0);
this.end = new ReactiveVar(false);

this.results = new ReactiveVar([]);
});

Template.directory.onRendered(function() {
$('.main-content').removeClass('rc-old');
$('.rc-directory-content').css('height', `calc(100vh - ${ document.querySelector('.rc-directory .rc-header').offsetHeight }px)`);
Expand Down