добавлен комментарий
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
getOwnRequests,
|
||||
getOwnRequestsByStatus,
|
||||
hydratePendingAuthors,
|
||||
hydrateReturnComments,
|
||||
searchOwnRequests,
|
||||
} from './myRequests.service';
|
||||
import { IMyRequest } from './models/IMyRequest';
|
||||
@@ -115,11 +116,27 @@ function statusOptionClassName(status: string): string {
|
||||
// 'own:created' — статус нужен, только пока показаны ВСЕ заявки. Стоит выбрать
|
||||
// его в фильтре, и колонка вырождается в тот же столбец одинаковых плашек,
|
||||
// поэтому она зависит не от одного вида, а ещё и от фильтра.
|
||||
function columnsFor(view: ListView, statusFilter: string): { author: boolean; status: boolean } {
|
||||
if (view === 'approvals' || view === 'execution') return { author: true, status: false };
|
||||
if (view === 'rework') return { author: false, status: false };
|
||||
if (view === 'own:created') return { author: false, status: !statusFilter };
|
||||
return { author: true, status: true };
|
||||
//
|
||||
// «Причина возврата» — там, где показаны ТОЛЬКО возвращённые заявки: для них
|
||||
// это главное, ради чего в список и заходят (что именно просят исправить).
|
||||
interface ITableColumns {
|
||||
author: boolean;
|
||||
status: boolean;
|
||||
returnComment: boolean;
|
||||
}
|
||||
|
||||
function columnsFor(view: ListView, statusFilter: string): ITableColumns {
|
||||
const returnedOnly =
|
||||
view === 'rework' || (view === 'own:created' && statusFilter === REQUEST_STATUS.returned);
|
||||
|
||||
if (view === 'approvals' || view === 'execution') {
|
||||
return { author: true, status: false, returnComment: false };
|
||||
}
|
||||
if (view === 'rework') return { author: false, status: false, returnComment: true };
|
||||
if (view === 'own:created') {
|
||||
return { author: false, status: !statusFilter, returnComment: returnedOnly };
|
||||
}
|
||||
return { author: true, status: true, returnComment: false };
|
||||
}
|
||||
|
||||
export interface IRequestsTableViewProps {
|
||||
@@ -171,6 +188,7 @@ const Table: React.FC<{
|
||||
<th className={styles.colDate}>Дата</th>
|
||||
{columns.author && <th className={styles.colAuthor}>Автор</th>}
|
||||
{columns.status && <th className={styles.colStatus}>Статус</th>}
|
||||
{columns.returnComment && <th className={styles.colComment}>Причина возврата</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -203,6 +221,11 @@ const Table: React.FC<{
|
||||
{r.status ? <StatusBadge status={r.status} size="sm" /> : '—'}
|
||||
</td>
|
||||
)}
|
||||
{columns.returnComment && (
|
||||
<td className={styles.colComment}>
|
||||
{r.returnComment || <span className={styles.commentEmpty}>Без комментария</span>}
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -323,7 +346,13 @@ export const RequestsTableView: React.FC<IRequestsTableViewProps> = ({
|
||||
// зашитым в раздел, а не выбранным в фильтре.
|
||||
if (view === 'rework' || (view === 'own:created' && statusFilter)) {
|
||||
const status = view === 'rework' ? REQUEST_STATUS.returned : statusFilter;
|
||||
return getOwnRequestsByStatus(context, types, status, page, debouncedQuery);
|
||||
const result = await getOwnRequestsByStatus(context, types, status, page, debouncedQuery);
|
||||
// Причина возврата живёт в строке маршрута — дочитываем только для
|
||||
// видимой страницы и только там, где колонка показывается.
|
||||
if (status === REQUEST_STATUS.returned) {
|
||||
await hydrateReturnComments(context, types, result.rows);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (view === 'own:created') {
|
||||
|
||||
Reference in New Issue
Block a user