-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Convert some coffeescript files into JS * Two less coffeescript files * sorted_table.js * remove sorted_table.js.coffee * setting.js * advanced_search.js * remove deprecated css * Remove unused logos * Remove require of removed file * enumerate_input * Another attempt at taming screenshot flakiness * text_edition * Remove bootstrap datepicker and Modernizr * bootstrap * Prettier * nullifiable_input * autocomplete_associations_form * schemas.js * Minor fix for flash messages * navigation.js * widget.js * time_charts.js * in_place_editing.js * listing.js * import.js * Remove coffee-rails and uglifier
- Loading branch information
Showing
68 changed files
with
1,940 additions
and
1,324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const unary_operators = [ | ||
'null', | ||
'not_null', | ||
'present', | ||
'blank', | ||
'is_true', | ||
'is_false', | ||
'today', | ||
'yesterday', | ||
'this_week', | ||
'last_week' | ||
] | ||
|
||
const updateFilterForm = select => { | ||
const operator = select.val() | ||
const operand = select.parents('tr').find('.operand') | ||
const visibility = unary_operators.indexOf(operator) === -1 | ||
operand.toggle(visibility).attr('required', visibility) | ||
var type = null | ||
if (operand.data('type') === 'integer' && operator !== 'IN') { | ||
if (operand.data('original-type') !== 'integer') operand.get(0).step = 'any' | ||
type = 'number' | ||
} else if (operand.data('type') === 'date') type = 'date' | ||
else type = 'text' | ||
operand.get(0).type = type | ||
} | ||
|
||
const setupAdvancedSearch = () => { | ||
$('table.filters').on('click', 'span.btn', function () { | ||
$(this).parents('tr').remove() | ||
}) | ||
$('table.filters').on('change', 'td.operators select', evt => | ||
updateFilterForm($(evt.currentTarget)) | ||
) | ||
$('table.filters td.operators select').each((_, select) => | ||
updateFilterForm($(select)) | ||
) | ||
$('#new_filter').on('change', event => { | ||
const column_name = event.target.value | ||
if (!column_name) return | ||
const optgroup = $(event.target).find(':selected').closest('optgroup') | ||
$('#new_filter').val('').trigger('change') | ||
const table = $('#new_filter').data('table') | ||
$.get( | ||
`/settings/${table}`, | ||
{ column_name, assoc: optgroup.data('name') }, | ||
resp => { | ||
filterDiv = $('<tr>').append(resp).appendTo($('.filters')) | ||
selectFilter = filterDiv.find('td.operators select').focus() | ||
updateFilterForm(selectFilter) | ||
} | ||
) | ||
}) | ||
} | ||
|
||
$(setupAdvancedSearch) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
app/assets/javascripts/autocomplete_associations_form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
class AutocompleteAssociationsForm { | ||
constructor(search_input) { | ||
if (search_input.data('autocomplete-association') === 'done') return | ||
const control = search_input.closest('.adminium-association') | ||
this.hidden_input = control.find('input[type=hidden]') | ||
this.single_record_area = control.find('.single-record') | ||
this.single_record_value = control.find('.single-record input') | ||
this.selected_records_area = control.find('.multiple-records') | ||
this.spinner = control.find('.fa-refresh') | ||
this.list = control.find('ul.list-unstyled') | ||
search_input.on('keyup', e => this.keyUp(e)) | ||
this.single_record_area | ||
.find('a.clear-selection') | ||
.on('click', () => this.clearSelected()) | ||
this.url = search_input.data('autocomplete-url') | ||
this.current_requests = 0 | ||
search_input.data('autocomplete-association', 'done') | ||
} | ||
|
||
clearSelected() { | ||
this.single_record_area.find('.input-group-addon i').addClass('invisible') | ||
this.single_record_value.val('null') | ||
this.hidden_input.val('') | ||
return false | ||
} | ||
|
||
keyUp(evt) { | ||
const value = $(evt.currentTarget).val() | ||
if (this.query === value.toLowerCase()) return | ||
this.query = value.toLowerCase() | ||
clearTimeout(this.timeoutId) | ||
this.timeoutId = setTimeout(() => this.search(), 300) | ||
} | ||
|
||
displaySearchResults(data) { | ||
this.list.html('') | ||
data.results.forEach(record => { | ||
var text = record.adminium_label.toString().toLowerCase() | ||
if (text.indexOf(this.query) !== -1) | ||
text = text.replace( | ||
this.query, | ||
`<span class='bg-success'>${this.query}</span>` | ||
) | ||
else { | ||
const attrs = Object.keys(record) | ||
.filter( | ||
key => | ||
record[key] && | ||
record[key].toString().toLowerCase().indexOf(this.query) !== -1 | ||
) | ||
.map( | ||
key => | ||
`<i class='text-muted'>${key}=</i>${record[key] | ||
.toString() | ||
.toLowerCase() | ||
.replace( | ||
this.query, | ||
`<span class='bg-success'>${this.query}</span>` | ||
)}` | ||
) | ||
if (attrs.length > 0) text += ` <span>${attrs.join(' ')}</span>` | ||
} | ||
const li = $('<li>') | ||
.html(text) | ||
.data('label', record.adminium_label) | ||
.data('record_pk', record[data.primary_key]) | ||
.appendTo(this.list) | ||
li.on('click', e => this.selectRecord(e)) | ||
}) | ||
} | ||
|
||
search() { | ||
if (!this.query.length) return this.list.html('') | ||
this.current_requests += 1 | ||
this.spinner.removeClass('invisible') | ||
$.ajax({ | ||
url: `${this.url}&search=${this.query}`, | ||
complete: () => { | ||
this.current_requests -= 1 | ||
if (this.current_requests < 0) this.current_requests = 0 | ||
this.spinner.toggleClass('invisible', this.current_requests === 0) | ||
}, | ||
success: data => this.displaySearchResults(data) | ||
}) | ||
} | ||
|
||
selectRecord(evt) { | ||
const li = $(evt.currentTarget) | ||
if (this.single_record_area.length) { | ||
this.hidden_input.val(li.data('record_pk')) | ||
this.single_record_value.val(li.data('label')) | ||
this.single_record_area | ||
.find('.input-group-addon i') | ||
.removeClass('invisible') | ||
} else { | ||
const label = $('<label>') | ||
const input = $('<input type="checkbox" checked="checked">') | ||
.attr({ name: this.selected_records_area.data('input-name') }) | ||
.val(li.data('record_pk')) | ||
.appendTo(label) | ||
label.append(` ${li.data('label')}`) | ||
$('<li>').append(label).appendTo(this.selected_records_area) | ||
} | ||
li.siblings('.bg-info').removeClass('bg-info') | ||
li.addClass('bg-info') | ||
} | ||
} | ||
|
||
AutocompleteAssociationsForm.setup = () => { | ||
$('input[data-autocomplete-url]').each( | ||
(_, input) => new AutocompleteAssociationsForm($(input)) | ||
) | ||
} | ||
|
||
AutocompleteAssociationsForm.setup() |
78 changes: 0 additions & 78 deletions
78
app/assets/javascripts/autocomplete_associations_form.js.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const autolinkQueryResults = () => { | ||
$('.table td, dl dd').each(function () { | ||
const text = $(this).text() | ||
if (text.match(/^\S+@\S+\.\S+$/)) { | ||
$(this).append( | ||
` <a target="_blank" title='send an email to this address' href="mailto:${text}"><i class='fa fa-envelope subtle'></i></a>` | ||
) | ||
} else { | ||
if (text.match(/\d+\.\d+/)) { | ||
return // Skip processing for numeric patterns with a dot | ||
} | ||
if ( | ||
text.match( | ||
/^((http|ftp|https):\/\/)?[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/ | ||
) | ||
) { | ||
const link = text.match('://') ? text : `http://${text}` | ||
$(this).append( | ||
` <a target="_blank" href="${link}" title='open a new page to this URL'><i class='fa fa-external-link subtle'></i></a>` | ||
) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
$(autolinkQueryResults) |
Oops, something went wrong.