Action

Select Workspace

Posted by agiletortoise, Last update 1 day ago

UPDATES

6 days ago

Switch to using new SelectPrompt introduced in v54

Select from your workspaces, and apply one to the draft list.

Steps

  • script

    // select from a list of workspace and load
    
    let f = () => {
       if (!app.isPro) {
           alert("Draft Pro required")
       	    return false
       }
    
    	let workspaces = Workspace.getAll()
    	let def = new Workspace()
    	def.name = "Clear Filters"
    	workspaces.push(def)
    	
    	if (workspaces.length == 0) {
    		alert("No workspaces defined.")
    		return false;
    	}
    
    	let p = new SelectPrompt()
    	p.message = "Select a Workspace"
    	
    	let ix = 0;
    	for (let ws of workspaces) {
    		p.addItem(ix.toString(), ws.name);
    		ix++;
    	}
    		
    	if (!p.show()) {
    		return false;
    	}
    	
    	let selectedIndex = parseInt(p.selectedItem.id);
    	if (selectedIndex == workspaces.length - 1) {
    		app.applyWorkspace()
    	}
    	else {
    		let ws = workspaces[selectedIndex];
    		app.applyWorkspace(ws);
    	}
    	app.showDraftList();
    }
    
    if (!f()) {
    	context.cancel();
    }
    
    

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.