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

[Bug]: sort doesn't apply in date column #371

Closed
DannyHatcher-Git opened this issue Sep 12, 2022 · 7 comments
Closed

[Bug]: sort doesn't apply in date column #371

DannyHatcher-Git opened this issue Sep 12, 2022 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@DannyHatcher-Git
Copy link
Collaborator

Contact Details

danny@dannyhatcher.com

What happened?

When sorting by a date property (deadline) there was no change in the display order.
image

What platform were you using?

Desktop

Version of the plugin

2.5.1

Relevant log output

No idea what I am copy and pasting.
This is what I see

Uncaught (in promise) Failed to index file: Notes/database.md: Error: Cannot index file, since it has no Obsidian file metadata.
2plugin:dbfolder:10 Uncaught Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.Qr.Gr.createPortal (plugin:dbfolder:10:125962)
    at zU (plugin:dbfolder:238:357774)
    at Ei (plugin:dbfolder:10:62177)
    at Os (plugin:dbfolder:10:73445)
    at Cl (plugin:dbfolder:10:119595)
    at yc (plugin:dbfolder:10:107733)
    at vc (plugin:dbfolder:10:107661)
    at gc (plugin:dbfolder:10:107524)
    at ac (plugin:dbfolder:10:104331)
    at lc (plugin:dbfolder:10:104720)
@DannyHatcher-Git DannyHatcher-Git added bug Something isn't working triage Issue not tagged yet. talking to the user labels Sep 12, 2022
@imed-ghomari
Copy link
Collaborator

Try updating to the latest version 2.5.3 and see if the issue remains.

@imed-ghomari imed-ghomari changed the title [Bug]: [Bug]: sort doesn't apply in date column Sep 12, 2022
@imed-ghomari
Copy link
Collaborator

I tested it with 2.5.3, and it works normally if all the cells of the column are not empty. But, if some cells remain empty the sort with not work.
image

@RafaelGB RafaelGB added wontfix This will not be worked on and removed bug Something isn't working labels Sep 12, 2022
@DannyHatcher-Git
Copy link
Collaborator Author

Yes, thankyou! I checked for updates yesterday 🤷‍♂️ How do I get a notification about updates?

@RafaelGB
Copy link
Owner

You can watch/unwatch the repository to be notified

@imed-ghomari
Copy link
Collaborator

imed-ghomari commented Sep 12, 2022

Select "release" under custom
image

You can install something like https://github.com/manosim/gitify to make it easier

@RafaelGB RafaelGB added bug Something isn't working and removed wontfix This will not be worked on triage Issue not tagged yet. talking to the user labels Sep 12, 2022
@RafaelGB
Copy link
Owner

resolved with a custom function

import { Row, SortingFn } from "@tanstack/react-table";
import { RowDataType } from "cdm/FolderModel";
import { LocalSettings } from "cdm/SettingsModel";
import { InputType } from "helpers/Constants";
import { Literal } from "obsidian-dataview";
import { DataviewService } from "services/DataviewService";

const dbfolderColumnSortingFn: (
  ddbbConfig: LocalSettings
) => SortingFn<RowDataType> =
  (ddbbConfig: LocalSettings) =>
  (
    rowA: Row<RowDataType>,
    rowB: Row<RowDataType>,
    columnId: string
  ): number => {
    const a = DataviewService.parseLiteral(
      rowA.getValue<Literal>(columnId),
      InputType.MARKDOWN,
      ddbbConfig,
      true
    )
      .toString()
      .toLowerCase();
    const b = DataviewService.parseLiteral(
      rowB.getValue<Literal>(columnId),
      InputType.MARKDOWN,
      ddbbConfig,
      true
    )
      .toString()
      .toLowerCase();
    return a === b ? 0 : a > b ? 1 : -1;
  };

export default dbfolderColumnSortingFn;

@RafaelGB
Copy link
Owner

Screen.Recording.2022-09-12.at.20.29.34.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants