Skip to content

Commit

Permalink
Merge pull request #75 from robaboyd/develop
Browse files Browse the repository at this point in the history
v0.1.3
  • Loading branch information
boydvoid authored Oct 18, 2018
2 parents 3057edb + 76fdb1d commit a028b28
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 39 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [0.1.3] 10-18-18

`Added`

- Added the `DD-MM-YYYY` date format [Issue #73](https://github.com/robaboyd/vs-org/issues/73)
- The setting can be changed under the VS-Org config in the Extension preferences
- The already scheduled TODOs will update to the new format when the setting is changed

## [0.1.2] 10-12-18

`Fixed`
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VS-ORG

![Version](https://img.shields.io/badge/version-v0.1.2-blue.svg)
![Version](https://img.shields.io/badge/version-v0.1.3-blue.svg)
[![Install](https://img.shields.io/badge/Marketplace-Install-green.svg)](https://marketplace.visualstudio.com/items?itemName=BobbyBoyd.vs-org)</br></br>
This is a work in progress extension that will, in the end, try to emulate [Emacs Org-Mode](https://orgmode.org/) as much as possible.

Expand Down Expand Up @@ -57,11 +57,13 @@ Submit an [Issue](https://github.com/robaboyd/vs-org/issues) if there is a bug y

## Release Notes

### [0.1.2] 10-12-18
### [0.1.3] 10-18-18

`Fixed`
`Added`

- Agenda view now shows on Mac [Issue #65](https://github.com/robaboyd/vs-org/issues/65)
- Added the `DD-MM-YYYY` date format [Issue #73](https://github.com/robaboyd/vs-org/issues/73)
- The setting can be changed under the VS-Org config in the Extension preferences
- The already scheduled TODOs will update to the new format when the setting is changed

## Upcoming Features

Expand Down
28 changes: 17 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vs-org",
"displayName": "VS-Org",
"description": "Quickly create todo lists, take notes, plan projects and organize your thoughts.",
"version": "0.1.2",
"version": "0.1.3",
"repository": "https://www.github.com/robaboyd/vs-org",
"icon": "potentialLogo.png",
"publisher": "BobbyBoyd",
Expand All @@ -14,12 +14,7 @@
"Other"
],
"activationEvents": [
"onCommand:extension.createVsoFile",
"onCommand:extension.getTags",
"onCommand:extension.getTitles",
"onCommand:extension.setFolderPath",
"onCommand:extension.viewAgenda",
"onLanguage:vso"
"*"
],
"keywords": [
"todo",
Expand All @@ -45,11 +40,22 @@
"default": "",
"description": "Main folder"
},
"vsorg.showChangeMessage": {
"type": "boolean",
"default": true,
"description": "Show the read change log message after update."
"vsorg.dateFormat": {
"type": "string",
"default": [
"MM-DD-YYYY"
],
"enum": [
"MM-DD-YYYY",
"DD-MM-YYYY"

],
"minItems": 1,
"maxItems": 3,
"uniqueItems": true,
"description": "The scheduled date format."
}

}
},
"commands": [{
Expand Down
3 changes: 2 additions & 1 deletion roadmap.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Roadmap v1.0.0

Live version: 0.1.2
Live version: 0.1.3

These are the features that I would like to add in the near future.

## Features

| Feature Name | Description | Progress | Version |
| ------------------------- | :---------------------------------------------------------------------------------------: | ----------: | ------- |
| TODO Notifications | Insert Tables into doc | In Progress | |
| Bulleted Lists | Make a ordered or unordered lists | In Progress | |
| TODO Tracking | Show TODO completion on the up most level | In Progress | |
| Make Titles Unique | Don't allow duplicate titles | Not Started | |
Expand Down
29 changes: 22 additions & 7 deletions src/agenda/agenda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = function () {
vscode.commands.executeCommand("workbench.action.files.save").then(() => {
let config = vscode.workspace.getConfiguration("vsorg");
let folderPath = config.get("folderPath");
let dateFormat: any = config.get("dateFormat");
let folder: any;
let taskText: any;
let taskTextGetTodo: any = "";
Expand Down Expand Up @@ -92,7 +93,7 @@ module.exports = function () {
}

//get the day of the week for items scheduled in the future
let d = new Date(getDateFromTaskText[1]).getDay();
let d = moment(getDateFromTaskText[1], dateFormat).day();
let nameOfDay;
if (d === 0) {
nameOfDay = "Sunday";
Expand All @@ -111,7 +112,7 @@ module.exports = function () {
}

convertedDateArray = [];
if (new Date(getDateFromTaskText[1]).setHours(0, 0, 0, 0) >= new Date().setHours(0, 0, 0, 0)) {
if (moment(getDateFromTaskText[1], dateFormat) >= moment(new Date(), dateFormat)) {

if (nameOfDay !== undefined) {
convertedDateArray.push({
Expand Down Expand Up @@ -145,8 +146,14 @@ module.exports = function () {
if (mm < 10) {
mm = "0" + mm;
}
if (dateFormat === "MM-DD-YYYY") {

today = mm + "-" + dd + "-" + yyyy;

today = mm + "-" + dd + "-" + yyyy;
} else {

today = dd + "-" + mm + "-" + yyyy;
}

if (getDayOverdue === 0) {
overdue = "Sunday";
Expand All @@ -164,7 +171,7 @@ module.exports = function () {
overdue = "Saturday";
}
//if date is a day in the past
if (new Date(getDateFromTaskText[1]).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) {
if (moment(getDateFromTaskText[1], dateFormat) < moment(new Date().getDate(), dateFormat)) {

convertedDateArray.push({
date:
Expand Down Expand Up @@ -217,14 +224,20 @@ module.exports = function () {

Object.keys(sortedObject)
.sort(function (a: any, b: any) {
let first: any = moment(a.match(/\[(.*)\]/), "MM-DD-YYYY").toDate();
let second: any = moment(b.match(/\[(.*)\]/), "MM-DD-YYYY").toDate();

let first: any = moment(a.match(/\[(.*)\]/), dateFormat).toDate();

let second: any = moment(b.match(/\[(.*)\]/), dateFormat).toDate();

return first - second;
})
.forEach(function (property) {
itemInSortedObject += property + sortedObject[property] + "</br>";
});




createWebview();
});
}
Expand Down Expand Up @@ -296,6 +309,8 @@ module.exports = function () {
for (let i = 0; i < x.length; i++) {
if (x[i].indexOf(text) > -1 && x[i].indexOf(textArray[3]) > -1) {
let removeSchedule: any = x[i].match(/\bSCHEDULED\b(.*)/g);
let date = moment().format('Do MMMM YYYY, h:mm:ss a');

x[i] = x[i].replace(removeSchedule[0], "");
x[i] = x[i].replace(
"TODO " + text,
Expand All @@ -305,7 +320,7 @@ module.exports = function () {
textArray[3] +
"\n COMPLETED:" +
"[" +
new Date().toLocaleString() +
date +
"]"
);
contents = x.join("\r\n");
Expand Down
19 changes: 13 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const increment = require("./incrementHeadings");
const decrement = require("./decrementHeadings");
const scheduling = require("./scheduling");
const agenda = require("./agenda/agenda");
const updateDates = require("./updateDate");

const GO_MODE: vscode.DocumentFilter = { language: "vso", scheme: "file" };
class GoOnTypingFormatter implements vscode.OnTypeFormattingEditProvider {
Expand Down Expand Up @@ -84,14 +85,20 @@ function numOfSpaces(asterisk: number) {
export function activate(ctx: vscode.ExtensionContext): void {


//add a folder path

vscode.commands.registerCommand("extension.viewAgenda", agenda);


//run updateDates on config change
vscode.commands.registerCommand("extension.updateDates", updateDates);
vscode.workspace.onDidChangeConfiguration((event) => {
let settingChanged = event.affectsConfiguration("vsorg.dateFormat");
if (settingChanged) {
vscode.commands.executeCommand('extension.updateDates');
}
})

//add a folder path
vscode.commands.registerCommand("extension.setFolderPath", changeDirectory);
vscode.workspace.onDidChangeTextDocument(() => {
vscode.commands.executeCommand("extension.updateAgenda");
});

//create a new file
vscode.commands.registerCommand("extension.createVsoFile", newFile);
//list tags
Expand Down
6 changes: 4 additions & 2 deletions src/keywordLeft.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from "vscode";

import * as moment from "moment";

module.exports = function () {
vscode.commands.executeCommand("workbench.action.files.save").then(() => {
Expand All @@ -14,7 +14,7 @@ module.exports = function () {
let unicode_char = characterDecode(characterArray);
let line_leading_spaces: string = current_line.text.substr(0, current_line.text.indexOf(unicode_char));
let text_after_unicode_char: string = current_line.text.replace(/[\?]/g, "").trim();
let date = new Date().toLocaleString();
let date;
let workspaceEdit = new vscode.WorkspaceEdit();
//check if the char exists on the line
if (current_line.text.includes(unicode_char)) {
Expand All @@ -34,6 +34,8 @@ module.exports = function () {
vscode.commands.executeCommand("workbench.action.files.save");
});
} else if (!current_line.text.includes("DONE")) {

date = moment().format('Do MMMM YYYY, h:mm:ss a');
//check if the line doesnt includes TODO

workspaceEdit.delete(document.uri, current_line.range);
Expand Down
6 changes: 4 additions & 2 deletions src/keywordRight.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';

import * as moment from "moment";
module.exports = function () {
vscode.commands.executeCommand("workbench.action.files.save").then(() => {
const { activeTextEditor } = vscode.window;
Expand All @@ -13,7 +13,8 @@ module.exports = function () {
let unicode_char = characterDecode(characterArray);
let line_leading_spaces: string = current_line.text.substr(0, current_line.text.indexOf(unicode_char));
let text_after_unicode_char: string = current_line.text.replace(/[\?]/g, '').trim();
let date = new Date().toLocaleString();
let date;

let workspaceEdit = new vscode.WorkspaceEdit();
//check if the char exists on the line
if (current_line.text.includes(unicode_char)) {
Expand Down Expand Up @@ -47,6 +48,7 @@ module.exports = function () {
vscode.commands.executeCommand("workbench.action.files.save");
});
} else if (!current_line.text.includes('DONE')) {
date = moment().format('Do MMMM YYYY, h:mm:ss a');
// remove todo from the line
let text_without_todo = text_after_unicode_char.replace(/\b(TODO)\b/, '').trim();

Expand Down
24 changes: 18 additions & 6 deletions src/scheduling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ module.exports = function () {
let year: string | undefined;
let month: string | undefined;
let workspaceEdit = new vscode.WorkspaceEdit();
let config = vscode.workspace.getConfiguration("vsorg");
let dateFormat = config.get("dateFormat");

//messages
let fullDateMessage = new WindowMessage('warning', "Full date must be entered", false, false);
let notADateMessage = new WindowMessage('warning', "That's not a valid date. ", false, false);

if (current_line.text.includes("SCHEDULED:")) {
let removeScheduled = current_line.text.replace(/\b(SCHEDULED)\b(.*)/, "").trim();
let removeScheduled = current_line.text.replace(/\b(SCHEDULED)\b(.*)/, "").trimRight();

workspaceEdit.delete(document.uri, current_line.range);

Expand Down Expand Up @@ -81,12 +83,22 @@ module.exports = function () {
workspaceEdit.delete(document.uri, current_line.range);

//insert based on date format
if (dateFormat === "MM-DD-YYYY") {

workspaceEdit.insert(
document.uri,
current_line.range.start,
current_line.text + " SCHEDULED: [" + month + "-" + day + "-" + year + "]"
);

} else if (dateFormat === "DD-MM-YYYY") {
workspaceEdit.insert(
document.uri,
current_line.range.start,
current_line.text + " SCHEDULED: [" + day + "-" + month + "-" + year + "]"
);
}

workspaceEdit.insert(
document.uri,
current_line.range.start,
current_line.text + " SCHEDULED: [" + month + "-" + day + "-" + year + "]"
);

return vscode.workspace.applyEdit(workspaceEdit).then(() => {
vscode.commands.executeCommand("workbench.action.files.save");
Expand Down
Loading

0 comments on commit a028b28

Please sign in to comment.