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

TICDI-87 - Standard Licence signing block issue #224

Merged
merged 1 commit into from
Aug 29, 2024
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
8 changes: 8 additions & 0 deletions backend/src/report/report.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ export class ReportService {
});
}

// individual Signing block takes 2 cdogs requests to be fully filled in, so this regex
// makes sure that the db_name_tenant variable is formatted correctly
if (free_text.toLowerCase().includes('db_name_tenant}')) {
free_text = free_text.replace(/db_name_tenant}/gi, 'DB_NAME_TENANT:convCRLF()}');
} else if (free_text.toLowerCase().includes('db_name_tenant:convcrlf()}')) {
free_text = free_text.replace(/db_name_tenant:convcrlf\(\)}/gi, 'DB_NAME_TENANT:convCRLF()}');
}

const key = `SECTION_${provision_group}`;
if (!provisions[key]) {
provisions[key] = [];
Expand Down
41 changes: 32 additions & 9 deletions frontend/src/app/content/pages/ManageProvisionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
removeProvision,
updateProvision,
} from '../../common/manage-provisions';
import SimpleSearch from '../../components/common/SimpleSearch';

interface ManageProvisionsPageProps {}

Expand All @@ -27,6 +26,7 @@ const ManageProvisionsPage: FC<ManageProvisionsPageProps> = () => {
const [showRemoveProvisionModal, setShowRemoveProvisionModal] = useState<boolean>(false);
const [refreshTrigger, setRefreshTrigger] = useState(0);
const [filteredProvisions, setFilteredProvisions] = useState<Provision[]>([]);
const [filterText, setFilterText] = useState('');

useEffect(() => {
const getData = async () => {
Expand All @@ -46,7 +46,11 @@ const ManageProvisionsPage: FC<ManageProvisionsPageProps> = () => {

useEffect(() => {
if (data.allProvisions) {
setFilteredProvisions(data.allProvisions);
if (!filterText || filterText === '') {
setFilteredProvisions(data.allProvisions);
} else {
handleFilterProvisions(filterText);
}
}
}, [data.allProvisions]);

Expand Down Expand Up @@ -76,8 +80,22 @@ const ManageProvisionsPage: FC<ManageProvisionsPageProps> = () => {
refreshTables();
};

const handleSearch = (filteredProvisions: Provision[]) => {
setFilteredProvisions(filteredProvisions);
const handleSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
const text: string = event.target.value;
handleFilterProvisions(text);
};

const handleFilterProvisions = (searchTerm: string) => {
const searchKeys: string[] = ['provision_name', 'category'];
setFilterText(searchTerm);

const fp: Provision[] = data.allProvisions
? data.allProvisions.filter((item) =>
searchKeys.some((key) => (item as any)[key]?.toString().toLowerCase().includes(searchTerm.toLowerCase()))
)
: [];

setFilteredProvisions(fp);
};

const currentVariables = data.allVariables?.filter((v) => v.provision_id === currentProvision?.id) || [];
Expand All @@ -86,11 +104,16 @@ const ManageProvisionsPage: FC<ManageProvisionsPageProps> = () => {
<>
<h1>Manage Provisions</h1>
<hr />
<SimpleSearch
searchKeys={['provision_name', 'category']}
data={data.allProvisions ? data.allProvisions : []}
onSearch={handleSearch}
/>
<div>
<input
type="text"
className="form-control"
style={{ maxWidth: '200px' }}
placeholder="Search..."
value={filterText}
onChange={handleSearch}
/>
</div>
<ManageProvisionsTable
provisions={filteredProvisions}
variables={data.allVariables}
Expand Down
Loading