-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { sortBy } from 'lodash-es'; | ||
|
||
interface CustomFormField { | ||
fieldIdentifier: string, | ||
isComplex: boolean | ||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Codacy found an issue: Expected indentation of 2 spaces but found 4. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { sortCustomFormFields } from 'open-event-frontend/utils/sort'; | ||
import { module, test } from 'qunit'; | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Codacy found an issue: A space is required after '{'. |
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Codacy found an issue: Strings must use singlequote. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy found an issue: A space is required after ','. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy found an issue: Missing space before value for key 'fieldIdentifier'. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codacy found an issue: A space is required after '{'. |
||
}); | ||
}); |
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.