Action

Return Home Packing List

Posted by paolo_santucci, Last update over 4 years ago

This action is a companion for Rosemary Orchard’s Packing List Action Group.

It copies all the checked items from the current packing list in a new one, for the journey home, to be sure that nothing is forgotten.

Steps

  • script

    let d = Draft.create();
    let oldLines = draft.content.split('\n');
    let tags = draft.tags;
    var newLines = [];
    
    for (var tag of tags) {
      d.addTag(tag);
    }
    
    newLines.push('# Return from ' + draft.title);
    
    for (var line of oldLines) {
      if (line.startsWith('- [x]')) {
        newLines.push(line);
      }
    }
    
    d.content = newLines.join('\n').replace(/- \[x\]/g, '- [ ]').replace(/?/g, '?');
    d.update();
    editor.load(d);
    editor.activate();
    

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.