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

removed the unwanted pagination div #902

Merged
Merged
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
9 changes: 0 additions & 9 deletions __tests__/users/user-management-home-screen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ describe('Tests the User Management User Listing Screen', () => {
let tileViewBtn;
let tableViewBtn;
let userSearchElement;
let paginationElement;
let prevBtn;
let nextBtn;
jest.setTimeout(60000);

beforeAll(async () => {
Expand Down Expand Up @@ -71,9 +68,6 @@ describe('Tests the User Management User Listing Screen', () => {
tileViewBtn = await page.$('#tile-view-btn');
tableViewBtn = await page.$('#table-view-btn');
userSearchElement = await page.$('#user-search');
paginationElement = await page.$('#pagination');
prevBtn = await page.$('#prevButton');
nextBtn = await page.$('#nextButton');
});

afterAll(async () => {
Expand All @@ -85,9 +79,6 @@ describe('Tests the User Management User Listing Screen', () => {
expect(tileViewBtn).toBeTruthy();
expect(tableViewBtn).toBeTruthy();
expect(userSearchElement).toBeTruthy();
expect(paginationElement).toBeTruthy();
expect(prevBtn).toBeTruthy();
expect(nextBtn).toBeTruthy();
});

it('Check the UI interactions of tile view and table view button.', async () => {
Expand Down
3 changes: 0 additions & 3 deletions users/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const TILE_VIEW_BTN = 'tile-view-btn';
const TABLE_VIEW_BTN = 'table-view-btn';
const USER_SEARCH_ELEMENT = 'user-search';
const DEFAULT_AVATAR = '/images/avatar.png';
const PAGINATION_ELEMENT = 'pagination';
const PREV_BUTTON = 'prevButton';
const NEXT_BUTTON = 'nextButton';
const USER_FETCH_COUNT = 100;
const NONE = 'NONE';
const OOO = 'OOO';
Expand Down
4 changes: 0 additions & 4 deletions users/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ <h2>Skills</h2>
<ul id="head_list"></ul>
</div>
<div id="loader_tag" style="display: none"></div>
<div id="pagination" class="remove-element">
<button class="pagination-btn" id="prevButton">&laquo; Previous</button>
<button class="pagination-btn" id="nextButton">Next &raquo;</button>
</div>
</section>
<footer>
<p class="info-repo">
Expand Down
93 changes: 16 additions & 77 deletions users/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ const userloaderElement = document.getElementById(USER_LOADER_ELEMENT);
const tileViewBtn = document.getElementById(TILE_VIEW_BTN);
const tableViewBtn = document.getElementById(TABLE_VIEW_BTN);
const userSearchElement = document.getElementById(USER_SEARCH_ELEMENT);
const paginationElement = document.getElementById(PAGINATION_ELEMENT);
const prevBtn = document.getElementById(PREV_BUTTON);
const nextBtn = document.getElementById(NEXT_BUTTON);
const filterModal = document.getElementsByClassName(FILTER_MODAL)[0];
const filterButton = document.getElementById(FILTER_BUTTON);
const availabilityFilter = document.getElementById(AVAILABILITY_FILTER);
Expand All @@ -22,13 +19,10 @@ let page = 0;
let run = true;

const init = (
prevBtn,
nextBtn,
tileViewBtn,
tableViewBtn,
userSearchElement,
userListElement,
paginationElement,
loaderElement,
) => {
window.addEventListener('scroll', async () => {
Expand All @@ -45,7 +39,7 @@ const init = (
showUserDataList(
page++,
userListElement,
paginationElement,

loaderElement,
);
}
Expand All @@ -65,11 +59,10 @@ const init = (
return getParticularUserData(
event.target.value,
userListElement,
paginationElement,
loaderElement,
);
}
showUserDataList(page, userListElement, paginationElement, loaderElement);
showUserDataList(page, userListElement, loaderElement);
}, 500),
);
};
Expand Down Expand Up @@ -104,21 +97,14 @@ function showTableView(userListElement, tableViewBtn, tileViewBtn) {
});
}

function showErrorMessage(
msg,
userListElement,
paginationElement,
loaderElement,
) {
function showErrorMessage(msg, userListElement, loaderElement) {
userListElement.innerHTML = '';
const paraELe = document.createElement('p');
const textNode = document.createTextNode(msg);
paraELe.appendChild(textNode);
paraELe.id = 'error_para';
paraELe.classList.add('error-text');
userListElement.appendChild(paraELe);
paginationElement.classList.add('remove-element');
paginationElement.classList.remove('pagination');
loaderElement.classList.add('remove-element');
}

Expand Down Expand Up @@ -146,16 +132,10 @@ function generateUserList(
users,
showPagination,
userListElement,
paginationElement,
loaderElement,
) {
if (!users || !users.length) {
showErrorMessage(
'No data found',
userListElement,
paginationElement,
loaderElement,
);
showErrorMessage('No data found', userListElement, loaderElement);
return;
}

Expand Down Expand Up @@ -237,46 +217,24 @@ function formatUsersData(usersData) {
async function getParticularUserData(
searchInput,
userListElement,
paginationElement,
loaderElement,
) {
try {
page = 0;
if (!searchInput.length) {
await showUserDataList(
page,
userListElement,
paginationElement,
loaderElement,
);
await showUserDataList(page, userListElement, loaderElement);
return;
}
const usersData = await fetchUsersData(searchInput);
if (usersData.users) {
const data = formatUsersData(usersData?.users);

generateUserList(
data,
true,
userListElement,
paginationElement,
loaderElement,
);
generateUserList(data, true, userListElement, loaderElement);
} else {
showErrorMessage(
usersData.message,
userListElement,
paginationElement,
loaderElement,
);
showErrorMessage(usersData.message, userListElement, loaderElement);
}
} catch (err) {
showErrorMessage(
'Something Went Wrong',
userListElement,
paginationElement,
loaderElement,
);
showErrorMessage('Something Went Wrong', userListElement, loaderElement);
}
}

Expand Down Expand Up @@ -309,8 +267,6 @@ function showUserList(users) {
window.location.href = `/users/details/index.html?username=${userData.username}`;
};
ulElement.appendChild(listElement);
paginationElement.classList.add('remove-element');
paginationElement.classList.remove('pagination');
});

userListElement.innerHTML = '';
Expand All @@ -328,13 +284,13 @@ function displayLoader() {
function clearFilters() {
availabilityFilter.value = 'none';
displayLoader();
showUserDataList(page, userListElement, paginationElement, loaderElement);
showUserDataList(page, userListElement, loaderElement);
}

const showUserDataList = async (
page,
userListElement,
paginationElement,

loaderElement,
) => {
try {
Expand All @@ -359,7 +315,7 @@ const showUserDataList = async (
usersDataList,
false,
userListElement,
paginationElement,

loaderElement,
);
}
Expand All @@ -368,7 +324,7 @@ const showUserDataList = async (
showErrorMessage(
err.message,
userListElement,
paginationElement,

loaderElement,
);
} finally {
Expand Down Expand Up @@ -449,23 +405,13 @@ async function generateSkills() {

window.onload = function () {
init(
prevBtn,
nextBtn,
tileViewBtn,
tableViewBtn,
userSearchElement,
userListElement,
paginationElement,
loaderElement,
);
showUserDataList(
page,
userListElement,
paginationElement,
loaderElement,
prevBtn,
nextBtn,
);
showUserDataList(page, userListElement, loaderElement);

populateFilters();
if (window.location.search) {
Expand Down Expand Up @@ -622,7 +568,7 @@ applyFilterButton.addEventListener('click', async () => {
users,
true,
userListElement,
paginationElement,

loaderElement,
prevBtn,
);
Expand All @@ -631,7 +577,7 @@ applyFilterButton.addEventListener('click', async () => {
showErrorMessage(
`User list request failed with error: ${err}`,
userListElement,
paginationElement,

loaderElement,
);
}
Expand Down Expand Up @@ -669,14 +615,7 @@ clearButton.addEventListener('click', function () {
filterModal.classList.toggle('hidden');
displayLoader();
page = 0;
showUserDataList(
page,
userListElement,
paginationElement,
loaderElement,
prevBtn,
nextBtn,
);
showUserDataList(page, userListElement, loaderElement);
manipulateQueryParamsToURL();
});

Expand Down
Loading