Skip to content

feat: only request to fill username for social links in forms #4943

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
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/components/widgets/forms/link-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '@ember/object';
'hasLinkName::labeled',
'hasLinkName::input:'
)

export default class LinkInput extends Component {
hasLinkName = false;
isChild = false;
Expand All @@ -31,14 +32,23 @@ export default class LinkInput extends Component {
protocolAddressObserver() {
let add = this.address;
let proto = this.protocol;
const link = this.linkName.toLowerCase();
const socialPlatforms = ['twitter', 'facebook', 'instagram', 'linkedin', 'youtube', 'github'];

if (add.includes('http://') || add.includes('https://')) {
const temp = add.split('://');
proto = temp[0];
add = temp[1];
}

if (add.includes('www.')) {
add = add.substring(add.indexOf('.') + 1);
}

if (socialPlatforms.includes(link)) {
proto = `https://${link}.com/`;
}

this.set('segmentedLink', {
protocol : proto,
address : add
Expand Down
3 changes: 3 additions & 0 deletions app/templates/components/forms/session-speaker-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{{#if field.isUrlField}}
<Widgets::Forms::LinkInput
@fixedName={{true}}
@linkName={{field.name}}
@inputId={{if field.isRequired (concat "session_" field.fieldIdentifier "_required") (concat "session_" field.fieldIdentifier)}}
@segmentedLink={{get this.data.session field.segmentedLinkName}}
@canRemoveItem={{false}} />
Expand Down Expand Up @@ -160,6 +161,7 @@
{{#if field.isUrlField}}
<Widgets::Forms::LinkInput
@fixedName={{true}}
@linkName={{field.name}}
@inputId={{if field.isRequired (concat "speaker_" field.fieldIdentifier "_required") (concat "speaker_" field.fieldIdentifier)}}
@segmentedLink={{get this.data.speaker field.segmentedLinkName}}
@canRemoveItem={{false}} />
Expand Down Expand Up @@ -276,6 +278,7 @@
{{#if field.isUrlField}}
<Widgets::Forms::LinkInput
@fixedName={{true}}
@linkName={{field.name}}
@inputId={{if field.isRequired (concat "speaker_" field.fieldIdentifier "_required") (concat "speaker_" field.fieldIdentifier)}}
@segmentedLink={{get this.data.speaker field.segmentedLinkName}}
@canRemoveItem={{false}} />
Expand Down
13 changes: 5 additions & 8 deletions app/templates/components/widgets/forms/link-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@
</div>
</div>
{{else}}
<UiDropdown @class="label" @selected={{this.protocol}} @onChange={{action (mut this.protocol)}}>
<div class="text">https://</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="http">http://</div>
<div class="item" data-value="https">https://</div>
<div class="ui labeled input">
<div class="ui label">
{{this.protocol}}
</div>
</UiDropdown>
<Input @type="text" @value={{this.address}} @name={{name}} @id={{this.inputId}} />
<Input @type="text" @value={{this.address}} @name={{name}} @id={{this.inputId}} />
</div>
{{/if}}