mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
10 lines
1.4 KiB
JavaScript
Vendored
10 lines
1.4 KiB
JavaScript
Vendored
/**
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/class n{constructor(){this.parentElement=document.querySelector(".form-check-parent"),this.parentForm=document.getElementById("bulkActions")}watchCheckboxes(e){document.querySelectorAll(".child-hidden-input").forEach(t=>t.remove()),document.querySelectorAll(".form-check-child").forEach(t=>{e.checked?(t.checked=e.checked,this.processChildItem(t,document.getElementById("bulkActions"))):(t.checked=!1,document.querySelectorAll(".child-hidden-input").forEach(r=>r.remove()))})}processChildItem(e,t,r={}){if(r.hasOwnProperty("single")&&document.querySelectorAll(".child-hidden-input").forEach(l=>l.remove()),e.checked===!1){let l=document.querySelectorAll("input.child-hidden-input");for(let d of l)d.value==e.dataset.value&&d.remove();return}let c=document.createElement("INPUT");c.setAttribute("name","purchase_orders[]"),c.setAttribute("value",e.dataset.value),c.setAttribute("class","child-hidden-input"),c.hidden=!0,t.append(c)}handle(){this.parentElement.addEventListener("click",()=>{this.watchCheckboxes(this.parentElement)});for(let e of document.querySelectorAll(".form-check-child"))e.addEventListener("click",()=>{this.processChildItem(e,this.parentForm)})}}new n().handle();
|