PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
betterdocs / react-src / admin / faq-builder / utils / reOrder.js

reOrder.js in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.5, at react-src/admin/faq-builder/utils/reOrder.js

28 lines 935 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 export const categoryOrdering = (result, sortableCategories, currentPage, perPage) => {
2 const cats = sortableCategories.map((cat) => ({
3 id: cat?.id,
4 current_position: cat?.meta?.order[0],
5 }));
6 let reOrderedCats = [];
7 let startIndex = currentPage != 1 ? ((( perPage * currentPage ) + 1) - 10) : currentPage;
8 cats?.splice(result?.destination?.index, 0, ...cats?.splice(result?.source?.index, 1));
9 for( let i = 0; i < cats?.length; i++ ) {
10 reOrderedCats.push({
11 ...cats[i],
12 updated_position: (startIndex).toString(),
13 });
14 startIndex++;
15 }
16 return reOrderedCats;
17 }
18
19 export const faqOrdering = (result, sortedFaqList) => {
20 const startIndex = result.source.index;
21 const endIndex = result.destination.index;
22
23 let data = [...sortedFaqList];
24 let [removed] = data.splice(startIndex, 1);
25 data.splice(endIndex, 0, removed);
26 return data;
27 };
28