Action

Update Tags...

Posted by agiletortoise, Last update 5 days ago

Prompt to assign or remove tags.

Steps

  • script

    // show multi-select with current assigned tags
    // and a static list of common tags
    
    // baseTags are always visible.
    let baseTags = ["personal", "work"];
    
    let currentTags = draft.tags;
    let allTags = baseTags.concat(currentTags);
    allTags = allTags.concat(Draft.recentTags());
    let selectableTags = Array.from(new Set(allTags));
    
    // create prompt to display
    let p = Prompt.create();
    p.title = "Assign tags";
    p.symbolName = "tag"
    
    p.addSelect("tags", "", selectableTags, currentTags, true);
    
    p.addTextField("othertags", "Other", "", {
      "placeholder": "comma-separated tags",
      "autocapitalization": "none"
    });
    
    p.addButton("Update");
    
    if (p.show()) {
    	var selectedTags = p.fieldValues["tags"];
       for (var tag of currentTags) {
       		draft.removeTag(tag);
       }
    	for (var tag of selectedTags) {
    		draft.addTag(tag);
    	}
    	var otherTags = p.fieldValues["othertags"].split(",");
    	for (var tag of otherTags) {
    	   draft.addTag(tag);
    	}
    	draft.update();
    }

Options

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