<commit_before>Polymer({
    is: 'book-lookup',

    /**
     * @description - properties
     */
    properties: {

        /**
         * @description - Model that governing the display
         * @value : Object
         */
        model: {
            type: Object,
            value: {
                "searchResults": [],
                "hideSuggestion": false,
                "hideButtons": true,
                "hideResults": true
            }
        },

        /**
         * @description - List of books selected for bulk update
         * @value : Object { "BookId" : bookObject }
         */
        selectedBookList: {
            type: Object,
            value: {}
        },

        /**
         * @description - Search query from user
         * @value : String
         */
        userInput: {
            type: String,
            observer: "onUserType"
        }
    },

    listeners: {
        "refreshList": "_cleanUp",
        "ONSELECTED": "onBookSelected",
        "ONUNSELECTED": "onBookUnselected",
        "onSearchSuccess": "onSearchSuccess",
        "onUpdateSuccess": "onUpdateSuccess",
        "onBookShelfChanged": "onBookShelfChanged"
    },

    /**
     * @description - Cleans this.userInput & this.selectedBookList
     * @returns null
     */
    _cleanUp: function() {
        this.set("userInput", "");
        this.set("selectedBookList", {});
        return null;
    },

    /**
     * @description - handler for ONSELECTED event from child element
     * @description - Injects the selected book into selectedBookList object
     * @eventListener
     * @param {object} event - ONSELECTED event object
     * @param {object} detail - Additional detail from same event
     * @returns null
     */
    onBookSelected: function(event, detail) {
        var propName = "selectedBookList" + "." + detail.book.id;
        this.set(propName, detail.book);
        return null;
    },

    /**
     * @description - handler for ONUNSELECTED event from child element
     * @description - Removes the unselected book from selectedBookList object
     * @eventListener
     * @param {object} event - ONUNSELECTED event object
     * @param {object} detail - Additional detail from same event
     * @returns null
     */
    onBookUnselected: function(event, detail) {
        var propName = "selectedBookList" + "." + detail.book.id;
        this.set(propName, undefined);
        return null;
    },

    /**
     * @description - Wrapper for BooksApi.searchBook
     * @description - observer for this.userInput property
     * @observer
     * @param {string} userInput - user typed input
     * @returns null
     */
    onUserType: function(userInput) {
        if(this.BooksApi)
          this.BooksApi.searchBook(userInput);
        return null;
    },

    /**
     * @description - Takes bookList and check for null
     * @description - If Empty, throws an alert message
     * @validation
     * @param {object} selectedBookList - List of books selected for bulk update
     * @returns boolean isEmpty or not
     */
    isSelectedBookListEmpty : function( selectedBookList ) {
      var isEmpty = true;
      //check for Empty object
      for(var bookId in selectedBookList)
        if(typeof bookId !== "undefined"){
           isEmpty = false;
           break;
        }

      //throws alertbox
      if(isEmpty) alert("Please select at least 1 book");<commit_msg>Fix: User tries to bulk update w/o selecting a book<commit_after>Polymer({
    is: 'book-lookup',

    /**
     * @description - properties
     */
    properties: {

        /**
         * @description - Model that governing the display
         * @value : Object
         */
        model: {
            type: Object,
            value: {
                "searchResults": [],
                "hideSuggestion": false,
                "hideButtons": true,
                "hideResults": true
            }
        },

        /**
         * @description - List of books selected for bulk update
         * @value : Object { "BookId" : bookObject }
         */
        selectedBookList: {
            type: Object,
            value: {}
        },

        /**
         * @description - Search query from user
         * @value : String
         */
        userInput: {
            type: String,
            observer: "onUserType"
        }
    },

    listeners: {
        "refreshList": "_cleanUp",
        "ONSELECTED": "onBookSelected",
        "ONUNSELECTED": "onBookUnselected",
        "onSearchSuccess": "onSearchSuccess",
        "onUpdateSuccess": "onUpdateSuccess",
        "onBookShelfChanged": "onBookShelfChanged"
    },

    /**
     * @description - Cleans this.userInput & this.selectedBookList
     * @returns null
     */
    _cleanUp: function() {
        this.set("userInput", "");
        this.set("selectedBookList", {});
        return null;
    },

    /**
     * @description - handler for ONSELECTED event from child element
     * @description - Injects the selected book into selectedBookList object
     * @eventListener
     * @param {object} event - ONSELECTED event object
     * @param {object} detail - Additional detail from same event
     * @returns null
     */
    onBookSelected: function(event, detail) {
        var propName = "selectedBookList" + "." + detail.book.id;
        this.set(propName, detail.book);
        return null;
    },

    /**
     * @description - handler for ONUNSELECTED event from child element
     * @description - Removes the unselected book from selectedBookList object
     * @eventListener
     * @param {object} event - ONUNSELECTED event object
     * @param {object} detail - Additional detail from same event
     * @returns null
     */
    onBookUnselected: function(event, detail) {
        var propName = "selectedBookList" + "." + detail.book.id;
        this.set(propName, undefined);
        return null;
    },

    /**
     * @description - Wrapper for BooksApi.searchBook
     * @description - observer for this.userInput property
     * @observer
     * @param {string} userInput - user typed input
     * @returns null
     */
    onUserType: function(userInput) {
        if(this.BooksApi)
          this.BooksApi.searchBook(userInput);
        return null;
    },

    /**
     * @description - Takes bookList and check for null
     * @description - If Empty, throws an alert message
     * @validation
     * @param {object} selectedBookList - List of books selected for bulk update
     * @returns boolean isEmpty or not
     */
    isSelectedBookListEmpty : function( selectedBookList ) {
      var isEmpty = true;
      //check for Empty object
      for(var bookId in selectedBookList)
        if(typeof selectedBookList[bookId] !== "undefined"){
           isEmpty = false;
           break;
        }

      //throws alertbox
      if(isEmpty) alert("Please select at least 1 book");
{'fraction_non_alphanumeric': 0.10712217718587146, 'fraction_numerical': 0.00028951939779965256, 'mean_word_length': 1.9066049642406395, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 3, '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': '7647098', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1817, 'n_words': 506}