-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add speaker and session custom form wizard (#4540)
- Loading branch information
1 parent
23f234c
commit 3f049ef
Showing
6 changed files
with
122 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="ui hidden divider"></div> | ||
<h3 class="ui dividing header"> | ||
<i class="checkmark box icon"></i> | ||
<div class="content"> | ||
{{t 'Add Custom Form Field'}} | ||
</div> | ||
</h3> | ||
<div class="ui action input" style="width: inherit;"> | ||
<Input type="text" placeholder="Field Name" @value={{@newFormField.name}} /> | ||
<UiDropdown class="ui selection dropdown" @selected={{@newFormField.type}} @onChange={{action (mut @newFormField.type)}}> | ||
<div class="default text"> | ||
{{ @newFormField.type}} | ||
</div> | ||
<i class="dropdown icon"></i> | ||
<div class="menu"> | ||
<div class="item" data-value="text">Text</div> | ||
<div class="item" data-value="number">Number</div> | ||
</div> | ||
</UiDropdown> | ||
<button class="ui button" {{action 'addFormField'}} disabled={{not this.validIdentifier}}>Add</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Component from '@glimmer/component'; | ||
import { slugify } from 'open-event-frontend/utils/text'; | ||
import { action } from '@ember/object'; | ||
import { computed } from '@ember/object'; | ||
import { inject as service } from '@ember/service'; | ||
import { set } from '@ember/object'; | ||
import DS from 'ember-data'; | ||
|
||
interface CustomForm { fieldIdentifier: string } | ||
|
||
function getIdentifier(name: string, fields: CustomForm[]): string { | ||
const fieldIdentifiers = new Set(fields.map(field => field.fieldIdentifier)); | ||
let identifier = slugify(name, '_'); | ||
while (fieldIdentifiers.has(identifier)) { | ||
identifier += '_'; | ||
} | ||
|
||
return identifier; | ||
} | ||
|
||
interface Args { | ||
newFormField: { | ||
name: string, | ||
type: string | ||
}, | ||
customForms: CustomForm[], | ||
form: string, | ||
event: any | ||
} | ||
|
||
export default class CustomFormInput extends Component<Args> { | ||
|
||
@service | ||
store!: DS.Store; | ||
|
||
get identifier(): string { | ||
return getIdentifier(this.args.newFormField.name, this.args.customForms); | ||
} | ||
|
||
@computed('args.newFormField.name') | ||
get validIdentifier(): boolean { | ||
return this.identifier.trim().length > 0 && this.args.newFormField.name.trim().length > 0; | ||
} | ||
|
||
@action | ||
addFormField() { | ||
if (!this.validIdentifier) { | ||
return; | ||
} | ||
this.args.customForms.pushObject(this.store.createRecord('custom-form', { | ||
fieldIdentifier : this.identifier, | ||
name : this.args.newFormField.name, | ||
form : this.args.form, | ||
type : this.args.newFormField.type, | ||
isRequired : false, | ||
isIncluded : false, | ||
event : this.args.event | ||
})); | ||
set(this.args.newFormField, 'name', ''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3f049ef
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.
Successfully deployed to following URLs: