<commit_before>//
//  AddFavoriteViewController.swift
//  FlavorFinder
//
//  Created by <NAME> on 2/8/16.
//  Copyright © 2016 TeamFive. All rights reserved.
//
//  Eventually, when we look to having add ingredient / add match capabilities,
//  we may want to abstract out some of this for a superclass since visually
//  these pages might be similar.
//

import Foundation
import Parse
import UIKit

class AddFavoriteViewController: SearchIngredientsViewController {
    
    // MARK: Properties:
    let pageTitle = "Add to Favorites"
    
    // MARK: connections:

    @IBOutlet weak var promptLabel: UILabel!
    
    @IBOutlet weak var addIngredientSearchBar: UISearchBar!
    
    @IBOutlet weak var searchTableView: UITableView!
    
    // MARK: Override methods: ----------------------------------------------
    
    /* viewDidLoad:
    */
    override func viewDidLoad() {
        // Assign values to parent class variables
        ingredientSearchBar = addIngredientSearchBar
        searchTable = searchTableView
        navTitle = pageTitle
        
        // Call super
        super.viewDidLoad()
    }
    
    /* viewDidAppear:
    */
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
    }
    
    // MARK: Overriding parent class functions ------------------------------
    
    /* gotSelectedIngredient
    - handle selection of ingredient in search: add to favs if not already in favs
    */
    override func gotSelectedIngredient(selected: PFIngredient) {
//        var favList = listObject.objectForKey(ingredientsColumnName) as! [PFIngredient]
//        if favList.contains(selected) && selected.isDataAvailable() {
//            addIngredientPromptLabel.text = "\(selected.name)\(alreadyContains)"
//        } else {
//            userList.append(selected)
//            listObject.setObject(userList, forKey: ingredientsColumnName)
//            listObject.saveInBackground()
//            if selected.isDataAvailable() {
//                addIngredientPromptLabel.text = "Added \(selected.name)"
//            }
//        }
    }
    
}<commit_msg>:fish: functionality 100% for add to favs page<commit_after>//
//  AddFavoriteViewController.swift
//  FlavorFinder
//
//  Created by <NAME> on 2/8/16.
//  Copyright © 2016 TeamFive. All rights reserved.
//
//

import Foundation
import Parse
import UIKit

class AddFavoriteViewController: SearchIngredientsViewController {
    
    // MARK: Properties:
    let pageTitle = "Add to Favorites"
    let alreadyContainsText = " is already in your favorites"

    // MARK: connections:
    @IBOutlet weak var promptLabel: UILabel!
    @IBOutlet weak var addIngredientSearchBar: UISearchBar!
    @IBOutlet weak var searchTableView: UITableView!
    
    // MARK: Override methods: ----------------------------------------------
    
    /* viewDidLoad:
    */
    override func viewDidLoad() {
        // Assign values to parent class variables
        ingredientSearchBar = addIngredientSearchBar
        searchTable = searchTableView
        navTitle = pageTitle
        
        // Call super
        super.viewDidLoad()
    }
    
    // MARK: Overriding parent class functions ------------------------------
    
    /* gotSelectedIngredient
    - handle selection of ingredient in search: add to favs if not already in favs
    */
    override func gotSelectedIngredient(selected: PFIngredient) {
        if currentUser != nil {
            if isFavoriteIngredient(currentUser!, ingredient: selected) != nil {
                if selected.isDataAvailable() {
                    promptLabel.text = "\(selected.name)\(alreadyContainsText)"
                }
            } else {
                if selected.isDataAvailable() {
                    promptLabel.text = "Added \(selected.name)"
                    favoriteIngredient(currentUser!, ingredient: selected)
                }
            }
        } else {
            print("ERROR: Accessing add-to-fav page without being logged in!")
        }
    }
    
}
{'fraction_non_alphanumeric': 0.12193308550185873, 'fraction_numerical': 0.004708798017348203, 'mean_word_length': 1.9567765567765567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016246', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1071, 'n_words': 289}