Sfoglia il codice sorgente

teilnehmerlisten und korr infos

burningTyger 5 anni fa
parent
commit
cf76b04a70

+ 8 - 6
components/infos.svelte

@@ -7,9 +7,9 @@
     </div>
   </div>
   <div class="field">
-    <label class="label">Für Klassen</label>
+    <label class="label">Für Klassen – oder alle ('alle' eintippen!)</label>
     <div class="control">
-      <input class="input" type="text" placeholder="z.B. C19A, B19b, ..." bind:value={neu.klasse}>
+      <input class="input" type="text" placeholder="z.B. C19A oder alle" bind:value={neu.klasse}>
     </div>
   </div>
   <div class="field">
@@ -59,6 +59,7 @@
 
 <script>
   export let privat
+  $: console.log(info)
   let neu = {}, info = []
   const { Pool } = R('pg')
   const pool = new Pool({ connectionString: privat.mein_bk_db})
@@ -67,7 +68,8 @@
     const values = [i.text, i.klasse, new Date(), i.id]
     try {
       const res = await pool.query(query, values)
-      info = res.rows
+      i = info.find(e=>e.id === i.id)
+      i = res.rows[0]
     } catch(err) {
       console.log(err.stack)
     }
@@ -77,7 +79,7 @@
     const values = [id]
     try {
       const res = await pool.query(query, values)
-      info = res.rows
+      info = info.filter(e => e.id !== id)
     } catch(err) {
       console.log(err.stack)
     }
