Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to filter translations by key #363

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion resources/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,25 @@
}
});

var rowsById = {};
$('.table tbody tr').each(function() {
rowsById[$(this).attr('id')] = $(this);
});

$('#search-field').keyup(function() {
var searchKey = $(this).val().toUpperCase();
Object.keys(rowsById).forEach(function(key) {
rowsById[key].toggle(!searchKey || key.includes(searchKey));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to replace key.includes(searchKey) with key.toUpperCase().includes(searchKey).
Otherwise very good. Good Job.

});
});

$("a.delete-key").click(function(event){
event.preventDefault();
var row = $(this).closest('tr');
var url = $(this).attr('href');
var id = row.attr('id');
$.post( url, {id: id}, function(){
delete rowsById[id];
row.remove();
} );
});
Expand Down Expand Up @@ -227,7 +240,10 @@
</div>
</form>
<hr>
<h4>Total: <?= $numTranslations ?>, changed: <?= $numChanged ?></h4>
<div class="row">
<h4 class="col-md-9">Total: <?= $numTranslations ?>, changed: <?= $numChanged ?></h4>
<div class="col-md-3"><input type="search" placeholder="Filter by key..." id="search-field" class="form-control" /></div>
</div>
<table class="table">
<thead>
<tr>
Expand Down