Action

Select Workspace (Filtered)

Posted by sylumer, Last update about 3 years ago - Unlisted

Steps

  • defineTemplateTag

    name
    Filter
    template
    Gg
  • 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 = "Select Workspace";
    	p.message = "Choose workspace to apply";
    	
    	let ix = 0;
    	let wsChoose = []
    	for (let ws of workspaces) {
    		if (ws.name.toLowerCase().includes(draft.getTemplateTag("Filter").toLowerCase()))
    		{
    			p.addButton(ws.name, ix);
    			wsChoose.push(ws);
    			ix++;
    		}
    	}
    	
    	if (!p.show()) {
    		return false;
    	}
    	
    	let selectedIndex = p.buttonPressed;
    	let ws = wsChoose[selectedIndex];
    	app.applyWorkspace(ws);
    	app.showDraftList();
    }
    
    if (!f()) {
    	context.cancel();
    }

Options

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