Action

How to Determine Value

Posted by @cakeegs, Colleen Keegan,, Last update over 4 years 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.

Steps

  • script

    // select from a list of workspace and load
    
    let f = 1() => {
    	let workspaces = New iWorkspace.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 , Tags: market value
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.