pagination for documents seo head meta refactor
This commit is contained in:
@@ -218,19 +218,6 @@ let AdvancedSearch = (props) => {
|
||||
|
||||
const required = (value) => (value ? undefined : "Required");
|
||||
|
||||
const getFormCollection = (formtype) => {
|
||||
formtype =
|
||||
"pinswg_" +
|
||||
(formtype.length > 39 ? formtype.slice(0, 39) : formtype);
|
||||
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')].UrlName"
|
||||
);
|
||||
//console.log(collectionName[0]);
|
||||
return collectionName[0];
|
||||
};
|
||||
|
||||
const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||
|
||||
let spinnerState = () => {
|
||||
@@ -243,15 +230,6 @@ let AdvancedSearch = (props) => {
|
||||
event.preventDefault();
|
||||
spinnerState();
|
||||
|
||||
//console.log(values);
|
||||
// var appTypeCollection = values.appealTypes.split(",")[1];
|
||||
|
||||
// appTypeCollection = getFormCollection(
|
||||
// appTypeCollection.length > 39
|
||||
// ? appTypeCollection.slice(0, 39)
|
||||
// : appTypeCollection
|
||||
// );
|
||||
|
||||
var searchString = "";
|
||||
|
||||
searchString += values.caseRef != null ? "?q=" + values.caseRef : "";
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
} from "../../store/searchOutput/action";
|
||||
import { getSearchDetailsPaged } from "../utils";
|
||||
|
||||
const DNSSearchResults = (props) => {
|
||||
const {
|
||||
@@ -250,66 +251,23 @@ const DNSSearchResults = (props) => {
|
||||
: pagesCount;
|
||||
|
||||
const getSearchPageResults = (pageNumber) => {
|
||||
console.log(advancedSearch, searchString, pageNumber);
|
||||
//console.log(advancedSearch, searchString, pageNumber);
|
||||
|
||||
getBasicDNSSearchPaged(pageNumber)
|
||||
.then((data) => {
|
||||
console.log(data);
|
||||
//console.log(data);
|
||||
setSearchResults(data);
|
||||
return data;
|
||||
})
|
||||
.then((data) => {
|
||||
console.log("getting details", data);
|
||||
return getSearchDetails(data).then((data) => {
|
||||
//console.log("getting details", data);
|
||||
return getSearchDetailsPaged(data).then((data) => {
|
||||
setSearchDetails(data);
|
||||
setShowSpinnerState(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getSearchDetails = (searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
//console.log("search results", searchResultsObj);
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
//console.log(searchDetail);
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(searchDetail.title);
|
||||
} else {
|
||||
let formMeta = getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
);
|
||||
|
||||
detailsArr.push(
|
||||
getBasicSearchDetailsPaged(
|
||||
formMeta.LogicalCollectionName,
|
||||
searchDetail.title,
|
||||
formMeta.PrimaryIdAttribute,
|
||||
searchDetail.incidentid
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
// console.log(detailsArr);
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const getFormCollection = (formtype) => {
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')]"
|
||||
);
|
||||
//console.log(collectionName[0]);
|
||||
return collectionName[0];
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-grid-row">
|
||||
|
||||
@@ -15,17 +15,17 @@ const PaginationControl = (props) => {
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 10);
|
||||
const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 5);
|
||||
|
||||
const getRange = (start, end) => {
|
||||
console.log(start, end);
|
||||
//console.log(start, end);
|
||||
return Array(end - start + 1)
|
||||
.fill()
|
||||
.map((v, i) => i + start);
|
||||
};
|
||||
|
||||
const paginationNumbers = (currentPage, pageCount) => {
|
||||
console.log(currentPage);
|
||||
//console.log(currentPage);
|
||||
let delta;
|
||||
if (pageCount <= 10) {
|
||||
// delta === 7: [1 2 3 4 5 6 7]
|
||||
@@ -65,7 +65,7 @@ const PaginationControl = (props) => {
|
||||
pages = pages.concat(withDots(pageCount, ["...", pageCount]));
|
||||
}
|
||||
|
||||
console.log(pages);
|
||||
//console.log(pages);
|
||||
return pages;
|
||||
};
|
||||
|
||||
@@ -82,8 +82,7 @@ const PaginationControl = (props) => {
|
||||
className="govuk-body govuk-link govuk-!-font-weight-bold govuk-link--no-underline activePaginationItem leftTextButton"
|
||||
onClick={() => {
|
||||
spinnerState(),
|
||||
getSearchPageResults(currentPage - 1),
|
||||
console.log(currentPage - 1);
|
||||
getSearchPageResults(currentPage - 1);
|
||||
}}
|
||||
>
|
||||
{t("common:previous-link-button")}
|
||||
@@ -131,8 +130,7 @@ const PaginationControl = (props) => {
|
||||
className="govuk-body govuk-link govuk-!-font-weight-bold govuk-link--no-underline activePaginationItem rightTextButton"
|
||||
onClick={() => {
|
||||
spinnerState(),
|
||||
getSearchPageResults(currentPage + 1),
|
||||
console.log(currentPage + 1);
|
||||
getSearchPageResults(currentPage + 1);
|
||||
}}
|
||||
>
|
||||
{t("common:next-link-button")}
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import { useEffect } from "react";
|
||||
|
||||
import PaginationControl from "./pagination";
|
||||
import { getSearchDetailsPaged } from "../utils";
|
||||
|
||||
const SearchResults = (props) => {
|
||||
const {
|
||||
@@ -296,7 +297,7 @@ const SearchResults = (props) => {
|
||||
: pagesCount;
|
||||
|
||||
const getSearchPageResults = (pageNumber) => {
|
||||
console.log(advancedSearch, searchString, pageNumber);
|
||||
//console.log(advancedSearch, searchString, pageNumber);
|
||||
|
||||
if (advancedSearch) {
|
||||
var searchoObj = Object.assign(
|
||||
@@ -311,7 +312,7 @@ const SearchResults = (props) => {
|
||||
})
|
||||
.then((data) => {
|
||||
//console.log("getting details", data);
|
||||
return getSearchDetails(data).then((data) => {
|
||||
return getSearchDetailsPaged(data).then((data) => {
|
||||
setSearchDetails(data);
|
||||
setShowSpinnerState(false);
|
||||
});
|
||||
@@ -325,7 +326,7 @@ const SearchResults = (props) => {
|
||||
})
|
||||
.then((data) => {
|
||||
//console.log("getting details", data);
|
||||
return getSearchDetails(data).then((data) => {
|
||||
return getSearchDetailsPaged(data).then((data) => {
|
||||
setSearchDetails(data);
|
||||
setShowSpinnerState(false);
|
||||
});
|
||||
@@ -333,50 +334,6 @@ const SearchResults = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getSearchDetails = (searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
//console.log("search results", searchResultsObj);
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
//console.log(searchDetail);
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(searchDetail.title);
|
||||
} else {
|
||||
let formMeta = getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
);
|
||||
|
||||
detailsArr.push(
|
||||
getBasicSearchDetailsPaged(
|
||||
formMeta.LogicalCollectionName,
|
||||
searchDetail.title,
|
||||
formMeta.PrimaryIdAttribute,
|
||||
searchDetail.incidentid
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
// console.log(detailsArr);
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const getFormCollection = (formtype) => {
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')]"
|
||||
);
|
||||
//console.log(collectionName[0]);
|
||||
return collectionName[0];
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="govuk-grid-row">
|
||||
|
||||
Reference in New Issue
Block a user