@@ -87,13 +89,13 @@
     const values = [neu.text, neu.klasse, new Date()]
     try {
       const res = await pool.query(query, values)
-      info = res.rows
+      info.unshift(res.rows[0])
     } catch(err) {
       console.log(err.stack)
     }
   }
   const get_infos = async () => {
-    const query = `SELECT * FROM infos`
+    const query = `SELECT * FROM infos ORDER BY timestamp DESC`
     try {
       const res = await pool.query(query)
       info = res.rows

+ 7 - 8
components/projektwoche-schueler.svelte

@@ -12,11 +12,11 @@
           </tr>
         </thead>
         <tbody>
-          {#each schuelers as s,i}
-            <tr>
+          {#each schuelers as s}
+            <tr on:click={() => modalset(s)} style="cursor: pointer">
               <td>{s.Name}</td>
               <td>{s.Vorname}</td>
-              <td class={'has-background-'+wahl(s)} on:click={() => modalset(s,i)} style="cursor: pointer">
+              <td class={'has-background-'+wahl(s)}>
                 {`Woche: ${s.woche == null ? '–' : s.woche} Mo/Di: ${s.mo_di == null ? '–' : s.mo_di} Mi/Do ${s.mi_do == null ? '–' : s.mi_do}`}
               </td>
             </tr>
@@ -76,9 +76,9 @@
               <div class="control">
                 <div class="select is-fullwidth">
                   <select bind:value={selected_woche} on:change={wahl_aendern}>
-                    <option value={null}>Kein Projekt gewählt</option>
+                    <option value={null} selected={modal_s.woche === null}>Kein Projekt gewählt</option>
                     {#each projekte.filter(p => p.woche) as p}
-                      <option value={p.id} selected={modal_s.woche}>{`${p.titel} – ${p.leitung} (${p.gewaehlt_woche}/${p.max_teilnehmer}`})</option>
+                      <option value={p.id} selected={modal_s.woche === p.id}>{`${p.titel} – ${p.leitung} (${p.gewaehlt_woche}/${p.max_teilnehmer}`})</option>
                     {/each}
                     <option value={0} selected={modal_s.woche === 0}>Krank/Beurlaubt</option>
                   </select>
@@ -98,7 +98,7 @@
                   <select bind:value={selected_mo_di} on:change={wahl_aendern}>
                     <option value={null}>Kein Projekt gewählt</option>
                     {#each projekte.filter(p => p.mo_di) as p}
-                      <option value={p.id} selected={modal_s.mo_di}>{`${p.titel} – ${p.leitung} (${p.gewaehlt_mo_di}/${p.max_teilnehmer}`})</option>
+                      <option value={p.id} selected={modal_s.mo_di === p.id}>{`${p.titel} – ${p.leitung} (${p.gewaehlt_mo_di}/${p.max_teilnehmer}`})</option>
                     {/each}
                     <option value={0} selected={modal_s.mo_di === 0}>Krank/Beurlaubt</option>
                   </select>
@@ -119,7 +119,7 @@
                     <option value={null}>Kein Projekt gewählt</option>
                     {#each projekte.filter(p => p.mi_do) as p}
                       <option value={p.id} selected={modal_s.mi_do}>
-                        {`${p.titel} – ${p.leitung} (${p.gewaehlt_mi_do}/${p.max_teilnehmer}`})
+                        {`${p.titel} – ${p.leitung} (${p.gewaehlt_mi_do === p.id}/${p.max_teilnehmer}`})
                       </option>
                     {/each}
                     <option value={0} selected={modal_s.mi_do === 0}>Krank/Beurlaubt</option>
@@ -244,7 +244,6 @@
       anwesend_wo = 0, anwesend_modi = 0, anwesend_mido = 0
       Object.entries(schueler).forEach(([k,v]) => {
         const nr = v.length
-        console.log(klassen[k])
         switch (klassen[k]) {
           case null: anwesend_wo += nr; break;
           case 1: anwesend_mido += nr; break;

+ 33 - 0
components/projektwoche-tn-listen.svelte

@@ -0,0 +1,33 @@
+{#each projekte as p}
+  <div class="page" orientation="portrait" size="A4">
+    <div class="main">
+      <h4>{p.titel}</h4>
+      <h5>Teilnehmerliste</h5>
+      <table class="table tabele-narrow">
+        <thead><th></th><th>Name</th><th>Anwesend/Abgemeldet</th></thead>
+        {#each Object.entries(schueler) as [klasse, gruppe]}
+          {#each gruppe.filter(s => [s.woche, s.mo_di, s.mi_do].includes(p.id)) as t,i}
+            <tr>
+              <td>{t.woche === p.id ? 'Mo-Do':''}{t.mo_di === p.id ? 'Mo/Di':''} {t.mi_do === p.id ? 'Mi/Do':''}</td>
+              <td>{t.Name}, {t.Vorname} – {t.Klasse}</td>
+              <td></td>
+            </tr>
+          {/each}
+        {/each}
+      </table>
+    </div>
+  </div>
+{/each}
+<style>
+  @import 'css/main.css';
+</style>
+<script>
+  export let privat, schueler
+  let projekte = []
+  const { Pool } = R('pg')
+  const pool = new Pool({ connectionString: privat.mein_bk_db})
+  function projekte_laden () {
+    pool.query(`SELECT * FROM projekte`, (err, resp) => projekte = resp.rows)
+  }
+  projekte_laden()
+</script>

+ 5 - 3
Übersicht.svelte

@@ -17,9 +17,10 @@
     <div class="tabs">
       <ul>
         <li class:is-active={active === Vouchers} on:click={() => active=Vouchers}>WLAN</li>
-        <li class:is-active={active === ProjektwocheSchueler} on:click={() => active=ProjektwocheSchueler}>Projektwoche Schüler</li>
-        <li class:is-active={active === ProjektwocheLehrer} on:click={() => active=ProjektwocheLehrer}>Projektwoche Lehrer</li>
-        <li class:is-active={active === ProjektwocheDrucksache} on:click={() => active=ProjektwocheDrucksache}>Projektwoche Drucksache</li>
+        <li class:is-active={active === ProjektwocheSchueler} on:click={() => active=ProjektwocheSchueler}>PW Schüler</li>
+        <li class:is-active={active === ProjektwocheLehrer} on:click={() => active=ProjektwocheLehrer}>PW Projekte</li>
+        <li class:is-active={active === ProjektwocheDrucksache} on:click={() => active=ProjektwocheDrucksache}>PW Drucksache</li>
+        <li class:is-active={active === ProjektwocheTnListen} on:click={() => active=ProjektwocheTnListen}>PW Teilnehmerliste</li>
         <li class:is-active={active === SVWahl} on:click={() => active=SVWahl}>SV-Wahl</li>
         <li class:is-active={active === Einstellungen} on:click={() => active=Einstellungen}>Einstellungen</li>
         <li class:is-active={active === Infos} on:click={() => active=Infos}>Infos</li>
@@ -61,6 +62,7 @@
   import ProjektwocheSchueler from './components/projektwoche-schueler.svelte'
   import ProjektwocheLehrer from './components/projektwoche-lehrer.svelte'
   import ProjektwocheDrucksache from './components/projektwoche-drucksache.svelte'
+  import ProjektwocheTnListen from './components/projektwoche-tn-listen.svelte'
   import SVWahl from './components/svwahl.svelte'
   import Einstellungen from './components/einstellungen.svelte'
   import Infos from './components/infos.svelte'