Skip to content

Commit f1c4b5a

Browse files
authored
feature-8983: Showing <br> tag in custom field when organizer tries … (#8993)
* feature-8983: Showing <br> tag in custom field when organizer tries to add custom question * feature-8983:Showing <br> tag in custom field when organizer tries to add custom question * feature-8983:Showing <br> tag in custom field when organizer tries to add custom question * feature-8983: Showing <br> tag in custom field when organizer tries to add custom question
1 parent 7d5d35d commit f1c4b5a

File tree

7 files changed

+81
-19
lines changed

7 files changed

+81
-19
lines changed

app/components/forms/wizard/badge-field-form.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ export default Component.extend(FormMixin, {
1313
booleanTextType : orderBy(booleanTextType, 'position'),
1414

1515
getCustomFields: computed('includeCustomField', function() {
16-
const validForms = this.includeCustomField.map(item => item.name);
17-
if (this.data.custom_field) {
18-
validForms.push(this.data.custom_field);
19-
}
16+
const validForms = this.includeCustomField.map(item => {
17+
if (item.isComplex) {
18+
return { 'isComplex': item.name };
19+
} else {
20+
return { 'isFixed': item.name };
21+
}
22+
});
2023
return union(validForms);
2124
}),
2225

@@ -42,6 +45,25 @@ export default Component.extend(FormMixin, {
4245
return warningFields;
4346
}),
4447

48+
getFieldComplex: computed('data.custom_field', function() {
49+
const { custom_field } = this.data;
50+
let isComplex = false;
51+
if (custom_field !== 'QR') {
52+
this.selectedTickets.forEach(ticket => {
53+
const listCFields = this.customForms.filter(form => (ticket.formID === form.formID) && form.isIncluded || form.isFixed);
54+
if (custom_field) {
55+
listCFields.forEach(field => {
56+
const { isComplex: fieldIsComplex } = field;
57+
if (field.name === custom_field) {
58+
isComplex = fieldIsComplex;
59+
}
60+
});
61+
}
62+
});
63+
}
64+
return isComplex;
65+
}),
66+
4567
getWarningQRFields: computed('data.qr_custom_field.@each', 'selectedTickets', function() {
4668
if (this.data.qr_custom_field) {
4769
const warningFields = [];

app/components/forms/wizard/badge-forms/badge-preview.hbs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
</div>
5555
{{else}}
5656
<p class="field-style" style={{_field.getFieldStyle}}>
57-
{{_field.custom_field}}
57+
{{#if _field.custom_field }}
58+
{{ rich-text-link _field.custom_field}}
59+
{{/if}}
5860
</p>
5961
{{/if}}
6062
{{/if}}

app/components/widgets/forms/rich-text-editor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ export default Component.extend({
6262

6363
const updateValue = () => {
6464
debounce(this, () => {
65-
let value = String(this.editor.getValue()).replace(/(<br>)*$/g, '');
66-
if (navigator.userAgent.indexOf('Firefox') !== -1) {
67-
value = value + '<br>';
68-
}
65+
let value = String(this.editor.getValue()).replace(/(<br>)*$/g, '').replace(/&nbsp;/g, ' ');
66+
// if (navigator.userAgent.indexOf('Firefox') !== -1) {
67+
// value = value + '<br>';
68+
// }
6969
let trimmedValue = new String('');
7070
let i = value.length;
7171
while (i--) {

app/components/widgets/forms/rich-text-link.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ export default Component.extend({
6262

6363
const updateValue = () => {
6464
debounce(this, () => {
65-
let value = String(this.editor.getValue()).replace(/(<br>)*$/g, '');
66-
if (navigator.userAgent.indexOf('Firefox') !== -1) {
67-
value = value + '<br>';
68-
}
65+
let value = String(this.editor.getValue()).replace(/(<br>)*$/g, '').replace(/&nbsp;/g, ' ');
66+
// if (navigator.userAgent.indexOf('Firefox') !== -1) {
67+
// value = value + '<br>';
68+
// }
6969
let trimmedValue = new String('');
7070
let i = value.length;
7171
while (i--) {

app/helpers/warning-badge-ticket.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { helper } from '@ember/component/helper';
2+
import { htmlSafe } from '@ember/string';
3+
4+
export function warningBadgeTicket(data) {
5+
let field = '';
6+
let fieldName = '';
7+
8+
if (data[0]) {
9+
field = `'${data[0]}' is not available in ticket`;
10+
}
11+
12+
if (data[1]) {
13+
fieldName = `${field} '${data[1]}'`;
14+
}
15+
16+
return htmlSafe(`<span>${fieldName}</span>`);
17+
}
18+
19+
export default helper(warningBadgeTicket);

app/templates/components/forms/orders/editable-fields.hbs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<div>
2-
<label class="{{if @field.isRequired 'required'}}" for="name">{{t-var @field.transName}}</label>
2+
<label class="{{if @field.isRequired 'required'}}" for="name">
3+
{{#if @field.isComplex}}
4+
{{rich-text-link @field.transName}}
5+
{{else}}
6+
{{t-var @field.transName}}
7+
{{/if}}
8+
</label>
39
</div>
410
{{#if (eq @field.type 'paragraph')}}
511
{{#if @editFields}}

app/templates/components/forms/wizard/badge-field-form.hbs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
<h3 class="lh-2r">
55
{{t 'Row'}} {{inc @index}}
66
{{#if @data.custom_field }}
7-
- {{@data.custom_field}}
7+
{{#if this.getFieldComplex}}
8+
- {{rich-text-link @data.custom_field}}
9+
{{else}}
10+
- {{t-var @data.custom_field}}
11+
{{/if}}
812
{{/if}}
13+
914
</h3>
1015
<div class="btn-row">
1116
<button type="button" class="ui compact icon button right floated" {{action 'toggleSetting' }}>
@@ -36,15 +41,23 @@
3641
<div class="default text">{{t 'Custom field'}}</div>
3742
<div class="menu">
3843
{{#each this.getCustomFields as |cfield|}}
39-
<div class="item" data-value="{{cfield}}">
40-
{{t-var cfield}}
41-
</div>
44+
{{#if cfield.isFixed}}
45+
<div class=" item fixed-item" data-value="{{cfield.isFixed}}">
46+
{{cfield.isFixed}}
47+
</div>
48+
{{else}}
49+
{{#if cfield.isComplex}}
50+
<div class=" item complex-item" data-value="{{cfield.isComplex}}">
51+
{{rich-text-link cfield.isComplex}}
52+
</div>
53+
{{/if}}
54+
{{/if}}
4255
{{/each}}
4356
</div>
4457
</UiDropdown>
4558
{{#if this.getWarningFields}}
4659
{{#each this.getWarningFields as |warning|}}
47-
<label class="warning">{{concat '\'' warning.field '\' is not available in ticket \'' warning.ticket '\''}}</label>
60+
<label class="warning">{{warning-badge-ticket warning.field warning.ticket}}</label>
4861
{{!-- <UiPopup
4962
@tagName="i"
5063
@class="info circle icon"

0 commit comments

Comments
 (0)