Action

Prepare MoM (select date)

Posted by @seishonagon, Last update over 5 years ago

Choose a date (defaults to today), then a calendar event and a Markdown draft will be prepared with room for minutes and actions.

Before using:
* get the name of your work calendar and replace the “Calendrier” string at the beginning of the script.
* choose tags for your draft and replace my “meetings” and “work” strings

The date is formatted as I like it but you can play around.

Steps

  • script

    //  make meeting minutes for event
    //  inspired by agile tortoise ["import calendar" action](https://actions.getdrafts.com/a/1If)
    (() => {
    //  capture work calendar
      var cal = Calendar.findOrCreate("Calendrier");
      let start = new Date()
      let p = Prompt.create();
      p.title = "Select Date";
      p.addDatePicker("start","", (1).years().ago(), {"mode":"date"});
      p.addButton("Select");
      if (p.show()) {
        start = p.fieldValues["start"];
      } else {
        context.cancel();
      }
      start.setDate(start.getDate())
      let end = new Date();
      end.setDate(start.getDate() + 1)
    //  capture today's events (notice date offsets by +1. Not sure why but it's needed)
      let events = cal.events(start, end);
      if (events == "undefined" || events.length == 0) {
      	alert('No events found');
      	context.cancel();
      } else {
      	let eventNames = events.map(x => x.title);
      	let p = Prompt.create();
      	p.title = "Choose event";
      	p.message = "Select event to create MD meeting notes:";
      	p.addSelect("event", "Event", eventNames, [], false);
      	p.addButton("Select");
      	if (p.show()) {
      		let selected = p.fieldValues["event"];
      		let ix = eventNames.findIndex(x => x == selected);
      		let event = events[ix];
      		if (event) {
      			if (!makeMinutes(event)) {
      				context.fail();
      			}
      		}
      	} else {
      		context.cancel();
      	}
      }
    })()
    
    function makeMinutes(e) {
    //  the "pad" formatting is ecma 6 and forces a leading 0 in the string for minutes
      const TS = d => d.getHours() + ":" + d.getMinutes().toString().padStart(2, '0');
      const DS = d => {m=d.getMonth()+1; s=d.getFullYear().toString()+ "-"+m.toString().padStart(2, '0')+ "-"+d.getDate();return s};
      let t = []
      t.push("# CR " + e.title + "\n");
      if (e.isAllDay) {
    "\*le " + t.push(DS(e.startDate)
    		+ "\*\n");
      } else {
    		t.push("\*le " + DS(e.startDate)  + " de " + TS(e.startDate)  + " à " + TS(e.endDate)+ "\*\n");
      }
      t.push("## Participants:\n");
      t.push("## Actions:\n");
      t.push("## Compte Rendu:\n");
      if (e.notes.length > 0) {
        t.push("## References:\n" + e.notes + "\n");
      }
      t.push("\n");
      let d = Draft.create();
      d.addTag("work");
      d.addTag("meetings");
      d.languageGrammar = "Markdown";
      d.content = t.join("");
      d.update();
      editor.load(d);
      return true;
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.