Can you change multiple rows at once?


#1

Can. you change multiple rows at the same time?

For example, I have a 2nd column called status. Is it possible to select multiple rows and then change the status of all of the rows? Or, do you have to change each row individually?


#2

One traditional route is to attach a script (for toggling the checked status of all selected rows in the front document) to a keystroke combination.

e.g. in AppleScript (though you could also do something similar with OmniJS)

on run
    
    tell application ("OmniOutliner")
        tell front document
            if state of first selected row is unchecked then
                set newStatus to checked
            else
                set newStatus to unchecked
            end if
            set state of selected rows to newStatus
            activate
        end tell
    end tell
    
end run

#3

If you prefer to assign a Javascript for Automation script to a keystroke, you can use the omniJS scripting interface to OO:

(() => {
    'use strict';

    // main :: IO ()
    const main = () =>
        outlineOmniJSWithArgs(
            statusToggle
        );

    // OO OMNJIS EVALUATION CONTEXT ---------------------

    // statusToggle :: IO ()
    const statusToggle = () => {
        const
            xs = document.editors[0].selectedNodes
            .map(x => x.object),
            lng = xs.length;
        return 0 < lng ? (() => {
            const
                newState = xs[0]
                .state !== State.Checked ? (
                    State.Checked
                ) : State.Unchecked,
                strLen = lng.toString();
            return (
                xs.forEach(x => x.state = newState),
                newState !== State.Checked ? (
                    'Cleared <-- ' + strLen + ' rows'
                ) : strLen + ' rows --> Checked'
            );
        })() : 'Nothing selected in OmniOutliner.'
    };

    // JXA EVALUATION CONTEXT ---------------------------

    // outlineOmniJSWithArgs :: Function ->
    //                          [...OptionalArgs] -> a
    function outlineOmniJSWithArgs(f) {
        return Application('omniOutliner')
            .evaluateJavascript(
                `(${f})(${Array.from(arguments)
                .slice(1).map(JSON.stringify)})`
            );
    };

    // MAIN ---------------------------------------------
    return main();
})();