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

Fix: App forgets default activity ID #80

Merged
merged 6 commits into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ desc 'Provision the environment.'
task :provision do
puts 'Installing dev packages...'
sleep(2)
sh 'docker compose exec redmine bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32'
sh 'docker compose exec redmine bundle config set with "default dev test"'
sh 'docker compose exec redmine bundle install'

Expand Down
4 changes: 2 additions & 2 deletions assets.src/javascripts/t2r.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class FilterForm {
const values: FilterFormValues = {}

const $defaultActivityId = $('select#default-activity-id')
const defaultActivityId = $defaultActivityId.val()
const defaultActivityId = $defaultActivityId.val() || $defaultActivityId.data('selected')
if (defaultActivityId) {
values['default-activity-id'] = parseInt(defaultActivityId as string)
}
Expand Down Expand Up @@ -553,7 +553,7 @@ class TogglReport {
entries[key] = entry
}

if (entries === {}) {
if (Object.keys(entries).length === 0) {
this.showEmptyMessage()
}

Expand Down
4 changes: 2 additions & 2 deletions assets.src/javascripts/t2r/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export class EventManager {
this.listeners[eventName].push(callback)
}

public trigger<Type>(eventName: string): void {
public trigger(eventName: string): void {
if (typeof this.listeners[eventName] === 'undefined') return

for (const listener of this.listeners[eventName]) {
const result = listener()
listener()
}
}
}
12 changes: 8 additions & 4 deletions assets.src/javascripts/t2r/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,15 @@ function initDurationInput(el: HTMLElement): void {
.on('input', function() {
const val = $el.val() as string
try {
// If a duration object could be created, then the the time is valid.
// If a duration object could be created, then the time is valid.
new datetime.Duration(val)
input.setCustomValidity('')
} catch (e) {
input.setCustomValidity(e)
if (e instanceof Error) {
input.setCustomValidity(e.toString())
} else {
throw e
}
}
})
// Update totals as the user updates hours.
Expand Down Expand Up @@ -241,7 +245,7 @@ function initRedmineActivityDropdown(el: HTMLElement): void {
redmineService.getTimeEntryActivities((activities: DropdownOption[] | null) => {
if (activities === null) return

// Generate a SELECT element and use it's options.
// Generate a SELECT element and use its options.
const $select = buildDropdownFromRecords({
placeholder: $el.data('placeholder'),
records: activities
Expand All @@ -250,7 +254,7 @@ function initRedmineActivityDropdown(el: HTMLElement): void {
$el.append($select.find('option')).val('');

const value = $el.data('selected') || '';
$el.val(value).removeAttr('selected');
$el.val(value).removeData('selected');
})
}

Expand Down
Loading