-
Notifications
You must be signed in to change notification settings - Fork 4
/
PropertySearchList.svelte
80 lines (66 loc) · 1.69 KB
/
PropertySearchList.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{#if numProperties > 0}
<div>
{numProperties} properties
({numSearchableProperties === numProperties ? 'all' : numSearchableProperties} searchable):
{#if numSearchableProperties == 0}
<label><input type="checkbox" bind:checked="propertySearchOverride">Override API</label>
{/if}
</div>
<table>
{#each Object.entries(properties) as [prop, { searchable, datatype }]}
<tr>
<td style="width: 105px; max-width: 105px; overflow: hidden;">
{prop}
</td>
{#if searchable || propertySearchOverride}
<td>
<PropertySearchField
prop={prop}
datatype={datatype}
initial={propertySearch[prop]}
on:update="updatePropertySearchField(event)"
/>
</td>
{:else}
<td></td>
{/if}
</tr>
{/each}
</table>
{/if}
<script>
export default {
data() {
return {
properties: null,
propertySearch: null
}
},
components: {
PropertySearchField: './PropertySearchField.svelte'
},
computed: {
numProperties: ({ properties }) => {
return properties ? Object.values(properties).length : 0;
},
numSearchableProperties: ({ properties }) => {
return properties ? Object.values(properties).filter(p => p.searchable).length : 0;
},
},
methods: {
updatePropertySearchField({ prop, values }) {
if (!prop) {
return;
}
const { propertySearch } = this.get();
if (values.op) {
propertySearch[prop] = { ...values };
}
else {
delete propertySearch[prop];
}
this.set({ propertySearch });
},
}
};
</script>