forked from letsblockit/letsblockit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathview-filter.hbs
121 lines (117 loc) · 6.53 KB
/
view-filter.hbs
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<div class="row">
<div class="col-12 col-lg-2 order-last pt-5 pt-lg-0">
<hr class="d-lg-none"/>
<nav class="navbar navbar-light flex-column align-items-stretch">
<span class="navbar-brand">
<a class="nav-link" href="{{href "list-filters" ""}}">← Back to list</a>
</span>
{{#with (avatars filter.contributors)}}
<span class="navbar-brand mt-3 mb-1">Contributors:</span>
{{>contributors}}
{{/with}}
<span class="navbar-brand mt-3">Filter tags:</span>
<nav class="nav nav-pills flex-column">
<span class="nav-link">{{#each filter.tags}}{{{tag this}}}{{/each}}</span>
</nav>
</nav>
</div>
<div class="col col-lg-10">
<h2>{{filter.title}}</h2>
{{{ filter.description }}}
{{#if filter.params}}
<div class="mt-4 card shadow-sm">
<div class="card-header">Build your customized content filter:</div>
<form id="filter_input" class="card-body" method="POST" action="#output-card"
hx-trigger="input delay:250ms"
hx-post="{{href "view-filter-render" filter.name}}"
hx-target="#output-card"
hx-swap="outerHTML">
{{{csrf @root}}}
{{#each filter.params}}
{{~>view-filter-param}}
{{/each}}
<div class="d-flex align-items-center">
{{#if @root.UserLoggedIn}}
<input type="hidden" name="__logged_in" value="true">
<noscript>
<button type="submit" name="__render" class="btn btn-secondary me-2">
Preview
</button>
</noscript>
<button type="submit" name="__save" class="ms-2 me-2 btn btn-primary"
hx-vals='{"__save": ""}'
hx-post="{{href "view-filter" filter.name}}"
hx-select="#main" hx-target="#main" hx-swap="outerHTML">
{{#if has_instance}}
{{>icon name="edit" class="button-icon"}}
Update filter
{{else}}
{{>icon name="plus" stroke=2.5 class="button-icon"}}
Add filter
{{/if}}
</button>
{{else}}
<noscript>
<button type="submit" name="__render" class="btn btn-primary">Render</button>
</noscript>
{{/if}}
{{#if (beta_features @root) }}
<div class="ms-2 form-check form-check-inline">
<input type="checkbox" class="form-check-input" id="__test_mode" name="__test_mode"
{{#equal true @root.data.test_mode}}checked{{/equal}}>
<label title="Matching elements will be given a red border instead of being hidden"
class="form-check-label" for="__test_mode">Test mode</label>
</div>
{{/if}}
<div class="ms-2 htmx-indicator spinner-border text-secondary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
{{#if has_instance}}
<button type="submit" name="__disable" class="btn btn-outline-dark ms-auto"
hx-confirm="Remove filter and delete its configuration?"
hx-vals='{"__disable": ""}'
hx-post="{{href "view-filter" filter.name}}"
hx-select="#main" hx-target="#main" hx-swap="outerHTML">
{{>icon name="trash" class="button-icon"}}
Remove filter
</button>
{{/if}}
</div>
</form>
</div>
{{else}}
<div class="mt-4 d-flex align-items-center">
<form id="filter_input" class="container form-inline" method="POST" action="#output-card"
hx-post="{{href "view-filter" filter.name}}"
hx-select="#main" hx-target="#main" hx-swap="outerHTML">
{{{csrf @root}}}
{{#if has_instance}}
<button class="btn btn-primary me-2" disabled>Filter already in your list.</button>
<button type="submit" name="__disable" class="ms-2 btn btn-outline-dark ms-auto"
hx-confirm="Remove filter and delete its configuration?"
hx-vals='{"__disable": ""}'
hx-post="{{href "view-filter" filter.name}}"
hx-select="#main" hx-target="#main" hx-swap="outerHTML">
{{>icon name="trash" class="button-icon"}}
Remove filter
</button>
{{else if @root.UserLoggedIn}}
<button type="submit" name="__save" class="btn btn-primary">
{{>icon name="plus" stroke=2.5 class="button-icon"}}
Add filter
</button>
{{#if (beta_features @root) }}
<div class="ms-2 form-check form-check-inline">
<input type="checkbox" class="form-check-input" id="__test_mode" name="__test_mode"
{{#equal true @root.data.test_mode}}checked{{/equal}}>
<label title="Matching elements will be given a red border instead of being hidden"
class="form-check-label" for="__test_mode">Test mode</label>
</div>
{{/if}}
{{/if}}
</form>
</div>
{{/if}}
{{>view-filter-render}}
</div>
</div>