-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: Add field order to session and speaker forms #4579
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
feat: Add field order to session and speaker forms #4579
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/eventyay/open-event-frontend/2medakpzl |
Issues
======
- Added 7
See the complete overview on Codacy |
test('test custom form fields sort', function(assert) { | ||
const items = [{fieldIdentifier: 'age', isComplex: false}, {fieldIdentifier: 'job', isComplex: false}, {fieldIdentifier: 'majama', isComplex: true}, {fieldIdentifier: 'name', isComplex: false}, {fieldIdentifier: 'hay', isComplex: true}, {fieldIdentifier: 'trust', isComplex: false}, {fieldIdentifier: 'company', isComplex: false}]; | ||
const order = ['name', 'age', 'company']; | ||
assert.equal(JSON.stringify(sortCustomFormFields(items, order)), JSON.stringify([{fieldIdentifier:"name",isComplex:false},{fieldIdentifier:"age",isComplex:false},{fieldIdentifier:"company",isComplex:false},{fieldIdentifier:"job",isComplex:false},{fieldIdentifier:"trust",isComplex:false},{fieldIdentifier:"majama",isComplex:true},{fieldIdentifier:"hay",isComplex:true}])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Strings must use singlequote.
test('test custom form fields sort', function(assert) { | ||
const items = [{fieldIdentifier: 'age', isComplex: false}, {fieldIdentifier: 'job', isComplex: false}, {fieldIdentifier: 'majama', isComplex: true}, {fieldIdentifier: 'name', isComplex: false}, {fieldIdentifier: 'hay', isComplex: true}, {fieldIdentifier: 'trust', isComplex: false}, {fieldIdentifier: 'company', isComplex: false}]; | ||
const order = ['name', 'age', 'company']; | ||
assert.equal(JSON.stringify(sortCustomFormFields(items, order)), JSON.stringify([{fieldIdentifier:"name",isComplex:false},{fieldIdentifier:"age",isComplex:false},{fieldIdentifier:"company",isComplex:false},{fieldIdentifier:"job",isComplex:false},{fieldIdentifier:"trust",isComplex:false},{fieldIdentifier:"majama",isComplex:true},{fieldIdentifier:"hay",isComplex:true}])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: A space is required after ','.
test('test custom form fields sort', function(assert) { | ||
const items = [{fieldIdentifier: 'age', isComplex: false}, {fieldIdentifier: 'job', isComplex: false}, {fieldIdentifier: 'majama', isComplex: true}, {fieldIdentifier: 'name', isComplex: false}, {fieldIdentifier: 'hay', isComplex: true}, {fieldIdentifier: 'trust', isComplex: false}, {fieldIdentifier: 'company', isComplex: false}]; | ||
const order = ['name', 'age', 'company']; | ||
assert.equal(JSON.stringify(sortCustomFormFields(items, order)), JSON.stringify([{fieldIdentifier:"name",isComplex:false},{fieldIdentifier:"age",isComplex:false},{fieldIdentifier:"company",isComplex:false},{fieldIdentifier:"job",isComplex:false},{fieldIdentifier:"trust",isComplex:false},{fieldIdentifier:"majama",isComplex:true},{fieldIdentifier:"hay",isComplex:true}])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Missing space before value for key 'fieldIdentifier'.
|
||
module('Unit | Sort | Custom Form Fields', function() { | ||
test('test custom form fields sort', function(assert) { | ||
const items = [{fieldIdentifier: 'age', isComplex: false}, {fieldIdentifier: 'job', isComplex: false}, {fieldIdentifier: 'majama', isComplex: true}, {fieldIdentifier: 'name', isComplex: false}, {fieldIdentifier: 'hay', isComplex: true}, {fieldIdentifier: 'trust', isComplex: false}, {fieldIdentifier: 'company', isComplex: false}]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: A space is required after '{'.
|
||
export function sortCustomFormFields(fields: CustomFormField[], fieldOrder: string[]): CustomFormField[] { | ||
fieldOrder = [...fieldOrder].reverse(); | ||
return sortBy(fields, 'isComplex', item => -fieldOrder.indexOf(item.fieldIdentifier)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Expected indentation of 2 spaces but found 4.
} | ||
|
||
export function sortCustomFormFields(fields: CustomFormField[], fieldOrder: string[]): CustomFormField[] { | ||
fieldOrder = [...fieldOrder].reverse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Expected indentation of 2 spaces but found 4.
test('test custom form fields sort', function(assert) { | ||
const items = [{fieldIdentifier: 'age', isComplex: false}, {fieldIdentifier: 'job', isComplex: false}, {fieldIdentifier: 'majama', isComplex: true}, {fieldIdentifier: 'name', isComplex: false}, {fieldIdentifier: 'hay', isComplex: true}, {fieldIdentifier: 'trust', isComplex: false}, {fieldIdentifier: 'company', isComplex: false}]; | ||
const order = ['name', 'age', 'company']; | ||
assert.equal(JSON.stringify(sortCustomFormFields(items, order)), JSON.stringify([{fieldIdentifier:"name",isComplex:false},{fieldIdentifier:"age",isComplex:false},{fieldIdentifier:"company",isComplex:false},{fieldIdentifier:"job",isComplex:false},{fieldIdentifier:"trust",isComplex:false},{fieldIdentifier:"majama",isComplex:true},{fieldIdentifier:"hay",isComplex:true}])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: A space is required after '{'.
Codecov Report
@@ Coverage Diff @@
## development #4579 +/- ##
===============================================
+ Coverage 22.21% 22.28% +0.07%
===============================================
Files 473 474 +1
Lines 4975 4985 +10
Branches 8 8
===============================================
+ Hits 1105 1111 +6
- Misses 3869 3873 +4
Partials 1 1
Continue to review full report at Codecov.
|
Fixes #3777