class AddCardViewController extends OnTimeViewController { viewDidLoad() { this.reset(); } /** * Preselects the specified category. */ setCategory(categoryKey) { this.cardCategorySelectController.element.value = categoryKey; } onCancelButtonPressed(event) { this.dismissModally(); } onDoneButtonPressed(event) { if (this.creatingCardData) { return; } if (!this.cardProjectSelect.value) { alert("You must specify a project."); return; } if (!this.cardTitleField.value) { alert("You must specify a card title."); return; } if (!this.cardCategorySelect.value) { alert("You must specify a category."); return; } this.creatingCardData = { title: this.cardTitleField.value, description: this.cardDescriptionField.value, category_key: this.cardCategorySelect.value, project_key: this.cardProjectSelect.value }; var createCardRequest = new Request(OnTime.REQUEST_URI + "Card/Create", Request.POST, this.cardCreated.bind(this), this.cardCreationError.bind(this)); createCardRequest.send(this.creatingCardData); } cardCreated(cardKey) { this.creatingCardData.card_key = cardKey; this.cardCollectionView.createCard(this.creatingCardData); this.reset(); this.dismissModally(); } cardCreationError(request, status, error) { this.reset(); } reset() { this.creatingCardData = null; this.cardTitleField.value = null; this.cardDescriptionField.value = null; this.cardCategorySelect.value = null; this.cardProjectSelect.value = null; this.doneButton.disabled = true; } onTitleFieldChanged(event) { if (this.cardTitleField.value == "") { this.doneButton.disabled = true; } else { this.doneButton.disabled = false; } } } UIKit.registerViewControllerType(AddCardViewController);