Drafts Action Directory

New Draft in Workspace

Posted by agiletortoise, Last update 17 days ago

Prompt to select a workspace, and create a new draft already assigned tags that match the tag filter for the workspace. Load the new draft in the editor.

Install

Steps

  • script

    // select from a list of workspace and load
    
    let f = () => {
    	let workspaces = Workspace.getAll();
    	if (workspaces.length == 0) {
    		alert("No workspaces defined.");
    		return false;
    	}
    	
    	let p = Prompt.create();
    	p.title = "New Draft in Workspace";
    	p.message = "Select workspace. A new draft will be created and assigned tags to match the workspace.";
    	
    	let ix = 0;
    	for (let ws of workspaces) {
    		if (ws.tagFilter.length > 0 && ws.tagFilter.trim() != "untagged") {
    			p.addButton(ws.name, ix);
    		}
    		ix++;
    	}
    	
    	if (!p.show()) {
    		return false;
    	}
    	
    	let selectedIndex = p.buttonPressed;
    	let ws = workspaces[selectedIndex];
    
    	let tags = ws.tagFilter.split(",").filter(tag => tag.trim().length > 0 && tag.trim()[0] != "!" && tag.trim() != "untagged")
    	let d = Draft.create();
    	for (var tag of tags) {
    		d.addTag(tag);
    	}
    	d.update();
    	editor.load(d);
    	editor.activate();
    	return true;
    }
    
    if (!f()) {
    	context.cancel();
    }

Options

  • After Success Default
    Notification Error
    Log Level Error

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.