Feature/dynamic float input (#9237)

* Added basic float input

* Added float type dynamic CF

* Remove unused input type

* Add spec

Co-authored-by: Oliver Günther <mail@oliverguenther.de>
pull/9245/head
Benjamin Bädorf 4 years ago committed by GitHub
parent 8d6c0f2c05
commit d4a0b55c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20015
      frontend/npm-shrinkwrap.json
  2. 2
      frontend/src/app/core/services/forms/typings.d.ts
  3. 5
      frontend/src/app/modules/common/dynamic-forms/services/dynamic-fields/dynamic-fields.service.ts
  4. 3
      frontend/src/app/modules/common/dynamic-forms/typings.d.ts
  5. 60
      spec/features/projects/projects_custom_fields_spec.rb
  6. 2
      spec/support/browsers/chrome.rb
  7. 2
      spec/support/browsers/firefox.rb
  8. 1
      spec/support/form_fields/input_form_field.rb

File diff suppressed because it is too large Load Diff

@ -104,7 +104,7 @@ interface IOPAllowedValue {
};
}
type OPFieldType = 'String' | 'Integer' | 'Boolean' | 'Date' | 'DateTime' | 'Formattable' |
type OPFieldType = 'String' | 'Integer' | 'Float' | 'Boolean' | 'Date' | 'DateTime' | 'Formattable' |
'Priority' | 'Status' | 'Type' | 'User' | 'Version' | 'TimeEntriesActivity' | 'Category' |
'CustomOption' | 'Project' | 'ProjectStatus' | 'Password';

@ -41,7 +41,7 @@ export class DynamicFieldsService {
locale: I18n.locale,
},
},
useForFields: ['Integer']
useForFields: ['Integer', 'Float']
},
{
config: {
@ -233,8 +233,7 @@ export class DynamicFieldsService {
let inputType = this.inputsCatalogue.find(inputType => inputType.useForFields.includes(fieldType))!;
if (!inputType) {
console.warn(
`Could not find a input definition for a field with the folowing type: ${fieldType}.
The full field configuration is ${field}`
`Could not find a input definition for a field with the folowing type: ${fieldType}. The full field configuration is`, field
);
return null;
}

@ -29,6 +29,3 @@ export interface IOPDynamicInputTypeSettings {
config:IOPFormlyFieldSettings,
useForFields:OPFieldType[];
}

@ -130,6 +130,65 @@ describe 'Projects custom fields', type: :feature, js: true do
end
end
describe 'with float CF' do
let!(:float_cf) do
FactoryBot.create(:float_project_custom_field, name: 'MyFloat')
end
let(:float_field) { ::FormFields::InputFormField.new float_cf }
context 'with english locale' do
let(:current_user) { FactoryBot.create :admin, language: 'en' }
it 'displays the float with english locale' do
visit new_project_path
name_field.set_value 'My project name'
find('.form--fieldset-legend a', text: 'ADVANCED SETTINGS').click
float_field.set_value '10000.55'
# Save project settings
click_on 'Save'
expect(page).to have_current_path /\/projects\/my-project-name\/?/
project = Project.find_by(name: 'My project name')
cv = project.custom_values.find_by(custom_field_id: float_cf.id).typed_value
expect(cv).to eq 10000.55
visit settings_generic_project_path(project)
float_field.expect_value '10000.55'
end
end
context 'with german locale',
driver: :firefox_de do
let(:current_user) { FactoryBot.create :admin, language: 'de' }
it 'displays the float with german locale' do
visit new_project_path
name_field.set_value 'My project name'
find('.form--fieldset-legend a', text: 'ERWEITERTE EINSTELLUNGEN').click
float_field.set_value '10000,55'
# Save project settings
click_on 'Speichern'
expect(page).to have_current_path /\/projects\/my-project-name\/?/
project = Project.find_by(name: 'My project name')
cv = project.custom_values.find_by(custom_field_id: float_cf.id).typed_value
expect(cv).to eq 10000.55
visit settings_generic_project_path(project)
# The field renders in german locale, but there's no way to test that
# as the internal value is always english locale
float_field.expect_value '10000.55'
end
end
end
describe 'with boolean CF' do
let!(:custom_field) do
FactoryBot.create(:bool_project_custom_field)
@ -147,7 +206,6 @@ describe 'Projects custom fields', type: :feature, js: true do
field = page.find(identifier)
expect(field).to be_checked
end
end
end

@ -1,8 +1,6 @@
# Force the latest version of chromedriver using the webdriver gem
require 'webdrivers/chromedriver'
::Webdrivers.logger.level = :DEBUG
def register_chrome(language, name: :"chrome_#{language}")
Capybara.register_driver name do |app|
options = Selenium::WebDriver::Chrome::Options.new

@ -2,8 +2,6 @@
require 'webdrivers/geckodriver'
require 'socket'
::Webdrivers.logger.level = :DEBUG
def register_firefox(language, name: :"firefox_#{language}")
require 'selenium/webdriver'

@ -4,6 +4,7 @@ module FormFields
class InputFormField < FormField
def expect_value(value)
scroll_to_element(field_container)
expect(field_container).to have_selector('input') { |el| el.value == value }
end

Loading…
Cancel
Save