Skip to content

Commit 8bb401d

Browse files
authored
Add "Clear all Rules/Events" button (#103)
* Add "Remove all Rules" button * Add clear all events button
1 parent c67e3bc commit 8bb401d

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/main/resources/static/css/style.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ body {
2121
width: 25rem;
2222
}
2323
.rule-button {
24-
width: 150px;
24+
width: auto;
25+
min-width: 150px;
2526
}
2627
.display-inline-table {
2728
display: inline-table;

src/main/resources/static/js/testrules.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ jQuery(document).ready(
152152
self.addEvent = function(data) {
153153
self.eventsBindingList.push({'data': ko.observable(self.parsedToString(data))});
154154
};
155+
156+
// This function is used to remove all rules
157+
self.clearAllRules = function(){
158+
self.rulesBindingList([]);
159+
self.addRule(ruleTemplate);
160+
}
161+
162+
// This function is used to remove all events
163+
self.clearAllEvents = function(){
164+
self.eventsBindingList([]);
165+
self.addEvent({});
166+
}
155167
return self;
156168
}
157169

src/main/resources/templates/testRules.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ <h1 id="test_rules_header">Test Rules</h1>
3232
<button class="btn btn-primary add_rule rule-button mr-1 mt-1 d-inline-block" data-bind="click : $root.addRule.bind($data, ruleTemplate)">
3333
Add Rule
3434
<i class="fa fa-fw fa-plus"></i>
35+
</button>
36+
<button class="btn btn-danger clear_all_rules rule-button mr-1 mt-1 d-inline-block" data-bind="click : $root.clearAllRules.bind()">
37+
Clear All Rules
38+
<i class="fa fa-fw fa-trash"></i>
3539
</button>
3640
</div>
3741
<div>
@@ -74,6 +78,10 @@ <h6>
7478
Add Event
7579
<i class="fa fa-fw fa-plus"></i>
7680
</button>
81+
<button class="btn btn-danger clear_all_events rule-button mr-1 mt-1 d-inline-block" data-bind="click : $root.clearAllEvents.bind()">
82+
Clear All Events
83+
<i class="fa fa-fw fa-trash"></i>
84+
</button>
7785
</div>
7886
<div>
7987
<img class="cursor-pointer" id="uploadEventsInfo" alt="Upload Information" src="assets/images/information.png" data-toggle="tooltip" data-placement="top" title="Upload events must be in a json list, Ex: [{},{}]"/>

0 commit comments

Comments
 (0)