mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-22 07:58:08 +00:00
Merge pull request #18 from sanderboom/meeting-note-extras
Add default tags and default folder to apply to a newly saved meeting-note.
This commit is contained in:
commit
6107d333c3
2 changed files with 54 additions and 6 deletions
|
@ -2,8 +2,8 @@
|
||||||
"name": "Meeting note",
|
"name": "Meeting note",
|
||||||
"identifier": "meeting-note",
|
"identifier": "meeting-note",
|
||||||
"script": "meeting-note.qml",
|
"script": "meeting-note.qml",
|
||||||
"authors": ["@pbek"],
|
"authors": ["@pbek", "@sanderboom"],
|
||||||
"version": "0.0.1",
|
"version": "1.0.0",
|
||||||
"minAppVersion": "17.05.7",
|
"minAppVersion": "17.05.7",
|
||||||
"description" : "This script creates a menu item and a button to create or jump to the current date's meeting note."
|
"description" : "This script creates a menu item and a button to create or jump to the current date's meeting note."
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.qownnotes.noteapi 1.0
|
||||||
*/
|
*/
|
||||||
QtObject {
|
QtObject {
|
||||||
property string headlinePrefix;
|
property string headlinePrefix;
|
||||||
|
property string defaultFolder;
|
||||||
|
property string defaultTags;
|
||||||
|
|
||||||
// register your settings variables so the user can set them in the script settings
|
// register your settings variables so the user can set them in the script settings
|
||||||
property variant settingsVariables: [
|
property variant settingsVariables: [
|
||||||
|
@ -16,6 +18,20 @@ QtObject {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Teammeeting",
|
"default": "Teammeeting",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identifier": "defaultFolder",
|
||||||
|
"name": "Default folder",
|
||||||
|
"description": "The default folder where the newly created meeting note should be placed. Specify the path to the folder relative to the note folder. Make sure that the full path exists. Examples: to place new meeting notes in the subfolder 'Meeting' enter: \"Meeting\"; to place new meeting notes in the subfolder 'Meeting' in the subfolder 'Work' enter: \"Work/Meeting\". Leave blank to disable (notes will be created in the currently active folder).",
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "defaultTags",
|
||||||
|
"name": "Default tags",
|
||||||
|
"description": "One or more default tags (separated by commas) to assign to a newly created meeting note. Leave blank to disable auto-tagging.",
|
||||||
|
"type": "string",
|
||||||
|
"default": "meeting",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +44,7 @@ QtObject {
|
||||||
/**
|
/**
|
||||||
* This function is invoked when a custom action is triggered
|
* This function is invoked when a custom action is triggered
|
||||||
* in the menu or via button
|
* in the menu or via button
|
||||||
*
|
*
|
||||||
* @param identifier string the identifier defined in registerCustomAction
|
* @param identifier string the identifier defined in registerCustomAction
|
||||||
*/
|
*/
|
||||||
function customActionInvoked(identifier) {
|
function customActionInvoked(identifier) {
|
||||||
|
@ -41,6 +57,17 @@ QtObject {
|
||||||
var headline = headlinePrefix + " " + m.getFullYear() + "-" + ("0" + (m.getMonth()+1)).slice(-2) + "-" + ("0" + m.getDate()).slice(-2);
|
var headline = headlinePrefix + " " + m.getFullYear() + "-" + ("0" + (m.getMonth()+1)).slice(-2) + "-" + ("0" + m.getDate()).slice(-2);
|
||||||
|
|
||||||
var fileName = headline + ".md";
|
var fileName = headline + ".md";
|
||||||
|
|
||||||
|
// Check if we already have a meeting note for today.
|
||||||
|
|
||||||
|
// When a default folder is set, make sure to search in that folder.
|
||||||
|
// This has the highest chance of finding an existing meeting note.
|
||||||
|
// Right now we can not search the whole database for a note with this
|
||||||
|
// name / filename.
|
||||||
|
if (defaultFolder && defaultFolder !== '') {
|
||||||
|
script.jumpToNoteSubFolder(defaultFolder);
|
||||||
|
}
|
||||||
|
|
||||||
var note = script.fetchNoteByFileName(fileName);
|
var note = script.fetchNoteByFileName(fileName);
|
||||||
|
|
||||||
// check if note was found
|
// check if note was found
|
||||||
|
@ -52,11 +79,32 @@ QtObject {
|
||||||
// create a new meeting note if it wasn't found
|
// create a new meeting note if it wasn't found
|
||||||
// keep in mind that the note will not be created instantly on the disk
|
// keep in mind that the note will not be created instantly on the disk
|
||||||
script.log("creating new meeting note: " + headline);
|
script.log("creating new meeting note: " + headline);
|
||||||
|
|
||||||
|
// Default folder.
|
||||||
|
if (defaultFolder && defaultFolder !== '') {
|
||||||
|
var msg = 'Jump to default folder \'' + defaultFolder + '\' before creating a new meeting note.';
|
||||||
|
script.log('Attempt: ' + msg);
|
||||||
|
var jump = script.jumpToNoteSubFolder(defaultFolder);
|
||||||
|
if (jump) {
|
||||||
|
script.log('Success: ' + msg);
|
||||||
|
} else {
|
||||||
|
script.log('Failed: ' + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the new meeting note.
|
||||||
script.createNote(headline + "\n====================\n\n");
|
script.createNote(headline + "\n====================\n\n");
|
||||||
|
|
||||||
// tag the current note
|
// Default tags.
|
||||||
script.tagCurrentNote("meeting");
|
if (defaultTags && defaultTags !== '') {
|
||||||
script.tagCurrentNote("fuf");
|
defaultTags
|
||||||
|
// Split on 0..* ws, 1..* commas, 0..* ws.
|
||||||
|
.split(/\s*,+\s*/)
|
||||||
|
.forEach(function(i) {
|
||||||
|
script.log('Tag the new meeting note with default tag: ' + i);
|
||||||
|
script.tagCurrentNote(i);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue