Reusable Templates: OmniJS Plug-In (Mac/iOS)

I often have the need to duplicate selected projects and uncheck all its tasks. I find this is a convenient to use a Project as a reusable template. For that reason, I did this cross-platform OmniJS Plug-In.

Twitter: @unlocked2412

Screenshots:

image

image

Link:

Full code:

/*{
	"type": "action"
}*/
// Twitter: @unlocked2412
(() => Object.assign(
    new PlugIn.Action(selection => {

        // OMNI JS CODE ---------------------------------------
        const omniJSContext = () => {
            // main :: IO ()
            const main = () => {
                const ps = duplicateSections(
                    selection.projects, 
                    selection.projects[0].after
                );
                return ps.map(uncheckProject)
            };

            // FUNCTIONS --
            // uncheckProject :: OFProject -> OFProject
            const uncheckProject = proj => {
                return (
                    proj
                    .flattenedTasks
                    .map(x => x.markIncomplete()),
                    proj
                )
            };

            return main();
        };

        return omniJSContext()

    }), {
        validate: selection => 
            selection.projects.length > 0
    }
))();
1 Like