2022-05-17 11:06:15 -07:00
|
|
|
<script>
|
|
|
|
|
import {Meteor} from "meteor/meteor";
|
2022-06-13 07:42:26 -07:00
|
|
|
import {onMount} from "svelte";
|
|
|
|
|
import {Sites} from "../api/sites";
|
|
|
|
|
import GridTable from "./GridTable.svelte";
|
|
|
|
|
import {writable} from "svelte/store";
|
|
|
|
|
import TextField from '@smui/textfield';
|
|
|
|
|
import HelperText from '@smui/textfield/helper-text';
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
|
Meteor.subscribe('sites');
|
|
|
|
|
});
|
2022-05-17 11:06:15 -07:00
|
|
|
|
|
|
|
|
const fixRecords = () => {Meteor.call("admin.fixRecords");}
|
2022-06-13 07:42:26 -07:00
|
|
|
|
|
|
|
|
const submitForm = () => {
|
|
|
|
|
Meteor.call('students.loadCsv');
|
|
|
|
|
}
|
|
|
|
|
let files;
|
|
|
|
|
|
|
|
|
|
const siteColumns = [
|
|
|
|
|
{
|
|
|
|
|
key: "_id",
|
|
|
|
|
title: "ID",
|
|
|
|
|
value: v => v._id,
|
|
|
|
|
minWidth: 20,
|
|
|
|
|
weight: 1,
|
|
|
|
|
cls: "id",
|
|
|
|
|
}, {
|
|
|
|
|
key: "name",
|
|
|
|
|
title: "Name",
|
|
|
|
|
value: v => v.name,
|
|
|
|
|
minWidth: 100,
|
|
|
|
|
weight: 1,
|
|
|
|
|
cls: "name",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
const actions = {
|
|
|
|
|
title: "Actions",
|
|
|
|
|
headerWidgets: [
|
|
|
|
|
{icon: "add_box", action: () => {editedSite.set({name: ""});}, tooltip: "Add a new Site."}
|
|
|
|
|
],
|
|
|
|
|
rowWidgets: [
|
|
|
|
|
{icon: "add_circle", action: (v) => {editedSite.set(v)}},
|
|
|
|
|
{icon: "delete", action: (v) => {deleteSite(v)}}
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const deleteSite = site => {
|
|
|
|
|
//TODO:
|
|
|
|
|
};
|
|
|
|
|
let editedSite = writable(null);
|
|
|
|
|
let sites = Sites.find({});
|
|
|
|
|
|
|
|
|
|
const applySiteChanges = () => {
|
|
|
|
|
if($editedSite._id)
|
|
|
|
|
Meteor.call("sites.update", $editedSite._id,$editedSite.name);
|
|
|
|
|
else
|
|
|
|
|
Meteor.call("sites.add", $editedSite.name);
|
|
|
|
|
editedSite.set(null);
|
|
|
|
|
}
|
|
|
|
|
const rejectSiteChanges = () => {
|
|
|
|
|
editedSite.set(null);
|
|
|
|
|
}
|
2022-05-17 11:06:15 -07:00
|
|
|
</script>
|
2022-06-13 07:42:26 -07:00
|
|
|
|
2022-05-17 11:06:15 -07:00
|
|
|
<div class="container">
|
2022-06-13 07:42:26 -07:00
|
|
|
<GridTable bind:rows={sites} columns="{siteColumns}" actions="{actions}" rowKey="{(user) => {return user._id}}" bind:edited="{editedSite}">
|
|
|
|
|
{#if $editedSite}
|
|
|
|
|
<div class="editorContainer">
|
|
|
|
|
<div style="grid-column: 1/span 1">
|
|
|
|
|
<TextField type="text" style="width: 100%" bind:value={$editedSite.name} label="Name">
|
|
|
|
|
<HelperText slot="helper">Provide a unique name for the site.</HelperText>
|
|
|
|
|
</TextField>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button type="button" style="grid-column: 2/span 1;" class="button accept-button material-icons material-symbols-outlined" on:click={applySiteChanges}>
|
|
|
|
|
check
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" style="grid-column: 3/span 1;" class="button reject-button material-icons material-symbols-outlined" on:click={rejectSiteChanges}>
|
|
|
|
|
close
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</GridTable>
|
|
|
|
|
|
|
|
|
|
<!--{#each sites as site}-->
|
|
|
|
|
<!-- <div>{site.name}</div>-->
|
|
|
|
|
<!--{/each}-->
|
|
|
|
|
<!-- <button type="button" on:click={fixRecords}>Fix Records</button>-->
|
|
|
|
|
<form on:submit={submitForm}>
|
|
|
|
|
<input type="file" bind:files={files}/>
|
|
|
|
|
<input type="submit"/>
|
|
|
|
|
</form>
|
2022-05-17 11:06:15 -07:00
|
|
|
</div>
|
2022-06-13 07:42:26 -07:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.editorContainer {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: minmax(10px, 1fr) minmax(3rem, 3rem) minmax(3rem, 3rem);
|
|
|
|
|
}
|
|
|
|
|
.accept-button, .reject-button {
|
|
|
|
|
font-size: .8rem;
|
|
|
|
|
padding: .6rem;
|
|
|
|
|
margin: auto;
|
|
|
|
|
color: white;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
border: 0;
|
|
|
|
|
font-weight: 800;
|
|
|
|
|
alignment: center;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.accept-button {
|
|
|
|
|
background-color: rgba(61, 148, 61, 0.91);
|
|
|
|
|
}
|
|
|
|
|
.reject-button {
|
|
|
|
|
background-color: rgba(176, 64, 64, 0.61);
|
|
|
|
|
}
|
|
|
|
|
.accept-button:hover {
|
|
|
|
|
background-color: rgb(61, 148, 61);
|
|
|
|
|
}
|
|
|
|
|
.reject-button:hover {
|
|
|
|
|
background-color: rgb(176, 64, 64);
|
|
|
|
|
}
|
|
|
|
|
</style>
|