-
-
Notifications
You must be signed in to change notification settings - Fork 392
Add Rename boards #73
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -242,6 +242,18 @@ class Render { | |
| error({prefix, message}); | ||
| } | ||
|
|
||
| missingStorage() { | ||
| const prefix = '\n'; | ||
| const message = 'There are no any boards, please create some task at least to start'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the copy to: "There are currently no boards" |
||
| error({prefix, message}); | ||
| } | ||
|
|
||
| missingBoardName(name) { | ||
| const prefix = '\n'; | ||
| const message = `There are no any board with name: ${name}`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the copy here to: |
||
| error({prefix, message}); | ||
| } | ||
|
|
||
| successCreate({_id, _isTask}) { | ||
| const [prefix, suffix] = ['\n', grey(_id)]; | ||
| const message = `Created ${_isTask ? 'task:' : 'note:'}`; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,6 +108,35 @@ class Storage { | |
| return archive; | ||
| } | ||
|
|
||
| renameBoardsWithName(oldName, newName) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't agree with this approach. The task data manipulation is not done in the Storage class, this class is supposed to read and write the data, not perform logic like this. |
||
| let finalData = null; | ||
| fs.exists(this._mainStorageFile, (exists) => { | ||
| if (!exists) { | ||
| render.missingStorage(); | ||
| return finalData; | ||
| } | ||
| const rs = fs.createReadStream(this._mainStorageFile, 'utf8'); | ||
| rs.on('data', (rsData) => { | ||
| const _rsData = JSON.parse(rsData); | ||
| Object.keys(_rsData).forEach((k) => { | ||
| _rsData[k].boards.forEach((boardName, i) => { | ||
| if (boardName === oldName) { | ||
| _rsData[k].boards[i] = newName; | ||
| finalData = { ..._rsData }; | ||
| finalData = JSON.stringify(finalData, null, 2); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
| rs.on('end', () => { | ||
| if (!finalData) { | ||
| return render.missingBoardName(oldName); | ||
| } | ||
| fs.createWriteStream(this._mainStorageFile).write(finalData); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| set(data) { | ||
| data = JSON.stringify(data, null, 4); | ||
| const tempStorageFile = this._getTempFile(this._mainStorageFile); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like
--rename-boardwould be more standard here :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
--rename-boardis more standard.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it looks like your alias
-rconflicts with the restore command, and you could use a comma after the full command name