Removed the unfinished partial implementation of overrideTitle functionality
This commit is contained in:
parent
124c851989
commit
3000da4edc
|
@ -56,7 +56,6 @@ export interface CustomSortGroup {
|
||||||
regexPrefix?: RegExpSpec
|
regexPrefix?: RegExpSpec
|
||||||
exactSuffix?: string
|
exactSuffix?: string
|
||||||
regexSuffix?: RegExpSpec
|
regexSuffix?: RegExpSpec
|
||||||
overrideTitle?: boolean // instead of title, use a derived text for sorting (e.g. regexp matching group).
|
|
||||||
order?: CustomSortOrder
|
order?: CustomSortOrder
|
||||||
byMetadataField?: string // for 'by-metadata:' sorting if the order is by metadata alphabetical or reverse
|
byMetadataField?: string // for 'by-metadata:' sorting if the order is by metadata alphabetical or reverse
|
||||||
secondaryOrder?: CustomSortOrder
|
secondaryOrder?: CustomSortOrder
|
||||||
|
|
|
@ -308,36 +308,6 @@ describe('determineSortingGroup', () => {
|
||||||
path: 'Some parent folder/Part:123-icle.md'
|
path: 'Some parent folder/Part:123-icle.md'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should match head and tail, when simple regexp in head and tail, overrideTitle', () => {
|
|
||||||
// given
|
|
||||||
const file: TFile = mockTFile('Part:123-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
|
|
||||||
const sortSpec: CustomSortSpec = {
|
|
||||||
targetFoldersPaths: ['Some parent folder'],
|
|
||||||
groups: [{
|
|
||||||
type: CustomSortGroupType.ExactHeadAndTail,
|
|
||||||
regexPrefix: {
|
|
||||||
regex: /^Part:\d/i
|
|
||||||
},
|
|
||||||
regexSuffix: {
|
|
||||||
regex: /\d-icle$/i
|
|
||||||
},
|
|
||||||
overrideTitle: true // Should be ignored when no advanced regexp
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
||||||
// when
|
|
||||||
const result = determineSortingGroup(file, sortSpec)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(result).toEqual({
|
|
||||||
groupIdx: 0, // Matched!
|
|
||||||
isFolder: false,
|
|
||||||
sortString: "Part:123-icle.md",
|
|
||||||
ctime: MOCK_TIMESTAMP + 555,
|
|
||||||
mtime: MOCK_TIMESTAMP + 666,
|
|
||||||
path: 'Some parent folder/Part:123-icle.md'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should match head and tail, when simple regexp in head and and mixed in tail', () => {
|
it('should match head and tail, when simple regexp in head and and mixed in tail', () => {
|
||||||
// given
|
// given
|
||||||
const file: TFile = mockTFile('Part:1 1-23.456-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
|
const file: TFile = mockTFile('Part:1 1-23.456-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
|
||||||
|
@ -368,37 +338,6 @@ describe('determineSortingGroup', () => {
|
||||||
path: 'Some parent folder/Part:1 1-23.456-icle.md'
|
path: 'Some parent folder/Part:1 1-23.456-icle.md'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should match head and tail, when simple regexp in head and and mixed in tail, with overrideTitle', () => {
|
|
||||||
// given
|
|
||||||
const file: TFile = mockTFile('Part:1 1-23.456-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
|
|
||||||
const sortSpec: CustomSortSpec = {
|
|
||||||
targetFoldersPaths: ['Some parent folder'],
|
|
||||||
groups: [{
|
|
||||||
type: CustomSortGroupType.ExactHeadAndTail,
|
|
||||||
regexPrefix: {
|
|
||||||
regex: /^Part:\d/i
|
|
||||||
},
|
|
||||||
regexSuffix: {
|
|
||||||
regex: / *(\d+(?:-\d+)*).\d\d\d-icle$/i,
|
|
||||||
normalizerFn: CompoundDashNumberNormalizerFn
|
|
||||||
},
|
|
||||||
overrideTitle: true
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
||||||
// when
|
|
||||||
const result = determineSortingGroup(file, sortSpec)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(result).toEqual({
|
|
||||||
groupIdx: 0, // Matched!
|
|
||||||
isFolder: false,
|
|
||||||
sortString: "00000001|00000023//",
|
|
||||||
ctime: MOCK_TIMESTAMP + 555,
|
|
||||||
mtime: MOCK_TIMESTAMP + 666,
|
|
||||||
path: 'Some parent folder/Part:1 1-23.456-icle.md'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should match head and tail, when advanced regexp in tail', () => {
|
it('should match head and tail, when advanced regexp in tail', () => {
|
||||||
// given
|
// given
|
||||||
const file: TFile = mockTFile('Part:123-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
|
const file: TFile = mockTFile('Part:123-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
|
||||||
|
@ -458,38 +397,6 @@ describe('determineSortingGroup', () => {
|
||||||
path: 'Some parent folder/Part 555-6 123-icle.md'
|
path: 'Some parent folder/Part 555-6 123-icle.md'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should match head and tail, when advanced regexp in both, head and tail, with overrideTitle', () => {
|
|
||||||
// given
|
|
||||||
const file: TFile = mockTFile('Part 555-6 123-icle', 'md', 444, MOCK_TIMESTAMP + 555, MOCK_TIMESTAMP + 666);
|
|
||||||
const sortSpec: CustomSortSpec = {
|
|
||||||
targetFoldersPaths: ['Some parent folder'],
|
|
||||||
groups: [{
|
|
||||||
type: CustomSortGroupType.ExactHeadAndTail,
|
|
||||||
regexPrefix: {
|
|
||||||
regex: /^Part *(\d+(?:-\d+)*)/i,
|
|
||||||
normalizerFn: CompoundDashNumberNormalizerFn
|
|
||||||
},
|
|
||||||
regexSuffix: {
|
|
||||||
regex: / *(\d+(?:-\d+)*)-icle$/i,
|
|
||||||
normalizerFn: CompoundDashNumberNormalizerFn
|
|
||||||
},
|
|
||||||
overrideTitle: true
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
|
|
||||||
// when
|
|
||||||
const result = determineSortingGroup(file, sortSpec)
|
|
||||||
|
|
||||||
// then
|
|
||||||
expect(result).toEqual({
|
|
||||||
groupIdx: 0, // Matched!
|
|
||||||
isFolder: false,
|
|
||||||
sortString: "00000555|00000006//00000123//",
|
|
||||||
ctime: MOCK_TIMESTAMP + 555,
|
|
||||||
mtime: MOCK_TIMESTAMP + 666,
|
|
||||||
path: 'Some parent folder/Part 555-6 123-icle.md'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
describe('CustomSortGroupType.ExactPrefix', () => {
|
describe('CustomSortGroupType.ExactPrefix', () => {
|
||||||
it('should correctly recognize exact prefix', () => {
|
it('should correctly recognize exact prefix', () => {
|
||||||
|
|
|
@ -485,11 +485,9 @@ export const determineSortingGroup = function (entry: TFile | TFolder, spec: Cus
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if (determined && derivedText) {
|
if (determined && derivedText) {
|
||||||
if (!group.overrideTitle) {
|
|
||||||
derivedText = derivedText + '//' + entry.name
|
derivedText = derivedText + '//' + entry.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const idxAfterLastGroupIdx: number = spec.groups.length
|
const idxAfterLastGroupIdx: number = spec.groups.length
|
||||||
let determinedGroupIdx: number | undefined = determined ? groupIdx! : idxAfterLastGroupIdx
|
let determinedGroupIdx: number | undefined = determined ? groupIdx! : idxAfterLastGroupIdx
|
||||||
|
|
Loading…
Reference in New Issue