{"size": 1346, "ext": "js", "max_stars_repo_path": "src/front-end/lists/static/js/custom/pages/tags/tags-delete.js", "max_stars_repo_name": "rrickgauer/lists", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/front-end/lists/static/js/custom/pages/tags/tags-delete.js", "max_issues_repo_name": "rrickgauer/lists", "max_issues_repo_issues_event_min_datetime": "2021-12-14T22:30:56.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-15T18:28:27.000Z", "max_forks_repo_path": "src/front-end/lists/static/js/custom/pages/tags/tags-delete.js", "max_forks_repo_name": "rrickgauer/lists", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 67, "max_forks_count": null, "avg_line_length": 31.3023255814, "max_line_length": 74, "alphanum_fraction": 0.4569093611}

import { ApiWrapper } from "../../classes/api-wrapper";
import { TagElements } from "./tag-elements";


/**
 * This class is responsible for deleting tag elements
 */
export class TagDelete
{
    
    /**********************************************************
    Constructor
    **********************************************************/
    constructor(eClickedBtn) {
        this.eClickedBtn = eClickedBtn;
        this.eTagContainer = TagElements.getParentTagElement(eClickedBtn);
        this.tagID = TagElements.getTagID(this.eTagContainer);

        // bind object methods
        this.confirm = this.confirm.bind(this);
        this.delete = this.delete.bind(this);
    }
    
    /**********************************************************
    Make sure the user wants to delete the tag

    Returns a bool:
        true: they confirmed yes they want to delete
        false: they do not want to delete
    **********************************************************/
    confirm() {
        return confirm('Are you sure you want to delete this tag?');
    }
    
    /**********************************************************
    Tell api to delete this tag
    **********************************************************/
    async delete() {
        ApiWrapper.tagsDelete(this.tagID);
        $(this.eTagContainer).remove();
    }
}