Skip to content

Commit 9ee2061

Browse files
authored
Merge pull request #653 from Real-Dev-Squad/develop
Dev to Main Sync
2 parents c7c0ae5 + dbc9604 commit 9ee2061

File tree

4 files changed

+21
-216
lines changed

4 files changed

+21
-216
lines changed

__tests__/user-details/task-duedate-hover.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ describe('Tasks On User Management Page', () => {
180180
await page.waitForTimeout(500); //waiting for a moment to check changes(very helpful when you turn headless into false)
181181
});
182182

183-
it('Scroll of task should work in dev mode', async () => {
183+
it('Scroll of task should work', async () => {
184184
await page.goto(
185-
'http://localhost:8000/users/details/index.html?username=ajeyakrishna&dev=true',
185+
'http://localhost:8000/users/details/index.html?username=ajeyakrishna',
186186
);
187187
await page.waitForNetworkIdle();
188188
const taskDiv = await page.$$('.accordion-tasks');
@@ -218,7 +218,7 @@ describe('Tasks On User Management Page', () => {
218218

219219
it('New task card should have all the detail fields', async () => {
220220
await page.goto(
221-
'http://localhost:8000/users/details/index.html?username=ajeyakrishna&dev=true',
221+
'http://localhost:8000/users/details/index.html?username=ajeyakrishna',
222222
);
223223
await page.waitForNetworkIdle();
224224
const taskDiv = await page.$$('.accordion-tasks');

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@
132132
</a>
133133
<a
134134
id="extension-requests-link"
135-
class="element-display-remove"
135+
class="action-button element-display-remove"
136136
href="extension-requests"
137137
>
138138
Extension Requests
139139
</a>
140140
<a
141141
id="task-requests-link"
142-
class="element-display-remove"
142+
class="action-button element-display-remove"
143143
href="taskRequests"
144144
>
145145
Task Requests

style.css

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -167,79 +167,6 @@ button {
167167
background-color: var(--blue-color);
168168
border-color: transparent;
169169
}
170-
#user-management-link {
171-
color: var(--black-color);
172-
font-weight: 500;
173-
font-size: larger;
174-
background-color: var(--white-color);
175-
border: 2px solid var(--black-color);
176-
border-radius: 5px;
177-
padding: 10px 3.12rem;
178-
cursor: pointer;
179-
transition: all 0.5s ease;
180-
width: 17rem;
181-
text-decoration: none;
182-
}
183-
#user-management-link:hover {
184-
color: var(--white-color);
185-
background-color: var(--blue-color);
186-
border-color: transparent;
187-
}
188-
189-
/* Extension Requests */
190-
#extension-requests-link {
191-
color: var(--black-color);
192-
font-weight: 500;
193-
font-size: larger;
194-
background-color: var(--white-color);
195-
border: 2px solid var(--black-color);
196-
border-radius: 5px;
197-
padding: 10px 3.12rem;
198-
cursor: pointer;
199-
transition: all 0.5s ease;
200-
width: max-content;
201-
text-decoration: none;
202-
}
203-
#extension-requests-link:hover {
204-
color: var(--white-color);
205-
background-color: var(--blue-color);
206-
border-color: transparent;
207-
}
208-
/* Task Requests */
209-
#task-requests-link {
210-
color: var(--black-color);
211-
font-weight: 500;
212-
font-size: larger;
213-
background-color: var(--white-color);
214-
border: 2px solid var(--black-color);
215-
border-radius: 5px;
216-
padding: 10px 3.12rem;
217-
cursor: pointer;
218-
transition: all 0.5s ease;
219-
width: max-content;
220-
text-decoration: none;
221-
}
222-
#task-requests-link:hover {
223-
color: var(--white-color);
224-
background-color: var(--blue-color);
225-
border-color: transparent;
226-
}
227-
/* Online-members */
228-
.online-members-link {
229-
color: var(--black-color);
230-
font-weight: 500;
231-
font-size: larger;
232-
border: 2px solid var(--black-color);
233-
border-radius: 5px;
234-
padding: 10px 3.12rem;
235-
transition: all 0.5s ease;
236-
}
237-
238-
.online-members-link:hover {
239-
color: var(--white-color);
240-
background-color: var(--blue-color);
241-
border-color: transparent;
242-
}
243170

244171
/* Online-members */
245172
.info-repo {
@@ -264,13 +191,13 @@ footer {
264191
transition: all 0.5s ease;
265192
outline: none;
266193
text-decoration: none;
267-
color: var(--black-color);
268194
}
269195

270-
.action-button:hover {
196+
.action-button:hover,
197+
.action-button:focus {
271198
color: var(--white-color);
272199
background-color: var(--blue-color);
273-
border: none;
200+
border-color: var(--blue-color);
274201
}
275202

276203
#sync-buttons.element-display-remove {

users/details/script.js

Lines changed: 13 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ let isTaskAccordionOpen = false;
1515
let totalPrsPages = 0;
1616
let totalPages = Math.ceil(userAllTasks.length / taskPerPage);
1717
const username = new URLSearchParams(window.location.search).get('username');
18-
const isDev = params.get('dev') === 'true';
1918

2019
function createElement({ type, classList = [] }) {
2120
const element = document.createElement(type);
@@ -198,7 +197,7 @@ function toggleAccordionTabsVisibility() {
198197
arrowIcon.classList.toggle('open');
199198
hiddenContent.classList.toggle('hide');
200199
}
201-
if (tab.innerText === 'Tasks' && isDev) {
200+
if (tab.innerText === 'Tasks') {
202201
isTaskAccordionOpen = !isTaskAccordionOpen && hiddenContent;
203202
if (isTaskAccordionOpen) {
204203
tab.classList.add('sticky-header');
@@ -251,59 +250,30 @@ function generateTasksTabDetails() {
251250

252251
const tasks = createElement({
253252
type: 'div',
254-
classList: isDev ? ['user-tasks', 'user-tasks-dev'] : ['user-tasks'],
253+
classList: ['user-tasks', 'user-tasks-dev'],
255254
});
256255
div.append(tasks);
257-
if (!isDev) {
258-
const pagination = createElement({
259-
type: 'div',
260-
classList: ['pagination'],
261-
});
262-
const prevBtn = createElement({
263-
type: 'button',
264-
classList: ['pagination-prev-page'],
265-
});
266-
prevBtn.appendChild(createTextNode('Prev'));
267-
prevBtn.addEventListener('click', fetchPrevTasks);
268-
const nextBtn = createElement({
269-
type: 'button',
270-
classList: ['pagination-next-page'],
271-
});
272-
nextBtn.appendChild(createTextNode('Next'));
273-
nextBtn.addEventListener('click', fetchNextTasks);
274-
275-
pagination.append(prevBtn, nextBtn);
276-
div.append(tasks, pagination);
277-
}
278-
279256
document.querySelector('.accordion-tasks').appendChild(div);
280257
}
281258

282259
async function getUserTasks() {
283260
try {
284-
taskSearchQuery = isDev
285-
? taskSearchQuery || `/tasks/?size=3&dev=true&assignee=${username}`
286-
: `/tasks/${username}`;
261+
taskSearchQuery =
262+
taskSearchQuery || `/tasks/?size=3&dev=true&assignee=${username}`;
287263

288264
//Flag to avoid multiple API calls with same payload
289-
if (!(isDev && isTaskFetching) && !allTasksFetched) {
265+
if (!isTaskFetching && !allTasksFetched) {
290266
isTaskFetching = true;
291267
const res = await makeApiCall(`${API_BASE_URL}${taskSearchQuery}`);
292268
if (res.status === 200) {
293269
const data = await res.json();
294270
generateTasksTabDetails();
295-
if (isDev) {
296-
taskSearchQuery = data.next;
297-
if (data.next === '') {
298-
allTasksFetched = true;
299-
}
300-
generateUserTaskList(data.tasks);
301-
} else {
302-
userAllTasks = data.tasks;
303-
totalPages = Math.ceil(userAllTasks.length / taskPerPage);
304-
const tasks = getTasksToFetch(userAllTasks, currentPageIndex);
305-
generateUserTaskList(tasks);
271+
272+
taskSearchQuery = data.next;
273+
if (data.next === '') {
274+
allTasksFetched = true;
306275
}
276+
generateUserTaskList(data.tasks);
307277
}
308278
isTaskFetching = false;
309279
}
@@ -335,8 +305,6 @@ function onScrollHandler() {
335305
}
336306

337307
function generateUserTaskList(userTasks) {
338-
if (isDev !== true) document.querySelector('.user-tasks').innerHTML = '';
339-
340308
if (!userTasks.length) {
341309
const errorEl = createElement({ type: 'p', classList: ['error'] });
342310
errorEl.appendChild(createTextNode('No Data Found'));
@@ -350,91 +318,13 @@ function generateUserTaskList(userTasks) {
350318
const taskCard = createSingleTaskCard(task);
351319
document.querySelector('.user-tasks').appendChild(taskCard);
352320
});
353-
354-
if (!isDev) {
355-
if (currentPageIndex === 1) {
356-
document.querySelector('.pagination-prev-page').disabled = true;
357-
} else {
358-
document.querySelector('.pagination-prev-page').disabled = false;
359-
}
360-
361-
if (currentPageIndex === totalPages) {
362-
document.querySelector('.pagination-next-page').disabled = true;
363-
} else {
364-
document.querySelector('.pagination-next-page').disabled = false;
365-
}
366-
}
367321
}
368322
}
369323

370324
function createSingleTaskCard(task) {
371325
const container = createElement({ type: 'div', classList: ['user-task'] });
372-
if (isDev === true) {
373-
const innerHTMl = generateCardUIInDev(task);
374-
container.innerHTML = innerHTMl;
375-
return container;
376-
}
377-
const h2 = createElement({ type: 'h2', classList: ['task-title'] });
378-
h2.appendChild(createTextNode(task?.title));
379-
const p = createElement({ type: 'p', classList: ['task-description'] });
380-
381-
if (task?.purpose == undefined) {
382-
p.appendChild(createTextNode('N/A'));
383-
} else {
384-
p.appendChild(createTextNode(task?.purpose));
385-
}
386-
387-
const div = createElement({ type: 'div', classList: ['task-details'] });
388-
389-
const dueDate = createElement({ type: 'div', classList: ['hidden-details'] });
390-
const dueDateTitle = createElement({ type: 'h3' });
391-
dueDateTitle.appendChild(createTextNode('Due Date'));
392-
const dueDateValue = createElement({
393-
type: 'p',
394-
classList: ['due-date-value'],
395-
}); // added class for testing purpose
396-
397-
const daysToGo = generateDaysToGo(
398-
generateReadableDateFromSecondsTimeStamp(task.endsOn),
399-
task.status,
400-
);
401-
if (daysToGo.includes('Less Than a Day Remaining')) {
402-
// Wrap the text in a <span> with a yellow color style
403-
dueDateValue.innerHTML = `<span style="color: yellow;">${daysToGo}</span>`;
404-
} else {
405-
dueDateValue.appendChild(createTextNode(daysToGo));
406-
}
407-
408-
dueDate.append(dueDateTitle, dueDateValue);
409-
410-
//creating tooltip, gets displayed when we hover the element
411-
const toolTip = createElement({
412-
type: 'span',
413-
classList: ['task-due-date'],
414-
}); //creating a span for tooltip
415-
toolTip.appendChild(
416-
createTextNode(
417-
`Due Date: ${generateReadableDateFromSecondsTimeStamp(task.endsOn)}`,
418-
),
419-
);
420-
421-
dueDateValue.appendChild(toolTip); //appending it to the dueDateValue that we have create above
422-
dueDateValue.addEventListener('mouseover', (event) => {
423-
toolTip.style.visibility = 'visible';
424-
});
425-
dueDateValue.addEventListener('mouseout', (event) => {
426-
toolTip.style.visibility = 'hidden';
427-
});
428-
429-
const status = createElement({ type: 'div', classList: ['hidden-details'] });
430-
const statusTitle = createElement({ type: 'h3' });
431-
statusTitle.appendChild(createTextNode('Status'));
432-
const statusValue = createElement({ type: 'p' });
433-
statusValue.appendChild(createTextNode(task.status));
434-
status.append(statusTitle, statusValue);
435-
436-
div.append(dueDate, status);
437-
container.append(h2, p, div);
326+
const innerHTMl = generateCardUIInDev(task);
327+
container.innerHTML = innerHTMl;
438328
return container;
439329
}
440330

@@ -473,13 +363,7 @@ function fetchPrevTasks() {
473363
}
474364

475365
async function fetchNextTasks() {
476-
if (isDev) {
477-
await getUserTasks();
478-
} else if (currentPageIndex < totalPages) {
479-
currentPageIndex++;
480-
const tasks = getTasksToFetch(userAllTasks, currentPageIndex);
481-
generateUserTaskList(tasks);
482-
}
366+
await getUserTasks();
483367
}
484368

485369
async function getUserSkills() {
@@ -953,12 +837,6 @@ function generateUserPrsList(userPrs) {
953837
const prsCard = createSinglePrCard(pr);
954838
document.querySelector('.user-pr').appendChild(prsCard);
955839
});
956-
if (!isDev) {
957-
document.querySelector('.pagination-next-page').disabled =
958-
currentPageIndex === totalPrsPages;
959-
document.querySelector('.pagination-prev-page').disabled =
960-
currentPageIndex === 1;
961-
}
962840
}
963841
}
964842

0 commit comments

Comments
 (0)