/
UIxFilterEditor.wox
200 lines (179 loc) · 8.9 KB
/
UIxFilterEditor.wox
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE container>
<container
xmlns="http://www.w3.org/1999/xhtml"
xmlns:var="http://www.skyrix.com/od/binding"
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:label="OGo:label"
xmlns:rsrc="OGo:url"
xmlns:uix="OGo:uix"><var:string var:value="doctype" const:escapeHTML="NO" />
<md-dialog flex="50" flex-sm="80" flex-xs="100">
<form id="filterForm" name="filterForm" class="md-inline-form" ng-submit="filterEditor.save(filterForm)">
<md-toolbar>
<div class="md-toolbar-tools">
<md-icon class="material-icons sg-icon-toolbar-bg">filter_list</md-icon>
<md-input-container class="md-block md-flex">
<label><var:string label:value="Filter name"/></label>
<input class="md-title"
type="text"
md-autofocus="true"
ng-model="filterEditor.filter.name"
label:placeholder="Filter name"
required="required"/>
</md-input-container>
</div>
</md-toolbar>
<md-dialog-content class="sg-has-form-sections">
<script type="text/javascript">
var filterId = '<var:string value="filterId"/>';
var mailTags = <var:string value="labels" const:escapeHTML="NO"/>;
</script>
<div class="sg-form-section">
<div layout="row" layout-align="start center">
<div class="pseudo-input-container">
<p class="pseudo-input-field"><var:string label:value="For incoming messages that"/></p>
</div>
<md-input-container class="md-flex">
<md-select ng-model="filterEditor.filter.match">
<md-option const:value="all">
<var:string label:value="match all of the following rules"/>
</md-option>
<md-option const:value="any">
<var:string label:value="match any of the following rules"/>
</md-option>
<md-option const:value="allmessages">
<var:string label:value="match all messages"/>
</md-option>
</md-select>
</md-input-container>
</div>
<!-- CONDITIONS -->
<div layout="column" ng-hide="filterEditor.filter.match == 'allmessages'">
<div id="filterRules"><!-- empty --></div>
<div layout="row" layout-align="start center"
ng-repeat="rule in filterEditor.filter.rules">
<md-input-container class="md-block" flex="25">
<md-select ng-model="rule.field">
<md-option ng-value="key" ng-repeat="(key, value) in filterEditor.fieldLabels">{{ value }}</md-option>
</md-select>
</md-input-container>
<md-input-container class="md-block" flex="25" ng-if="rule.field == 'header'">
<input type="text" ng-model="rule.custom_header" required="required"/>
</md-input-container>
<md-input-container class="md-block" flex="25" ng-if="rule.field == 'size'">
<md-select ng-model="rule.operator">
<md-option ng-value="key" ng-repeat="(key, value) in filterEditor.numberOperatorLabels">
{{ value }}
</md-option>
</md-select>
</md-input-container>
<md-input-container class="md-block" flex="25" ng-if="rule.field != 'size'">
<md-select ng-model="rule.operator">
<md-option ng-value="key" ng-repeat="(key, value) in filterEditor.textOperatorLabels">
{{ value }}
</md-option>
</md-select>
</md-input-container>
<md-input-container class="md-block md-flex" md-no-float="md-no-float">
<label><var:string label:value="Value"/></label>
<input type="text" ng-model="rule.value" required="required"/>
</md-input-container>
<md-button class="md-icon-button" type="button"
ng-click="filterEditor.removeMailFilterRule($index)">
<md-icon>remove_circle</md-icon>
</md-button>
</div>
<div layout="row" layout-align="end center">
<label class="button-label button-label--right"><var:string label:value="Add a condition"/></label>
<md-button class="md-icon-button" type="button"
ng-click="filterEditor.addMailFilterRule($event)">
<md-icon>add_circle</md-icon>
</md-button>
</div>
</div>
</div>
<div class="sg-form-section">
<!-- ACTIONS -->
<div layout="column">
<p><var:string label:value="Perform these actions"/></p>
<div id="filterActions"><!-- empty --></div>
<div class="sg-list-sortable"
ng-model="filterEditor.filter.actions"
as-sortable="{ containment: '.sg-list-sortable', containerPositioning: 'relative' }">
<div layout="row" layout-align="start center"
ng-repeat="action in filterEditor.filter.actions"
as-sortable-item="as-sortable-item">
<md-button class="md-icon-button" md-no-ink="md-no-ink"
as-sortable-item-handle="as-sortable-item-handle">
<md-icon class="sg-sortable-grip">drag_handle</md-icon>
</md-button>
<md-input-container class="md-block md-flex">
<md-select ng-model="action.method">
<md-option ng-value="key" ng-repeat="(key, value) in filterEditor.methodLabels">{{ value }}</md-option>
</md-select>
</md-input-container>
<!-- FORWARD MESSAGE TO -->
<md-input-container class="md-block" flex="50" ng-if="action.method == 'redirect'" >
<label><var:string label:value="Email"/></label>
<input type="text" ng-model="action.argument" required="required"/>
</md-input-container>
<!-- DISCARD -->
<!-- nada -->
<!-- KEEP -->
<!-- nada -->
<!-- SEND REJECT MESSAGE -->
<md-input-container class="md-block" flex="50" ng-if="action.method == 'reject'">
<label><var:string label:value="Message"/></label>
<input type="text" ng-model="action.argument" required="required"/>
</md-input-container>
<!-- FILE INTO -->
<md-input-container class="md-block" flex="50" ng-if="action.method == 'fileinto'">
<label><var:string label:value="Mailbox"/></label>
<md-select ng-model="action.argument" required="required">
<md-option ng-value="item.path" ng-repeat="item in filterEditor.mailboxes">
<div ng-class="'sg-child-level-' + item.level">
{{ item.name }}
</div>
</md-option>
</md-select>
</md-input-container>
<!-- FLAG WITH -->
<md-input-container class="md-block" flex="50" ng-if="action.method == 'addflag'">
<label><var:string label:value="Flag"/></label>
<md-select ng-model="action.argument" required="required">
<md-option value="seen"><var:string label:value="Seen"/></md-option>
<md-option value="deleted"><var:string label:value="Deleted"/></md-option>
<md-option value="answered"><var:string label:value="Answered"/></md-option>
<md-option value="flagged"><var:string label:value="Flagged"/></md-option>
<md-option value="junk"><var:string label:value="Junk"/></md-option>
<md-option value="not_junk"><var:string label:value="Not Junk"/></md-option>
<md-option ng-value="key" ng-repeat="(key, value) in filterEditor.labels">{{ value[0] }}</md-option>
</md-select>
</md-input-container>
<!-- STOP -->
<!-- nada -->
<md-button class="md-icon-button" type="button"
ng-click="filterEditor.removeMailFilterAction($index)">
<md-icon>remove_circle</md-icon>
</md-button>
</div>
</div>
<div layout="row" layout-align="end center">
<label class="button-label button-label--right"><var:string label:value="Add an action"/></label>
<md-button class="md-icon-button" type="button"
ng-click="filterEditor.addMailFilterAction($event)">
<md-icon>add_circle</md-icon>
</md-button>
</div>
</div>
</div>
</md-dialog-content>
<md-dialog-actions>
<md-button type="button" ng-click="filterEditor.cancel()"><var:string label:value="Cancel"/></md-button>
<md-button type="submit"
ng-disabled="filterForm.$invalid || !filterEditor.hasRulesAndActions()"
ng-bind="::'OK' | loc"><!-- OK --></md-button>
</md-dialog-actions>
</form>
</md-dialog>
</container>