Skip to content

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

Merged
merged 2 commits into from
Jul 19, 2020

Conversation

iamareebjamal
Copy link
Member

@iamareebjamal iamareebjamal commented Jul 19, 2020

Fixes #3777

@auto-label auto-label bot added the feature label Jul 19, 2020
@vercel
Copy link

vercel bot commented Jul 19, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/eventyay/open-event-frontend/2medakpzl
✅ Preview: https://open-event-frontend-git-fork-iamareebjamal-field-order.eventyay.vercel.app

@niranjan94
Copy link
Member

Codacy Here is an overview of what got changed by this pull request:

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}]));
Copy link
Member

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}]));
Copy link
Member

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}]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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}];
Copy link
Member

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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

export function sortCustomFormFields(fields: CustomFormField[], fieldOrder: string[]): CustomFormField[] {
fieldOrder = [...fieldOrder].reverse();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}]));
Copy link
Member

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
Copy link

codecov bot commented Jul 19, 2020

Codecov Report

Merging #4579 into development will increase coverage by 0.07%.
The diff coverage is 42.85%.

Impacted file tree graph

@@               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              
Impacted Files Coverage Δ
app/components/forms/session-speaker-form.js 0.00% <0.00%> (ø)
.../components/forms/wizard/sessions-speakers-step.js 0.00% <0.00%> (ø)
app/routes/events/view/edit/sessions-speakers.js 0.00% <ø> (ø)
app/routes/public/cfs/edit-session.js 0.00% <ø> (ø)
app/routes/public/cfs/edit-speaker.js 0.00% <ø> (ø)
app/models/custom-form.js 28.57% <100.00%> (+28.57%) ⬆️
app/utils/sort.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d509ce...a738d0a. Read the comment docs.

@iamareebjamal iamareebjamal merged commit 490ec01 into fossasia:development Jul 19, 2020
@iamareebjamal iamareebjamal deleted the field-order branch July 19, 2020 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Organizer Edit Speakers Form: Fields Missing and Fields are randomized
2 participants