Plug-In: Grocery Shopping List

An extensive grocery shopping list project.

Instructions:

Requires: OmniFocus 3.11 (macOS), OmniFocus 4 (iOS/iPadOS)

grocery-shopping-list
Grocery Shopping List Project
   

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.grocery-shopping-list", "version": "1.3", "description": "Creates or displays a project containing a list of shopping items grouped by category.", "label": "Shopping List", "shortLabel": "Shopping List", "paletteLabel": "Shopping List", "image": "list.bullet" }*/ (() => { var projectName = "Grocery Shopping List" function buildProject(){ // CREATE FOLDER IF NEEDED folder = folderNamed("Family") || new Folder("Family") // CREATE PROJECT project = Object.assign( new Project(projectName, folder), { sequential : false, note : "Flag items to get. Check items when picked up.", containsSingletonActions : true } ) // CREATE CATEGORY TASKS categoryTitle = 'Fresh Vegetables' groupTask = new Task(categoryTitle, project) categoryItems = ["Asparagus", "Broccoli", "Carrots", "Cauliflower", "Celery", "Corn", "Cucumbers", "Lettuce / Greens", "Mushrooms", "Onions", "Peppers", "Potatoes", "Spinach", "Squash", "Tomatoes", "Zucchini", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Fresh Fruits' groupTask = new Task(categoryTitle, project) categoryItems = ["Apples", "Avocados", "Bananas", "Berries", "Cherries", "Grapefruit", "Grapes", "Kiwis", "Lemons", "Limes", "Melon", "Oranges", "Peaches", "Nectarines", "Pears", "Plums", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Refrigerated Items' groupTask = new Task(categoryTitle, project) categoryItems = ["Bagels","Chip dip","English muffins","Eggs / Fake eggs","Fruit juice","Hummus ","Ready-bake breads","Tofu","Tortillas","…","…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Frozen' groupTask = new Task(categoryTitle, project) categoryItems = ["Breakfasts", "Burritos", "Fish sticks", "Ice cream / Sorbet ", "Juice concentrate ", "Pizza / Pizza Rolls ", "Popsicles", "Fries / Tater tots ", "TV dinners", "Vegetables", "Veggie burgers", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Condiments / Sauces' groupTask = new Task(categoryTitle, project) categoryItems = ["BBQ sauce", "Gravy", "Honey", "Hot sauce", "Jam / Jelly / Preserves", "Ketchup / Mustard", "Mayonnaise", "Pasta sauce", "Relish", "Salad dressing", "Salsa", "Soy sauce", "Steak sauce", "Syrup", "Worcestershire sauce", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Spices & Herbs' groupTask = new Task(categoryTitle, project) categoryItems = ["Basil", "Black pepper", "Cilantro", "Cinnamon", "Garlic", "Ginger", "Mint", "Oregano", "Paprika", "Parsley", "Red pepper", "Salt", "Spice mix", "Vanilla extract", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Canned Foods' groupTask = new Task(categoryTitle, project) categoryItems = ["Applesauce", "Baked beans", "Chili", "Fruit", "Olives", "Tinned meats", "Tuna", "Chicken", "Soups", "Tomatoes", "Veggies", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Dairy' groupTask = new Task(categoryTitle, project) categoryItems = ["Butter / Margarine", "Cottage cheese", "Half & half", "Milk", "Sour cream ", "Whipped cream", "Yogurt", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Cheese' groupTask = new Task(categoryTitle, project) categoryItems = ["Bleu cheese", "Cheddar", "Cottage cheese", "Cream cheese", "Feta", "Goat cheese", "Mozzarella / Provolone", "Parmesan", "Provolone", "Ricotta", "Sandwich slices", "Swiss", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Meat' groupTask = new Task(categoryTitle, project) categoryItems = ["Bacon / Sausage", "Beef", "Chicken", "Ground beef / Turkey", "Ham / Pork", "Hot dogs", "Lunchmeat", "Turkey", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Seafood' groupTask = new Task(categoryTitle, project) categoryItems = ["Catfish", "Crab", "Lobster", "Mussels", "Oysters", "Salmon", "Shrimp", "Tilapia", "Tuna", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Beverages' groupTask = new Task(categoryTitle, project) categoryItems = ["Club soda / Tonic", "Juice", "Soda pop", "Sports drink", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Baked Goods' groupTask = new Task(categoryTitle, project) categoryItems = ["Bagels / Croissants", "Buns / Rolls", "Cake / Cookies", "Donuts / Pastries", "Fresh bread", "Sliced bread", "Pie! Pie! Pie!", "Pita bread", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Baking' groupTask = new Task(categoryTitle, project) categoryItems = ["Baking powder / Soda", "Bread crumbs", "Cake / Brownie mix", "Cake icing / Decorations", "Chocolate chips / Cocoa", "Flour", "Shortening", "Sugar", "Sugar substitute", "Yeast", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Snacks' groupTask = new Task(categoryTitle, project) categoryItems = ["Candy / Gum", "Cookies", "Crackers", "Dried fruit", "Granola bars / Mix", "Nuts / Seeds", "Oatmeal", "Popcorn", "Potato / Corn chips", "Pretzels", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Various Groceries' groupTask = new Task(categoryTitle, project) categoryItems = ["Bouillon cubes", "Cereal", "Coffee / Filters", "Instant potatoes", "Lemon / Lime juice", "Mac & cheese", "Olive oil", "Pancake / Waffle mix", "Pasta", "Peanut butter", "Pickles", "Rice", "Tea", "Vegetable oil", "Vinegar", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) categoryTitle = 'Cleaning Products' groupTask = new Task(categoryTitle, project) categoryItems = ["Air freshener", "Bathroom cleaner", "Bleach / Detergent", "Dish / Dishwasher soap", "Garbage bags", "Glass cleaner", "Mop head", "Vacuum bags", "Sponges / Scrubbers", "…", "…"] categoryItems.forEach(item => {new Task(item, groupTask)}) // SORT TASKS ALPHABETICALLY tasks = project.children tasks.sort((a, b) => { var x = a.name.toLowerCase(); var y = b.name.toLowerCase(); if (x < y) {return -1;} if (x > y) {return 1;} return 0; }) moveTasks(tasks, project) // RETURN OBJECT REFERENCE TO PROJECT return project } const action = new PlugIn.Action(async function(selection, sender){ try { // LOCATE PROJECT BY NAME targetProject = flattenedProjects.byName(projectName) if(targetProject){ // IF FOUND, DISPLAY FLAGGED ITEMS window = document.windows[0] window.focus = [targetProject] window.perspective = Perspective.BuiltIn.Flagged } else { // PROMPT USER WITH OPTION TO BUILD alertTitle = projectName alertMessage = `The project “${projectName}” was not found.` alert = new Alert(alertTitle, alertMessage) alert.addOption("Cancel") alert.addOption("Build Project") buttonIndex = await alert.show() if (buttonIndex === 1){ project = buildProject() projectID = project.id.primaryKey URL.fromString("omnifocus:///task/" + projectID).open() } } } catch(err){ if(!err.causedByUserCancelling){ new Alert(err.name, err.message).show() } } }); action.validate = function(selection, sender){ return true }; return action; })();