Skip to content

Commit

Permalink
Remove coffeescript (#740)
Browse files Browse the repository at this point in the history
* 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
isc authored Nov 16, 2023
1 parent 9e3f471 commit d74c020
Show file tree
Hide file tree
Showing 68 changed files with 1,940 additions and 1,324 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ gem 'webauthn'
group :mysql_support do
gem 'mysql2'
end
group :assets do
gem 'coffee-rails'
gem 'uglifier'
end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
Expand Down
12 changes: 0 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ GEM
launchy
cbor (0.5.9.6)
coderay (1.1.3)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
railties (>= 5.2.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
cose (1.3.0)
Expand All @@ -141,7 +134,6 @@ GEM
dry-cli (1.0.0)
encryptor (3.0.0)
erubi (1.12.0)
execjs (2.9.1)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
Expand Down Expand Up @@ -389,8 +381,6 @@ GEM
openssl-signature_algorithm (~> 1.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.5.0)
vite_rails (3.0.17)
railties (>= 5.1, < 8)
Expand Down Expand Up @@ -435,7 +425,6 @@ DEPENDENCIES
bootstrap-wysihtml5-rails
capybara
capybara-screenshot
coffee-rails
database_cleaner
factory_bot_rails
font-awesome-rails
Expand Down Expand Up @@ -466,7 +455,6 @@ DEPENDENCIES
simplecov
slim-rails
spring
uglifier
vite_rails
webauthn
webdrivers
Expand Down
Binary file removed app/assets/images/logos/google.png
Binary file not shown.
Binary file removed app/assets/images/logos/google_oauth2-icon.png
Binary file not shown.
Binary file removed app/assets/images/logos/heroku-icon.png
Binary file not shown.
Binary file removed app/assets/images/logos/heroku.png
Binary file not shown.
Binary file removed app/assets/images/logos/mysql.png
Binary file not shown.
Binary file removed app/assets/images/logos/postgresql.png
Binary file not shown.
56 changes: 56 additions & 0 deletions app/assets/javascripts/advanced_search.js
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)
36 changes: 0 additions & 36 deletions app/assets/javascripts/advanced_search.js.coffee

This file was deleted.

2 changes: 0 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//= require jquery-2.1.4.min
//= require bootstrap-3.3.6.min
//= require modernizr-custom
//= require jquery_ujs
//= require jquery-ui-1.11.4.custom.min
//= require sh_main.min
Expand All @@ -9,6 +8,5 @@
//= require bootstrap-wysihtml5
//= require jquery.csv-0.8.1.min
//= require select2
//= require bootstrap-datepicker.min
//= require clipboard.min
//= require_tree .
115 changes: 115 additions & 0 deletions app/assets/javascripts/autocomplete_associations_form.js
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 app/assets/javascripts/autocomplete_associations_form.js.coffee

This file was deleted.

26 changes: 26 additions & 0 deletions app/assets/javascripts/autolinks.js
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\-\.,@?^=%&amp;:\/~\+#]*[\w\-\@?^=%&amp;\/~\+#])?$/
)
) {
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)
Loading

0 comments on commit d74c020

Please sign in to comment.