v1 of deadline feature
This commit is contained in:
@@ -18,11 +18,12 @@
|
|||||||
import TextField from '../../../../Form/TextField.svelte';
|
import TextField from '../../../../Form/TextField.svelte';
|
||||||
import TextArea from '../../../../Form/TextArea.svelte';
|
import TextArea from '../../../../Form/TextArea.svelte';
|
||||||
import Checkbox from '../../../../Form/Checkbox.svelte';
|
import Checkbox from '../../../../Form/Checkbox.svelte';
|
||||||
|
import DateTime from '../../../../Form/DateTime.svelte';
|
||||||
import RadioItem from '../../../../Form/RadioItem.svelte';
|
import RadioItem from '../../../../Form/RadioItem.svelte';
|
||||||
import IconButton from '../../../../IconButton/index.svelte';
|
import IconButton from '../../../../IconButton/index.svelte';
|
||||||
import ErrorMessage from '../../../../ErrorMessage/index.svelte';
|
import ErrorMessage from '../../../../ErrorMessage/index.svelte';
|
||||||
import PrimaryButton from '../../../../PrimaryButton/index.svelte';
|
import PrimaryButton from '../../../../PrimaryButton/index.svelte';
|
||||||
import Dropdown from '../../../../Dropdown/index.svelte';
|
import EditContent from '../../../../EditContent/index.svelte';
|
||||||
import { VARIANTS } from '../../../../PrimaryButton/constants';
|
import { VARIANTS } from '../../../../PrimaryButton/constants';
|
||||||
import Select from '../../../../Form/Select.svelte';
|
import Select from '../../../../Form/Select.svelte';
|
||||||
import QuestionContainer from '../../../../QuestionContainer/index.svelte';
|
import QuestionContainer from '../../../../QuestionContainer/index.svelte';
|
||||||
@@ -75,17 +76,22 @@
|
|||||||
placeholder="Title"
|
placeholder="Title"
|
||||||
bind:value={$questionnaire.title}
|
bind:value={$questionnaire.title}
|
||||||
className="mb-2"
|
className="mb-2"
|
||||||
onChange={() => {
|
onChange={() => ($questionnaire.is_title_dirty = true)}
|
||||||
console.log('title dirty');
|
|
||||||
$questionnaire.is_title_dirty = true;
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<TextArea
|
<DateTime
|
||||||
placeholder="Description and Rules"
|
label="Due by"
|
||||||
|
bind:value={$questionnaire.due_by}
|
||||||
|
placeholder="2021-03-25"
|
||||||
|
className="w-50"
|
||||||
|
useTime={true}
|
||||||
|
onChange={() => ($questionnaire.is_due_by_dirty = true)}
|
||||||
|
/>
|
||||||
|
<EditContent
|
||||||
|
writeLabel="Description"
|
||||||
bind:value={$questionnaire.description}
|
bind:value={$questionnaire.description}
|
||||||
onChange={() => {
|
placeholder="Start typing your lesson"
|
||||||
$questionnaire.is_description_dirty = true;
|
textAreaHeight="100px"
|
||||||
}}
|
onInputChange={() => ($questionnaire.is_description_dirty = true)}
|
||||||
/>
|
/>
|
||||||
</QuestionContainer>
|
</QuestionContainer>
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
.from('exercise')
|
.from('exercise')
|
||||||
.select(
|
.select(
|
||||||
`
|
`
|
||||||
id, title, description,
|
id, title, description, due_by,
|
||||||
questions:question(
|
questions:question(
|
||||||
*,
|
*,
|
||||||
options:option(*),
|
options:option(*),
|
||||||
@@ -89,6 +89,7 @@
|
|||||||
|
|
||||||
data.is_title_dirty = false;
|
data.is_title_dirty = false;
|
||||||
data.is_description_dirty = false;
|
data.is_description_dirty = false;
|
||||||
|
data.is_due_by_dirty = false;
|
||||||
|
|
||||||
questionnaire.set(data);
|
questionnaire.set(data);
|
||||||
console.log('getExercise', exerciseId, $questionnaire);
|
console.log('getExercise', exerciseId, $questionnaire);
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ export const questionnaireValidation = writable({});
|
|||||||
|
|
||||||
export const questionnaire = writable({
|
export const questionnaire = writable({
|
||||||
title: '',
|
title: '',
|
||||||
|
due_by: '',
|
||||||
|
is_due_by_dirty: false,
|
||||||
is_title_dirty: false,
|
is_title_dirty: false,
|
||||||
description: '',
|
description: '',
|
||||||
is_description_dirty: false,
|
is_description_dirty: false,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
export let value;
|
export let value;
|
||||||
export let placeholder = ``;
|
export let placeholder = ``;
|
||||||
export let onInputChange = () => {};
|
export let onInputChange = () => {};
|
||||||
|
export let textAreaHeight = '';
|
||||||
const activeClassName = 'border-b-2 border-blue-700';
|
const activeClassName = 'border-b-2 border-blue-700';
|
||||||
|
|
||||||
const handleTabClick = (tab) => () => {
|
const handleTabClick = (tab) => () => {
|
||||||
@@ -33,12 +34,13 @@
|
|||||||
<textarea
|
<textarea
|
||||||
bind:value
|
bind:value
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
style="height: {textAreaHeight}"
|
||||||
class="border border-gray rounded-md p-2"
|
class="border border-gray rounded-md p-2"
|
||||||
on:change={onInputChange}
|
on:change={onInputChange}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<article class="preview prose prose-sm sm:prose p-2">
|
<article class="preview prose prose-sm sm:prose p-2">
|
||||||
{@html marked(value)}
|
{@html marked(value || 'Nothing to preview')}
|
||||||
</article>
|
</article>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -81,7 +83,6 @@
|
|||||||
<style>
|
<style>
|
||||||
.root {
|
.root {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 200px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-item {
|
.form-item {
|
||||||
|
|||||||
@@ -2,14 +2,17 @@
|
|||||||
export let label;
|
export let label;
|
||||||
export let placeholder;
|
export let placeholder;
|
||||||
export let value;
|
export let value;
|
||||||
|
export let className = '';
|
||||||
|
export let onChange = () => {}; // This is to know if element is 'dirty'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="block">
|
<label class="block {className}">
|
||||||
<span class="text-gray-700">{label}</span>
|
<span class="text-gray-700">{label}</span>
|
||||||
<input
|
<input
|
||||||
bind:value
|
bind:value
|
||||||
{placeholder}
|
{placeholder}
|
||||||
type="date"
|
type="date"
|
||||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
|
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
|
||||||
|
on:blur={onChange}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<script>
|
||||||
|
export let label;
|
||||||
|
export let placeholder;
|
||||||
|
export let value;
|
||||||
|
export let className = '';
|
||||||
|
export let onChange = () => {}; // This is to know if element is 'dirty'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<label class="block {className}">
|
||||||
|
<span class="text-gray-700">{label}</span>
|
||||||
|
<input
|
||||||
|
bind:value
|
||||||
|
{placeholder}
|
||||||
|
type="datetime-local"
|
||||||
|
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
|
||||||
|
on:blur={onChange}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
@@ -178,16 +178,19 @@ export async function upsertExercise(questionnaire, exerciseId) {
|
|||||||
questions,
|
questions,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
due_by,
|
||||||
is_title_dirty,
|
is_title_dirty,
|
||||||
is_description_dirty,
|
is_description_dirty,
|
||||||
|
is_due_by_dirty,
|
||||||
} = questionnaire;
|
} = questionnaire;
|
||||||
|
|
||||||
if (is_description_dirty || is_title_dirty) {
|
if (is_description_dirty || is_title_dirty || is_due_by_dirty) {
|
||||||
await supabase
|
await supabase
|
||||||
.from('exercise')
|
.from('exercise')
|
||||||
.update({
|
.update({
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
due_by,
|
||||||
})
|
})
|
||||||
.match({ id: exerciseId });
|
.match({ id: exerciseId });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user