forked from gregschmit/recurring_select
-
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.
Merge pull request gregschmit#166 from glaszig/modernization
Modernization
- Loading branch information
Showing
29 changed files
with
777 additions
and
594 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: test | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
test: | ||
name: ${{matrix.ruby}}, ${{matrix.gemfile}} | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
ruby: [ '3.0', '3.1', '3.2', '3.3' ] | ||
gemfile: | ||
- Gemfile | ||
- spec/gemfiles/rails-6.1 | ||
- spec/gemfiles/rails-7.0 | ||
|
||
env: | ||
BUNDLE_GEMFILE: ${{matrix.gemfile}} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{matrix.ruby}} | ||
bundler-cache: true # 'bundle install' and cache | ||
- run: bundle exec rspec --format documentation |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
*.gem | ||
spec/gemfiles/Gemfile*.lock | ||
Gemfile.lock | ||
spec/gemfiles/*.lock | ||
*Gemfile.lock | ||
*.gem | ||
|
||
.bundle/ | ||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
2.5.7 | ||
3.0.6 |
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
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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
source "https://rubygems.org" | ||
gemspec | ||
|
||
gem "pg" | ||
|
||
gem "jquery-rails" | ||
|
||
gem "rails", "~> 5.2" | ||
gem "sass-rails", "~> 5.0" | ||
gem "thin" | ||
gem "rails", "~> 7.1.1" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const defaultConfig = { | ||
options: { | ||
monthly: { | ||
show_week: [true, true, true, true, false, false] | ||
} | ||
}, | ||
texts: { | ||
locale_iso_code: "en", | ||
repeat: "Repeat", | ||
last_day: "Last Day", | ||
frequency: "Frequency", | ||
daily: "Daily", | ||
weekly: "Weekly", | ||
monthly: "Monthly", | ||
yearly: "Yearly", | ||
every: "Every", | ||
days: "day(s)", | ||
weeks_on: "week(s) on", | ||
months: "month(s)", | ||
years: "year(s)", | ||
day_of_month: "Day of month", | ||
day_of_week: "Day of week", | ||
cancel: "Cancel", | ||
ok: "OK", | ||
summary: "Summary", | ||
first_day_of_week: 0, | ||
days_first_letter: ["S", "M", "T", "W", "T", "F", "S" ], | ||
order: ["1st", "2nd", "3rd", "4th", "5th", "Last"], | ||
show_week: [true, true, true, true, false, false] | ||
} | ||
} |
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,20 @@ | ||
//= require recurring_select | ||
//= require_self | ||
|
||
const $ = jQuery | ||
|
||
$(function() { | ||
$(document).on("recurring_select:cancel recurring_select:save", ".recurring_select", function() { | ||
$(this).selectmenu('refresh'); | ||
}); | ||
|
||
$(document).on("recurring_select:dialog_opened", ".rs_dialog_holder", function() { | ||
$(this).find("select").attr("data-theme", $('.recurring_select').data("theme")).attr("data-mini", true).selectmenu(); | ||
$(this).find("input[type=text]").textinput(); | ||
|
||
$(this).on("recurring_select:dialog_positioned", ".rs_dialog", function() { | ||
$(this).css({ | ||
"top" : $(window).scrollTop()+"px"}); | ||
}); | ||
}); | ||
}); |
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,96 @@ | ||
//= require recurring_select_dialog | ||
//= require_self | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
document.addEventListener("focusin", (e) => { | ||
if (e.target.matches(".recurring_select")) { | ||
recurring_select.call(e.target, "set_initial_values") | ||
} | ||
}) | ||
|
||
document.addEventListener("input", (e) => { | ||
if (e.target.matches(".recurring_select")) { | ||
recurring_select.call(e.target, "changed") | ||
} | ||
}) | ||
}) | ||
|
||
const methods = { | ||
set_initial_values() { | ||
const str = this.querySelectorAll('option')[this.selectedIndex].textContent | ||
this.setAttribute('data-initial-value-hash', this.value); | ||
this.setAttribute('data-initial-value-str', str); | ||
}, | ||
|
||
changed() { | ||
if (this.value == "custom") { | ||
methods.open.call(this); | ||
} else { | ||
methods.set_initial_values.call(this); | ||
} | ||
}, | ||
|
||
open() { | ||
this.setAttribute("data-recurring-select-active", true); | ||
new RecurringSelectDialog(this); | ||
this.blur(); | ||
}, | ||
|
||
save(new_rule) { | ||
this.querySelectorAll("option[data-custom]").forEach((el) => el.parentNode.removeChild(el) ) | ||
const new_json_val = JSON.stringify(new_rule.hash) | ||
|
||
// TODO: check for matching name, and replace that value if found | ||
|
||
const options = Array.from(this.querySelectorAll("option")).map(() => this.value) | ||
if (!options.includes(new_json_val)) { | ||
methods.insert_option.apply(this, [new_rule.str, new_json_val]) | ||
} | ||
|
||
this.value = new_json_val | ||
methods.set_initial_values.apply(this) | ||
this.dispatchEvent(new CustomEvent("recurring_select:save")) | ||
}, | ||
|
||
current_rule() { | ||
return { | ||
str: this.getAttribute("data-initial-value-str"), | ||
hash: JSON.parse(this.getAttribute("data-initial-value-hash")) | ||
}; | ||
}, | ||
|
||
cancel() { | ||
this.value = this.getAttribute("data-initial-value-hash") | ||
this.setAttribute("data-recurring-select-active", false); | ||
this.dispatchEvent(new CustomEvent("recurring_select:cancel")) | ||
}, | ||
|
||
|
||
insert_option(new_rule_str, new_rule_json) { | ||
let separator = this.querySelectorAll("option[disabled]"); | ||
if (separator.length === 0) { | ||
separator = this.querySelectorAll("option"); | ||
} | ||
separator = separator[separator.length-1] | ||
|
||
const new_option = document.createElement("option") | ||
new_option.setAttribute("data-custom", true); | ||
|
||
if (new_rule_str.substr(new_rule_str.length - 1) !== "*") { | ||
new_rule_str+="*"; | ||
} | ||
|
||
new_option.textContent = new_rule_str | ||
new_option.value = new_rule_json | ||
separator.parentNode.insertBefore(new_option, separator) | ||
} | ||
}; | ||
|
||
function recurring_select(method) { | ||
this['recurring_select'] = this['recurring_select'] || recurring_select.bind(this) | ||
if (method in methods) { | ||
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) ); | ||
} else { | ||
throw new Error( `Method ${method} does not exist on recurring_select` ); | ||
} | ||
} |
Oops, something went wrong.