mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-23 11:16:07 +02:00
Rename and cleanup
This commit is contained in:
parent
342d6f2f0b
commit
cad6238932
4 changed files with 10 additions and 11 deletions
|
@ -382,7 +382,7 @@ export class BaseTable {
|
||||||
* for a member, they will also see the kebab column)
|
* for a member, they will also see the kebab column)
|
||||||
* @param {Object} dataObjects - Data which contains info on domain requests or a user's permission
|
* @param {Object} dataObjects - Data which contains info on domain requests or a user's permission
|
||||||
* Currently returns a dictionary of either:
|
* Currently returns a dictionary of either:
|
||||||
* - "isDeletable": If a new column should be displayed
|
* - "hasAdditionalActions": If additional elements need to be added to the Action column
|
||||||
* - "UserPortfolioPermissionChoices": A user's portfolio permission choices
|
* - "UserPortfolioPermissionChoices": A user's portfolio permission choices
|
||||||
*/
|
*/
|
||||||
customizeTable(dataObjects){ return {}; }
|
customizeTable(dataObjects){ return {}; }
|
||||||
|
@ -406,7 +406,7 @@ export class BaseTable {
|
||||||
* Returns either: data.members, data.domains or data.domain_requests
|
* Returns either: data.members, data.domains or data.domain_requests
|
||||||
* @param {Object} dataObject - The data used to populate the row content
|
* @param {Object} dataObject - The data used to populate the row content
|
||||||
* @param {HTMLElement} tbody - The table body to which the new row is appended to
|
* @param {HTMLElement} tbody - The table body to which the new row is appended to
|
||||||
* @param {Object} customTableOptions - Additional options for customizing row appearance (ie isDeletable)
|
* @param {Object} customTableOptions - Additional options for customizing row appearance (ie hasAdditionalActions)
|
||||||
*/
|
*/
|
||||||
addRow(dataObject, tbody, customTableOptions) {
|
addRow(dataObject, tbody, customTableOptions) {
|
||||||
throw new Error('addRow must be defined');
|
throw new Error('addRow must be defined');
|
||||||
|
|
|
@ -52,8 +52,8 @@ export class DomainRequestsTable extends BaseTable {
|
||||||
// Manage "export as CSV" visibility for domain requests
|
// Manage "export as CSV" visibility for domain requests
|
||||||
this.toggleExportButton(data.domain_requests);
|
this.toggleExportButton(data.domain_requests);
|
||||||
|
|
||||||
let needsDeleteColumn = data.domain_requests.some(request => request.is_deletable);
|
let isDeletable = data.domain_requests.some(request => request.is_deletable);
|
||||||
return { 'isDeletable': needsDeleteColumn };
|
return { 'hasAdditionalActions': isDeletable };
|
||||||
}
|
}
|
||||||
|
|
||||||
addRow(dataObject, tbody, customTableOptions) {
|
addRow(dataObject, tbody, customTableOptions) {
|
||||||
|
@ -118,13 +118,13 @@ export class DomainRequestsTable extends BaseTable {
|
||||||
</td>
|
</td>
|
||||||
<td class="${ this.portfolioValue ? '' : "width-quarter"}">
|
<td class="${ this.portfolioValue ? '' : "width-quarter"}">
|
||||||
<div class="tablet:display-flex tablet:flex-row">
|
<div class="tablet:display-flex tablet:flex-row">
|
||||||
<a href="${actionUrl}" ${customTableOptions.isDeletable ? "class='margin-right-2'" : ''}>
|
<a href="${actionUrl}" ${customTableOptions.hasAdditionalActions ? "class='margin-right-2'" : ''}>
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24">
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24">
|
||||||
<use xlink:href="/public/img/sprite.svg#${request.svg_icon}"></use>
|
<use xlink:href="/public/img/sprite.svg#${request.svg_icon}"></use>
|
||||||
</svg>
|
</svg>
|
||||||
${actionLabel} <span class="usa-sr-only">${request.requested_domain ? request.requested_domain : 'New domain request'}</span>
|
${actionLabel} <span class="usa-sr-only">${request.requested_domain ? request.requested_domain : 'New domain request'}</span>
|
||||||
</a>
|
</a>
|
||||||
${customTableOptions.isDeletable ? modalTrigger : ''}
|
${customTableOptions.hasAdditionalActions ? modalTrigger : ''}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -61,7 +61,7 @@ export class MembersTable extends BaseTable {
|
||||||
tableHeaderRow.appendChild(extraActionsHeader);
|
tableHeaderRow.appendChild(extraActionsHeader);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
'isDeletable': hasEditPermission,
|
'hasAdditionalActions': hasEditPermission,
|
||||||
'UserPortfolioPermissionChoices' : data.UserPortfolioPermissionChoices
|
'UserPortfolioPermissionChoices' : data.UserPortfolioPermissionChoices
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ export class MembersTable extends BaseTable {
|
||||||
const num_domains = member.domain_urls.length;
|
const num_domains = member.domain_urls.length;
|
||||||
const last_active = this.handleLastActive(member.last_active);
|
const last_active = this.handleLastActive(member.last_active);
|
||||||
let cancelInvitationButton = member.type === "invitedmember" ? "Cancel invitation" : "Remove member";
|
let cancelInvitationButton = member.type === "invitedmember" ? "Cancel invitation" : "Remove member";
|
||||||
const kebabHTML = customTableOptions.isDeletable ? generateKebabHTML('remove-member', unique_id, cancelInvitationButton, `for ${member.name}`): '';
|
const kebabHTML = customTableOptions.hasAdditionalActions ? generateKebabHTML('remove-member', unique_id, cancelInvitationButton, `for ${member.name}`): '';
|
||||||
|
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ export class MembersTable extends BaseTable {
|
||||||
${member.action_label} <span class="usa-sr-only">${member.name}</span>
|
${member.action_label} <span class="usa-sr-only">${member.name}</span>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
${customTableOptions.isDeletable ? '<td>'+kebabHTML+'</td>' : ''}
|
${customTableOptions.hasAdditionalActions ? '<td>'+kebabHTML+'</td>' : ''}
|
||||||
`;
|
`;
|
||||||
tbody.appendChild(row);
|
tbody.appendChild(row);
|
||||||
if (domainsHTML || permissionsHTML) {
|
if (domainsHTML || permissionsHTML) {
|
||||||
|
@ -137,7 +137,7 @@ export class MembersTable extends BaseTable {
|
||||||
}
|
}
|
||||||
// This easter egg is only for fixtures that dont have names as we are displaying their emails
|
// This easter egg is only for fixtures that dont have names as we are displaying their emails
|
||||||
// All prod users will have emails linked to their account
|
// All prod users will have emails linked to their account
|
||||||
if (customTableOptions.isDeletable) MembersTable.addMemberDeleteModal(num_domains, member.email || "Samwise Gamgee", member_delete_url, unique_id, row);
|
if (customTableOptions.hasAdditionalActions) MembersTable.addMemberDeleteModal(num_domains, member.email || "Samwise Gamgee", member_delete_url, unique_id, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -187,7 +187,6 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<th data-sortable="status" scope="col" role="columnheader">Status</th>
|
<th data-sortable="status" scope="col" role="columnheader">Status</th>
|
||||||
<th scope="col" role="columnheader">Action</th>
|
<th scope="col" role="columnheader">Action</th>
|
||||||
<!-- AJAX will conditionally add a th for delete actions -->
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="domain-requests-tbody">
|
<tbody id="domain-requests-tbody">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue