class AddCardViewController extends TimeCardsViewController { viewDidLoad() { this.reset(); } /** * Preselects the specified category. */ setCategory(categoryId) { this.cardCategorySelectController.element.value = categoryId; } 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, id_category: this.cardCategorySelect.value, id_project: this.cardProjectSelect.value }; TimeCards.dataManager.store("card", this.creatingCardData, this.onCardCreated.bind(this)); } onCardCreated(cardId, card) { 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.setAttribute("disabled", "true"); } onTitleFieldChanged(event) { if (this.cardTitleField.value == "") { this.doneButton.setAttribute("disabled", "true"); } else { this.doneButton.removeAttribute("disabled"); } } } UIKit.registerViewControllerType(AddCardViewController);