imdone-core 1.53.16 → 1.53.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/project.js CHANGED
@@ -98,6 +98,14 @@ module.exports = class WorkerProject extends Project {
98
98
 
99
99
  if (!cb) return promise
100
100
  }
101
+
102
+ initIndexes(allLists) {
103
+ allLists.forEach((list) => {
104
+ list.tasks.filter(list => !list.filter).forEach((task, index) => {
105
+ task.index = index
106
+ })
107
+ })
108
+ }
101
109
 
102
110
  // HACK To handle circular dependency issue with file
103
111
  // <!--
@@ -107,17 +115,23 @@ module.exports = class WorkerProject extends Project {
107
115
  return { path: this.path }
108
116
  }
109
117
 
110
- getListsForImdoneJSON(totals) {
111
- return this.allLists.map((list) => {
118
+ getListsForImdoneJSON() {
119
+ this.initIndexes(this.repo.getTasksByList())
120
+ let allLists = this.getLists({
121
+ populateFiltered: true,
122
+ })
123
+ const totals = calculateTotals(allLists)
124
+ allLists = allLists.map((list) => {
112
125
  list = { ...list }
113
126
  list.tasks = list.tasks.map((card, index) => {
114
127
  card.interpretedContent = ''
115
128
  card.totals = totals
116
- card.index = index
117
129
  return card
118
130
  })
119
131
  return list
120
132
  })
133
+
134
+ return { allLists, totals }
121
135
  }
122
136
 
123
137
  getInitializedCards(allLists, totals) {
@@ -133,12 +147,7 @@ module.exports = class WorkerProject extends Project {
133
147
  this.pluginManager.initDevMode()
134
148
  console.time('toJSON time')
135
149
  this._updatedAt = new Date()
136
- const totals = calculateTotals(
137
- this.getLists({
138
- populateFiltered: true,
139
- })
140
- )
141
- const allLists = this.getListsForImdoneJSON(totals)
150
+ const { allLists , totals } = this.getListsForImdoneJSON()
142
151
 
143
152
  console.time('plugin onBeforeBoardUpdate')
144
153
  await this.pluginManager.onBeforeBoardUpdate()
@@ -152,17 +161,13 @@ module.exports = class WorkerProject extends Project {
152
161
  console.timeEnd('card init')
153
162
 
154
163
  console.time('plugin onBoardUpdate')
155
- await this.pluginManager.onBoardUpdate(
156
- this.getLists({
157
- tasks: cards,
158
- })
159
- )
164
+ await this.pluginManager.onBoardUpdate(allLists)
160
165
  console.timeEnd('plugin onBoardUpdate')
161
166
 
162
- const lists = this.getLists({
167
+ const lists = this.filter ? this.getLists({
163
168
  tasks: this.getCards(this.filter, cards),
164
169
  populateFiltered: true,
165
- })
170
+ }) : allLists
166
171
 
167
172
  console.timeEnd('toJSON time')
168
173
  return {
@@ -263,8 +268,8 @@ module.exports = class WorkerProject extends Project {
263
268
  getLists(opts) {
264
269
  const {tasks = this.getDefaultFilteredCards(), populateFiltered = false} = opts || {}
265
270
  return Repository.getTasksByList(this.repo, tasks, true, populateFiltered)
266
- }
267
-
271
+ }
272
+
268
273
  getTaskQueryProps(props) {
269
274
  const queryProps = []
270
275
  if (props) {
@@ -328,15 +333,15 @@ module.exports = class WorkerProject extends Project {
328
333
  return this.getCards(filter, allTasks)
329
334
  }
330
335
 
331
- getCards(filter, tasks = this.getDefaultFilteredCards()) {
332
- tasks = filter ? this.filterCards(tasks, filter) : tasks
333
- return tasks
336
+ getCards(filter, cards = this.getDefaultFilteredCards()) {
337
+ cards = filter ? this.filterCards(cards, filter) : cards
338
+ return cards
334
339
  }
335
340
 
336
- filterCards(tasks, filter) {
341
+ filterCards(cards, filter) {
337
342
  const {
338
343
  result,
339
- } = Repository.filterCards(tasks, filter)
344
+ } = Repository.filterCards(cards, filter)
340
345
  return result
341
346
  }
342
347
 
package/lib/task.js CHANGED
@@ -70,7 +70,7 @@ class Task {
70
70
  this.content = obj.content
71
71
  this.lastLine = this.getLastLine()
72
72
  this.orderModified = obj.orderModified
73
- this.index = undefined
73
+ this.index = obj.index
74
74
  if (dontParse || !this.text) return
75
75
  this.parse()
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "1.53.16",
3
+ "version": "1.53.17",
4
4
  "description": "imdone-core",
5
5
  "main": "index.js",
6
6
  "scripts": {