Skip to content
Snippets Groups Projects
management.js 1.89 KiB
Newer Older
  • Learn to ignore specific revisions
  • // Imports
    import * as Auth from "/services/auth/auth.js";
    import * as Election from "/components/management/election.js";
    import * as Round from "/components/management/round.js";
    
    // DOM elements
    
    // local variables
    let current_user;
    
    export async function mount(where) {
      const managementPage = new Management();
      await managementPage.mount(where);
    }
    
    class Management {
      constructor() {}
    
      async mount(where) {
        const mountpoint = where;
        document.getElementById(mountpoint).innerHTML = /* HTML */ `
          <div class="tabs is-boxed is-toggle is-fullwidth">
            <ul>
              <li id="election" class="is-active">
                <a>
                  <span class="icon is-small"
                    ><i class="fas fa-vote-yea" aria-hidden="true"></i
                  ></span>
                  <span>Election</span>
                </a>
              </li>
              <li id="round">
                <a>
                  <span class="icon is-small"
                    ><i class="fas fa-calendar" aria-hidden="true"></i
                  ></span>
                  <span>Tour</span>
                </a>
              </li>
            </ul>
          </div>
          <section class="section" id="management-section" style="margin-bottom: 230px;"></section>
        `;
        current_user = await Auth.GetUser();
        this.handleDom();
        document.getElementById("election").click()
    
      }
    
      handleDom(){
          document.getElementById("election").addEventListener("click", async function (){
            await Election.mount("management-section");
            document.getElementById("election").setAttribute("class", "is-active")
            document.getElementById("round").setAttribute("class", "")
        });
        document.getElementById("round").addEventListener("click", async function (){
            await Round.mount("management-section");
            document.getElementById("election").setAttribute("class", "")
            document.getElementById("round").setAttribute("class", "is-active")
          });
      }
    }