AssignedDocumentMenuItem
A menu item that provides assigned document submission functionality.
Declaration
@objc class AssignedDocumentMenuItemOverview
AssignedDocumentMenuItem enables students to submit and withdraw assigned documents directly from AppKit menus. The menu element loads asynchronously, fetching document metadata from ClassKit and displaying the appropriate action based on the current submission status. The element shows an in-line spinner during both initial loading and submission processing.
The following example shows how to create an assigned document menu item and customize its behavior with validation and completion actions:
let menuItem = AssignedDocumentMenuItem(
documentURL: documentURL,
willSubmit: { url in
// Validate the assigned document before submission
guard await validateDocument(url) else {
await showAlert("Please complete all sections before submitting")
return false // Prevents submission
}
return true // Allows submission to continue
},
didSubmit: { url in
// Handle successful submission
logEvent("Assigned document submitted successfully!")
}
)
// Add the configured item to the menu
menu.addItem(menuItem)