@@ -36,6 +36,7 @@ import { EIssueLayoutTypes, ISSUE_PRIORITIES } from "@/constants/issue";
3636// helpers
3737import { convertToISODateString } from "@/helpers/date-time.helper" ;
3838// local-db
39+ import { SPECIAL_ORDER_BY } from "@/local-db/utils/query-constructor" ;
3940import { updatePersistentLayer } from "@/local-db/utils/utils" ;
4041// services
4142import { CycleService } from "@/services/cycle.service" ;
@@ -164,8 +165,8 @@ const ISSUE_ORDERBY_KEY: Record<TIssueOrderByOptions, keyof TIssue> = {
164165 "-issue_cycle__cycle__name" : "cycle_id" ,
165166 target_date : "target_date" ,
166167 "-target_date" : "target_date" ,
167- estimate_point : "estimate_point" ,
168- "-estimate_point " : "estimate_point" ,
168+ estimate_point__key : "estimate_point" ,
169+ "-estimate_point__key " : "estimate_point" ,
169170 start_date : "start_date" ,
170171 "-start_date" : "start_date" ,
171172 link_count : "link_count" ,
@@ -282,6 +283,19 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
282283 const displayFilters = this . issueFilterStore ?. issueFilters ?. displayFilters ;
283284 if ( ! displayFilters ) return ;
284285
286+ const layout = displayFilters . layout ;
287+ const orderBy = displayFilters . order_by ;
288+
289+ // Temporary code to fix no load order by
290+ if (
291+ this . rootIssueStore . rootStore . user . localDBEnabled &&
292+ layout !== EIssueLayoutTypes . SPREADSHEET &&
293+ orderBy &&
294+ Object . keys ( SPECIAL_ORDER_BY ) . includes ( orderBy )
295+ ) {
296+ return "sort_order" ;
297+ }
298+
285299 return displayFilters ?. order_by ;
286300 }
287301
@@ -1701,13 +1715,14 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
17011715 * @returns string | string[] of sortable fields to be used for sorting
17021716 */
17031717 populateIssueDataForSorting (
1704- dataType : "state_id" | "label_ids" | "assignee_ids" | "module_ids" | "cycle_id" ,
1718+ dataType : "state_id" | "label_ids" | "assignee_ids" | "module_ids" | "cycle_id" | "estimate_point" ,
17051719 dataIds : string | string [ ] | null | undefined ,
1720+ projectId : string | undefined | null ,
17061721 order ?: "asc" | "desc"
17071722 ) {
17081723 if ( ! dataIds ) return ;
17091724
1710- const dataValues : string [ ] = [ ] ;
1725+ const dataValues : ( string | number ) [ ] = [ ] ;
17111726 const isDataIdsArray = Array . isArray ( dataIds ) ;
17121727 const dataIdsArray = isDataIdsArray ? dataIds : [ dataIds ] ;
17131728
@@ -1757,6 +1772,26 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
17571772 }
17581773 break ;
17591774 }
1775+ case "estimate_point" : {
1776+ // return if project Id does not exist
1777+ if ( ! projectId ) break ;
1778+ // get the estimate ID for the current Project
1779+ const currentProjectEstimateId =
1780+ this . rootIssueStore . rootStore . projectEstimate . currentActiveEstimateIdByProjectId ( projectId ) ;
1781+ // return if current Estimate Id for the project is not available
1782+ if ( ! currentProjectEstimateId ) break ;
1783+ // get Estimate based on Id
1784+ const estimate = this . rootIssueStore . rootStore . projectEstimate . estimateById ( currentProjectEstimateId ) ;
1785+ // If Estimate is not available, then return
1786+ if ( ! estimate ) break ;
1787+ // Get Estimate Value
1788+ const estimateKey = estimate ?. estimatePointById ( dataIds as string ) ?. key ;
1789+
1790+ // If Value string i not available or empty then return
1791+ if ( estimateKey === undefined ) break ;
1792+
1793+ dataValues . push ( estimateKey ) ;
1794+ }
17601795 }
17611796
17621797 return isDataIdsArray ? ( order ? orderBy ( dataValues , undefined , [ order ] ) : dataValues ) : dataValues ;
@@ -1771,11 +1806,17 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
17711806 return getIssueIds ( orderBy ( array , "sort_order" ) ) ;
17721807 case "state__name" :
17731808 return getIssueIds (
1774- orderBy ( array , ( issue ) => this . populateIssueDataForSorting ( "state_id" , issue ?. [ "state_id" ] ) )
1809+ orderBy ( array , ( issue ) =>
1810+ this . populateIssueDataForSorting ( "state_id" , issue ?. [ "state_id" ] , issue ?. [ "project_id" ] )
1811+ )
17751812 ) ;
17761813 case "-state__name" :
17771814 return getIssueIds (
1778- orderBy ( array , ( issue ) => this . populateIssueDataForSorting ( "state_id" , issue ?. [ "state_id" ] ) , [ "desc" ] )
1815+ orderBy (
1816+ array ,
1817+ ( issue ) => this . populateIssueDataForSorting ( "state_id" , issue ?. [ "state_id" ] , issue ?. [ "project_id" ] ) ,
1818+ [ "desc" ]
1819+ )
17791820 ) ;
17801821 // dates
17811822 case "created_at" :
@@ -1826,15 +1867,23 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
18261867 case "-attachment_count" :
18271868 return getIssueIds ( orderBy ( array , "attachment_count" , [ "desc" ] ) ) ;
18281869
1829- case "estimate_point " :
1870+ case "estimate_point__key " :
18301871 return getIssueIds (
1831- orderBy ( array , [ getSortOrderToFilterEmptyValues . bind ( null , "estimate_point" ) , "estimate_point" ] )
1872+ orderBy ( array , [
1873+ getSortOrderToFilterEmptyValues . bind ( null , "estimate_point" ) ,
1874+ ( issue ) =>
1875+ this . populateIssueDataForSorting ( "estimate_point" , issue ?. [ "estimate_point" ] , issue ?. [ "project_id" ] ) ,
1876+ ] )
18321877 ) ; //preferring sorting based on empty values to always keep the empty values below
1833- case "-estimate_point " :
1878+ case "-estimate_point__key " :
18341879 return getIssueIds (
18351880 orderBy (
18361881 array ,
1837- [ getSortOrderToFilterEmptyValues . bind ( null , "estimate_point" ) , "estimate_point" ] , //preferring sorting based on empty values to always keep the empty values below
1882+ [
1883+ getSortOrderToFilterEmptyValues . bind ( null , "estimate_point" ) ,
1884+ ( issue ) =>
1885+ this . populateIssueDataForSorting ( "estimate_point" , issue ?. [ "estimate_point" ] , issue ?. [ "project_id" ] ) ,
1886+ ] , //preferring sorting based on empty values to always keep the empty values below
18381887 [ "asc" , "desc" ]
18391888 )
18401889 ) ;
@@ -1854,7 +1903,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
18541903 return getIssueIds (
18551904 orderBy ( array , [
18561905 getSortOrderToFilterEmptyValues . bind ( null , "label_ids" ) , //preferring sorting based on empty values to always keep the empty values below
1857- ( issue ) => this . populateIssueDataForSorting ( "label_ids" , issue ?. [ "label_ids" ] , "asc" ) ,
1906+ ( issue ) =>
1907+ this . populateIssueDataForSorting ( "label_ids" , issue ?. [ "label_ids" ] , issue ?. [ "project_id" ] , "asc" ) ,
18581908 ] )
18591909 ) ;
18601910 case "-labels__name" :
@@ -1863,7 +1913,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
18631913 array ,
18641914 [
18651915 getSortOrderToFilterEmptyValues . bind ( null , "label_ids" ) , //preferring sorting based on empty values to always keep the empty values below
1866- ( issue ) => this . populateIssueDataForSorting ( "label_ids" , issue ?. [ "label_ids" ] , "asc" ) ,
1916+ ( issue ) =>
1917+ this . populateIssueDataForSorting ( "label_ids" , issue ?. [ "label_ids" ] , issue ?. [ "project_id" ] , "asc" ) ,
18671918 ] ,
18681919 [ "asc" , "desc" ]
18691920 )
@@ -1873,7 +1924,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
18731924 return getIssueIds (
18741925 orderBy ( array , [
18751926 getSortOrderToFilterEmptyValues . bind ( null , "module_ids" ) , //preferring sorting based on empty values to always keep the empty values below
1876- ( issue ) => this . populateIssueDataForSorting ( "module_ids" , issue ?. [ "module_ids" ] , "asc" ) ,
1927+ ( issue ) =>
1928+ this . populateIssueDataForSorting ( "module_ids" , issue ?. [ "module_ids" ] , issue ?. [ "project_id" ] , "asc" ) ,
18771929 ] )
18781930 ) ;
18791931 case "-issue_module__module__name" :
@@ -1882,7 +1934,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
18821934 array ,
18831935 [
18841936 getSortOrderToFilterEmptyValues . bind ( null , "module_ids" ) , //preferring sorting based on empty values to always keep the empty values below
1885- ( issue ) => this . populateIssueDataForSorting ( "module_ids" , issue ?. [ "module_ids" ] , "asc" ) ,
1937+ ( issue ) =>
1938+ this . populateIssueDataForSorting ( "module_ids" , issue ?. [ "module_ids" ] , issue ?. [ "project_id" ] , "asc" ) ,
18861939 ] ,
18871940 [ "asc" , "desc" ]
18881941 )
@@ -1892,7 +1945,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
18921945 return getIssueIds (
18931946 orderBy ( array , [
18941947 getSortOrderToFilterEmptyValues . bind ( null , "cycle_id" ) , //preferring sorting based on empty values to always keep the empty values below
1895- ( issue ) => this . populateIssueDataForSorting ( "cycle_id" , issue ?. [ "cycle_id" ] , "asc" ) ,
1948+ ( issue ) => this . populateIssueDataForSorting ( "cycle_id" , issue ?. [ "cycle_id" ] , issue ?. [ "project_id" ] , "asc" ) ,
18961949 ] )
18971950 ) ;
18981951 case "-issue_cycle__cycle__name" :
@@ -1901,7 +1954,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
19011954 array ,
19021955 [
19031956 getSortOrderToFilterEmptyValues . bind ( null , "cycle_id" ) , //preferring sorting based on empty values to always keep the empty values below
1904- ( issue ) => this . populateIssueDataForSorting ( "cycle_id" , issue ?. [ "cycle_id" ] , "asc" ) ,
1957+ ( issue ) =>
1958+ this . populateIssueDataForSorting ( "cycle_id" , issue ?. [ "cycle_id" ] , issue ?. [ "project_id" ] , "asc" ) ,
19051959 ] ,
19061960 [ "asc" , "desc" ]
19071961 )
@@ -1911,7 +1965,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
19111965 return getIssueIds (
19121966 orderBy ( array , [
19131967 getSortOrderToFilterEmptyValues . bind ( null , "assignee_ids" ) , //preferring sorting based on empty values to always keep the empty values below
1914- ( issue ) => this . populateIssueDataForSorting ( "assignee_ids" , issue ?. [ "assignee_ids" ] , "asc" ) ,
1968+ ( issue ) =>
1969+ this . populateIssueDataForSorting ( "assignee_ids" , issue ?. [ "assignee_ids" ] , issue ?. [ "project_id" ] , "asc" ) ,
19151970 ] )
19161971 ) ;
19171972 case "-assignees__first_name" :
@@ -1920,7 +1975,8 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
19201975 array ,
19211976 [
19221977 getSortOrderToFilterEmptyValues . bind ( null , "assignee_ids" ) , //preferring sorting based on empty values to always keep the empty values below
1923- ( issue ) => this . populateIssueDataForSorting ( "assignee_ids" , issue ?. [ "assignee_ids" ] , "asc" ) ,
1978+ ( issue ) =>
1979+ this . populateIssueDataForSorting ( "assignee_ids" , issue ?. [ "assignee_ids" ] , issue ?. [ "project_id" ] , "asc" ) ,
19241980 ] ,
19251981 [ "asc" , "desc" ]
19261982 )
0 commit comments