Skip to content

Commit c8cca5c

Browse files
Merge pull request #284 from RSE-Sheffield/fix/add-drag-handle
Use drag handle instead of entire div for drag event
2 parents ab059be + fc0742a commit c8cca5c

16 files changed

+264
-100
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default ts.config(
4747
'svelte/require-each-key': 'warn',
4848
'@typescript-eslint/no-unused-vars' : 'warn',
4949
'svelte/no-at-html-tags': 'warn',
50+
"no-import-assign": "off",
5051
}
5152
}
5253
);

survey/templates/survey/report.html

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,28 @@ <h1><i class='bx bxs-report'></i> Report: {{ survey.name }}</h1>
1010

1111

1212
<div class="mb-3">
13+
14+
<h2>Summary Ranking Matrix</h2>
15+
<div class="sort-response-summary-matrix"
16+
data-json-config-id="configData"
17+
data-json-responses-id="responsesData"></div>
18+
19+
<h3>Report sections</h3>
20+
<ul>
21+
{% for section in sections %}
22+
{% if section.section_config.type != "consent" %}
23+
<li><a href="#page-section-{{ forloop.counter0 }}">{{ section.section_config.title }}</a></li>
24+
{% endif %}
25+
{% endfor %}
26+
27+
</ul>
28+
29+
1330
{% for section in sections %}
1431
{% if section.section_config.type != "consent" %}
32+
<div class="page-break"></div>
1533
<div>
16-
<h2>{{ section.section_config.title }}</h2>
34+
<h2 id="page-section-{{ forloop.counter0 }}">{{ section.section_config.title }}</h2>
1735
</div>
1836
<div>
1937
<div
@@ -47,10 +65,7 @@ <h3>Improvement plan</h3>
4765
{% endif %}
4866
{% endfor %}
4967

50-
<h2>Summary Ranking Matrix</h2>
51-
<div class="sort-response-summary-matrix"
52-
data-json-config-id="configData"
53-
data-json-responses-id="responsesData"></div>
68+
5469
</div>
5570

5671

@@ -110,10 +125,6 @@ <h2>Summary Ranking Matrix</h2>
110125
page-break-after: avoid;
111126
}
112127

113-
h2 {
114-
break-before: always;
115-
}
116-
117128
@page {
118129
size: a3;
119130
}
@@ -123,6 +134,10 @@ <h2>Summary Ranking Matrix</h2>
123134
background: #fff;
124135
}
125136

137+
.page-break {
138+
break-before: always;
139+
}
140+
126141
.container {
127142
min-width: 992px !important;
128143
}
Lines changed: 54 additions & 0 deletions
Loading

ui_components/src/lib/components/SurveyConfigurator.svelte

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,55 @@
1+
<script lang="ts" module>
2+
import type {SurveyConfig} from "../interfaces.ts";
3+
4+
export function getDefaultSurveyConfig(){
5+
return {
6+
sections: [],
7+
} as SurveyConfig;
8+
9+
}
10+
</script>
111
<script lang="ts">
212
313
import * as _ from "lodash-es"
414
import SectionComponent, {getDefaultSectionConfig} from "./input/SectionComponent.svelte";
515
16+
interface Props {
17+
config: SurveyConfig;
18+
editable?: boolean;
19+
sectionTypeEditable?: boolean;
20+
sectionEditable?: boolean;
21+
}
22+
623
let {
724
config = $bindable(),
825
editable = true,
926
sectionTypeEditable = true,
1027
sectionEditable = true,
11-
} = $props();
12-
13-
if(config == null || config === undefined){
14-
config = {}
15-
}
16-
17-
if(!("sections" in config)){
18-
config.sections = [];
28+
}: Props = $props();
29+
30+
if(config === null || config === undefined){
31+
config = getDefaultSurveyConfig();
32+
} else if(!("sections" in config)){
33+
config = {
34+
...getDefaultSurveyConfig(),
35+
...config
36+
};
1937
}
2038
2139
// Keeps track of all section components
2240
// when components are deleted the derived property filters this out
23-
let _sectionComponents = $state([]);
41+
let _sectionComponents: SectionComponent[] = $state([]);
2442
let sectionComponents = $derived(_sectionComponents.filter(Boolean));
2543
2644
function addSection() {
2745
config.sections.push(getDefaultSectionConfig());
2846
}
2947
30-
function deleteSection(index){
48+
function deleteSection(index: number){
3149
config.sections.splice(index, 1);
3250
}
3351
34-
function handleMoveRequest(srcSectionIndex, srcFieldIndex, destSectionIndex, destFieldIndex){
52+
function handleMoveRequest(srcSectionIndex: number, srcFieldIndex: number, destSectionIndex: number, destFieldIndex: number){
3553
if(!editable || srcSectionIndex < 0 || destSectionIndex < 0 || srcFieldIndex < 0)
3654
return;
3755

ui_components/src/lib/components/SurveyDataView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
return generateStatsFromSurveyResponses(config, filteredResponses);
2626
})
2727
28-
function handleFilterChange(changedFilteredResponses) {
28+
function handleFilterChange(changedFilteredResponses: SurveyResponseBatch) {
2929
filteredResponses = changedFilteredResponses;
3030
}
3131

ui_components/src/lib/components/SurveyResponseComponent.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
let isValid = $state();
1212
let isInvalid = $state();
1313
14-
function setIsValid(valid) {
14+
function setIsValid(valid: boolean) {
1515
isValid = valid;
1616
isInvalid = !valid;
1717
}
@@ -23,7 +23,7 @@
2323
2424
// Keeps track of all section components
2525
// when components are deleted the derived property filters this out
26-
let currentSectionComponent = $state();
26+
let currentSectionComponent: SectionComponent | undefined = $state();
2727
2828
// Value in plaintext for submitting to the backend
2929
let valueStr = $derived(JSON.stringify(value))
@@ -37,7 +37,7 @@
3737
let currentPage = $state(0);
3838
3939
function validate() {
40-
const currentPageValidates = currentSectionComponent.validate();
40+
const currentPageValidates = currentSectionComponent?.validate() ?? false;
4141
setIsValid(currentPageValidates)
4242
return currentPageValidates;
4343
}
@@ -58,7 +58,7 @@
5858
}
5959
}
6060
61-
function onSubmitHandler(e) {
61+
function onSubmitHandler(e: Event) {
6262
if (!validate()) {
6363
// Don't submit if there's still an error on the page
6464
e.preventDefault();

ui_components/src/lib/components/input/Checkbox.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script>
1+
<script lang="ts">
22
import {getUniqueIDArray} from "../../misc.svelte.ts";
33
import DOMPurify from "dompurify";
44
@@ -9,7 +9,7 @@
99
let isValid = $state(false);
1010
let isInvalid = $state(false);
1111
12-
function setIsValid(valid) {
12+
function setIsValid(valid: boolean) {
1313
isValid = valid;
1414
isInvalid = !valid;
1515
}

0 commit comments

Comments
 (0)