Skip to content

Commit

Permalink
feature 8783:Implement rich text links in custom forms (#8972)
Browse files Browse the repository at this point in the history
* feature-8783: Implement rich text links in custom forms

* feature-8783: Implement rich text links in custom forms

* feature-8783: Fix git comment

* feature-8783: Fix comment

* feature-8783: Fix comment

* feature-8783: Fix comment

* feature-8783: Fix comment

* feature-8783: Implement rich text links in custom forms

* feature-8783: Fix bug not show title on the screen order

* feature-8783: Implement rich text links in custom forms

---------

Co-authored-by: lthanhhieu <lthanhhieu@tma.com.vn>
Co-authored-by: cweitat <cweitat@gmail.com>
Co-authored-by: ntthitrinh <ntthitrinh@tma.com.vn>
  • Loading branch information
4 people authored Jul 18, 2023
1 parent 9e4e4ea commit a0aaced
Show file tree
Hide file tree
Showing 15 changed files with 681 additions and 71 deletions.
3 changes: 0 additions & 3 deletions app/components/forms/orders/order-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,7 @@ export default Component.extend(FormMixin, {
if ((main_language && main_language.split('-')[0] === current_locale) || !field.translations || !field.translations.length) {
field.transName = field.name;
} else if (field.translations?.length) {

const transName = field.translations.filter(trans => trans.language_code.split('-')[0] === current_locale);

if (transName.length) {
field.transName = transName[0].name;
} else {
Expand All @@ -641,7 +639,6 @@ export default Component.extend(FormMixin, {
} else {
field.transName = field.name;
}

return !isFixed;
}), ['position']);
return groupBy(requiredFixed.concat(customFields), field => field.get('form'));
Expand Down
51 changes: 30 additions & 21 deletions app/components/forms/wizard/custom-form-input-translation.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
{{#if (not-eq @type "number")}}
<div style="width: 30%">
<Input type="text" placeholder={{t "Field Name"}} @value={{@data.name}}/>
{{#if (eq @type "number")}}
<div class="rich-text-type-number" >
<Widgets::Forms::RichTextLink
@value={{@data.name}}/>
</div>
{{else}}
<div style="width: 20%">
<Input type="text" placeholder={{t "Field Name"}} @value={{@data.name}}/>
<div class="rich-text-other" >
<Widgets::Forms::RichTextLink
@value={{@data.name}}/>
</div>
{{/if}}
<UiDropdown class="ui selection dropdown custom-form-dropdown-attendee"
@selected={{@data.selectedLang}}
@onChange={{action 'onChangeLanguage' }}>
<div class="default text">
{{ @data.selectedLang }}
</div>
<i class="dropdown icon"></i>
<div class="menu">
{{#each this.languageList as |language|}}
<div class="item" data-value={{language.code}}>{{language.name}}</div>
{{/each}}
</div>
</UiDropdown>
<button style="font-size: 1.1em;" class="ui compact icon negative circular button" data-tooltip="{{t 'Delete'}}" {{action (confirm (t "Are you sure you want to delete this?") (action 'onRemoveForm' ))}}>
<i class="trash box icon"></i>
</button>
<div style="width: 11rem">
<div class="ui hidden divider wrapper-button"></div>
<UiDropdown class="ui selection dropdown custom-form-dropdown-attendee"
@selected={{@data.selectedLang}}
@onChange={{action 'onChangeLanguage'}}
style="line-height: inherit; min-width: 11rem;">
<div class="default text">
{{ @data.selectedLang }}
</div>
<i class="dropdown icon"></i>
<div class="menu">
{{#each this.languageList as |language|}}
<div class="item" data-value={{language.code}}>{{language.name}}</div>
{{/each}}
</div>
</UiDropdown>
</div>
<div>
<div class="ui hidden divider wrapper-button"></div>
<button class="ui compact icon negative button btn-delele-lang" data-tooltip="{{t 'Delete'}}" {{action (confirm (t "Are you sure you want to delete this?") (action 'onRemoveForm' ))}}>
<i class="trash box icon"></i>
</button>
</div>
6 changes: 3 additions & 3 deletions app/components/forms/wizard/custom-form-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
</UiDropdown>
{{/if}}
{{#if (or (eq this.type "number") (eq this.type "year"))}}
<div class="ui action input input-attendee-custom-form" style="width: 8%;">
<div class="ui action input input-attendee-custom-form number-item">
<Input
@type="number"
@name="min_price"
placeholder={{t "Min"}}
@value={{this.min}} />
</div>
<div class="ui action input input-attendee-custom-form" style="width: 8%;">
<div class="ui action input input-attendee-custom-form number-item">
<Input
@type="number"
@name="max_price"
Expand Down Expand Up @@ -71,7 +71,7 @@
</div>
<div style="display: flex; flex-direction: column">
{{#each this.visibleForm as |sub|}}
<div {{did-update this.updated @field}} class="ui action input sub" style="width: inherit; margin-top: 10px">
<div {{did-update this.updated @field}} class="ui action input sub child-language">
{{#unless sub.isDeleted }}
<Forms::Wizard::CustomFormInputTranslation
@data={{sub}}
Expand Down
99 changes: 99 additions & 0 deletions app/components/forms/wizard/custom-form-rich-text.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<div class="ui hidden divider"></div>
<div class="ui dividing">
<i class="checkmark box icon"></i>
<span class="content">
{{t 'Add Custom Form Field'}}
</span>
</div>
<div class="cf-container">
<div {{did-update this.updated @field}} class="ui action input main number-text">
{{#if (eq this.type "number")}}
<div class="number-div">
<Widgets::Forms::RichTextLink
@value={{this.name}}/>
</div>
{{else}}
<div class="other-div">
<Widgets::Forms::RichTextLink
@value={{this.name}}/>
</div>
{{/if}}
<div class="lang-dropdown">
<div class="ui hidden divider lang-dropdown-item"></div>
{{#if (eq @form 'attendee')}}
<UiDropdown
class="ui selection dropdown custom-form-dropdown-attendee item-content"
@selected={{this.mainLanguage}}
@onChange={{action 'onMainLanguageChange'}}
>
<div class="default text">
{{ this.mainLanguage }}
</div>
<i class="dropdown icon"></i>
<div class="menu">
{{#each this.languageList as |language|}}
<div class="item" data-value={{language.code}}>{{language.name}}</div>
{{/each}}
</div>
</UiDropdown>
{{/if}}
</div>
<div>
{{#if (eq this.type "number")}}
<div class="ui hidden divider range-box"></div>
<div class="number-wrapper">
<Input
@type="number"
@name="min_price"
placeholder={{t "Min"}} style="width: 5rem; line-height: 1.7rem"
@value={{this.min}} />
<Input
@type="number"
@name="max_price"
placeholder={{t "Max"}} style="width: 5rem; line-height: 1.7rem"
@value={{this.max}} />
</div>
{{/if}}
</div>
<div style="width: 11rem;">
<div class="ui hidden divider" style="margin: 1.2rem 0rem;"></div>
<UiDropdown
class="ui selection dropdown custom-form-dropdown-attendee"
@selected={{this.type}}
@onChange={{action (mut this.type)}}
style="line-height: inherit; min-width: 11rem">
<div class="default text">
{{ this.type }}
</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="text">{{t "Short Answer"}}</div>
<div class="item" data-value="paragraph">{{t "Paragraph"}}</div>
<div class="item" data-value="number">{{t "Number"}}</div>
<div class="item" data-value="year">{{t "Year"}}</div>
<div class="item" data-value="boolean">{{t "Yes/No"}}</div>
</div>
</UiDropdown>
</div>
<div>
<div class="ui hidden divider wrapper-button"></div>
{{#if (eq @form 'attendee')}}
<button class="ui button btn-add-translate" {{action 'addTranslation'}} disabled={{this.disableAddTranslation}}>{{t 'Add Translation'}}</button>
{{/if}}
<button class="ui button btn-add-save" {{action 'addFormField'}} disabled={{not this.validIdentifier}}>{{if @field (t 'Save') (t 'Add')}}</button>
</div>
</div>
</div>
<div style="display: flex; flex-direction: column">
{{#each this.visibleForm as |sub|}}
<div {{did-update this.updated @field}} class="ui action input sub" style="width: inherit; margin-top: 10px">
{{#unless sub.isDeleted }}
<Forms::Wizard::CustomFormInputTranslation
@data={{sub}}
@type={{this.type}}
@onRemoveTranslation={{action (mut sub.isDeleted) true}}
@onChange={{action 'onChildChangeLanguage'}}/>
{{/unless}}
</div>
{{/each}}
</div>
Loading

1 comment on commit a0aaced

@vercel
Copy link

@vercel vercel bot commented on a0aaced Jul 18, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.