|
@@ -36,6 +36,31 @@
|
|
|
<input type="checkbox" bind:checked={nur_aktive}> Nur aufgestellte Schüler anzeigen.
|
|
|
<div class="columns">
|
|
|
<div class="column is-two-thirds">
|
|
|
+ <table class="table is-striped">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>Name</th>
|
|
|
+ <th>Wahlstatus</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ {#each lehrer as l}
|
|
|
+ <tr>
|
|
|
+ <td>{l.name}</td>
|
|
|
+ <td class:has-background-success={l.waehlbar}>
|
|
|
+ wählbar: <input checked={l.waehlbar} type="checkbox" on:click={()=>lehrer_waehlbar(l)}>
|
|
|
+ {#if l.waehlbar}
|
|
|
+ <button class="button is-link tooltip is-tooltip-multiline" data-tooltip={l.info}
|
|
|
+ on:click="{()=>lehrer_edit=l}">Infotext</button>
|
|
|
+ {/if}
|
|
|
+ {#if l===lehrer_edit}
|
|
|
+ <textarea cols="80" rows="10" bind:value={l.info}></textarea><button on:click={lehrer_info}>Speichern</button>
|
|
|
+ {/if}
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ {/each}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
{#each Object.entries(schueler) as [klasse, schuelers]}
|
|
|
<h3 class="title">{klasse}</h3>
|
|
|
<table class="table is-striped">
|
|
@@ -56,8 +81,12 @@
|
|
|
Sprecher: <input checked={s.sprecher} type="checkbox" on:click={()=>check_aktiv(s, 'sprecher')}>
|
|
|
gewählt: <input checked={s.gewaehlt} type="checkbox" on:click={()=>check_aktiv(s, 'gewaehlt')}>
|
|
|
wählbar: <input checked={s.waehlbar} type="checkbox" on:click={()=>check_aktiv(s, 'waehlbar')}>
|
|
|
- {#if s.info || s.nachname || s.email}
|
|
|
- <button class="button is-link tooltip is-tooltip-multiline" data-tooltip={`${s.info || ''} – ${s.Vorname} ${s.nachname || ''} – ${s.email || ''}`}>Infotext</button>
|
|
|
+ {#if s.schuko || s.sprecher}
|
|
|
+ <button class="button is-link tooltip is-tooltip-multiline" data-tooltip={`${s.info || ''} – ${s.Vorname} ${s.nachname || ''} – ${s.email || ''}`}
|
|
|
+ on:click="{()=>edit=s}">Infotext</button>
|
|
|
+ {/if}
|
|
|
+ {#if s===edit}
|
|
|
+ <textarea cols="80" rows="10" bind:value={s.info}></textarea><button on:click={info}>Speichern</button>
|
|
|
{/if}
|
|
|
</td>
|
|
|
</tr>
|
|
@@ -72,8 +101,33 @@
|
|
|
let nur_aktive
|
|
|
let wahlergebnis_schueler = []
|
|
|
let wahlergebnis_lehrer = []
|
|
|
+ let edit
|
|
|
+ let lehrer_edit
|
|
|
+ let lehrer=[]
|
|
|
const { Pool } = R('pg')
|
|
|
const pool = new Pool({ connectionString: privat.mein_bk_db})
|
|
|
+ pool.query(`SELECT * from lehrer`).then(res=>lehrer=res.rows)
|
|
|
+ const lehrer_info = async _ => {
|
|
|
+ const query = `UPDATE lehrer SET info=$2 where id=$1`
|
|
|
+ const values = [lehrer_edit.id, lehrer_edit.info]
|
|
|
+ try {
|
|
|
+ await pool.query(query, values)
|
|
|
+ } catch (e) {console.log(e)}
|
|
|
+ }
|
|
|
+ const info = async _ => {
|
|
|
+ const query = `UPDATE schueler SET info=$2 where id=$1`
|
|
|
+ const values = [edit.id, edit.info]
|
|
|
+ try {
|
|
|
+ await pool.query(query, values)
|
|
|
+ } catch (e) {console.log(e)}
|
|
|
+ }
|
|
|
+ const lehrer_waehlbar = async _ => {
|
|
|
+ const query = `UPDATE lehrer SET waehlbar=$2 where id=$1`
|
|
|
+ const values = [lehrer_edit.id, !lehrer_edit.waehlbar]
|
|
|
+ try {
|
|
|
+ await pool.query(query, values)
|
|
|
+ } catch (e) {console.log(e)}
|
|
|
+ }
|
|
|
const check_aktiv = async (s, art) => {
|
|
|
const query = `INSERT INTO schueler(id, ${art}, vorname, klasse)
|
|
|
VALUES($1, $2, $3, $4)
|