close time entry modal on enter (#8653)

* close time entry modal on enter

As the time entry is saved anyway once the user saves the form, e.g. by pressing enter in the hours field, we can close the whole modal along with it. The "Save" and "Cancel" buttons do not make sense then anymore

* attempt to stabilize flickering spec

* fix ruby 2.7.1 hash parameter deprecations
pull/8667/head
ulferts 4 years ago committed by GitHub
parent e0aa19bd16
commit 8969afe617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      frontend/src/app/modules/time_entries/create/create.modal.ts
  2. 1
      frontend/src/app/modules/time_entries/edit/edit.modal.ts
  3. 26
      frontend/src/app/modules/time_entries/shared/modal/base.modal.ts
  4. 2
      lib/api/decorators/schema_representer.rb
  5. 2
      lib/api/utilities/endpoints/bodied.rb
  6. 2
      lib/api/v3/work_packages/schema/work_package_schema_representer.rb
  7. 6
      lib/open_project/journal_formatter/diff.rb
  8. 4
      lib/plugins/acts_as_journalized/lib/journal_formatter/base.rb
  9. 2
      lib/redmine/i18n.rb
  10. 8
      spec/features/work_packages/table/queries/query_name_inline_edit_spec.rb

@ -21,6 +21,7 @@ export class TimeEntryCreateModal extends TimeEntryBaseModal {
public setModifiedEntry($event:{savedResource:HalResource, isInital:boolean}) {
this.createdEntry = $event.savedResource as TimeEntryResource;
this.reloadWorkPackageAndClose();
}
public get saveText() {

@ -18,6 +18,7 @@ export class TimeEntryEditModal extends TimeEntryBaseModal {
public setModifiedEntry($event:{savedResource:HalResource, isInital:boolean}) {
this.modifiedEntry = $event.savedResource as TimeEntryResource;
this.reloadWorkPackageAndClose();
}
public get saveAllowed() {

@ -52,18 +52,7 @@ export abstract class TimeEntryBaseModal extends OpModalComponent {
this.formInFlight = true;
this.editForm.save()
.then(() => {
// reload workPackage
if (this.entry.workPackage) {
this
.apiV3Service
.work_packages
.id(this.entry.workPackage)
.refresh();
}
this.service.close();
this.formInFlight = false;
})
.then(() => this.reloadWorkPackageAndClose())
.catch(() => this.formInFlight = false);
}
@ -78,4 +67,17 @@ export abstract class TimeEntryBaseModal extends OpModalComponent {
public get deleteAllowed() {
return true;
}
protected reloadWorkPackageAndClose() {
// reload workPackage
if (this.entry.workPackage) {
this
.apiV3Service
.work_packages
.id(this.entry.workPackage)
.refresh();
}
this.service.close();
this.formInFlight = false;
}
}

@ -359,7 +359,7 @@ module API
attributes[:allowed_values_getter] = allowed_values_getter if allowed_values_getter
representer = ::API::Decorators::AllowedValuesByCollectionRepresenter
.new(attributes)
.new(**attributes)
if form_embedded
representer.allowed_values = instance_exec(&values_callback)

@ -91,7 +91,7 @@ module API
process_service
.new(**args.compact)
.call(params)
.call(**params)
end
def render(current_user, call)

@ -86,7 +86,7 @@ module API
def initialize(schema, self_link, context)
@base_schema_link = context.delete(:base_schema_link) || nil
@show_lock_version = !context.delete(:hide_lock_version)
super(schema, self_link, context)
super(schema, self_link, **context)
end
link :baseSchema do

@ -54,11 +54,11 @@ class OpenProject::JournalFormatter::Diff < JournalFormatter::Base
label = label(key, options[:no_html])
if value.blank?
l(:text_journal_deleted_with_diff, label: label, link: link)
I18n.t(:text_journal_deleted_with_diff, label: label, link: link)
elsif old_value.present?
l(:text_journal_changed_with_diff, label: label, link: link)
I18n.t(:text_journal_changed_with_diff, label: label, link: link)
else
l(:text_journal_set_with_diff, label: label, link: link)
I18n.t(:text_journal_set_with_diff, label: label, link: link)
end
end

@ -87,9 +87,9 @@ module JournalFormatter
def render_binary_detail_text(label, value, old_value)
if value.blank?
l(:text_journal_deleted, label: label, old: old_value)
I18n.t(:text_journal_deleted, label: label, old: old_value)
else
l(:text_journal_added, label: label, value: value)
I18n.t(:text_journal_added, label: label, value: value)
end
end
end

@ -54,7 +54,7 @@ module Redmine
::I18n.t(*args)
when 2
if args.last.is_a?(Hash)
::I18n.t(*args)
::I18n.t(args.first, **args.last)
elsif args.last.is_a?(String)
::I18n.t(args.first, value: args.last)
else

@ -90,6 +90,10 @@ describe 'Query name inline edit', js: true do
# Expect unchanged
query_title.expect_not_changed
# TODO: The notification should actually not be shown at all since no update
# has taken place
wp_table.expect_and_dismiss_notification message: 'Successful update.'
assignee_query.reload
expect(assignee_query.filters.count).to eq(1)
expect(assignee_query.filters.first.name).to eq :status_id
@ -100,7 +104,7 @@ describe 'Query name inline edit', js: true do
# Rename query
query_title.rename 'Not my assignee query'
wp_table.expect_notification message: 'Successful update.'
wp_table.expect_and_dismiss_notification message: 'Successful update.'
assignee_query.reload
expect(assignee_query.name).to eq 'Not my assignee query'
@ -112,7 +116,7 @@ describe 'Query name inline edit', js: true do
page.driver.browser.switch_to.active_element.send_keys('Some other name')
page.driver.browser.switch_to.active_element.send_keys(:return)
wp_table.expect_notification message: 'Successful update.'
wp_table.expect_and_dismiss_notification message: 'Successful update.'
assignee_query.reload
expect(assignee_query.name).to eq 'Some other name'

Loading…
Cancel
Save