Skip to content

Commit

Permalink
Merge pull request #372 from imdone/1.37.0
Browse files Browse the repository at this point in the history
1.37.0
  • Loading branch information
piascikj authored Mar 9, 2024
2 parents 9b35144 + 4e71d2b commit e2f8e79
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ File.prototype.modifyTask = function (task, config, noEmit) {
if (this.getContent().trim() === newContent.trim()) return
this.setContent(newContent)
this.setModified(true)
task.lastLine = task.line + description.length
if (!noEmit) {
this.emit('task.modified', task)
this.emit('file.modified', this)
Expand Down
8 changes: 8 additions & 0 deletions lib/project-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ const ProjectContext = require('./ProjectContext')
const Project = require('./project')
const context = require('./context/ApplicationContext')

function createWatchedFSProject({path, config, repo = watchedFsStore(new Repository(path, config))}) {
context().repo = repo
context().projectContext = new ProjectContext(repo)
context().project = new Project(repo)
return context().project
}

module.exports = {
createWatchedFileSystemProject: function(path) {
if (typeof path === 'object' && path.confg) return createWatchedFSProject(path)
const repo = watchedFsStore(new Repository(path))
context().repo = repo
context().projectContext = new ProjectContext(repo)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imdone-core",
"version": "1.37.0",
"version": "1.37.1",
"description": "imdone-core",
"main": "index.js",
"bin": {
Expand Down
89 changes: 89 additions & 0 deletions test/repos/move-meta-order-keep-empty-priority/.imdone/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
keepEmptyPriority: true
code:
include_lists:
- TODO
- DOING
- DONE
- PLANNING
- FIXME
- ARCHIVE
- HACK
- CHANGED
- XXX
- IDEA
- NOTE
- REVIEW
lists:
- hidden: false
name: NOTE
- hidden: false
name: TODO
- hidden: false
name: DOING
- hidden: false
ignore: true
name: DONE
settings:
journalType: Folder
journalPath: content
newCardSyntax: HASH_META_ORDER
cards:
maxLines: 6
addNewCardsToTop: true
colors: []
metaNewLine: true
computed:
date: "${(new Date()).toDateString()}"
time: "${(new Date()).toLocaleTimeString()}"
timestamp: "${(new Date()).toISOString()}"
sourceLink: "[${source.path}:${line}](${source.path}:${line})"
dueEmoji: !<tag:yaml.org,2002:js/function> |-
function anonymous(
) {
const due = this.totals["What's Due?"]
let emoji = ':2nd_place_medal:'
if (due >= 3) {
emoji = ':fire:'
} else if (due === 0) {
emoji = ':rocket:'
}
return `<span style="font-size: 1.5em;">${emoji}</span>`
}
recentEmoji: !<tag:yaml.org,2002:js/function> |-
function anonymous(
) {
const recentlyCompleted = this.totals["Recently Completed"]
let emoji = ':2nd_place_medal:'
if (recentlyCompleted >= 3) {
emoji = ':rocket:'
} else if (recentlyCompleted === 0) {
emoji = ':fire:'
}
return `<span style="font-size: 1.5em;">${emoji}</span>`
}
wipEmoji: !<tag:yaml.org,2002:js/function> |-
function anonymous(
) {
const doing = this.totals["DOING"]
let emoji = ':2nd_place_medal:'
if (doing >= 3) {
emoji = ':fire:'
} else if (doing === 0) {
emoji = ':sleeping:'
} else if (doing === 1) {
emoji = ':rocket:'
}
return `<span style="font-size: 1.5em;">${emoji}</span>`
}
doneList: DONE
defaultList: TODO
taskPrefix: "- [ ]"
addCheckBoxTasks: true
filteredLists: []
journalTemplate: ""
openIn: code
editorTheme: blackboard
replaceSpacesWith: "-"
appendNewCardsTo: ""
theme: dark
useVimKeyBindings: false
5 changes: 5 additions & 0 deletions test/repos/move-meta-order-keep-empty-priority/file-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#DOING Task a
#TODO Task b
#TODO Task c
#TODO Task d
#TODO Task e
19 changes: 18 additions & 1 deletion test/repository-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var should = require('should'),
const appContext = require('../lib/context/ApplicationContext')
const ProjectContext = require('../lib/ProjectContext')
const Task = require('../lib/task')
const { createFileSystemProject } = require('../lib/project-factory')
const { createFileSystemProject, createWatchedFileSystemProject } = require('../lib/project-factory')

describe('Repository', function () {
var tmpDir = path.join(process.cwd(), 'tmp'),
Expand All @@ -34,6 +34,7 @@ describe('Repository', function () {
defaultCards2Dir = path.join(tmpReposDir, 'default-cards-2'),
noOrderRepoDir = path.join(tmpReposDir, 'no-order-repo'),
moveMetaOrderDir = path.join(tmpReposDir, 'move-meta-order'),
moveMetaOrderKeepEmptyPriorityDir = path.join(tmpReposDir, 'move-meta-order-keep-empty-priority'),
metaSepTestDir = path.join(tmpReposDir, 'meta-sep-test'),
repo,
repo1,
Expand Down Expand Up @@ -1229,6 +1230,22 @@ describe('Repository', function () {
})
})

it('Should move a task in a file with orderMeta and keepEmptyPriority = true', (done) => {
const listName = 'DOING'
const project = createFileSystemProject({path: moveMetaOrderKeepEmptyPriorityDir})
const repo = project.repo
project.init((err, result) => {
var list = repo.getTasksInList(listName)
var task = list[0]
repo.moveTasks([task], 'TODO', 2, (err) => {
expect(err).to.be(undefined)
var list = repo.getTasksInList('TODO')
task.equals(list[2]).should.be.true
done()
})
})
})

it('should move a task to the proper location even if other tasks around it have the same order', (done) => {
const listName = 'DOING'
appContext().projectContext = new ProjectContext(noOrderRepo)
Expand Down

0 comments on commit e2f8e79

Please sign in to comment.