pagination for documents seo head meta refactor
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
import jsonpath from "jsonpath";
|
||||
import data from "../../data/collections.json";
|
||||
import {
|
||||
getBasicSearchDetails,
|
||||
getBasicSearchDetailsPaged,
|
||||
} from "../../actions";
|
||||
|
||||
/*
|
||||
* Get the lookup collection by the appeal type entity
|
||||
* @param String formtype - string from appeal entity name
|
||||
*/
|
||||
export const getFormCollection = (formtype) => {
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')]"
|
||||
);
|
||||
return collectionName[0];
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the details of a case from the appeal type
|
||||
* @param String token
|
||||
* @param object searchResultsObj
|
||||
*/
|
||||
export const getSearchDetails = (token, searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
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(
|
||||
getBasicSearchDetails(
|
||||
token,
|
||||
formMeta.LogicalCollectionName,
|
||||
searchDetail.title,
|
||||
formMeta.PrimaryIdAttribute,
|
||||
searchDetail.incidentid
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
//console.log(detailsArr);
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the details of a case from the appeal type
|
||||
* @param object searchResultsObj
|
||||
*/
|
||||
export const getSearchDetailsPaged = (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);
|
||||
};
|
||||
Reference in New Issue
Block a user