47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { getShopifyProducts, runShopifyOrders } from "./shopifyApi"
|
|
import { fillProductFromTemplate } from "./fillProductFromTemplate"
|
|
import { createMissingPhotoFolders } from "./createMissingPhotoFolders"
|
|
import { matchProductToShopify } from "./match"
|
|
import { reinstallTriggers } from "./triggers"
|
|
|
|
export function initMenu() {
|
|
let ui = SpreadsheetApp.getUi()
|
|
ui.createMenu("BLM")
|
|
.addSubMenu(
|
|
ui
|
|
.createMenu("This row...")
|
|
.addItem("Fill out product from template", fillProductFromTemplate.name)
|
|
.addItem("Match product to Shopify", matchProductToShopifyHandler.name)
|
|
)
|
|
.addSeparator()
|
|
.addSubMenu(
|
|
ui
|
|
.createMenu("Bulk operations...")
|
|
.addItem("Create missing photo folders", createMissingPhotoFolders.name)
|
|
.addItem("Run Shopify Orders", runShopifyOrders.name)
|
|
.addItem("Get Shopify Products", getShopifyProducts.name)
|
|
)
|
|
.addSeparator()
|
|
.addSubMenu(
|
|
ui
|
|
.createMenu("Utilities...")
|
|
.addItem("Reauthorize script", reauthorizeScript.name)
|
|
.addItem("Reinstall triggers", reinstallTriggers.name)
|
|
)
|
|
.addToUi()
|
|
}
|
|
|
|
export function matchProductToShopifyHandler() {
|
|
var sheet = SpreadsheetApp.getActive().getActiveSheet()
|
|
if (sheet.getName() !== "product_inventory") {
|
|
console.log("skipping edit on sheet " + sheet.getName())
|
|
return
|
|
}
|
|
let row = SpreadsheetApp.getCurrentCell().getRow()
|
|
matchProductToShopify(row)
|
|
}
|
|
|
|
export function reauthorizeScript() {
|
|
ScriptApp.invalidateAuth()
|
|
}
|